Skip to main content
Glama

solidworks-mcp-python

An MCP server that lets Claude (or any MCP client) drive SOLIDWORKS through its COM API, written in plain Python (stdlib + pywin32). Leer en español.

Its design follows the native Fusion 360 MCP: the main tool is sw_execute_script, which runs arbitrary Python against the live COM session. The typed tools are shortcuts on top. What makes that workable is the second half of the server: a local semantic index of the SOLIDWORKS API (signatures from your installation's type library + meaning, enums, units and official examples from the 2026 API help), so the model looks a call up before writing it instead of guessing 20 positional parameters.

Status: personal project, used daily to model parts, build assemblies with mates and produce dimensioned drawings. Windows only (COM). Tested with SOLIDWORKS 2026 (3DEXPERIENCE R2026x, Spanish UI) and Python 3.14 only. Reports from other versions and languages are welcome (open an issue).

Tools (22)

Group

Tools

Session / document

sw_connect sw_doc_info sw_new_part sw_open sw_close sw_rebuild

Modelling shortcut

sw_extrude (sketch + boss/cut in one step, mm)

Inspection

sw_list_bodies sw_bbox sw_list_features sw_screenshot

Save / export

sw_save_as sw_export_step

Engineering / manufacturing

sw_mass_properties (optionally sets the material), sw_check_machining (3-axis DFM, default profile Makera Carvera Air, STEP for the CAM), sw_interferences (grouped by component pair)

Script

sw_execute_script — scope: sw, doc, c (core), fx (features), mz (machining), am (assembly); readOnly guard

API knowledge

sw_api_doc sw_api_enum sw_api_members sw_api_search sw_api_example

Related MCP server: SolidWorks MCP Server

Install

Requirements: Windows, SOLIDWORKS running, Python ≥ 3.10.

git clone https://github.com/rskproductions/solidworks-mcp-python.git
cd solidworks-mcp-python
py -m pip install -e .

Claude Desktop (%APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "solidworks": {
      "command": "C:\\path\\to\\python.exe",
      "args": ["-m", "solidworks_mcp"]
    }
  }
}

Without pip install, point PYTHONPATH at the src folder instead: "env": {"PYTHONPATH": "C:\\path\\to\\solidworks-mcp-python\\src"}.

Check it: py -m solidworks_mcp --probe lists the tools.

Build the API index (once, locally)

The index is not distributed: the API help text and examples are Dassault Systèmes' copyright. The scripts below build it on your machine from your own installation and the public help site. Everything lands in data/ (or %LOCALAPPDATA%\solidworks-mcp, or SW_MCP_DATA).

:: 1. type library of YOUR installation -> data\api_index.txt (SOLIDWORKS open)
py tools\dump_api.py
:: 2. API help -> data\sw_api_index.sqlite (~15,000 pages, resumable)
py tools\index_build\crawl_full.py all
py tools\index_build\parse_raw.py
py tools\index_build\build_index_full.py
:: 3. swconst values (the help omits many) -> data\swconst.json
py -m solidworks_mcp.const --typelib

The server runs without the index; only the sw_api_* tools need it.

Layout

src/solidworks_mcp/
  server.py      MCP protocol (stdio JSON-RPC), tool definitions and handlers
  core.py        COM helpers: connection, sketch, extrude, thread, bodies, bbox,
                 edges/faces by geometry, chamfer/fillet, screenshot, save
  features.py    revolve, shell, Hole Wizard, circular/linear pattern, mirror,
                 draft, rib, reference plane, loft, sweep, sheet metal + flat DXF,
                 material, mass properties, equations, configurations
  mecanizado.py  3-axis DFM check (Carvera Air profile) and STEP export for the CAM
  asm.py         assemblies: components by position, faces by geometry, AddMate5,
                 interference detection
  const.py       swconst values from the help index + type library
  api_doc.py     merges type library + help for the sw_api_* tools
  api_lookup.py  sqlite client (stdlib)
  paths.py       where local data lives
