CFXSchemaCache#

class ansys.cfx.mcp.cfx.schema_cache.CFXSchemaCache(config_files: Iterable[str] | None = None)#

In-memory index of the CFX API tree for code generation grounding.

Overview#

get

Get schema metadata for a CFX API path.

exists

Return whether a normalized CFX path exists in the schema cache.

has_allowed_values

Return whether the schema declares an explicit value set for path.

get_allowed_values

Get the schema-declared allowed values for path.

get_command_arguments

Get the argument schema for a CFX Command/Query path.

children

Return child schema paths directly under a CFX parent path.

suggest

Suggest close schema paths for an unknown CFX path.

__len__

Return the number of schema paths currently stored in the cache.

Import detail#

from ansys.cfx.mcp.cfx.schema_cache import CFXSchemaCache

Method detail#

CFXSchemaCache.__len__() int#

Return the number of schema paths currently stored in the cache.

Returns:
int

Number of schema entries stored in the cache.

CFXSchemaCache.get(path: str) SchemaNode | None#

Get schema metadata for a CFX API path.

Parameters:
pathstr

Dotted CFX schema path to find. The path may be supplied in display form or normalized PyCFX attribute form.

Returns:
SchemaNode | None

Schema metadata for the path when it exists in the cache. Otherwise, None.

CFXSchemaCache.exists(path: str) bool#

Return whether a normalized CFX path exists in the schema cache.

Parameters:
pathstr

CFX API, object, schema, or file path to process.

Returns:
bool

Whether the cache contains the requested normalized CFX path.

CFXSchemaCache.has_allowed_values(path: str) bool#

Return whether the schema declares an explicit value set for path.

True when the bundled configuration files attach an enum-style allowed-value list to the path or to its cfx_type (such as UIMode). False for free-form primitives (integer/real/string/boolean) and for paths that the schema does not know.

CFXSchemaCache.get_allowed_values(path: str) tuple[Any, Ellipsis] | None#

Get the schema-declared allowed values for path.

Returns None when no enumeration is known. Callers should prefer the live-state probe (Backend.get_allowed_values) and use this as a fallback for offline/disconnected workflows.

CFXSchemaCache.get_command_arguments(path: str) tuple[CommandArgument, Ellipsis]#

Get the argument schema for a CFX Command/Query path.

Returns an empty tuple for non-command paths or for paths not present in the cache.

CFXSchemaCache.children(path: str) list[str]#

Return child schema paths directly under a CFX parent path.

Parameters:
pathstr

Parent CFX schema path whose immediate children should be listed.

Returns:
list[str]

Sorted child paths recorded for the parent, or an empty list when the parent is unknown or has no recorded children.

CFXSchemaCache.suggest(path: str, *, limit: int = 3) list[str]#

Suggest close schema paths for an unknown CFX path.

Parameters:
pathstr

Unknown or partially typed CFX schema path to match against known entries.

limitint, default: 3

Maximum number of suggested schema paths to return.

Returns:
list[str]

Candidate schema paths ordered by closeness to the requested path.