FluidsLeafMCP#

class ansys.fluent.mcp.common.base.FluidsLeafMCP(*, backends: dict[str, ansys.fluent.mcp.common.backend.Backend], expose_tools: Iterable[str] = ALL_TOOLS, name: str | None = None, **fastmcp_kwargs: Any)#

Bases: ansys.common.mcp.server.PyAnsysBaseMCP

Base server class for a single Fluids MCP leaf.

Overview#

run

Start the MCP server via the parent implementation when available.

product_startup

No persistent product session at startup. Backends connect lazily.

product_cleanup

Disconnect any active backend at shutdown.

build_toolsets

Build toolset definitions filtered to the tools this leaf exposes.

register_run_code_observer

Register a callable invoked after every run_code tool call.

backend

Return the active backend instance.

Import detail#

from ansys.fluent.mcp.common.base import FluidsLeafMCP

Property detail#

property FluidsLeafMCP.backend: ansys.fluent.mcp.common.backend.Backend#

Return the active backend instance.

Returns:
Backend

Backend produced by the operation.

Attribute detail#

FluidsLeafMCP.leaf_name: str = 'fluids'#
FluidsLeafMCP.default_backend_kind: str | None = None#
FluidsLeafMCP.cache_ttl_seconds: float = 30.0#
FluidsLeafMCP.component_label: str = ''#

Method detail#

FluidsLeafMCP.run(transport: str = 'stdio', host: str | None = None, port: int | None = None) None#

Start the MCP server via the parent implementation when available.

Parameters:
transportstr

Transport name used to run the MCP server.

hoststr | None

Host interface used by the server transport.

portint | None

Port used by the selected server transport.

Returns:
None

The function completes through its side effects.

FluidsLeafMCP.product_startup() None#

No persistent product session at startup. Backends connect lazily.

Returns:
None

The function completes through its side effects.

FluidsLeafMCP.product_cleanup() None#

Disconnect any active backend at shutdown.

Returns:
None

The function completes through its side effects.

FluidsLeafMCP.build_toolsets() list[dict[str, Any]]#

Build toolset definitions filtered to the tools this leaf exposes.

Returns a list of toolset dicts conforming to the PyAnsysMCPService conductor contract.

Returns:
list[dict[str, Any]]

Mapping containing the operation result.

FluidsLeafMCP.register_run_code_observer(observer: Callable[Ellipsis, Awaitable[None] | None]) None#

Register a callable invoked after every run_code tool call.

The observer is called as observer(code=..., result=..., error=...). result is the backend’s RunCodeResult on success (and None on exception); error is the raised exception on failure (and None on success). Observers may be sync or async. Exceptions raised by an observer are logged and swallowed so the original tool result is preserved.

Parameters:
observerCallable[…, Awaitable[None] | None]

Observer callback invoked after run-code execution.

Returns:
None

The function completes through its side effects.