Solidworks MCP

MCP server for SolidWorks 2021 - create engineering drawings from any MCP client (Claude Code, Codex, Gemini CLI, Cursor...) via COM

Documentation

solidworks-mcp banner

solidworks-mcp

CI License: MIT Python 3.10+

English | 繁體中文

An MCP server that lets Claude — or any MCP client that speaks Streamable HTTP — drive SolidWorks 2021 to create engineering drawings over your LAN, through the pywin32 COM API.

Open a part, generate first-angle standard views, add dimensions and balloons, insert a BOM table, then export to PDF — all from a Claude conversation.

Features

21 tools in 5 categories:

CategoryTools
File operations (3)open / close / list documents
Drawing views (6)create drawing from template, standard views, first-angle aligned 3-view, section view, detail view, custom-orientation view
Annotation (6)import model dimensions, probe edges, add dimensions (linear / diameter / radius / angle), auto reference dimensions, balloons, BOM table
Export (4)capture drawing (JPEG), capture model views, save as PDF, save drawing
Assembly analysis (2)read mates, read feature tree

See the full tool reference below.

Architecture

Claude Code ◄── Streamable HTTP ──► src/server.py (FastMCP)
                                         │
                                    async tool handlers
                                         │
                                    sw.execute(func)  ← asyncio + Future
                                         │
                                    COM Worker Thread (STA, singleton)
                                         │
                                    pywin32 COM → SolidWorks 2021

SolidWorks COM must be driven from a single STA thread. All tool handlers are async and dispatch their COM callables onto a dedicated worker thread, bridged back with concurrent.futures.Future.

Requirements

  • Windows 10/11 host with SolidWorks 2021 installed
  • Python 3.10+
  • An MCP client that supports Streamable HTTP (e.g. Claude Code, Codex CLI, Gemini CLI, Cursor — see Compatible MCP clients) on the same trusted LAN
  • Optional: a drawing template (.drwdot) and an SMB shared folder for large screenshots / PDFs

Only SolidWorks 2021 has been tested. Other versions may work since the COM API is largely stable, but no guarantees.

Quick Start

1. Install (on the SolidWorks host)

git clone https://github.com/haunchen/solidworks-mcp.git
cd solidworks-mcp
python -m venv .venv
.venv\Scripts\pip install -r requirements.txt
Offline installation (host without internet access)

On a machine with internet access:

pip download -d ./wheels -r requirements.txt

Copy the repo (including wheels/) to the SolidWorks host, then:

.venv\Scripts\pip install --no-index --find-links wheels -r requirements.txt

2. Configure

Copy-Item .env.example .env
# edit .env — see Configuration below

3. Run

.venv\Scripts\python src\server.py

4. Connect from Claude Code (client machine)

claude mcp add --transport http solidworks http://<sw-host>:8080/mcp

Then just ask Claude: "Open bracket.sldprt and create a first-angle 3-view drawing with dimensions, then export it as PDF."

Compatible MCP clients

Any MCP client that supports Streamable HTTP and runs on your machine (or inside the LAN) can connect. Verified examples:

ClientConfig
Claude Codeclaude mcp add --transport http solidworks http://<sw-host>:8080/mcp
Codex CLIconfig.toml: [mcp_servers.solidworks]
url = "http://<sw-host>:8080/mcp"
Gemini CLIgemini mcp add --transport http solidworks http://<sw-host>:8080/mcp
Cursormcp.json: { "mcpServers": { "solidworks": { "url": "http://<sw-host>:8080/mcp" } } }
VS Code Copilot.vscode/mcp.json: { "servers": { "solidworks": { "type": "http", "url": "http://<sw-host>:8080/mcp" } } }
Clinecline_mcp_settings.json: { "mcpServers": { "solidworks": { "type": "streamableHttp", "url": "http://<sw-host>:8080/mcp" } } }
Windsurf~/.codeium/windsurf/mcp_config.json: { "mcpServers": { "solidworks": { "serverUrl": "http://<sw-host>:8080/mcp" } } }
Continue / Zed / JetBrains AI Assistant / opencode / Goosesee their MCP docs (url / uri field)

Agent frameworks work too: OpenAI Agents SDK (MCPServerStreamableHttp), LangChain (langchain-mcp-adapters).

Cloud-brokered connectors cannot reach a LAN-only server: Claude Desktop / claude.ai custom connectors and the Anthropic Messages API MCP connector all connect from the vendor's cloud, which is exactly what the trusted-LAN security model blocks.

Configuration

All settings are loaded from .env (see .env.example):

VariableDefaultDescription
SW_MCP_HOST0.0.0.0Address the server binds to
SW_MCP_PORT8080Server port
SW_MCP_SMB_PATHC:\mcp-shareServer-side folder for screenshots / PDFs that exceed the base64 limit
SW_MCP_SMB_CLIENT_PATH(empty)The same folder as seen from the client (e.g. U:\mcp-share); used to rewrite returned paths
SW_MCP_TEMPLATE(empty)Drawing template (.drwdot) used by create_drawing
SW_MCP_PAPER_SIZEA3Default paper size
SW_MCP_MAX_BASE641048576Max screenshot size (bytes) returned inline as base64; larger images are saved to the shared folder

Security

This server has no authentication. Anyone who can reach the port can drive your SolidWorks instance and read/write files through it.

  • Deploy on a trusted LAN only — never expose the port to the internet
  • Prefer binding SW_MCP_HOST to a specific LAN interface instead of 0.0.0.0
  • Consider OS-level firewall rules restricting access to known client IPs

Tool Reference

File operations

ToolDescription
open_documentOpen a SolidWorks document (.sldprt / .sldasm / .slddrw)
close_documentClose the specified document
list_open_documentsList all documents currently open in SolidWorks

Drawing views

ToolDescription
create_drawingCreate a new drawing document from a template
insert_standard_viewsInsert independent standard views (no projection alignment, custom scale)
insert_standard_views_alignedCreate first-angle aligned front / top / right views with auto scale
insert_section_viewCreate a section view on a parent view
insert_detail_viewCreate a detail (magnified) view on a parent view
insert_custom_viewInsert a named-orientation or arbitrary XYZ-rotation view

Annotation

ToolDescription
insert_model_dimensionsImport model dimensions into drawing views
probe_drawing_edgesInspect visible edges (index / type / coordinates in mm) before dimensioning
add_dimensionAdd a linear / diameter / radius / angle dimension between probed edges
auto_add_reference_dimensionsAuto-add reference dimensions (bounding box + circles) for non-parametric geometry
insert_balloonInsert balloons on an assembly drawing view (optionally filtered by component)
insert_bom_tableInsert a top-level-only BOM table

Export

ToolDescription
capture_drawingCapture the current drawing as JPEG (inline base64 or shared-folder path)
capture_viewCapture multi-angle screenshots from the 3D model
save_as_pdfExport the current drawing to PDF
save_drawingSave the current drawing (.slddrw)

Assembly analysis

ToolDescription
read_assembly_matesRead all mate relationships of a component in an assembly
get_feature_treeRead the feature tree of a document

Development

# run all tests (no SolidWorks needed — the COM layer is fully mocked)
.venv\Scripts\pytest tests/ -v

Behavior contracts live in docs/specs/ — specs with status: active describe the expected behavior of shipped features. Design history is in docs/plans/.

See CONTRIBUTING.md for development setup and PR guidelines.

License

MIT