PrefectHQ/fastmcp · error · ResourceError
Unsupported content type: {type(item)}
Error message
Unsupported content type: {type(item)} What it means
ProxyProvider.read() converts MCP content blocks returned by the remote server into FastMCP ResourceContent objects. When the remote resource returns a content block type the proxy does not recognize (not text, and not base64 blob), it raises ResourceError. This guards against silently dropping unknown content from upstream servers.
Source
Thrown at fastmcp_slim/fastmcp/server/providers/proxy.py:579
for item in result:
if isinstance(item, TextResourceContents):
contents.append(
ResourceContent(
content=item.text,
mime_type=item.mime_type,
meta=item.meta,
)
)
elif isinstance(item, BlobResourceContents):
contents.append(
ResourceContent(
content=base64.b64decode(item.blob),
mime_type=item.mime_type,
meta=item.meta,
)
)
else:
raise ResourceError(f"Unsupported content type: {type(item)}")
return ResourceResult(contents=contents)
def get_span_attributes(self) -> dict[str, Any]:
return super().get_span_attributes() | {
"fastmcp.provider.type": "ProxyProvider",
"fastmcp.proxy.backend_uri": self._backend_uri or str(self.uri),
}
class ProxyTemplate(ResourceTemplate):
"""A ResourceTemplate that represents and creates resources from a remote server template."""
task_config: TaskConfig = TaskConfig(mode="forbidden")
_backend_uri_template: str | None = None
def __init__(self, client_factory: ClientFactoryT, **kwargs: Any):
super().__init__(**kwargs)View on GitHub (pinned to 1f02114297)
Solutions
- Check what content types the upstream server actually returns for that resource URI (raw MCP read_resource call) and make it return plain text or base64 blob content
- Upgrade fastmcp to the latest version in case support for additional content types was added
- Convert the upstream resource to return text/blob content, or copy the resource locally instead of proxying it
Example fix
// before: upstream returns an EmbeddedResource block -> proxy raises
// after: make the upstream resource handler return text
@mcp.resource('data://x')
def get_x() -> str:
return json.dumps(data) # text content instead of embedded resource Defensive patterns
Strategy: type-guard
Validate before calling
# before reading through the proxy, check the upstream returns mappable blocks
result = await upstream_client.read_resource(uri)
if not all(getattr(b, 'text', None) is not None or getattr(b, 'blob', None) is not None for b in result):
raise ValueError(f'{uri} returns non-text/blob content; proxy cannot map it') Type guard
def is_mappable_content(item) -> bool:
return hasattr(item, 'text') or hasattr(item, 'blob') Try / catch
from fastmcp.exceptions import ResourceError
try:
result = await provider.read(uri)
except ResourceError as e:
logger.warning('Unmappable upstream content: %s', e)
result = fallback_read(uri) Prevention
- Prefer upstream resources that return plain text or base64 blob content
- Test proxied resources with the real upstream server before production
- Keep fastmcp updated for new content-type support
When it happens
Trigger: Calling read() on a proxied resource whose remote ReadResourceResult contains a content block that is neither TextResourceContents (text) nor BlobResourceContents (blob) — e.g. an embedded resource or a custom content type the upstream server emitted.
Common situations: Proxying an upstream MCP server that returns EmbeddedResource blocks (e.g. resources-within-resources), or an upstream server using a newer/custom content type your FastMCP version doesn't map yet.
Related errors
- Remote server returned empty content for {parameterized_uri}
- Error reading resource {uri!r}
- Error reading resource {uri!r}: {e}
- Unknown resource: {uri!r}
- Unknown resource: {uri!r} version {version!r}
AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29).
Data as JSON: /api/errors/548e8addef79d283.
Report an issue: GitHub.