PrefectHQ/fastmcp · error
ResourcesAsTools requires a FastMCP server instance, not a {
Error message
ResourcesAsTools requires a FastMCP server instance, not a {type(provider).__name__}. The generated tools route through the server's middleware chain at runtime for auth and visibility. Pass your FastMCP server: ResourcesAsTools(mcp) What it means
ResourcesAsTools exposes a server's resources as tools and, like PromptsAsTools, must route generated tools through the server's middleware chain for auth and visibility — so it only accepts a FastMCP instance. Any other Provider raises TypeError.
Source
Thrown at fastmcp_slim/fastmcp/server/transforms/resources_as_tools.py:67
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.
Example:
```python
mcp = FastMCP("Server")
mcp.add_transform(ResourcesAsTools(mcp))
# Now has list_resources and read_resource tools
```
"""
def __init__(self, provider: Provider) -> None:
from fastmcp.server.server import FastMCP
if not isinstance(provider, FastMCP):
raise TypeError(
"ResourcesAsTools requires a FastMCP server instance, not a"
f" {type(provider).__name__}. The generated tools route through"
" the server's middleware chain at runtime for auth and"
" visibility. Pass your FastMCP server: ResourcesAsTools(mcp)"
)
self._provider = provider
def __repr__(self) -> str:
return f"ResourcesAsTools({self._provider!r})"
async def list_tools(self, tools: Sequence[Tool]) -> Sequence[Tool]:
"""Add resource tools to the tool list."""
return [
*tools,
self._make_list_resources_tool(),
self._make_read_resource_tool(),
]
View on GitHub (pinned to 1f02114297)
Solutions
- Pass your FastMCP server: ResourcesAsTools(mcp)
- Mount the provider into a FastMCP server first, then wrap that server
- Check argument order in your transform pipeline
Example fix
// before ResourcesAsTools(resource_provider) // after ResourcesAsTools(mcp)
Defensive patterns
Strategy: type-guard
Validate before calling
from fastmcp.server.server import FastMCP assert isinstance(mcp, FastMCP), "ResourcesAsTools needs a FastMCP server"
Type guard
def is_fastmcp(obj) -> bool:
from fastmcp.server.server import FastMCP
return isinstance(obj, FastMCP) Try / catch
try:
t = ResourcesAsTools(mcp)
except TypeError as e:
logger.error("bad transform arg: %s", e) Prevention
- Pass the FastMCP server instance, not a resource provider
- Review transform docs for accepted types
- Wire transforms after the server is constructed
When it happens
Trigger: ResourcesAsTools(provider) where provider is a raw Provider/transform rather than a FastMCP server.
Common situations: Passing a resource provider directly instead of the server that owns it; misreading the API as accepting any Provider.
Related errors
- contents[{i}] must be ResourceContent, got {type(item).__nam
- contents must be str, bytes, or list[ResourceContent], got {
- Expected Resource, ResourceTemplate, or @resource-decorated
- PromptsAsTools requires a FastMCP server instance, not a {ty
- Protocol mode for server {name!r} must be a string
AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29).
Data as JSON: /api/errors/652e3cfaff4e012a.
Report an issue: GitHub.