Skip to main content
Glama
SolidworksMCP-python

SolidworksMCP-python

Run Macro

execute_macro
Destructive

Runs a SolidWorks macro file or supplied VBA source in the active SolidWorks session, invoking its main procedure and returning the run results.

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. Changed4 schema fields changedv2.1.0
    • changedInput schema / properties / input_data / description
      Previous value: -"The macro to run. Give `macro_path` (or `macro_file`);\n`proc_name` (main), `repeat_count` (1) and `pause_between_runs` (0 s)\nhave defaults."New value: +"The macro to run. Give `macro_path` (or `macro_file`), or\n`vba_source`; `proc_name` (main), `repeat_count` (1),\n`pause_between_runs` (0 s) and `dialog_timeout` (30 s) have\ndefaults."
    • addedInput schema / properties / input_data / properties / dialog_timeout
      Added value: +{
      +  "default": 30,
      +  "description": "Seconds a dialog the macro opens (MsgBox, form, prompt) may wait before it is answered with Cancel (or its only button) and the run fails as macro_waited_for_user",
      +  "maximum": 600,
      +  "minimum": 1,
      +  "type": "number"
      +}
    • changedInput schema / properties / input_data / properties / macro_path / description
      Previous value: -"Path to a binary SolidWorks macro (.swp, or legacy .swb). VBA source (.vb, .bas, text) cannot be run directly."New value: +"Path to a SolidWorks macro file (.swp, or legacy .swb). For VBA source text, use vba_source."
    • addedInput schema / properties / input_data / properties / vba_source
      Added value: +{
      +  "anyOf": [
      +    {
      +      "maxLength": 200000,
      +      "minLength": 1,
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "The macro's VBA text, instead of a file: written to a .swb and run. Only when the server allows it (SOLIDWORKS_MCP_ALLOW_VBA_SOURCE)"
      +}
  2. Changed13 schema fields changedv2.0.0
    • changedInput schema / properties / input_data / description
      Previous value: -"The input data value."New value: +"The macro to run. Give `macro_path` (or `macro_file`);\n`proc_name` (main), `repeat_count` (1) and `pause_between_runs` (0 s)\nhave defaults."
    • removedInput schema / properties / input_data / properties / execution_mode
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "type": "string"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "description": "Execution mode"
      -}
    • removedInput schema / properties / input_data / properties / execution_parameters
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "description": "Execution parameters"
      -}
    • removedInput schema / properties / input_data / properties / log_execution
      Removed value: -{
      -  "default": false,
      -  "description": "Log execution",
      -  "type": "boolean"
      -}
    • removedInput schema / properties / input_data / properties / parameters
      Removed value: -{
      -  "additionalProperties": true,
      -  "description": "Macro parameters",
      -  "type": "object"
      -}
    • changedInput schema / properties / input_data / properties / pause_between_runs / description
      Previous value: -"Pause between executions in seconds"New value: +"Seconds to wait between runs"
    • addedInput schema / properties / input_data / properties / pause_between_runs / minimum
      Added value: +0
    • removedInput schema / properties / input_data / properties / pause_on_error
      Removed value: -{
      -  "default": false,
      -  "description": "Pause on error",
      -  "type": "boolean"
      -}
    • addedInput schema / properties / input_data / properties / proc_name
      Added value: +{
      +  "default": "main",
      +  "description": "The macro procedure to call; main by default",
      +  "type": "string"
      +}
    • changedInput schema / properties / input_data / properties / repeat_count / description
      Previous value: -"Number of times to execute"New value: +"How many times to run the macro (1-100); it stops at the first failure"
    • addedInput schema / properties / input_data / properties / repeat_count / maximum
      Added value: +100
    • addedInput schema / properties / input_data / properties / repeat_count / minimum
      Added value: +1
    • removedInput schema / properties / input_data / properties / target_file
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "type": "string"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "default": null,
      -  "description": "Target file"
      -}
  3. Changed2 schema fields changedv1.5.0
    • changedInput schema / properties / input_data / properties / macro_file / description
      Previous value: -"Alternative macro file path"New value: +"Alternative to macro_path (.swp or .swb)"
    • changedInput schema / properties / input_data / properties / macro_path / description
      Previous value: -"Path to macro file (.swp or .vb)"New value: +"Path to a binary SolidWorks macro (.swp, or legacy .swb). VBA source (.vb, .bas, text) cannot be run directly."
  4. First observedv1.0.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