Skip to main content
Glama
PyAEDT-MCP
by yuxuan6426

Run Python Code

run_python_code

Execute custom Python code inside Ansys Electronics Desktop to automate design workflows and access the connected AEDT instance via PyAEDT.

Instructions

Execute Python code inside AEDT.

This tool runs inline Python code within the AEDT environment. The code has access to the connected AEDT instance via the desktop variable.

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": {
      "code": "<code>"
    },
    "name": "run_python_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesThe Python code to execute. The code has access to: - `desktop`: PyAEDT instance - `odesktop`: Native AEDT oDesktop COM object - `aedt_port`: gRPC port of the connected AEDT instance

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.4/5.0
Behavior3/5

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

No annotations are supplied, so the description carries the full disclosure burden. It usefully reveals that the code runs in-process against a connected AEDT instance with a live 'desktop' variable, but says nothing about side effects, error/timeout behavior, state persistence, or what happens to the AEDT session on failure.

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?

Short and front-loaded, with the environment stated in the first line. The second sentence largely restates the first and could be trimmed, but nothing is confusing or verbose.

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 single-parameter tool with full schema coverage and an output schema that covers return values, the description supplies the essential execution-context fact (inline code with access to the connected instance). The only missing element is sibling differentiation, which is partly covered elsewhere.

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% and the single 'code' parameter's injected variables (desktop, odesktop, aedt_port) are documented in the schema itself. The description repeats the 'desktop' variable and adds no syntax or format guidance beyond the schema.

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

Purpose4/5

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

States a specific verb and resource ('Execute Python code inside AEDT') and clarifies that execution happens inside the live AEDT environment. It does not differentiate itself from the sibling run_python_script, so an agent cannot tell from the text which one to use for a code string versus a script file.

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

Usage Guidelines2/5

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

There is no when-to-use guidance, no exclusions, and no mention of the obvious alternative run_python_script. The agent must infer selection from tool names alone.

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