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. The generated tools route through ctx.fastmcp at runtime, so all server middleware (auth, visibility, rate limiting, etc.) applies to resource operations exactly as it would for direct resources/read calls. Example:

Classes

ResourcesAsTools

Transform that adds tools for listing and reading resources. Generates two tools:
  • list_resources: Lists all resources and templates
  • read_resource: Reads a resource by URI
The generated tools route through the server at runtime, so auth, middleware, and visibility apply automatically. This transform should be applied to a FastMCP server instance, not a raw Provider, because the generated tools need the server’s middleware chain for auth and visibility filtering. Methods:

list_tools

Add resource tools to the tool list.

get_tool

Get a tool by name, including generated resource tools.