PyAnsysBaseAppContext#
- class ansys.common.mcp.context.PyAnsysBaseAppContext#
Base application context for PyAnsys MCP servers.
This class provides a common structure that product-specific contexts can extend. The
product_instancefield can hold any Ansys product connection (such as MAPDL, Fluent, or Maxwell).- Attributes:
- product_instance[
Any], default:None Main product instance (such as MAPDL or Fluent) associated with the context.
- python_executable[
Any], default:None Python executable to use for the session.
- python_session[
Any], default:None Instance of the
PersistentPythonSessionclass for managing the persistent Python session.- metadata
dict Dictionary for storing arbitrary metadata related to the context.
- command_history
list List to keep track of executed commands in the session.
- product_instance[
Examples
Extend the base context for a specific product:
>>> from ansys.common.mcp import PyAnsysBaseAppContext >>> from dataclasses import dataclass >>> from typing import Optional, Any >>> >>> @dataclass >>> class NewAppContext(PyAnsysBaseAppContext): ... instance: Optional[Any] = None ... ... @property ... def product_instance(self): ... return self.instance
Overview#
Import detail#
from ansys.common.mcp.context import PyAnsysBaseAppContext