tools/           dump_api.py and index_build/ (crawler -> parser -> sqlite)
scripts/         selftest, probetas.py (23-step regression: every feature checked
                 by VOLUME against its theoretical value), benchmarks, diagnostics
docs/            notes on other SOLIDWORKS MCP servers and APIs

Hard-won COM notes

Late-bound pywin32 against SOLIDWORKS has traps that neither the type library nor the help mention. The short version (details in README.es.md):

  • The COM API works in metres and radians.

  • A zero-argument member may arrive already evaluated: use c.soft(obj, "Name") (callable() does not tell you — CDispatch is always callable).

  • [in,out] ints → c.byref_int(); null interface → c.null_dispatch().

  • "Member not found" on methods that exist (CreateTransform, FixComponent) → c.call_method(obj, "Name", *args) forces DISPATCH_METHOD.

  • Parameterised property puts (ITableAnnotation.Text(r, c) = ...) → c.put_property(obj, "Text", r, c, value).

  • Array properties (IView.Position) need VARIANT(VT_ARRAY|VT_R8, [...]); a tuple silently misplaces the view.

  • Every COM round trip costs ~30 ms: performance is the number of calls. Scope face/edge searches to one feature (comp.FeatureByName(...).GetFaces).

  • win32com.client.constants is empty without makepy: use const("swFmFillet").

  • The default part template is in metres: flat-pattern DXFs come out 1000x too small. sw_new_part now sets MMGS; fx.units_mm(doc) for existing parts.

  • ISurface.EvaluateAtPoint returns the normal at [0:3], and IFace2.FaceInSurfaceSense == True means face and surface normals are opposite.

  • Hole Wizard: HoleWizard5 returned None in every combination tried; CreateDefinition(swFmHoleWzd) + InitializeHole + SelectByRay + CreateFeature works.

  • Mirror features: select the features (mark 1) before the plane (mark 2). Ribs can't be mirrored as features: mirror the body (mark 256).

  • A tool call has a 60 s budget in Claude Desktop: run long jobs as a subprocess that writes a log. Never two COM clients on the same session at once.

What we learned from them is in docs/.

License

MIT — see LICENSE. SOLIDWORKS is a trademark of Dassault Systèmes; this project is not affiliated with or endorsed by Dassault Systèmes.

Available Tools

22 tools
sw_api_docA

Ficha completa de un metodo o propiedad de la API: bloque de la typelib de ESTA instalacion (orden y tipo COM de cada parametro) + ayuda oficial 2026 SP04 (que significa cada parametro, enum que lo gobierna, unidades, retorno, remarks con las tablas de marcas de seleccion, desde que version existe). Consultar antes de escribir una llamada COM en sw_execute_script. Acepta 'FeatureManager' o 'IFeatureManager'.

Inputs: iface (required), member (required).

sw_api_enumA

Miembros y valores de un enum swconst (swEndConditions_e, swSelectType_e, swDocumentTypes_e...). Acepta tambien el nombre de un miembro suelto (swEndCondBlind) y resuelve a que enum pertenece. En codigo usa el nombre via win32com.client.constants, no el numero. swSelectType_e trae la tabla enum -> string que espera SelectByID2 (swSelFACES -> "FACE").

Inputs: name (required).

sw_api_exampleA

Ejemplos oficiales de codigo de la ayuda de la API 2026 (VBA; VB.NET si no hay VBA), indexados con las interfaces y miembros que los enlazan. Para descubrir el flujo completo de una operacion (que seleccionar, en que orden, que marcas) antes de escribirla en sw_execute_script. query = busqueda libre ('thread feature', 'insert component transform'); iface/member = los que enlaza esa interfaz o miembro; id = el codigo completo de uno.

Inputs: id, iface, limit, query, +1 more.

sw_api_membersA

Todos los miembros de una interfaz con su resumen de una linea: para descubrir que se puede hacer con IFeatureManager, IBody2, IFace2... Cubre todas las interfaces de los 10 namespaces de la ayuda 2026 (sldworks, swdimxpert, swmotionstudy, swpublished...). Incluye la ficha de la interfaz: resumen, como se obtiene (accessors), categoria funcional y ejemplos oficiales. Puede ser largo (IModelDoc2 tiene 762): filtra con kind si solo quieres propiedades.

Inputs: iface (required), kind.

sw_bboxB

Caja envolvente global en mm: min, max, tamano y centro.

Inputs: no named parameters.

sw_check_machiningA

Revision de fabricabilidad para fresado de 3 ejes desde +Z (perfil por defecto: Makera Carvera Air, 300x200x130 mm, pinzas 1/8", 1/4", 3/4/6 mm): cabe en el area, radio concavo minimo y fresas que caben, esbeltez L/D, agujeros justos para la fresa y caras que piden voltear la pieza. Con export_dir exporta ademas un STEP (mm) para Makera CAM. No genera trayectorias.

Inputs: export_dir.

sw_closeA

Cierra el documento activo. No guarda salvo que save=true.

Inputs: save.

sw_connectA

Adjunta a la instancia de SOLIDWORKS en marcha y devuelve version y documento activo. SOLIDWORKS debe estar ya abierto.

Inputs: no named parameters.

sw_doc_infoB

Titulo, ruta, tipo y numero de cuerpos del documento activo.

Inputs: no named parameters.

sw_execute_scriptA

Ejecuta Python arbitrario contra la sesion de SOLIDWORKS, igual que el 'script' del MCP de Fusion. En el scope del script: sw (la aplicacion), doc (ActiveDoc, puede ser None), c (el modulo solidworks_mcp.core, alias sw_core: extrude, bodies_info, overall_bbox, features_info, save_as...), fx (features: revolve, shell, hole_wizard, circular/linear_pattern, mirror_body, draft, rib, ref_plane_offset, loft, sweep, chapa, ecuaciones, configuraciones, mass_props), mz (mecanizado: dfm_3ejes, export_cam) y am (ensamblaje: add_mate, interferences). Escribe en la variable 'result' para devolver datos estructurados; lo impreso por print() se devuelve en 'stdout'.

ANTES de escribir una llamada COM que no conozcas de memoria, consulta sw_api_doc(iface, member): devuelve el orden y tipo real de los parametros en esta instalacion mas su significado, el enum que los gobierna y las unidades (la API trabaja en METROS y radianes). Los metodos de features tienen 20+ parametros posicionales; adivinarlos falla en silencio.

readOnly=true declara que el script no modifica el documento. Se comprueba en dos pasos: antes de ejecutar se bloquea si el texto contiene una llamada con pinta de mutar (Feature*, Insert*, Set*, Save*...) o una asignacion a propiedad; despues de ejecutar se compara el numero de cuerpos, de caras y el flag de modificado del documento, y si algo cambio pese a todo se devuelve en 'readOnlyViolation' en vez de ocultarlo. ESTO NO ES UNA CAJA DE ARENA: es una red contra el despiste, no una barrera de seguridad; con COM cualquier script con acceso a doc puede llamar a lo que quiera. No hay limite de tiempo: un script que cuelga bloquea el servidor hasta que termine.

Inputs: script (required), readOnly.

sw_export_stepC

Exporta el documento activo a STEP.

Inputs: path (required).

sw_extrudeA

Croquis + extrusion en un solo paso sobre el documento activo. Todo en mm. El croquis va en el plano indicado y la extrusion crece en +Z desde z0 hasta z1 (z0 >= 0; si z1 < z0 se invierte). cut=true elimina material en vez de anadirlo.

Inputs: z0 (required), z1 (required), profile (required), cut, +4 more.

sw_interferencesA

Interferencias del ENSAMBLAJE activo agrupadas por pareja de componentes (numero, volumen total y maximo en mm3). Puede tardar: ~40 s con 22 componentes.

Inputs: coincidence.

sw_list_bodiesB

Cuerpos solidos del documento activo con su caja envolvente en mm.

Inputs: no named parameters.

sw_list_featuresC

Arbol de operaciones del documento activo (nombre, tipo, suprimida).

Inputs: limit.

sw_mass_propertiesB

Propiedades fisicas del documento activo: volumen (mm3), area (mm2), masa (g), densidad (kg/m3) y centro de gravedad (mm). Si se pasa material, lo asigna antes (nombre del .sldmat, p.ej. '6061-T6 (SS)').

Inputs: database, material.

sw_new_partA

Crea una pieza nueva con la plantilla por defecto y la deja activa. Por defecto fija unidades MMGS (mm): la plantilla de fabrica viene en METROS y los DXF/DWG de chapa saldrian en metros.

Inputs: mm.

sw_openA

Abre un documento existente (.SLDPRT/.SLDASM) y lo deja activo.

Inputs: path (required).

sw_rebuildC

Fuerza reconstruccion del documento activo.

Inputs: full.

sw_save_asC

Guarda el documento activo en la ruta dada, opcionalmente tambien en STEP.

Inputs: path (required), step.

sw_screenshotB

Captura la vista activa a PNG. Equivalente al queryType 'screenshot' de Fusion: permite ver lo que se ha construido sin que el usuario este delante de la pantalla. Usa SaveBMP (unica exportacion de imagen confirmada en la typelib) y convierte a PNG con codigo propio, sin depender de Pillow.

Inputs: path, width, height, direction.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 22 tools

    Disambiguation4/5

    Each tool targets a distinct operation or resource, with the five sw_api_* tools clearly differentiated by purpose (search, doc, enum, members, example). Minor overlap exists between sw_bbox and sw_list_bodies (both report bounding boxes) and between sw_save_as (which can optionally export STEP) and sw_export_step, but descriptions disambiguate well.

    Naming Consistency4/5

    All tools use a consistent sw_ snake_case prefix, making them easy to recognize as part of the same server. However, the verb style varies: some are verb-first (sw_list_features, sw_open) while others are noun-first (sw_bbox, sw_mass_properties), a minor deviation from a pure verb_noun pattern.

    Tool Count4/5

    With 22 tools, the set is on the heavier side for a typical MCP server, but the breadth of SolidWorks automation (modeling, assembly, machining check, and API introspection) justifies most tools. No tool feels redundant enough to warrant removal, though some merging (e.g., bbox into list_bodies) could reduce count.

    Completeness4/5

    The server covers document lifecycle (new, open, save, close, export), inspection (bbox, mass, features, bodies), assembly interferences, and machining checks. Direct modeling tools are sparse (only extrude), but sw_execute_script plus extensive API documentation provides a complete escape hatch for any missing operation, leaving no dead ends.

    Maintenance

    ActivitySlowing
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables an AI assistant to drive an already-running SOLIDWORKS session over its COM API, so it can build sketches, solid features, reference geometry, assemblies, mates, and engineering drawings, then inspect the result through topology listings, mass properties, measurements, and screenshots returned as images.
      1
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents such as Claude to drive SolidWorks through its COM API using natural language, creating parts and assemblies, sketching geometry, and adding features without clicking menus. Also supports running arbitrary API scripts and verifying results through model reports, rendered views, interference checks, and exports.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude to control SolidWorks through natural language, supporting part and assembly creation, sketches, advanced features, dimension editing, selection inspection, screenshots, and rebuilds.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude to drive SolidWorks in natural language, creating parts and assemblies, sketching and modeling features, editing dimensions, setting materials, and exporting CAD files. It also exposes selection, mass-property, and viewport-capture tools so 3D designs can be built and verified conversationally.
      MIT