Skip to main content
Glama
SolidWorks MCP Python

SolidWorks MCP Python

by locense

Run Macro

execute_macro
Destructive

Run SolidWorks .swp/.swb macros or VBA source in the active SolidWorks session, calling a procedure to automate modeling tasks with optional repeat runs and dialog timeouts.

Instructions

Run a SolidWorks macro (.swp, or legacy .swb), or VBA source text, in the running SolidWorks, calling its main procedure.

Use it for a macro file, or VBA you wrote as vba_source. Source runs only if the user set SOLIDWORKS_MCP_ALLOW_VBA_SOURCE to restricted or full, else vba_source_off: ask the user, never set it yourself. Restricted source may call SolidWorks on the open documents only, else vba_source_refused, naming each line. The reply gives source_file and the vba_source run. The macro must not wait for the user: a dialog still open after dialog_timeout s (30) is answered with Cancel or its only button, and the run fails as macro_waited_for_user; a Yes/No prompt is left. It runs repeat_count times, pause_between_runs s apart, stopping at the first failure. Needs: SolidWorks running. Changes: whatever the macro does; it can't be undone from here. Returns: runs_completed and data from the last run (macro_path, module_name, proc_name, errors).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "input_data": "<input_data>"
    },
    "name": "execute_macro"
  }
}

Input Schema

NameRequiredDescriptionDefault
input_dataYesThe macro to run. Give `macro_path` (or `macro_file`), or `vba_source`; `proc_name` (main), `repeat_count` (1), `pause_between_runs` (0 s) and `dialog_timeout` (30 s) have defaults.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare destructive/non-idempotent, and the description goes well beyond them: changes cannot be undone from here, a lingering dialog is auto-cancelled after `dialog_timeout` and fails as `macro_waited_for_user`, a Yes/No prompt is left alone, and runs stop at the first failure. The refusal/error codes (`vba_source_off`, `vba_source_refused`) add real operational context.

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

Conciseness4/5

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

Front-loaded with the core action, then structured with 'Needs:', 'Changes:' and 'Returns:' labels that make it scannable. It is dense and repeats a few schema-stated defaults and behaviors, costing some economy.

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?

For a destructive, environment-gated execution tool, the description covers prerequisites, safety, dialog/repeat semantics and failure modes, and even summarizes the response fields despite an output schema existing. Nothing needed to invoke it correctly appears missing.

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 100%, so the baseline is 3; the description nevertheless adds meaning by tying `dialog_timeout` to the Cancel/only-button outcome and the `macro_waited_for_user` failure, and by noting `repeat_count` halts at the first failure. Some of this duplicates the schema text on those same params.

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 a SolidWorks macro (.swp, or legacy .swb), or VBA source text, in the running SolidWorks, calling its `main` procedure') and enumerates the accepted input forms. The purpose is unambiguous and easily separable from the geometry-construction siblings in the catalog.

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 explicit conditions separating the file path from `vba_source`, including the environment gate (SOLIDWORKS_MCP_ALLOW_VBA_SOURCE) and the instruction to ask the user rather than change it. It also states the prerequisite that SolidWorks must be running. It does not name an alternative tool, so it falls short of a 5.

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

Deploy Server

Other Tools