Something went wrong. Try again.
mirror of github.com/PrefectHQ/fastmcp
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667---title: resources_as_toolssidebarTitle: resources_as_tools---
# `fastmcp.server.transforms.resources_as_tools`
Transform that exposes resources as tools.
This transform generates tools for listing and reading resources, enablingclients that only support tools to access resource functionality.
The generated tools route through `ctx.fastmcp` at runtime, so all servermiddleware (auth, visibility, rate limiting, etc.) applies to resourceoperations exactly as it would for direct `resources/read` calls.
Example: ```python 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` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/transforms/resources_as_tools.py#L41" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
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, nota raw Provider, because the generated tools need the server'smiddleware chain for auth and visibility filtering.
**Methods:**
#### `list_tools` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/transforms/resources_as_tools.py#L78" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonlist_tools(self, tools: Sequence[Tool]) -> Sequence[Tool]```
Add resource tools to the tool list.
#### `get_tool` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/transforms/resources_as_tools.py#L86" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonget_tool(self, name: str, call_next: GetToolNext) -> Tool | None```
Get a tool by name, including generated resource tools.