PrefectHQ/fastmcp · error · ResourceError

Remote server returned empty content for {parameterized_uri}

Error message

Remote server returned empty content for {parameterized_uri}

What it means

ProxyProvider.create_resource() validates the result of a read from the remote server before building a ProxyResource. If the remote server returns an empty result (no content blocks at all) for the parameterized URI, the proxy cannot construct valid resource content and raises ResourceError. This prevents creating a resource whose read would yield nothing.

Source

Thrown at fastmcp_slim/fastmcp/server/providers/proxy.py:673

            # The backend template asked for input. `InputRequiredResourceResult`
            # is a `ResourceResult`, so caching it on the returned resource lets
            # the ask ride the ordinary read path out to the parent's wire
            # handler, which unwraps it.
            return ProxyResource(
                client_factory=self._client_factory,
                uri=parameterized_uri,
                name=self.name,
                title=self.title,
                description=self.description,
                mime_type=self.mime_type or "text/plain",
                icons=self.icons,
                meta=self.meta,
                tags=get_fastmcp_metadata(self.meta).get("tags", []),
                _cached_content=InputRequiredResourceResult(result),
            )

        if not result:
            raise ResourceError(
                f"Remote server returned empty content for {parameterized_uri}"
            )

        # Process all items in the result list, not just the first one
        contents: list[ResourceContent] = []
        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),

View on GitHub (pinned to 1f02114297)

Solutions

  1. Fix the upstream server so its resource handler returns at least one content block for that URI
  2. Verify the parameterized URI matches the intended upstream resource (an over-broad template can match URIs the upstream can't populate)
  3. Log/inspect the raw upstream read_resource response to confirm it is truly empty, then add explicit content or a clear upstream error

Example fix

// before: upstream handler returns nothing for unmatched input
if not data:
    return []
// after: return explicit empty-content block or raise a descriptive error
if not data:
    raise ValueError('No data for ' + uri)
return [TextResourceContents(uri=uri, text='')]
Defensive patterns

Strategy: validation

Validate before calling

result = await upstream_client.read_resource(uri)
if not result or len(result) == 0:
    raise ValueError(f'Upstream returns empty content for {uri}; fix upstream before proxying')

Type guard

def has_content(result) -> bool:
    return bool(result) and all(
        getattr(b, 'text', None) is not None or getattr(b, 'blob', None) is not None
        for b in result
    )

Try / catch

try:
    resource = await provider.create_resource(uri)
except ResourceError as e:
    if 'empty content' in str(e):
        resource = null_resource(uri)  # explicit empty placeholder

Prevention

When it happens

Trigger: Reading a resource through the proxy where the upstream server's read_resource returns an empty list of contents (no text/blob items) for the given parameterized URI.

Common situations: Upstream resource handler returns an empty list, or the upstream server has a bug/changed behavior after a version update so the template now matches but returns nothing.

Related errors


AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29). Data as JSON: /api/errors/ecb2b143cce1baf5. Report an issue: GitHub.