{"record":{"id":"14d71d53edbd07c6","repo":"Hmbown/CodeWhale","slug":"resource-uri-is-ambiguous-across-mcp-servers-pass-the-legacy","errorCode":null,"errorMessage":"resource URI '{}' is ambiguous across MCP servers: {}; pass the legacy server parameter to disambiguate","messagePattern":"resource URI '(.+?)' is ambiguous across MCP servers: (.+?); pass the legacy server parameter to disambiguate","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mcp/src/lib.rs","lineNumber":599,"sourceCode":"                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,\n                \"method\": \"codex/sandbox-state/update\",\n                \"params\": {\n                    \"sandbox_mode\": sandbox_mode,\n                    \"cwd\": cwd","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/mcp/src/lib.rs#L581-L617","documentation":"Multiple running MCP servers advertise the same resource URI, so resolving it by URI alone is ambiguous. The library refuses to guess and asks the caller to pass the legacy server parameter to disambiguate.","triggerScenarios":"Calling read_resource_by_uri(uri, None) where two or more running servers advertise the identical URI via resources/list.","commonSituations":"Two servers mounting the same file:// path or exposing overlapping resources; duplicated server configs pointing at the same workspace.","solutions":["Pass the server name via the legacy server parameter to pick one","Stop or unregister one of the servers advertising the duplicate URI","Change one server's resource root so URIs no longer collide"],"exampleFix":"// before\nmanager.read_resource_by_uri(\"file:///ws/notes.md\", None)?\n// after\nmanager.read_resource_by_uri(\"file:///ws/notes.md\", Some(\"docs\"))?","handlingStrategy":"validation","validationCode":"let matches: Vec<_> = manager.list_resources()?.iter().filter(|r| r.uri == uri).collect(); if matches.len() > 1 { /* need server param */ }","typeGuard":null,"tryCatchPattern":"match manager.read_resource_by_uri(uri, None) { Err(e) if e.to_string().contains(\"is ambiguous\") => /* parse server names from message and retry with Some(server) */, other => other }","preventionTips":["Avoid mounting identical URIs on multiple servers","Track which server owns each resource in your app state","Prefer server-scoped read_resource over URI-only lookups"],"tags":["mcp","ambiguity","resource"],"backgroundTag":"invalid-argument-value","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}