{"record":{"id":"ecb2b143cce1baf5","repo":"PrefectHQ/fastmcp","slug":"remote-server-returned-empty-content-for-paramete","errorCode":null,"errorMessage":"Remote server returned empty content for {parameterized_uri}","messagePattern":"Remote server returned empty content for (.+?)","errorType":"exception","errorClass":"ResourceError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/providers/proxy.py","lineNumber":673,"sourceCode":"            # The backend template asked for input. `InputRequiredResourceResult`\n            # is a `ResourceResult`, so caching it on the returned resource lets\n            # the ask ride the ordinary read path out to the parent's wire\n            # handler, which unwraps it.\n            return ProxyResource(\n                client_factory=self._client_factory,\n                uri=parameterized_uri,\n                name=self.name,\n                title=self.title,\n                description=self.description,\n                mime_type=self.mime_type or \"text/plain\",\n                icons=self.icons,\n                meta=self.meta,\n                tags=get_fastmcp_metadata(self.meta).get(\"tags\", []),\n                _cached_content=InputRequiredResourceResult(result),\n            )\n\n        if not result:\n            raise ResourceError(\n                f\"Remote server returned empty content for {parameterized_uri}\"\n            )\n\n        # Process all items in the result list, not just the first one\n        contents: list[ResourceContent] = []\n        for item in result:\n            if isinstance(item, TextResourceContents):\n                contents.append(\n                    ResourceContent(\n                        content=item.text,\n                        mime_type=item.mime_type,\n                        meta=item.meta,\n                    )\n                )\n            elif isinstance(item, BlobResourceContents):\n                contents.append(\n                    ResourceContent(\n                        content=base64.b64decode(item.blob),","sourceCodeStart":655,"sourceCodeEnd":691,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/providers/proxy.py#L655-L691","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the upstream server so its resource handler returns at least one content block for that URI","Verify the parameterized URI matches the intended upstream resource (an over-broad template can match URIs the upstream can't populate)","Log/inspect the raw upstream read_resource response to confirm it is truly empty, then add explicit content or a clear upstream error"],"exampleFix":"// before: upstream handler returns nothing for unmatched input\nif not data:\n    return []\n// after: return explicit empty-content block or raise a descriptive error\nif not data:\n    raise ValueError('No data for ' + uri)\nreturn [TextResourceContents(uri=uri, text='')]","handlingStrategy":"validation","validationCode":"result = await upstream_client.read_resource(uri)\nif not result or len(result) == 0:\n    raise ValueError(f'Upstream returns empty content for {uri}; fix upstream before proxying')","typeGuard":"def has_content(result) -> bool:\n    return bool(result) and all(\n        getattr(b, 'text', None) is not None or getattr(b, 'blob', None) is not None\n        for b in result\n    )","tryCatchPattern":"try:\n    resource = await provider.create_resource(uri)\nexcept ResourceError as e:\n    if 'empty content' in str(e):\n        resource = null_resource(uri)  # explicit empty placeholder","preventionTips":["Assert upstream read_resource returns >=1 content block in integration tests","Audit resource templates so they only match URIs the upstream can populate","Fail fast upstream with descriptive errors instead of returning empty lists"],"tags":["proxy","resource","empty-content","mcp"],"backgroundTag":"empty-remote-content","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}