PyMechanicalAppContext#
- class ansys.mechanical.mcp.server.PyMechanicalAppContext#
Bases:
ansys.common.mcp.context.PyAnsysBaseAppContextApplication context with typed dependencies and CLI options.
- Attributes:
- mechanical
Optional[Any] Mechanical instance connection.
- owns_mechanical
bool Whether this server launched the connected Mechanical instance. Only owned instances are shut down on disconnect or server exit; attached instances are released and left running.
- lifecycle_lock
asyncio.Lock Serializes launch, connect, and disconnect operations.
- session_job
Optional[Any] Launch or connect operation that is still in progress, if any.
- change_previews
dict Pending property change previews by token. Each token is single use and expires after a few minutes.
- transport_type
str Transport type for PyMechanical-MCP. Options are
'stdio'and'http'.- mechanical_ip
Optional[str] IP address or hostname for Mechanical connection.
- mechanical_port
Optional[int] Port number for Mechanical connection.
- connect_on_startup
bool Whether to attempt Mechanical connection on PyMechanical-MCP startup.
- static_tools
bool Whether to expose all tools from startup instead of dynamically hiding tools that require an active Mechanical connection. When
False(default), tools taggedrequires_mechanicalstay hidden untillaunch_mechanicalorconnect_to_mechanicalsucceeds.- http_host
str Host address for HTTP transport.
- http_port
int Port number for HTTP transport.
- cors_origins
Optional[list[str]] List of allowed CORS origins for HTTP transport.
- grpc_transport_mode
Optional[str] gRPC transport mode for Mechanical connections. Options are
'auto','insecure','mtls', and'wnua'. When set to'auto'(default), the mode is determined automatically based on the platform and certificate availability.- certs_dir
Optional[str] Path to directory containing mTLS certificate files (
ca.crt,client.crt, andclient.key). Used whengrpc_transport_modeis'mtls'.
- mechanical
Overview#
Returns the Mechanical instance for backward compatibility. |
Import detail#
from ansys.mechanical.mcp.server import PyMechanicalAppContext
Property detail#
Attribute detail#
- PyMechanicalAppContext.lifecycle_lock: asyncio.Lock#