{"record":{"id":"a9e9bbf2ed531440","repo":"PrefectHQ/fastmcp","slug":"unknown-resource-uri-r","errorCode":null,"errorMessage":"Unknown resource: {uri!r}","messagePattern":"Unknown resource: (.+?)","errorType":"exception","errorClass":"NotFoundError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/server.py","lineNumber":1664,"sourceCode":"                            ) from e\n                        if is_timeout_error(e):\n                            raise ResourceError(\n                                \"Upstream request timed out, please retry\"\n                            ) from e\n                        # Standard masking logic\n                        if self._mask_error_details:\n                            raise ResourceError(\n                                f\"Error reading resource {uri!r}\"\n                            ) from e\n                        raise ResourceError(\n                            f\"Error reading resource {uri!r}: {e}\"\n                        ) from e\n\n                # Try templates (transforms + auth via get_resource_template)\n                template = await self.get_resource_template(uri, version=version)\n                if template is None:\n                    if version is None:\n                        raise NotFoundError(f\"Unknown resource: {uri!r}\")\n                    raise NotFoundError(\n                        f\"Unknown resource: {uri!r} version {version!r}\"\n                    )\n                span.set_attributes(template.get_span_attributes())\n                params = template.matches(uri)\n                assert params is not None\n\n                # Path-security screening: reject traversal / absolute-path /\n                # null-byte payloads in extracted parameter values BEFORE the\n                # handler runs. This is the single chokepoint for every\n                # templated read (local decorator and provider-sourced), so\n                # enforcement lives here rather than in any decorator.\n                security = template.resolve_security(self._resource_security)\n                if security is not None:\n                    failed = security.validate(params)\n                    if failed is not None:\n                        logger.debug(\n                            \"Rejected resource %r: parameter %r failed \"","sourceCodeStart":1646,"sourceCodeEnd":1682,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/server.py#L1646-L1682","documentation":"FastMCP raises NotFoundError(\"Unknown resource: {uri!r}\") from read_resource when neither a concrete resource nor a matching resource template resolves for the requested URI (get_resource and get_resource_template both return None). This is the standard MCP 'not found' signal for resources/read.","triggerScenarios":"Calling `read_resource(uri)` with a URI that was never added (typo, wrong scheme), a template whose parameters don't match the URI, a resource removed/disabled, or via client.read_resource on a server that doesn't expose it.","commonSituations":"Typos in URI scheme or path; client pointing at the wrong server; resource registered under a different name/URI; template pattern mismatch (e.g. 'user://{id}' vs requested 'users/42'); forgetting @resource decorator execution.","solutions":["List available resources (`await server.get_resources()` / client.list_resources) and confirm the exact URI.","Correct the URI in the caller to match a registered resource or template pattern.","Register the missing resource or fix the template pattern so it matches the requested URI.","Check that the resource wasn't disabled, removed by transforms, or filtered by middleware/provider routing."],"exampleFix":"// before\ncontent = await client.read_resource(\"data://users/42\")   # template is \"user://{id}\"\n// after\ncontent = await client.read_resource(\"data://user/42\")    # matches registered template","handlingStrategy":"validation","validationCode":"available = {str(r.uri) for r in await client.list_resources()}\nif uri not in available:\n    raise ValueError(f\"{uri} is not a registered resource\")\nawait client.read_resource(uri)","typeGuard":null,"tryCatchPattern":"try:\n    result = await client.read_resource(uri)\nexcept NotFoundError:\n    print(f\"{uri} unknown — call client.list_resources() for valid URIs\")","preventionTips":["Copy URIs from list_resources output instead of hand-typing them.","Verify template patterns match the URIs you construct.","Confirm the resource is registered and not disabled/transformed away.","Check client/server scheme and path conventions early in integration."],"tags":["mcp","resource","not-found","uri"],"backgroundTag":"resource-not-found","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}