Skip to main content

fastmcp.utilities.components

Classes

FastMCPMeta

FastMCPComponent

Base class for FastMCP tools, prompts, resources, and resource templates. Methods:

make_key

make_key(cls, identifier: str) -> str
Construct the lookup key for this component type. Args:
  • identifier: The raw identifier (name for tools/prompts, uri for resources)
Returns:
  • A prefixed key like “tool:name” or “resource:uri”

key

key(self) -> str
The globally unique lookup key for this component. Format: ”:” e.g. “tool:my_tool”, “resource:file://x.txt” Subclasses should override this to use their specific identifier. Base implementation uses name.

get_meta

get_meta(self, include_fastmcp_meta: bool | None = None) -> dict[str, Any] | None
Get the meta information about the component. If include_fastmcp_meta is True, a _fastmcp key will be added to the meta, containing a tags field with the tags of the component.

enable

enable(self) -> None
Removed in 3.0. Use server.enable(keys=[…]) instead.

disable

disable(self) -> None
Removed in 3.0. Use server.disable(keys=[…]) instead.

copy

copy(self) -> Self
Create a copy of the component.

register_with_docket

register_with_docket(self, docket: Docket) -> None
Register this component with docket for background execution. No-ops if task_config.mode is “forbidden”. Subclasses override to register their callable (self.run, self.read, self.render, or self.fn).

add_to_docket

add_to_docket(self, docket: Docket, *args: Any, **kwargs: Any) -> Execution
Schedule this component for background execution via docket. Subclasses override this to handle their specific calling conventions:
  • Tool: add_to_docket(docket, arguments: dict, **kwargs)
  • Resource: add_to_docket(docket, **kwargs)
  • ResourceTemplate: add_to_docket(docket, params: dict, **kwargs)
  • Prompt: add_to_docket(docket, arguments: dict | None, **kwargs)
The **kwargs are passed through to docket.add() (e.g., key=task_key).