cadcamfun-mcp-server
v1.2.0
Published
MCP server for CAD/CAM applications with AI integration
Maintainers
Readme
CADCAMfun MCP Server
A Model Context Protocol (MCP) server for CAD/CAM applications that provides AI-powered design assistance, toolpath optimization, and machining parameter recommendations.
Overview
This MCP server exposes resources, tools, and prompts for CAD/CAM operations, allowing LLM applications to:
- Generate CAD components from text descriptions
- Optimize G-code for CNC machines
- Analyze CAD designs for manufacturability, structural integrity, and cost
- Get optimal cutting parameters for specific materials and tools
- Save components and toolpaths to the database
- Access CAD/CAM libraries, materials, and tools
Features
- Resources: Access component data, toolpaths, projects, materials, and machine configurations
- Tools: Generate CAD components, optimize G-code, analyze designs, calculate cutting parameters
- Prompts: Generate component designs, get machining parameters, and suggest design improvements
- Chat: Interactive assistance for CAD/CAM questions
Requirements
- Node.js 18+
- PostgreSQL database
- TypeScript 5.0+
- Prisma ORM
Installation
Clone the repository:
git clone https://github.com/yourusername/cadcamfun-mcp-server.git cd cadcamfun-mcp-serverInstall dependencies:
npm installConfigure environment variables:
cp .env.example .env # Edit the .env file with your database credentials and settingsApply database migrations:
npx prisma migrate devBuild the project:
npm run build
Running the Server
HTTP Server (Default)
To run as an HTTP server (recommended for web applications):
npm run start:httpThe server will start at http://localhost:3000/mcp by default.
Stdio Server
To run as a stdio server (useful for command-line tools):
npm run start:stdioDocker Deployment
Prerequisites
- Docker and Docker Compose
- API key for Anthropic Claude
Steps
Set up the environment variables:
Create a
.envfile in the root directory with your API key:ANTHROPIC_API_KEY=your-api-key-hereStart the containers:
cd docker docker-compose up -dInitialize the database:
docker-compose exec mcp-server npm run setup-dbAccess the server at http://localhost:3000/mcp
API Reference
Resources
| URI | Description |
|-----|-------------|
| version://app | Application version information |
| component://{id} | Get component by ID |
| toolpath://{id} | Get toolpath by ID |
| project://{id} | Get project by ID |
| cam://materials | List available materials |
| cam://tools | List available cutting tools |
| cam://machine-configs | List available machine configurations |
| cad://library-items | List public library items |
Tools
| Name | Description |
|------|-------------|
| generate-cad-component | Generate CAD components from text description |
| optimize-gcode | Optimize G-code for CNC machines |
| analyze-design | Analyze a CAD design for various aspects |
| get-cutting-parameters | Get optimal cutting parameters |
| save-component | Save a component to the database |
| save-toolpath | Save a toolpath to the database |
Prompts
| Name | Description |
|------|-------------|
| generate-cad-component | Generate CAD components from description |
| suggest-cad-improvements | Get suggestions for improving a CAD model |
| machining-parameters-advice | Get advice on machining parameters |
Client Usage Example
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
// Create client
const client = new Client({
name: "My CADCAMfun Client",
version: "1.0.0"
});
// Connect to server
const serverUrl = new URL("http://localhost:3000/mcp");
const transport = new StreamableHTTPClientTransport(serverUrl);
await client.connect(transport);
// Generate a CAD component
const result = await client.callTool({
name: "generate-cad-component",
arguments: {
description: "A simple 10mm x 10mm x 2mm base plate with 4 mounting holes",
complexity: "simple",
style: "precise"
}
});
console.log("Generated Component:", result.content[0].text);Using with Claude and Cursor
To use the CADCAMfun MCP server with Claude and Cursor, you'll need to:
- Start the MCP server
- Configure Cursor to use the MCP server as a language model provider
- Use Claude via the MCP server to assist with CAD/CAM tasks
This setup allows you to leverage Claude's capabilities through the MCP protocol, enhancing your CAD/CAM workflow with AI assistance.
Project Structure
cadcamfun-mcp-server/
├── .env # Environment variables
├── .env.example # Example environment file
├── .gitignore # Git ignore file
├── package.json # Node.js package configuration
├── tsconfig.json # TypeScript configuration
├── prisma/ # Prisma ORM files
│ └── schema.prisma # Database schema
├── src/ # Source code
│ ├── index.ts # Main entry point
│ ├── mcp-server.ts # MCP server implementation
│ ├── types/ # TypeScript type definitions
│ │ └── index.ts # Types used in the server
│ ├── services/ # Service implementations
│ │ ├── aiService.ts # AI service implementation
│ │ ├── cadService.ts # CAD service implementation
│ │ └── camService.ts # CAM service implementation
├── dist/ # Compiled JavaScript files
├── scripts/ # Utility scripts
│ └── setup-db.ts # Database setup script
└── docker/ # Docker deployment files
├── Dockerfile # Docker image definition
└── docker-compose.yml # Docker Compose configurationAvailable Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| DATABASE_URL | PostgreSQL connection string | postgresql://username:password@localhost:5432/cadcamfun |
| DIRECT_DATABASE_URL | Direct PostgreSQL connection | Same as DATABASE_URL |
| TRANSPORT | Transport type (http or stdio) | http |
| PORT | HTTP server port | 3000 |
| ANTHROPIC_API_KEY | API key for Anthropic Claude | |
| AI_MODEL | Default AI model | claude-3-7-sonnet-20250219 |
| AI_MAX_TOKENS | Maximum tokens for AI responses | 6000 |
| AI_TEMPERATURE | Temperature for AI generation | 0.7 |
| AI_CACHE_ENABLED | Enable AI response caching | true |
| AI_ANALYTICS_ENABLED | Enable AI analytics | true |
| MCP_ENABLED | Enable MCP protocol | true |
| MCP_STRATEGY | MCP caching strategy | balanced |
| MCP_CACHE_LIFETIME | Cache lifetime in milliseconds | 3600000 |
| CORS_ORIGINS | Allowed CORS origins | http://localhost:3000,https://cadcam.example.com |
| JWT_SECRET | Secret for JWT tokens | |
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT
