Skip to main content
Glama
NejcDvorsek

SolidWorks MCP

by NejcDvorsek

run_script

Execute Python in live SolidWorks to create or edit parts and assemblies and receive geometry, mass, clash, sketch, and image verification in one report.

Instructions

Run Python against the live SolidWorks: a whole part in one call, or what no tool covers; only when the server runs with --allow-scripts.

Give the script as code, or as a file at path: it may import helpers from its own folder (reloaded every run), so fix a part by editing the file and running it again. The script sees sw, model (current part/ assembly), drawing, mod (typed interfaces), wrap(obj, mod.IFeature), mm (mm -> m), to_mm, doubles([..]) (a VARIANT array) and session (this server's tools: session.new_part(), session.add_box(...)). print() is captured and result = ... comes back. All or nothing: a script that raises leaves the part as it was.

One report comes back for a part: features_added, failing_features, bodies (volume, box), clashes between bodies, under_defined_sketches, mass properties, seconds, and image: one PNG of the iso, right, top and bottom views (for a path, next to the script; image='x.png' elsewhere).

Input Schema

NameRequiredDescriptionDefault
codeNo
pathNo
imageNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.16.3

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries the full burden and does it well: atomicity is spelled out ('all or nothing: a script that raises leaves the part as it was'), the reload-every-run file semantics are disclosed, print capture and `result = ...` return behavior are named, and the returned report contents are enumerated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose and the --allow-scripts gate come first, then input modes, then the runtime namespace, then failure and return semantics. The dense namespace list is long but every entry is actionable information an agent needs to write a working script.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no annotations and no output schema, the description must cover safety profile, side effects, and return shape — and it does: mutation is implied, atomic rollback is stated, and the report fields (features_added, failing_features, bodies, clashes, under_defined_sketches, mass properties, image) are all listed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, but the prose defines all three parameters' roles: code vs path as alternative script sources, and image as a filename resolved next to the script for a path input or as a literal name otherwise. It never states the mutual exclusivity/requiredness of code vs path (both default to null, zero required), which is the one remaining ambiguity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource (run Python against the live SolidWorks) plus the two distinct modes: build a whole part in one call, or handle what no dedicated tool covers. The sibling list confirms dozens of narrow modeling tools, and this description makes clear this is the escape hatch rather than a duplicate of add_box/add_fillet.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a hard precondition (only when the server runs with --allow-scripts) and scopes usage to whole-part scripts or gaps in dedicated coverage. It stops short of an explicit 'prefer the dedicated tool when one exists', but 'what no tool covers' strongly implies the exclusion rule.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.