{"record":{"id":"36e4d1f9f743a9fe","repo":"Hmbown/CodeWhale","slug":"resource-uri-uri-was-not-advertised-by-any-running-mcp","errorCode":null,"errorMessage":"resource URI '{uri}' was not advertised by any running MCP server","messagePattern":"resource URI '(.+?)' was not advertised by any running MCP server","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mcp/src/lib.rs","lineNumber":595,"sourceCode":"                .list_resources()?\n                .iter()\n                .any(|resource| resource.uri == uri)\n            {\n                matches.push(server_name.clone());\n            }\n        }\n\n        match matches.len() {\n            1 => self.read_resource(&matches[0], uri),\n            0 => {\n                // Preserve the pre-standard URI convention for clients whose\n                // server does not implement resources/list.\n                if let Some(server_name) = parse_server_from_uri(uri)\n                    && self.clients.contains_key(&server_name)\n                {\n                    return self.read_resource(&server_name, uri);\n                }\n                bail!(\"resource URI '{uri}' was not advertised by any running MCP server\")\n            }\n            _ => {\n                matches.sort();\n                bail!(\n                    \"resource URI '{uri}' is ambiguous across MCP servers: {}; pass the legacy \\\n                     server parameter to disambiguate\",\n                    matches.join(\", \")\n                )\n            }\n        }\n    }\n\n    /// Generate sandbox state update notices for all registered servers.\n    pub fn update_sandbox_state(&self, sandbox_mode: &str, cwd: &str) -> Result<Vec<Value>> {\n        let mut notices = Vec::new();\n        for server_name in self.configs.keys() {\n            notices.push(json!({\n                \"server_name\": server_name,","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/mcp/src/lib.rs#L577-L613","documentation":"read_resource_by_uri looks up which running MCP server advertised a resource URI. If no server advertised it — and the URI does not embed a recognizable server name for a connected server — the manager rejects the read rather than guessing. It fails closed for unknown or stale resource URIs.","triggerScenarios":"Calling read_resource_by_uri(uri) where the URI matches no server's advertised resource list, and parse_server_from_uri either cannot extract a server name or the extracted server is not among the running clients.","commonSituations":"Using a resource URI captured from a previous session where the server is no longer running; typo in the URI scheme/path; server was restarted and advertises a different URI set; resource was removed from the server's list since caching.","solutions":["Refresh the resource catalog (list resources from running servers) and use a URI that is currently advertised.","Check the URI spelling/scheme against what the server actually advertises.","If the URI embeds a server name (legacy form), ensure that server is connected/running before the read.","If you know the owning server, use read_resource(server_name, uri) directly instead of URI-only resolution."],"exampleFix":"// before\nmanager.read_resource_by_uri(\"file:///old/logs.txt\")  // server restarted, URI gone\n// after\nlet uri = current_catalog().resolve(\"logs.txt\")?;\nmanager.read_resource_by_uri(&uri)","handlingStrategy":"validation","validationCode":"fn uri_is_advertised(manager: &McpManager, uri: &str) -> bool {\n    manager.clients.keys().any(|s|\n        manager.list_resources(s).map(|rs| rs.iter().any(|r| r.uri == uri)).unwrap_or(false))\n}","typeGuard":null,"tryCatchPattern":"match manager.read_resource_by_uri(uri) {\n    Err(e) if e.to_string().contains(\"was not advertised\") => {\n        manager.refresh_catalog()?; // server may have restarted\n        manager.read_resource_by_uri(uri)\n    }\n    other => other,\n}","preventionTips":["Refresh the resource catalog after every server (re)connect before resolving stored URIs.","Validate URIs against the live catalog instead of caching across sessions.","Prefer read_resource(server, uri) when you already know the owning server."],"tags":["mcp","resource-uri","not-found"],"backgroundTag":"record-not-found","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}