onshape-mcp
Enables Claude Code to drive OnShape CAD through the REST API for parametric modeling, FeatureScript queries, and STL export/verification.
README
onshape-mcp
MCP server that drives OnShape CAD from Claude Code: parametric modeling (sketches, extrudes, revolves, fillets, patterns), FeatureScript queries, and STL export/verification — via the OnShape REST API.
One-time setup
uv sync --no-editable
uv run --no-editable onshape-mcp setup # writes ~/.config/onshape-mcp/.env (chmod 600); no-op if it exists
uv run --no-editable onshape-mcp doctor # auth smoke test against the live API (4 calls)
Why
--no-editableeverywhere? macOS asynchronously marks files under.venvwith thehiddenflag here, and Python ≥3.13.8 skips hidden.pthfiles — editable installs silently stop importing minutes after a sync. Non-editable installs don't use.pthand are immune.
Credentials
API keys come from https://dev-portal.onshape.com/keys (an access key +
secret key pair). Credentials live ONLY in ~/.config/onshape-mcp/.env,
created by onshape-mcp setup with permissions 600 (owner read/write
only) — never in project folders, never committed, never printed. See
.env.example for the variable names; the process
environment (ONSHAPE_ACCESS_KEY / ONSHAPE_SECRET_KEY) takes precedence
over the file if both exist.
Per-project registration
From the CAD project folder where you want the server available (replace
/path/to/onshape-mcp with wherever you cloned this repo):
/path/to/onshape-mcp/install.sh
or equivalently:
claude mcp add --scope project onshape -- \
uv run --quiet --no-editable --project /path/to/onshape-mcp onshape-mcp
Or register it by hand in the project's .mcp.json:
{
"mcpServers": {
"onshape": {
"command": "uv",
"args": ["run", "--quiet", "--no-editable", "--project", "/path/to/onshape-mcp", "onshape-mcp"]
}
}
}
(--project, not --directory: the server resolves this repo's venv but keeps
the caller's cwd. File-path tool params should be absolute paths regardless.)
Project-scoped servers show "Pending approval" on the first interactive
session — approve when prompted.
Usage cheatsheet (for the LLM driving the tools)
Typical build flow
create_document (parentId = folder id) -> documentId, workspaceId, partStudioElementId
import_cad (ABSOLUTE path to .zip/STEP) -> foreign CAD into an existing workspace [async, +quota]
set_variable (optional, e.g. wall_thk) -> use "#wall_thk" in later expressions
create_sketch (plane {"default":"TOP"}) -> featureId [one closed profile per sketch]
extrude (sketchFeatureId, NEW, depth) -> base solid
create_sketch + extrude REMOVE THROUGH_ALL [holes: skip native hole feature]
find_entities (EDGE, radiusBetween) -> transient ids for fillet/chamfer
fillet_or_chamfer (entityIds) -> check featureStatus == OK after EVERY feature
pattern / revolve / boolean_parts as needed
export_stl (ABSOLUTE path) -> compare_stl(candidate, reference) [mesh: 3D-print, verify]
export_step (ABSOLUTE path) -> editable STEP B-rep solid [CAD/prototyping; async, +quota]
Iron rules
- Transient IDs go stale after ANY mutation. Always call
find_entitiesimmediately before the tool call that consumes the ids. Feature IDs (from create_sketch/extrude/...) are stable — prefer them where accepted (extrude regions, pattern seeds, boolean bodies). - Units: tool params and outputs are inches by default (
unitsparam to change). Dimension strings pass through:"1.53 in","25 mm","#wall_thk * 2". Angles are degrees.eval_featurescriptraw results are METERS/radians. - featureStatus is the regen feedback loop:
OKproceed;ERRORmeans the feature was added but failed — fix parameters viaupdate_featureordelete_featureand retry. Check it after every modeling call. - extrude REMOVE subtracts from ALL solids in the studio (defaultScope). Keep one part per studio unless you intend that.
- One closed profile per sketch keeps extrude region selection unambiguous.
- File paths must be ABSOLUTE (the server's cwd is not the project's).
- Be frugal: ~2,500 API calls/YEAR. Don't poll, don't re-list needlessly; analyze_stl/compare_stl cost zero calls.
Quota warning
OnShape EDU/Free accounts have an annual API quota (~2,500 calls/user/year);
exhaustion returns 402 and no backoff fixes it. This server keeps a persistent
call counter at ~/.config/onshape-mcp/call_log and logs a running total to
stderr. Monitor usage in OnShape under My Account → Developer.
Development
uv run --no-editable pytest # offline tests (no API calls, no credentials needed)
uv run --no-editable onshape-mcp doctor
License
MIT — see LICENSE.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.