onshape-cad MCP server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@onshape-cad MCP serverCreate a 50mm diameter, 10mm thick cylinder in Onshape"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
onshape-cad MCP server
A local MCP server that lets Claude make real, editable changes in Onshape: sketches with constraints and dimensions on planes or faces, solid features, Variable Studios, configurations with per-row values, configurable library inserts, assemblies with working mates and motion tests, exact interference, colors, materials, FeatureScript custom features, versions and branches, and import/export to disk. 63 tools in millimeters on top of hedless/onshape-mcp.
Pair it with the Claude skill onshape-cad (separate repository) for the workflow, safety rules and request budgeting.
Quick start
curl -LsSf https://astral.sh/uv/install.sh | sh # if you do not have uv
uv sync
cp .env.example .env # then paste your Onshape API keys into .envCreate API keys at https://dev-portal.onshape.com/keys (read, write, delete). Never commit
.env.Add to Claude Desktop's
claude_desktop_config.json(macOS:~/Library/Application Support/Claude/, Windows:%APPDATA%\Claude\) and restart Claude Desktop:{"mcpServers": {"onshape-cad": {"command": "/full/path/to/uv", "args": ["--directory", "/full/path/to/onshape-cad-mcp", "run", "onshape-mcp"]}}}Optional, about 10 API requests:
uv run python scripts/setup_tools_doc.pycreates a "Claude CAD Tools" document in your account (Set appearance, Mate connector at point) and writes its IDs to.env.
Related MCP server: 3DP MCP Server
Mind the API budget
Onshape plans have a yearly API request limit (often 2,500) plus daily caps per endpoint group. Check yours at Developer portal > Overview. The cost of each tool is listed below under "API budget".
Verified
Every tool was run against a live Onshape account. Request formats, known API problems and workarounds: docs/api-findings.md. Tool reference: docs/tools.md. Example configurable library part: NEMA 17/23 stepper motors from StepperOnline datasheets, scripts/build_nema_motor.py (about 110 requests).
License
MIT. Fork of hedless/onshape-mcp (MIT). Onshape is a trademark of PTC; this project is not affiliated with PTC or Anthropic.
Onshape MCP Server
This fork (
extendedbranch) adds the onshape-cad tool set. 63 extra tools in millimeters by default: sketches on any plane or face with constraints and dimensions, every core solid feature with face/edge queries, Variable Studios and#variables, configurations with per-option values and suppression, configurable library inserts, all mate types with limits and motion tests, exact (mesh) interference, appearance and part properties, Feature Studio writing and custom features, import and export to disk, versions and branches. See Extended build and docs/tools.md.
Enhanced Model Context Protocol (MCP) server for programmatic CAD modeling with Onshape.
Features
This MCP server provides comprehensive programmatic access to Onshape's REST API, enabling:
Core Capabilities (45 tools)
Document Discovery - Search and list projects, find Part Studios, navigate workspaces
Parametric Sketches - Rectangles, circles, lines, and arcs on standard planes
Feature Management - Extrude, revolve, thicken, fillet, chamfer, boolean, and pattern features
Assembly Management - Create assemblies, add instances, position parts, create mates (fastened, slider, revolute, cylindrical)
Assembly Analysis - Interference checking, position verification, face coordinate systems, body details
Variable Tables - Read and write Onshape variable tables for parametric designs
FeatureScript - Evaluate FeatureScript expressions, get bounding boxes
Export - Export Part Studios and Assemblies to STL, STEP, PARASOLID, GLTF, OBJ
Part Studio Management - Create and manage Part Studios programmatically
Installation
Prerequisites
Python 3.10 or higher
Onshape account with API access
Onshape API keys (access key and secret key)
Setup
Clone the repository:
git clone https://github.com/hedless/onshape-mcp.git
cd onshape-mcpCreate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activateInstall dependencies:
pip install -e .Set up environment variables:
export ONSHAPE_ACCESS_KEY="your_access_key"
export ONSHAPE_SECRET_KEY="your_secret_key"Or create a .env file:
ONSHAPE_ACCESS_KEY=your_access_key
ONSHAPE_SECRET_KEY=your_secret_keyGetting Onshape API Keys
Go to Onshape Developer Portal
Sign in with your Onshape account
Create a new API key
Copy the Access Key and Secret Key
Usage
Running the Server
onshape-mcpOr directly with Python:
python -m onshape_mcp.serverConfiguring with Claude Code
Add to your ~/.claude/mcp.json:
{
"mcpServers": {
"onshape": {
"command": "/absolute/path/to/onshape-mcp/venv/bin/python",
"args": ["-m", "onshape_mcp.server"],
"env": {
"ONSHAPE_ACCESS_KEY": "your_access_key_here",
"ONSHAPE_SECRET_KEY": "your_secret_key_here"
}
}
}
}Important Notes:
Use the absolute path to your virtual environment's Python executable
Find your path:
cd onshape-mcp && pwdto get the directory pathOn Windows: Use
C:/path/to/onshape-mcp/venv/Scripts/python.exeReplace the API keys with your actual keys from Onshape Developer Portal
Restart Claude Code after editing
mcp.json
Verify it works: Ask Claude Code: "Can you list my Onshape documents?"
For complete setup instructions, see docs/QUICK_START.md.
Available Tools
Document & Navigation Tools
Tool | Description |
| List documents with filtering and sorting |
| Search documents by name or description |
| Get detailed document information |
| Get comprehensive summary with workspaces and elements |
| Find Part Studios with optional name filtering |
| Get all elements (Part Studios, Assemblies, BOMs) in a workspace |
| Get all parts from a Part Studio |
| Create a new Onshape document |
| Create a new Part Studio in a document |
Assembly Tools
Tool | Description |
| Create a new Assembly in a document |
| Add a part or sub-assembly instance to an assembly |
| Get assembly structure with instances and occurrences |
| Apply a relative transform (inches/degrees). Fails on fixed instances. |
| Set absolute position (resets rotation). Fails on fixed instances. |
| Align one instance flush against a face of another |
| Create an explicit mate connector on a face with offsets |
| Create a rigid (fastened) mate between two instances |
| Create a linear motion mate. First instance slides relative to second. |
| Create a rotational mate. First instance rotates relative to second. |
| Create a slide+rotate mate. First instance moves relative to second. |
| Delete a feature (mate, mate connector, etc.) from an assembly or Part Studio |
Assembly Analysis Tools
Tool | Description |
| Get positions, sizes, and bounds of all instances (in inches) |
| Get all features with their state (OK/ERROR/SUPPRESSED) |
| Get face IDs, surface types, normals, and origins for all parts |
| Query the outward-facing coordinate system for a specific face |
| Check for overlapping/interfering parts using bounding box detection |
Sketch Tools
Tool | Description |
| Rectangle with optional variable references for width/height |
| Circle with center point and radius |
| Line from start point to end point |
| Arc with center, radius, start angle, and end angle |
All sketch tools support plane (Front/Top/Right) and name parameters. Dimensions are in inches.
Feature Tools
Tool | Description |
| Extrude a sketch with depth, optional variable reference, and operation type |
| Thicken a sketch into a solid with optional midplane/opposite direction |
| Revolve a sketch around an axis (X/Y/Z) with angle and operation type |
| Round edges by edge IDs with radius (supports variable references) |
| Bevel edges by edge IDs with distance (supports variable references) |
| Repeat features along an axis (X/Y/Z) with distance and count |
| Repeat features around an axis with count and angle spread |
| Union, subtract, or intersect bodies by deterministic IDs |
Variable & Feature Tools
Tool | Description |
| Get all variables from a Part Studio variable table |
| Set or update a variable (e.g., |
| Get all features from a Part Studio |
FeatureScript Tools
Tool | Description |
| Evaluate a FeatureScript lambda expression (read-only) |
| Get the tight bounding box of all parts in a Part Studio |
Export Tools
Tool | Description |
| Export to STL, STEP, PARASOLID, GLTF, or OBJ (optional |
| Export to STL, STEP, or GLTF |
Architecture
onshape_mcp/
├── api/
│ ├── client.py # HTTP client with HMAC authentication
│ ├── documents.py # Document discovery & navigation
│ ├── partstudio.py # Part Studio management
│ ├── variables.py # Variable table management
│ ├── assemblies.py # Assembly lifecycle, mates & features
│ ├── export.py # Part Studio & Assembly export
│ └── featurescript.py # FeatureScript evaluation
├── builders/
│ ├── sketch.py # Sketch builder (rectangle, circle, line, arc, polygon)
│ ├── extrude.py # Extrude feature builder
│ ├── revolve.py # Revolve feature builder
│ ├── fillet.py # Fillet feature builder
│ ├── chamfer.py # Chamfer feature builder
│ ├── boolean.py # Boolean operations (union, subtract, intersect)
│ ├── pattern.py # Linear & circular pattern builders
│ ├── mate.py # Mate connector & mate builders (face-based)
│ └── thicken.py # Thicken feature builder
├── analysis/
│ ├── interference.py # Bounding-box interference detection
│ ├── positioning.py # Instance position queries & alignment
│ └── face_cs.py # Face coordinate system queries
├── tools/
│ └── __init__.py # MCP tool definitions
└── server.py # Main MCP server (45 tools)Examples
Example 1: Finding and Working on a Project
# Search for your project
documents = await search_documents(query="robot arm", limit=5)
# Get the first matching document
doc_id = documents[0].id
# Get comprehensive summary
summary = await get_document_summary(doc_id)
# Find Part Studios in main workspace
workspace_id = summary['workspaces'][0].id
part_studios = await find_part_studios(doc_id, workspace_id, namePattern="base")
# Now work with the Part Studio
elem_id = part_studios[0].idExample 2: Creating a Parametric Cabinet
# Set variables
await set_variable(doc_id, ws_id, elem_id, "width", "39.5 in")
await set_variable(doc_id, ws_id, elem_id, "depth", "16 in")
await set_variable(doc_id, ws_id, elem_id, "height", "67.125 in")
await set_variable(doc_id, ws_id, elem_id, "wall_thickness", "0.75 in")
# Create side panel sketch
await create_sketch_rectangle(
doc_id, ws_id, elem_id,
name="Side Panel",
plane="Front",
corner1=[0, 0],
corner2=[16, 67.125],
variableWidth="depth",
variableHeight="height"
)
# Extrude to create side
await create_extrude(
doc_id, ws_id, elem_id,
name="Side Extrude",
sketchFeatureId="<sketch_id>",
depth=0.75,
variableDepth="wall_thickness"
)Development
Running Tests
The project has comprehensive test coverage with 471 unit tests.
# Run all tests
pytest
# Run with coverage
pytest --cov
# Run specific module tests
pytest tests/api/test_documents.py -v
# Use make commands
make test
make test-cov
make coverage-htmlFor detailed testing documentation, see docs/TESTING.md.
Code Formatting
ruff format .
ruff check .Documentation
Getting Started
docs/QUICK_START.md - Quick start guide for Claude Code users
docs/DEV_SETUP.md - Development environment setup with SSE mode and debugging
Development & Testing
docs/TESTING.md - Testing guide and best practices
docs/TEST_SUMMARY.md - Test suite overview
docs/FEATURE_SUMMARY.md - Implementation details and statistics
API & Implementation
docs/ONSHAPE_API_IMPROVEMENTS.md - API format fixes and BTMSketch-151 implementation
docs/SKETCH_PLANE_REFERENCE_GUIDE.md - Advanced: Geometry-referenced sketch planes
docs/NEXT_STEPS_GEOMETRY_REFERENCES.md - Roadmap for geometry reference implementation
docs/DOCUMENT_DISCOVERY.md - Complete guide to document discovery features
docs/PARTS_ASSEMBLY_TOOLS.md - Parts and assembly tool documentation
Project Analysis & Research
docs/CARPENTRY_PRINCIPLES_FOR_CAD.md - How to think like a carpenter in CAD
docs/LEARNING_SUMMARY.md - Summary of side panel analysis and learnings
docs/DISPLAY_CABINETS_ANALYSIS_SUMMARY.md - Analysis of display cabinets project
docs/AGENT_CREATION_GUIDE.md - Guide for creating CAD agents
docs/CREATING_CAD_EXPERT_AGENT.md - Creating specialized CAD expert agents
Knowledge Base & Examples
knowledge_base/assembly_workflow_guide.md - Comprehensive assembly methodology (positioning, mates, solver behavior)
examples/cabinet_assembly.md - Complete worked example: cabinet with sliding drawers
knowledge_base/ - Onshape feature examples and research
Roadmap
Current Status
Document discovery and navigation (10 tools)
Sketch creation with rectangles, circles, lines, and arcs
Feature tools: extrude, revolve, thicken, fillet, chamfer, boolean, patterns
Full assembly management: fastened, slider, revolute, and cylindrical mates with face-based mate connectors
Assembly analysis: interference checking, position verification, face coordinate systems
Variable table management
FeatureScript evaluation and bounding box queries
Export to STL, STEP, PARASOLID, GLTF, OBJ
471 comprehensive unit tests
Live-tested on multi-part assemblies (25-instance cabinet with 66 features)
In Research
Geometry-referenced sketch planes - Create sketches on faces from existing features (see docs/SKETCH_PLANE_REFERENCE_GUIDE.md)
Query API investigation - How to programmatically reference geometry
Entity ID mapping - Understanding Onshape's internal ID system
Near-Term Priorities
Implement
create_sketch_on_geometry()for carpentry-correct cabinet assemblySketch constraints (coincident, parallel, tangent, etc.)
Pocket cuts and profiles for joinery (dados, rabbets)
Long-Term Goals
Drawing creation
Bill of Materials (BOM) generation
Advanced constraints and relations
Configuration parameter support
Woodworking-Specific Features
Joinery library (dado, rabbet, mortise & tenon, dovetail)
Standard hardware patterns (shelf pins, drawer slides)
Cut list generation
Material optimization (sheet layout)
Assembly instructions generation
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License
Acknowledgments
Inspired by OnPy
Built on the Model Context Protocol
Onshape API documentation: https://onshape-public.github.io/docs/
Support
For issues and questions:
GitHub Issues: https://github.com/hedless/onshape-mcp/issues
Onshape API Forum: https://forum.onshape.com/
Extended build (onshape-cad)
Install
git clone <this repo> onshape-mcp && cd onshape-mcp
git checkout extended
curl -LsSf https://astral.sh/uv/install.sh | sh # if uv is missing
uv syncAPI keys
Create keys at https://dev-portal.onshape.com/keys with read, write and delete permissions.
Put them in
.envin the repo root (git ignores it). Never commit or paste them anywhere else.
ONSHAPE_ACCESS_KEY=...
ONSHAPE_SECRET_KEY=...
# optional
ONSHAPE_UNITS=mm # mm | cm | m | in
ONSHAPE_AUTOVERSION_MINUTES=60 # write tools share one auto-version per this many minutesClaude Desktop
File: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS),
%APPDATA%\Claude\claude_desktop_config.json (Windows). Add under mcpServers, then restart Claude Desktop:
"onshape-cad": {
"command": "/Users/<you>/.local/bin/uv",
"args": ["--directory", "/path/to/onshape-mcp", "run", "onshape-mcp"]
}How the extended tools behave
Every length input and output uses
units(default mm). Angles are degrees. Any numeric input also takes an Onshape expression such as"#width / 2".Geometry inputs take deterministic IDs, a plane name, or a FeatureScript query (
find_entitiesreturns one). Queries resolve at call time; Onshape stores the result as a persistent reference.Write tools return IDs (feature, part, instance, mate) and a
regenblock. They create an automatic version first (create_version_first, default true; one version per 60 minutes of edits).Errors come back as
{"ok": false, "error": ...}with the Onshape message.Calls are logged without credentials to
logs/onshape-mcp.log.HTTP 429 with a short
Retry-Afteris retried with backoff. A long one (a daily limit) fails fast with the reset time.get_api_usageshows remaining calls per endpoint group.
API budget
Onshape plans have a yearly API request limit (often 2,500; see Developer portal > Overview). Daily per-group limits also apply. Typical cost per tool call:
Tool | Requests |
| 1, +1 if |
| 1, +1 per query input, +1 more only if the feature fails |
| 3 |
| 1 |
| 2 |
| 4 to 5 |
| 2 |
| 3 to 5 |
| about 5 + 2 per step (+1 per step with views), +1 per distinct part for interference |
| 1 + 1 per distinct part |
Auto-version | 1 per 60 minutes of edits per workspace |
Rules: read the model once and plan; batch edits; use find_entities once and reuse the returned query; skip views until the end; use checkSolve only on sketches that must be fully defined.
Tests
uv run pytest # unit tests, no network
uv run python scripts/smoke_test.py # live: every extended tool, about 150 requests. Avoid on a tight budget.
uv run python scripts/gen_tool_docs.pyKnown limits
Onshape daily API limits per endpoint group (for example
partstudios,assembliesabout 1000,partsabout 500). Heavy modeling can exhaust a group for about 23 hours.A mate with limits switched on ignores new mate values, and switching limits on returns it to 0.
test_motionworks around this; a limited mate cannot be held at a non-zero pose.Feature Studio writes do not return compile errors.
write_feature_studiodetects failure (no exported features) and test-parses function bodies to find line numbers; annotation and precondition errors are not located.MIDPOINTagainst the origin overdefines sketches; center rectangles use half-size dimensions instead.Faces of sketches placed on part faces:
qCreatedBy(sketch, VERTEX)also returns the face corners; use sketch point IDs.Assembly mate connectors from a FeatureScript query need the part in this workspace; for library parts use connectors defined in the part's Part Studio (
create_part_mate_connector).Exact interference uses tessellated meshes (0.2 mm chord tolerance). Overlaps under
minVolumeare ignored.
Details and request formats: docs/api-findings.md. Code layout: docs/architecture.md.
This server cannot be deployed
Maintenance
Related MCP Connectors
- OwlCADOAuthcom.owlcad
Parametric 3D CAD for AI agents: build print-ready parts, check them, export STL, 3MF or STEP.
Design 3D-printable parts by chatting: create, edit, render and publish parametric forges.
Run 3D CAD operations, pipelines, parametric models and STEP conversions on CAD Cloud with a key
Agent-first CAD: editable .kcad.ts source, deterministic review, OpenCASCADE kernel.
Related MCP Servers
- FlicenseBqualityAmaintenanceEnables programmatic CAD modeling with Onshape's REST API, offering 45 tools for parametric sketches, feature management, assemblies, analysis, variables, and exports.48151-
- AlicenseNot gradedqualityDmaintenanceEnables Claude to create 3D-printable CAD models using build123d, with tools for modeling, modification, analysis, and publishing to platforms like Thingiverse and GitHub.14Creative Commons Attribution Non Commercial No Derivatives 4.0 International
- FlicenseNot gradedqualityDmaintenanceEnables Claude to create and manipulate SolidWorks CAD models through natural language commands, automating part creation, sketching, and extrusion.10-
- AlicenseNot gradedqualityCmaintenanceEnables Claude Code to drive OnShape CAD through the REST API for parametric modeling, FeatureScript queries, and STL export/verification.MIT