The base.py module#

Summary#

FluidsLeafMCP

Base server class for a single Fluids MCP leaf.

BackendUnavailableError

Raised when a backend call fails because the backend is unavailable.

NotConnectedError

Raised when a backend call fails because the backend is not connected.

select_named_objects_from_mapping

Glob-expand pattern over named[collection].

Description#

Base MCP server for a Fluids leaf (geometry/mesh/solve/post).

A leaf:

  • Picks one or more Backend instances at construction time.

  • Inherits from PyAnsysBaseMCP so it can be registered alongside other PyAnsys MCP servers at the organisation level.

  • Auto-registers the standard deterministic tool surface:

    session_status, connect, disconnect, list_named_objects, get_state, get_targeted_context, run_code, validate_code, screenshot, and others (see ALL_TOOLS).

Concrete leaves only have to declare which tools to expose (subset of the above) so we keep the MCP surface lean per leaf.

Module detail#

base.select_named_objects_from_mapping(named: dict[str, list[str]], *, collection: str, pattern: str = '*', include_shadows: bool = True, exclude: list[str] | None = None) dict[str, Any]#

Glob-expand pattern over named[collection].

Pure-data helper — no backend, no I/O. Used by both the select_named_objects MCP tool and tests. Accepts either dotted (setup.boundary_conditions.wall) or slashed-and-hyphenated (setup/boundary-conditions/wall) collection spellings so callers don’t have to know which naming convention the active backend happens to use.

Parameters:
nameddict[str, list[str]]

Mapping of available named objects.

collectionstr

Collection of named objects to search.

patternstr

Selection pattern used to match object names.

include_shadowsbool

Whether shadow objects should be included in results.

excludeOptional[list[str]]

Names or patterns excluded from the selection.

Returns:
dict[str, Any]

Mapping containing the operation result.

base.ALL_TOOLS = ('session_status', 'connect', 'disconnect', 'list_named_objects', 'find_named_object',...#