aiida_mcp.plugins.inputs module

Builds AiiDA input nodes from paths, text, PKs or parameters.

class aiida_mcp.plugins.inputs.ControlInput(*, path: str | None = None, text: str | None = None, pk: int | None = None, parameters: dict[str, Any] | None = None)

Bases: FileInput

A control input. Give exactly one of path, text, pk or parameters.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

parameters: dict[str, Any] | None
class aiida_mcp.plugins.inputs.FileInput(*, path: str | None = None, text: str | None = None, pk: int | None = None)

Bases: BaseModel

Where an input comes from. Give exactly one of path, text or pk.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

path: str | None
pk: int | None
text: str | None
aiida_mcp.plugins.inputs.build_node(source: FileInput, name: str, default_filename: str, accepted: tuple[type[Node], ...]) → Node

Build an unstored node, or load a stored one, from a single input source.

Parameters:
  • source (FileInput) – The input source. Exactly one of its fields must be set.

  • name (str) – Name of the input, used in error messages.

  • default_filename (str) – Filename to use for a SinglefileData built from source.text.

  • accepted (tuple[type[orm.Node], ...]) – Node types accepted when source.pk refers to a stored node.

Returns:

The built or loaded node.

Return type:

orm.Node

Raises:

ToolError – If source does not have exactly one field set, the referenced path does not exist, the referenced PK does not exist, or the loaded node’s type is not in accepted.

aiida_mcp.plugins.inputs.load_existing_node(pk: int, name: str, accepted: tuple[type[Node], ...]) → Node

Load a stored node by PK, checking it is one of the accepted types.

For inputs that can only ever reference an existing node (e.g. a FolderData retrieved by some other calculation), rather than be built fresh from a path or text.

Parameters:
  • pk (int) – Primary key of the node to load.

  • name (str) – Name of the input, used in error messages.

  • accepted (tuple[type[orm.Node], ...]) – Node types accepted.

Returns:

The loaded node.

Return type:

orm.Node

Raises:

ToolError – If no node has the given PK, or its type is not in accepted.