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_instance field 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 PersistentPythonSession class for managing the persistent Python session.

metadatadict

Dictionary for storing arbitrary metadata related to the context.

command_historylist

List to keep track of executed commands in the session.

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

Attribute detail#

PyAnsysBaseAppContext.product_instance: Any | None = None#
PyAnsysBaseAppContext.python_executable: Any | None = None#
PyAnsysBaseAppContext.python_session: Any | None = None#
PyAnsysBaseAppContext.metadata: dict[str, Any]#
PyAnsysBaseAppContext.command_history: list[str] = []#