{"record":{"id":"2443119076f6e067","repo":"unclecode/crawl4ai","slug":"resource-not-found","errorCode":null,"errorMessage":"resource not found","messagePattern":"resource not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"deploy/docker/mcp_bridge.py","lineNumber":170,"sourceCode":"        try:\n            res = await proxy(**(arguments or {}))\n        except HTTPException as exc:\n            # map server‑side errors into MCP \"text/error\" payloads\n            err = {\"error\": exc.status_code, \"detail\": exc.detail}\n            return [t.TextContent(type = \"text\", text=json.dumps(err, ensure_ascii=False))]\n        return [t.TextContent(type = \"text\", text=json.dumps(res, default=str, ensure_ascii=False))]\n\n    @mcp.list_resources()\n    async def _list_resources() -> List[t.Resource]:\n        return [\n            t.Resource(name=k, description=inspect.getdoc(f) or \"\", mime_type=\"application/json\")\n            for k, f in resources.items()\n        ]\n\n    @mcp.read_resource()\n    async def _read_resource(name: str) -> List[t.TextContent]:\n        if name not in resources:\n            raise HTTPException(404, \"resource not found\")\n        res = resources[name]()\n        return [t.TextContent(type = \"text\", text=json.dumps(res, default=str, ensure_ascii=False))]\n\n    @mcp.list_resource_templates()\n    async def _list_templates() -> List[t.ResourceTemplate]:\n        return [\n            t.ResourceTemplate(\n                name=k,\n                description=inspect.getdoc(f) or \"\",\n                parameters={\n                    p: {\"type\": \"string\"} for p in _path_params(app, f)\n                },\n            )\n            for k, f in templates.items()\n        ]\n\n    init_opts = InitializationOptions(\n        server_name=server_name,","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/deploy/docker/mcp_bridge.py#L152-L188","documentation":"The MCP bridge's read_resource handler raises HTTPException(404, 'resource not found') when the requested resource name is absent from the resources registry populated at attach_mcp time. Valid names are exactly those returned by resources/list.","triggerScenarios":"Calling resources/read with a mistyped or stale resource name; reading a resource whose backing function was registered after attach_mcp; client holding a cached resource list from a previous server build.","commonSituations":"Version skew between MCP client cache and server; renames of resource-backed endpoints; trailing whitespace in names from copy-paste.","solutions":["List first: resources/read must use a name verbatim from resources/list.","Re-list resources after any server redeploy.","Register resource providers before attach_mcp() so they appear in the registry."],"exampleFix":"# before\nresources/read {\"name\": \" stats \"}\n\n# after\nresources/list -> [\"stats\"]\nresources/read {\"name\": \"stats\"}","handlingStrategy":"validation","validationCode":"available = [r.name for r in (await session.list_resources()).resources]\nif resource_name not in available:\n    raise ValueError(f\"resource {resource_name!r} not in {available}\")","typeGuard":"def is_known_resource(name, advertised) -> bool:\n    return isinstance(name, str) and name in advertised","tryCatchPattern":"result = await session.read_resource(resource_name)\n# bridge raises HTTPException(404, 'resource not found'); client sees it as an error response:\nexcept ResourceError as e:\n    if \"resource not found\" in str(e):\n        advertised = await session.list_resources()\n        raise KeyError(f\"{resource_name!r} not in {[r.name for r in advertised]}\") from e","preventionTips":["Refresh resources/list after every redeploy.","Strip whitespace from names sourced via copy-paste.","Register resource providers before attach_mcp()."],"tags":["mcp","http-404","resources","api"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}