Skip to main content
Glama
SolidWorks MCP Python

SolidWorks MCP Python

by locense

Generate VBA Code

generate_vba_code
Read-onlyIdempotent

Write a VBA macro skeleton for a described SolidWorks operation, including connection, document type check and optional error handling, with the operation left as a TODO starting point.

Instructions

Write a VBA macro skeleton for an operation you describe: the SolidWorks connection, a check of the active document's type and optional error handling, with the operation itself left as a TODO.

Use it as a starting point for a custom macro. For a complete macro for a specific feature, use a generate_vba_* tool (extrusion, revolve, mates, drawing views, batch export). The macro reports through Debug.Print, never a dialog, so it runs without waiting on anyone: save it as a .swb file and run it with execute_macro (its Sub main() calls the Sub named sub_name; SolidWorks runs a .swb macro only through main). It stops, printing why, when the active document isn't target_document. Read-only. Nothing runs in SolidWorks. Returns: vba_code with code, sub_name, operation, target_document, lines_of_code and includes_error_handling.

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": "generate_vba_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
input_dataYesThe macro to write. Nothing is required: give `operation_description` (it also names the Sub) and `target_document` (Part, Assembly or Drawing); `include_error_handling` is on by default.

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 read-only/idempotent/non-destructive, and the description reinforces this with "Read-only. Nothing runs in SolidWorks" rather than merely repeating the hint. It adds behavior annotations cannot express: output goes through `Debug.Print` never a dialog, the macro aborts and prints a reason when the active document isn't `target_document`, and SolidWorks only invokes a .swb macro through `main` — a non-obvious execution constraint.

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 purpose and alternative routing before the mechanics, and the dense sentences each carry information. The trailing enumeration of the return payload is largely redundant given an output schema exists, which is the one place the text does not earn its space.

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 read-only code-generator with a full schema and an output schema, everything an agent needs to call it and act on the result is present: when to pick it, what it will and won't do, how to execute the artifact, and failure behavior. Returning values are documented by the output schema, so no gap remains.

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

Parameters3/5

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

Schema description coverage is 100%, so the nested `operation_description`, `target_document` enum, and `include_error_handling` default are already documented, and the description's document-type gating restates what the schema says. It adds essentially no new parameter meaning, and it never mentions the required `input_data` wrapper, so the baseline 3 is the right ceiling.

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 deliverable: "Write a VBA macro skeleton for an operation you describe," then enumerates the skeleton's contents (SolidWorks connection, active-document type check, optional error handling, operation left as TODO). It immediately distinguishes itself from the feature-specific generators by naming the `generate_vba_*` family and listing the concrete members (extrusion, revolve, mates, drawing views, batch export).

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

Usage Guidelines5/5

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

Explicit when-to-use ("Use it as a starting point for a custom macro") and explicit when-not with the alternative named ("For a complete macro for a specific feature, use a `generate_vba_*` tool"). It goes further and hands the agent the downstream workflow — save as .swb, run via `execute_macro` — so the routing decision and the follow-on call are both unambiguous.

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