Skip to main content
Glama
README.md
# SolidworksMCP

**SolidworksMCP** is a production-oriented Model Context Protocol server for
controlling a live SOLIDWORKS session through the Windows COM API.

This is a fork of [alisamsam/Solidworks-MCP](https://github.com/alisamsam/Solidworks-MCP)
that extends it from 82 to 143 tools, adding drawings, assembly editing, sheet
metal, manufacturing package export and document reference tracing. See
[What this fork adds](#what-this-fork-adds).

Current release: **6.5.31**. The release was acceptance-tested with
**SOLIDWORKS 2026 SP2.1** and retains compatibility guards for SOLIDWORKS 2025.

## Highlights

- Native sketch, feature, body, reference-geometry, view, probe, and export
  operations.
- Transactional CAD plans with checkpoints, invariants, idempotency, budgets,
  and rollback.
- Parametric sketches with named entities, constraints, dimensions, equations,
  persistent IDs, and degree-of-freedom analysis.
- Multibody tools with explicit merge scope, clearance, interference, bounding
  box, and volume verification.
- Deterministic raster-to-sketch pipelines for silhouettes and line art,
  including GPU-backed segmentation, topology preservation, primitive fitting,
  and reverse-raster quality gates.
- Native sketch/body export and calibrated geometric comparison instead of
  screenshot-only acceptance.
- Verified active-sketch Normal To and Fit to Screen. The server reads the
  resulting camera matrix and pixel occupancy instead of trusting a UI command.
- Drawing documents end to end: sheets, views, model annotations, manual
  dimensions, notes, balloons, centre marks, and BOM tables.
- Assembly editing: components, mates, patterns, suppression, replacement, and
  exploded views.
- Sheet metal from base flange to flat pattern DXF, and a one-call
  manufacturing package that exports STEP, DXF and PDF for a whole assembly.
- Document search and reference tracing in both directions, including
  where-used across a project folder.
- Structured diagnostics, modal-dialog preflight, a narrowly scoped Modify
  watchdog, and finite recovery policies.

## What this fork adds

This repository is a fork of
[alisamsam/Solidworks-MCP](https://github.com/alisamsam/Solidworks-MCP). The
upstream release exposed **82 tools** covering sketches, solid features,
bodies, probes, vectorization and the transactional layer. This fork brings
that to **143 tools** and the test suite from 155 to **382 tests**, all of
which pass.

The additions follow the discipline the upstream project already established:
no COM return value is trusted. Every new operation reads the resulting state
back - annotation counts, component lists, suppression flags, face counts,
files on disk - and reports failure when the model does not actually show the
change, rather than when the API says so.

### Drawings (17 tools)

Upstream had no drawing document support at all. This fork covers the full
detailing path: `create_new_drawing`, `add_sheet`, `activate_sheet`,
`list_sheets`, `insert_drawing_view`, `insert_standard_views`,
`insert_section_view`, `insert_detail_view`, `list_drawing_views`,
`set_view_scale`, `insert_model_annotations`, `insert_bom_table`,
`add_drawing_dimension`, `insert_drawing_note`, `insert_balloons`,
`insert_center_marks` and `list_drawing_annotations`.

Views and annotations are verified by counting what appeared on the sheet;
`CreateDrawViewFromModelView3` and `InsertModelAnnotations3` both report
success for views and annotations that were never created.

### Assemblies (14 tools)

Upstream stopped at opening an assembly. This fork adds component and mate
work: `insert_component`, `list_components`, `add_mate`, `delete_mate`,
`list_mates`, `set_component_fixed`, `check_assembly_interference`,
`delete_component`, `replace_component`, `set_component_suppression`,
`pattern_components`, `explode_assembly`, `show_exploded` and
`list_exploded_views`.

### Sheet metal (6 tools)

Sheet metal is the one part discipline whose deliverable is not the solid but
the flat pattern - the DXF a laser or turret consumes. `create_base_flange`
thickens a sketch into a sheet metal body; `convert_to_sheet_metal` turns an
existing solid into one, which is the route imported geometry has to take
since a STEP of a bent bracket carries no bend information;
`create_edge_flange` bends flanges off edges without a profile sketch;
`set_flat_pattern` flattens or folds; `export_flat_pattern` writes the DXF or
DWG; `get_sheet_metal_info` reports the thickness, radius, K-factor and flat
pattern extents a quote or a nesting run needs.

`ExportFlatPatternView` reports success for a part whose flat pattern failed to
build, so the export is verified against the file on disk. The flat pattern
feature is found by its API type name rather than its displayed name, because
displayed names are localized.

### Manufacturing package (1 tool)

`export_manufacturing_package` produces the folder a shop actually receives, in
one call: a STEP for every part and for the assembly, a DXF for every sheet
metal part, a PDF of the drawing sitting beside each model, and a
`manifest.json` listing every file with the material and mass of each part. It
walks an assembly component by component, so a twenty-part machine takes one
call rather than sixty. Documents it had to open are closed again afterwards
and the originally active document is restored.

### Document search and references (3 tools)

`search_documents` finds SolidWorks files in a folder by name fragment and
type. `list_document_references` reports what a document uses and whether each
of those files is still on disk. `find_where_used` answers the reverse
question - which assemblies and drawings use this part - which SolidWorks
cannot answer directly, since a document records what it references and never
what references it. The reverse map is built by reading the dependencies of
every assembly and drawing in a folder tree, which is affordable only because
`GetDocumentDependencies2` reads a file's references without opening it.

### Features (5 tools)

`create_loft`, `create_rib`, `apply_draft`, `simple_hole` and `hole_wizard`,
each with the dead-feature guard: a feature that reports success while adding
no geometry is deleted rather than left in the tree.

### Configurations, properties and parameters (15 tools)

`activate_configuration`, `list_configurations`, `list_custom_properties`,
`set_custom_property`, `delete_custom_property`, `get_material`,
`set_material`, `get_mass_properties`, `get_dimension`, `set_dimension`,
`add_equation`, `set_equation`, `delete_equation`, `list_equations` and
`rebuild_document`.

`ShowConfiguration2` is one of the verified liars: it returns success for a
configuration that was never activated, so the active configuration is read
back afterwards.

### Beyond the tools

- Tool schemas moved out of `server.py` into a `schemas/` package grouped by
  family, which cut `server.py` from 3819 lines to 2300.
- Packaging metadata (`pyproject.toml`), a separate `vision` extra for the
  multi-gigabyte PyTorch backend, and a GitHub Actions workflow running the
  suite.
- `LICENSE` records both copyright holders and what the fork changes.

## Requirements

- Windows 10 or Windows 11.
- SOLIDWORKS 2025 or 2026, installed and licensed.
- Python 3.10 or newer; Python 3.11 is the acceptance-tested runtime.
- Git LFS for the packaged line-art checkpoints.
- An NVIDIA CUDA environment is strongly recommended for the deep
  vectorization modes. `get_capabilities` reports the actual backend state.

The server drives the interactive SOLIDWORKS process. It is not a headless CAD
kernel, and an unknown modal dialog must be inspected by a human.

## Clone and install

Install Git LFS before cloning, or pull the model objects afterwards:

```powershell
git lfs install
git clone https://github.com/aryesil/SolidworksMCP.git
Set-Location SolidworksMCP
git lfs pull
```

Create an isolated Python environment and install the package:

```powershell
py -3.11 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -e .
```

The base install covers every tool except deep silhouette vectorization, whose
PyTorch backend lives in the `vision` extra:

```powershell
python -m pip install -e ".[vision]"
```

The extra is separate because the CUDA wheels add several gigabytes to an
install that most tools never touch. Install the PyTorch build appropriate for
the machine's CUDA driver first if the default wheel does not match it;
`get_capabilities` reports the backend that is actually active.

`requirements.txt` still lists the base dependencies for anyone installing
without the package metadata.

## MCP configuration

Point the MCP client at the repository entry point using the virtual
environment's Python executable:

```json
{
  "mcpServers": {
    "SolidworksMCP": {
      "command": "C:\\path\\to\\SolidworksMCP\\.venv\\Scripts\\python.exe",
      "args": [
        "C:\\path\\to\\SolidworksMCP\\solidworks_mcp_server.py"
      ]
    }
  }
}
```

Start SOLIDWORKS, restart or reconnect the MCP client, then call
`get_capabilities` and `get_environment_status` before a substantial modeling
operation.

### Stable compatibility identifiers

`SolidworksMCP` is the public project and MCP handshake name. The Python package
remains `solidworks_mcp`, the configured tool namespace remains `solidworks`,
and existing artifact schemas retain their `solidworks-mcp/...` identifiers.
Those internal names are compatibility contracts and are intentionally not
renamed.

## Operation families

The server exposes both small native operations and higher-level verified
workflows. Important families include:

- documents and environment: create/open/save/close, capabilities, session
  metrics, modal-state inspection, recovery;
- sketches: standard planes, planar faces, exact model-coordinate contours,
  primitive drawing, parametric sketches, dimensions, constraints, equations;
- features: verified extrude/cut, revolve, sweep, fillet, chamfer, shell,
  mirrors, patterns, reference axes and planes;
- bodies: visibility, naming, appearance, volume, clearance, interference,
  multibody insert workflows;
- verification: ray/section probes, sketch topology, native geometry export,
  sketch-to-sketch and calibrated image comparisons, body silhouettes;
- vectorization: selectable silhouette/region/line-art modes, deep segmentation,
  controllable approximation, CAD commit, and reverse-raster verification;
- drawings: sheets, model and standard views, section and detail views, model
  annotations, manual dimensions, notes, balloons, centre marks, BOM tables;
- assemblies: component insertion and deletion, mates, replacement,
  suppression, component patterns, exploded views, interference checks;
- sheet metal: base flange, conversion of imported solids, edge flanges, flat
  pattern state, DXF/DWG flat pattern export, sheet metal parameters;
- manufacturing output: one-call package export of STEP, DXF and PDF with a
  manifest, for a part or a whole assembly;
- documents on disk: file search by name and type, outgoing references with
  missing-file detection, and where-used across a folder tree;
- configurations and parameters: configurations, custom properties, materials,
  mass properties, dimensions, equations;
- orchestration: transactions, declarative CAD plans, semantic primitives,
  model-graph synchronization, atomic export bundles.

Use MCP tool discovery for the authoritative live schema. Tool descriptions and
`get_capabilities` are versioned with the server.

## Safety rules

- Supply an absolute `save_path` before the first mutation of an unsaved
  document, or explicitly opt into disposable work with
  `allow_unsaved_document=true`.
- Treat `success` as execution evidence. Verify topology, body count, bounding
  boxes, volume, tolerances, and a readable independent artifact.
- Use `scope_bodies` and `expected_merge_bodies` for multibody cuts and bosses.
- Do not auto-confirm unknown dialogs. Only the recognized, operation-scoped
  dimension Modify dialog may be handled by the watchdog.
- Native MCP tool coordinates use the declared user unit, normally millimetres.
  Raw SOLIDWORKS COM coordinates use metres.
- Do not invoke a blind `Ctrl+8` after sketch operations. Version 6.5.31 already
  applies and verifies the stable side/up orientation and working-geometry fit.

## Vectorization models

The deterministic line-art checkpoints live under
`solidworks_mcp/models/lineart/` and are stored with Git LFS:

- `dexined_biped_v2.pt`
- `teed_biped_5.pt`

Their source and license notices are documented in
`solidworks_mcp/models/lineart/LICENSES.md`. A clone containing small LFS pointer
files instead of the binary objects is incomplete; run `git lfs pull` before
starting the server.

SOLIDWORKS Autotrace/Picture to Sketch is an interactive PropertyManager feature
and has no supported public API entry point. This server therefore uses its own
deterministic segmentation and line-art pipelines.

## Configuration

Default runtime settings are stored in `solidworks_mcp/config.json`. Keep
machine-specific or sensitive overrides in `config.local.json`; that file is
ignored by Git.

Notable defaults include:

- automatic SOLIDWORKS executable and template discovery;
- millimetres as the user unit;
- operation-scoped dimension dialog guard;
- bounded transaction/runtime limits;
- automatic checkpoint directory management;
- INFO-level file logging.

Relative `log_file` values are written under
`%LOCALAPPDATA%\SolidworksMCP\`, not into the source checkout. An absolute path
in `config.json` remains supported.

## Tests

The repository contains the deterministic unit and regression suite:

```powershell
python -m unittest discover -s tests -p "test_*.py"
```

The suite passes **382 tests**. These tests do not replace live acceptance
for COM behavior: qualifying another SOLIDWORKS major version should also cover
standard planes, planar faces, existing-sketch activation, view recovery,
features, transactions, vectorization, and export.

## Project layout

```text
SolidworksMCP/
|-- solidworks_mcp_server.py       MCP stdio entry point
|-- requirements.txt
|-- LICENSE
|-- solidworks_mcp/
|   |-- server.py                  MCP dispatch and handlers
|   |-- schemas/                   tool schemas, grouped by family
|   |-- tool_registry.py           high-level tool metadata
|   |-- vector_worker.py           isolated scientific worker
|   |-- config.py / config.json
|   |-- constants.py
|   |-- automation/                SOLIDWORKS COM implementation
|   |-- models/lineart/            Git-LFS checkpoints and licenses
|   `-- utils/
`-- tests/
    `-- test_v6.py                 unit and regression suite
```

Runtime logs, caches, local client settings, checkpoints, generated reports,
acceptance artifacts, and manual probes are intentionally excluded from the
repository.

## License

The server is distributed under the MIT License; see `LICENSE`. Packaged model
notices are retained separately in `solidworks_mcp/models/lineart/LICENSES.md`.

This repository is a fork of
[alisamsam/Solidworks-MCP](https://github.com/alisamsam/Solidworks-MCP) by
Samsaam Ali Baig. The original copyright notice is retained, and the
modifications made here are released under the same MIT License. `LICENSE`
records both copyright holders and summarises what this fork adds.