Skip to main content

fastmcp.server.transforms.resources_as_tools

Transform that exposes resources as tools. This transform generates tools for listing and reading resources, enabling clients that only support tools to access resource functionality. Example:
from fastmcp import FastMCP
from fastmcp.server.transforms import ResourcesAsTools

mcp = FastMCP("Server")
mcp.add_transform(ResourcesAsTools(mcp))
# Now has list_resources and read_resource tools

Classes

ResourcesAsTools

Transform that adds tools for listing and reading resources. Generates two tools:
  • list_resources: Lists all resources and templates from the provider
  • read_resource: Reads a resource by URI
The transform captures a provider reference at construction and queries it for resources when the generated tools are called. When used with FastMCP, the provider’s auth and visibility filtering is automatically applied. Methods:

list_tools

list_tools(self, tools: Sequence[Tool]) -> Sequence[Tool]
Add resource tools to the tool list.

get_tool

get_tool(self, name: str, call_next: GetToolNext) -> Tool | None
Get a tool by name, including generated resource tools.