FluentLeafMCP#
- class ansys.fluent.mcp.common.base.FluentLeafMCP(*, 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.PyAnsysBaseMCPBase MCP server class that exposes one or more
Backendinstances.
Overview#
Start the MCP server via the parent implementation when available. |
|
Return the MCP behavior hints for one of this server’s tools. |
|
Register a tool with behavior hints and the host contract applied. |
|
No persistent product session at startup. Backends connect lazily. |
|
Disconnect any active backend at shutdown. |
|
Return the product that owns |
|
Return the reconnect instruction valid for THIS server’s |
|
Return extra recovery fields for a |
|
Return the toolset catalog used by |
|
Build toolset definitions filtered to the tools this leaf exposes. |
|
Register a callable invoked after every |
Return the active backend instance. |
|
Names of the tools this server was asked to expose. |
Import detail#
from ansys.fluent.mcp.common.base import FluentLeafMCP
Property detail#
- property FluentLeafMCP.backend: ansys.fluent.mcp.common.backend.Backend#
Return the active backend instance.
- Returns:
BackendBackend produced by the operation.
Attribute detail#
Method detail#
- FluentLeafMCP.run(transport: str = 'stdio', host: str | None = None, port: int | None = None) None#
Start the MCP server via the parent implementation when available.
- FluentLeafMCP.tool_annotations_for(tool_name: str | None) dict[str, bool] | None#
Return the MCP behavior hints for one of this server’s tools.
Subclasses that register extra tools override this to add their own classifications and fall back to
super().
- FluentLeafMCP.tool(name_or_fn: Any = None, *args: Any, **kwargs: Any) Any#
Register a tool with behavior hints and the host contract applied.
Accepts every
FastMCP.toolcall form (direct function, positional or keyword name, bare decorator). Explicitannotations=win.- Parameters:
- name_or_fn
Any Tool name or function, as accepted by
FastMCP.tool.- args
Any Positional arguments forwarded to
FastMCP.tool.- kwargs
Any Keyword arguments forwarded to
FastMCP.tool.
- name_or_fn
- Returns:
AnyWhatever
FastMCP.toolreturns (a decorator or a tool).
- FluentLeafMCP.product_startup() None#
No persistent product session at startup. Backends connect lazily.
- Returns:
NoneThe function completes through its side effects.
- FluentLeafMCP.product_cleanup() None#
Disconnect any active backend at shutdown.
- Returns:
NoneThe function completes through its side effects.
- FluentLeafMCP.owning_product(tool_name: str) str | None#
Return the product that owns
tool_nameon this server.A single-product server owns all of its tools and reports its
leaf_name. A server that routes tools to several backends must override this so recovery guidance names the tool’s real owner.
- FluentLeafMCP.connect_recovery(product: str | None) dict[str, Any]#
Return the reconnect instruction valid for THIS server’s
connect.The base
connecttool acceptsbackend_kindandconnect_kwargs; it has noproductargument. Servers that register a differentconnectsignature must override this.
- FluentLeafMCP.extra_recovery(product: str | None) dict[str, Any]#
Return extra recovery fields for a
not_connectedresult.Extension point for embedding applications that need another step before a reconnect works (for example starting the solver in their own environment). Return
{}when there is none.- Parameters:
- product
Optional[str] Value returned by
owning_product()for the failing tool.
- product
- Returns:
- FluentLeafMCP.toolset_catalogue() dict[str, dict[str, Any]]#
Return the toolset catalog used by
build_toolsets().Subclasses that register extra tools override this and merge their own groups into
super().toolset_catalogue().
- FluentLeafMCP.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.
- FluentLeafMCP.register_run_code_observer(observer: Callable[..., Awaitable[None] | None]) None#
Register a callable invoked after every
run_codetool call.The observer is called as
observer(code=..., result=..., error=...).resultis the backend’sRunCodeResulton success (andNoneon exception);erroris the raised exception on failure (andNoneon success). Observers may be sync or async. Exceptions raised by an observer are logged and swallowed so the original tool result is preserved.