fastmcp.utilities.components

Classes

FastMCPMeta

FastMCPComponent

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

key

key(self) -> str
The key of the component. This is used for internal bookkeeping and may reflect e.g. prefixes or other identifiers. You should not depend on keys having a certain value, as the same tool loaded from different hierarchies of servers may have different keys.

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.

with_key

with_key(self, key: str) -> Self

enable

enable(self) -> None
Enable the component.

disable

disable(self) -> None
Disable the component.

copy

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

MirroredComponent

Base class for components that are mirrored from a remote server. Mirrored components cannot be enabled or disabled directly. Call copy() first to create a local version you can modify. Methods:

enable

enable(self) -> None
Enable the component.

disable

disable(self) -> None
Disable the component.

copy

copy(self) -> Self
Create a copy of the component that can be modified.