The tools.py module#
Summary#
Check the status of AEDT initialization. |
|
Return recent entries from the PyAEDT global logger. |
|
Check if AEDT is installed on the system. |
|
Launch a new AEDT instance. |
|
Connect to an existing AEDT instance via gRPC. |
|
Disconnect from the AEDT instance. |
|
Execute a Python script file inside AEDT. |
|
Execute Python code inside AEDT. |
|
List projects and designs for the connected AEDT instance. |
|
List all open AEDT projects. |
|
Open an AEDT project. |
|
Save an AEDT project. |
|
Create a new design in AEDT. |
|
Run analysis on an AEDT design. |
|
Export simulation results from AEDT. |
|
Capture a screenshot of the current AEDT design view. |
|
Export the active design configuration as a JSON file. |
|
Clear the AEDT state by closing all projects. |
|
Get information about the current model/design. |
Description#
List of tools in PyAEDT-MCP.
This module provides MCP tools for interacting with Ansys Electronics Desktop (AEDT) through PyAEDT library. It supports all AEDT applications including HFSS, Maxwell, Icepak, Circuit, and Q3D.
Module detail#
- tools.check_aedt_status(ctx: fastmcp.server.Context) str#
Check the status of AEDT initialization.
This tool is always reachable, even before a connection has been established. When no AEDT session is active, it returns a short hint describing how to establish one (
launch_aedtorconnect_to_aedt). When a session is active, it returns full status information.This makes the tool the recommended pre-flight call to decide whether to
launch_aedt(no active session) orconnect_to_aedt(existing session detected).This tool retrieves comprehensive information from the connected AEDT instance including version, active projects, designs, and connection details.
- Parameters:
- ctx
Context MCP context containing server session and application context.
- ctx
- Returns:
strJSON string containing comprehensive AEDT status information including:
connection: Basic connection info (version, machine, port, is_grpc)
projects: List of open projects
active_project: Currently active project name
active_design: Currently active design name
installed_versions: Available AEDT versions on the system
Returns an error message if AEDT is not available.
- tools.get_pyaedt_logs(ctx: fastmcp.server.Context, tail_lines: int = 200, contains: str | None = None, max_chars: int = 40000) str#
Return recent entries from the PyAEDT global logger.
This tool reads the active PyAEDT global log file and returns a tail view of the log contents. Optionally filter lines using a case-insensitive substring.
- Parameters:
- Returns:
strJSON string with log metadata and selected log text.
- tools.check_aedt_installed(ctx: fastmcp.server.Context) str#
Check if AEDT is installed on the system.
This tool checks for valid AEDT installations on the system and returns information about available versions.
When running inside a Docker container, the tool probes the remote gRPC endpoint (
AEDT_MACHINE:AEDT_PORT) instead of searching for a local AEDT installation.- Returns:
strStatus message indicating whether AEDT is installed and which versions are available.
- async tools.launch_aedt(ctx: fastmcp.server.Context, version: str | None = None, non_graphical: bool = False, confirm_new_session: bool = False, application: AEDTAppType | None = None) str#
Launch a new AEDT instance.
This tool starts a new AEDT instance using PyAEDT’s
Desktopclass, or it launches directly into a specific AEDT application session when requested. The launched instance is automatically connected and stored in the context for subsequent operations.- Parameters:
- ctx
Context MCP context containing server session and application context.
- version
str, default:None AEDT version to launch (such as
"2026.1"or"261"). IfNone, the latest installed version is used.- non_graphicalbool, default:
False Whether to launch AEDT in non-graphical mode. If
False, AEDT launches with the GUI visible.- confirm_new_sessionbool, default:
False Whether a new AEDT instance should be launched even when one or more connectable AEDT sessions are already available.
- application
AEDTAppType, default:None AEDT application to launch directly, such as
"Hfss"or"Maxwell3d". IfNone, AEDT launches in desktop mode.
- ctx
- Returns:
strLaunch status message with AEDT version and connection information.
- async tools.connect_to_aedt(ctx: fastmcp.server.Context, port: int | None = None, machine: str = 'localhost', version: str | None = None, non_graphical: bool = True, project_name: str | None = None, design_name: str | None = None) str#
Connect to an existing AEDT instance via gRPC.
This tool establishes a connection to a running AEDT instance using gRPC. The AEDT instance must be started with a gRPC server enabled: ansysedt.exe -grpcsrv
- Parameters:
- ctx
Context MCP context containing server session and application context.
- port
int, default:None gRPC port where AEDT is listening. If
None, the tool can auto-select a discovered local gRPC session or fall back to 50051.- machine
str, default:"localhost" Machine hostname or IP address where AEDT is running.
- version
str, default:None AEDT version to connect to. If
None, the tool automatically detects the version.- non_graphicalbool, default:
True Whether AEDT is running in non-graphical mode.
- project_name
str, default:None Project name to activate when connecting directly to a design.
- design_name
str, default:None Design name to attach directly to a PyAEDT application session. If
None, the connection remains at the AEDT level.
- ctx
- Returns:
strConnection status message with AEDT version information.
- async tools.disconnect_from_aedt(ctx: fastmcp.server.Context, close_projects: bool = False) str#
Disconnect from the AEDT instance.
This tool closes the connection to the AEDT instance and releases associated resources.
- tools.run_python_script(ctx: fastmcp.server.Context, script_path: str) str#
Execute a Python script file inside AEDT.
This tool runs a Python script from a file path within the AEDT environment, using AEDT’s built-in Python interpreter. The script has access to all AEDT APIs including oDesktop, oProject, and oDesign.
- tools.run_python_code(ctx: fastmcp.server.Context, code: str) str#
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
desktopvariable.- Parameters:
- ctx
Context MCP context containing server session and application context.
- code
str The 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
- ctx
- Returns:
strCode execution result or error message.
- tools.list_designs(ctx: fastmcp.server.Context, project_name: str | None = None) str#
List projects and designs for the connected AEDT instance.
- Parameters:
- Returns:
strJSON string containing the connected instance projects and designs.
- tools.list_projects(ctx: fastmcp.server.Context) str#
List all open AEDT projects.
- Parameters:
- ctx
Context MCP context containing server session and application context.
- ctx
- Returns:
strJSON string containing the list of open projects and their count.
- tools.open_project(ctx: fastmcp.server.Context, project_path: str, design_name: str | None = None) str#
Open an AEDT project.
- Parameters:
- Returns:
strStatus message with project and design information.
- tools.save_project(ctx: fastmcp.server.Context, project_name: str | None = None, save_as: str | None = None) str#
Save an AEDT project.
- Parameters:
- Returns:
strStatus message confirming the save operation.
- tools.create_design(ctx: fastmcp.server.Context, app_type: AEDTAppType, design_name: str | None = None, project_name: str | None = None, solution_type: str | None = None) str#
Create a new design in AEDT.
- Parameters:
- ctx
Context MCP context containing server session and application context.
- app_type
str AEDT application type. Options are
"Hfss","Maxwell2d","Maxwell3d","Q3d","Q2d","Icepak","Circuit","TwinBuilder","Mechanical","Emit","RMXprt", and"Hfss3dLayout".- design_name
str, default:None Name for the new design. If
None, an auto-generated name is used.- project_name
str, default:None Project to create design in. If
None, the active project is used.- solution_type
str, default:None Solution type for the design (app-specific).
- ctx
- Returns:
strStatus message with the created design information.
- tools.analyze_design(ctx: fastmcp.server.Context, setup_name: str | None = None, project_name: str | None = None, design_name: str | None = None, num_cores: int | None = None, num_tasks: int | None = None, num_gpus: int | None = None, acf_file: str | None = None, use_auto_settings: bool = True, solve_in_batch: bool = False, machine: str = 'localhost', run_in_thread: bool = False, revert_to_initial_mesh: bool = False, blocking: bool = True, analyze_all_designs: bool = False) str#
Run analysis on an AEDT design.
- Parameters:
- ctx
Context MCP context containing server session and application context.
- setup_name
str, default:None Name of the setup to analyze. If
None, all setups in the target design are analyzed.- project_name
str, default:None Name of the project to analyze. If
None, the active project is used.- design_name
str, default:None Name of the design to analyze. If
None, the active design is used.- num_cores
int, default:None Number of CPU cores to use for analysis.
- num_tasks
int, default:None Number of HPC tasks to use for analysis.
- num_gpus
int, default:None Number of GPUs to use for analysis.
- acf_file
str, default:None Full path to a custom ACF file for HPC configuration.
- use_auto_settingsbool, default:
True Whether to use automatic HPC settings when supported.
- solve_in_batchbool, default:
False Whether to solve the design in batch mode.
- machine
str, default: “localhost” Target machine name for remote or batch solves.
- run_in_threadbool, default:
False Whether to submit the batch solve in a background thread.
- revert_to_initial_meshbool, default:
False Whether to revert to the initial mesh before solving.
- blockingbool, default:
True Whether to block until the solve is complete.
- analyze_all_designsbool, default:
False Whether to analalyze all designs. When
True,Desktop.analyze_allis called for the target project/design. This analyzes all setups in a design or all designs in a project.
- ctx
- Returns:
strStatus message with analysis results.
- tools.export_results(ctx: fastmcp.server.Context, output_path: str, export_type: str = 'touchstone', setup_name: str | None = None) str#
Export simulation results from AEDT.
- Parameters:
- ctx
Context MCP context containing server session and application context.
- output_path
str Path to export the results to.
- export_type
str, default:"touchstone" Type of export. Options are
"touchstone","profile","convergence", and"mesh".- setup_name
str, default:None Setup name for the export. If
None, the active setup is used.
- ctx
- Returns:
strStatus message with export file path.
- tools.screenshot(ctx: fastmcp.server.Context, path: str = 'screenshot.jpg', project: str | None = None, design: str | None = None, plot_type: str = 'model', open_viewer: bool = True) list[mcp.types.TextContent | mcp.types.ImageContent]#
Capture a screenshot of the current AEDT design view.
This tool captures the current design preview as an image. It supports model views, field plots, and mesh visualizations, depending on what’s currently displayed in AEDT.
- Parameters:
- ctx
Context MCP context containing server session and application context.
- path
str, default:"screenshot.jpg" Output image path.
- project
str, default:None Project containing the design to capture. If
None, the active project is used.- design
str, default:None Design to capture. If
None, the active design is used.- plot_type
str, default:"model" Type of screenshot. Options are
"model","field", and"mesh".- open_viewerbool, default:
True Whether to open the saved screenshot in the system image viewer.
- ctx
- Returns:
list[TextContent|ImageContent]A list containing:
TextContent with the screenshot file path
ImageContent with the base64-encoded image data
- tools.export_config(ctx: fastmcp.server.Context, output: str | None = None, project: str | None = None, design: str | None = None, overwrite: bool = False) str#
Export the active design configuration as a JSON file.
- Parameters:
- ctx
Context MCP context containing server session and application context.
- output
str, default:None Path to output the JSON file to. If
None, the configuration is exported to a temporary file and returned inline.- project
str, default:None Project containing the design to export.
- design
str, default:None Design to export configuration from.
- overwritebool, default:
False Whether to overwrite an existing configuration file.
- ctx
- Returns:
strJSON string containing the exported configuration and associated design metadata. When
outputis provided, the returned JSON string also includes the written configuration file path.
- tools.clear_aedt(ctx: fastmcp.server.Context, close_projects: bool = True) str#
Clear the AEDT state by closing all projects.
- tools.get_model_info(ctx: fastmcp.server.Context, design_name: str | None = None) str#
Get information about the current model/design.
- tools.REQUIRES_AEDT_TAG = 'requires_aedt'#
- tools.logger#
- tools.AEDTAppType#