MCP server for CAD/CAM applications with AI integration
npm install cadcamfun-mcp-serverA Model Context Protocol (MCP) server for CAD/CAM applications that provides AI-powered design assistance, toolpath optimization, and machining parameter recommendations.
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
- 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
- Node.js 18+
- PostgreSQL database
- TypeScript 5.0+
- Prisma ORM
1. Clone the repository:
``bash`
git clone https://github.com/yourusername/cadcamfun-mcp-server.git
cd cadcamfun-mcp-server
2. Install dependencies:
`bash`
npm install
3. Configure environment variables:
`bash`
cp .env.example .env
# Edit the .env file with your database credentials and settings
4. Apply database migrations:
`bash`
npx prisma migrate dev
5. Build the project:
`bash`
npm run build
To run as an HTTP server (recommended for web applications):
`bash`
npm run start:http
The server will start at http://localhost:3000/mcp by default.
To run as a stdio server (useful for command-line tools):
`bash`
npm run start:stdio
- Docker and Docker Compose
- API key for Anthropic Claude
1. Set up the environment variables:
Create a .env file in the root directory with your API key:`
`
ANTHROPIC_API_KEY=your-api-key-here
2. Start the containers:
`bash`
cd docker
docker-compose up -d
3. Initialize the database:
`bash`
docker-compose exec mcp-server npm run setup-db
4. Access the server at http://localhost:3000/mcp
| 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 |
| 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 |
| 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 |
`typescript
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);
`
To use the CADCAMfun MCP server with Claude and Cursor, you'll need to:
1. Start the MCP server
2. Configure Cursor to use the MCP server as a language model provider
3. 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.
``
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 configuration
| 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 | |
|
Contributions are welcome! Please feel free to submit a Pull Request.
MIT