Skip to main content

MCP (Model Context Protocol) server for CadQuery - enables AI assistants to create 3D CAD models

Project description

CadQuery MCP Server

An MCP (Model Context Protocol) server that enables AI assistants like Claude to execute CadQuery scripts and render 3D CAD models.

Features

  • render - Execute CadQuery code and return SVG images of the 3D model

    • Multiple camera angles: isometric, front, back, top, bottom, left, right
    • Multi-view mode for complex models
    • Configurable image dimensions
    • Hidden line rendering
  • inspect - Get geometry information about a shape

    • Bounding box dimensions
    • Volume and surface area
    • Center of mass
    • Topology counts (solids, faces, edges, vertices)
  • get_parameters - Extract customizable parameters from CadQuery scripts

  • export - Export models to various formats

    • STEP, STL, SVG, DXF, AMF, 3MF, VRML, BREP

Installation

Prerequisites

CadQuery must be installed first. The recommended method is via conda:

conda install -c conda-forge cadquery

Install from Source

git clone https://github.com/CadQuery/cadquery-contrib.git
cd cadquery-contrib/mcp-server
pip install .

For development (editable install):

pip install -e .

Run Tests

pip install pytest
pytest test_cadquery_mcp_server.py -v

Configuration

Claude Code

Add to your ~/.claude/settings.json:

{
    "mcpServers": {
        "cadquery": {
            "command": "cadquery-mcp"
        }
    }
}

Claude Desktop

Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
    "mcpServers": {
        "cadquery": {
            "command": "cadquery-mcp"
        }
    }
}

Note: If using conda, you may need to specify the full path:

{
    "mcpServers": {
        "cadquery": {
            "command": "/path/to/conda/envs/yourenv/bin/cadquery-mcp"
        }
    }
}

Usage Examples

Once configured, you can ask Claude to create 3D models:

"Create a box with a hole through it"

Claude will execute:

import cadquery as cq

result = (
    cq.Workplane('XY')
    .box(20, 20, 10)
    .faces('>Z')
    .workplane()
    .hole(5)
)

And return a rendered SVG image of the model.

Multi-View Rendering

For complex models, request multiple views:

"Show me this bracket from multiple angles"

The server will return isometric, front, top, and right views.

Parametric Models

CadQuery scripts can define parameters:

height = 10.0  # Height of the box
width = 20.0   # Width of the box
depth = 5.0    # Depth of the box

import cadquery as cq
result = cq.Workplane('XY').box(width, height, depth)

Use the get_parameters tool to extract these for modification.

Exporting Models

Export to STEP for manufacturing or STL for 3D printing:

"Export this model as a STEP file to ~/models/bracket.step"

API Reference

render

Execute CadQuery code and return rendered image(s).

Parameter Type Default Description
code string required CadQuery Python code to execute
view string "isometric" Camera angle (isometric, front, back, top, bottom, left, right, isometric_back)
multi_view boolean false Return multiple views
width integer 800 Image width in pixels
height integer 600 Image height in pixels
show_hidden boolean true Show hidden lines

inspect

Get geometry information about the resulting shape.

Parameter Type Default Description
code string required CadQuery Python code to execute

get_parameters

Extract customizable parameters from a script.

Parameter Type Default Description
code string required CadQuery Python code to parse

export

Export the model to a file.

Parameter Type Default Description
code string required CadQuery Python code to execute
filename string required Output filename
format string auto Export format (STEP, STL, SVG, DXF, AMF, 3MF, VRML, BREP)

Writing CadQuery Scripts for MCP

Scripts should either:

  1. Assign the final shape to a variable named result:

    result = cq.Workplane('XY').box(1, 2, 3)
    
  2. Use show_object() to output shapes:

    box = cq.Workplane('XY').box(1, 2, 3)
    show_object(box)
    

License

Apache License 2.0 - see LICENSE for details.

Contributing

Contributions are welcome! Please see the cadquery-contrib repository for guidelines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cadquery_mcp-0.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cadquery_mcp-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file cadquery_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: cadquery_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for cadquery_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1d839b8a0ccfaa48031c628905062a1af9be03c4cafbe3747338a49e822ae372
MD5 8d2fabec03b96cccb5c84d4152ffb1b1
BLAKE2b-256 b61498d5a78124d8f211981d4dc4d7b9d3f5412949b85f8bc4eff74cd6dab430

See more details on using hashes here.

File details

Details for the file cadquery_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cadquery_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for cadquery_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70d5288c724532d1b2fa479c35af0fd17bb60bfdec98c28cbb8c3647e12a11b7
MD5 e0786b7f62e5f6ec41499e938a89fc58
BLAKE2b-256 6eed5948ec5c8fdc17fdc04d6790540ef01377e185badeba0f1892fd56e4b2e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page