{"record":{"id":"60be5866dfa5c09f","repo":"Hmbown/CodeWhale","slug":"resource-uri-uri-is-ambiguous-across-mcp-servers-pass-the","errorCode":null,"errorMessage":"resource URI '{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":"validation","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/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/mcp/src/lib.rs#L581-L617","documentation":"When a resource URI is advertised by two or more running MCP servers, read_resource_by_uri cannot determine which server to read from and refuses to guess. The error lists the conflicting servers and instructs the caller to pass the legacy server parameter to disambiguate.","triggerScenarios":"Calling read_resource_by_uri(uri) where matches spans multiple server names after matching the URI against each server's advertised resources.","commonSituations":"Two MCP servers advertise the same standard URI scheme (e.g., both expose file:// or a shared docs:// namespace); connecting a second server whose resource URIs overlap the first; migrating servers without deduplicating URIs.","solutions":["Call the read with the legacy disambiguation: pass the explicit server name (read_resource(server, uri)) chosen from the server list in the error message.","Change one server's advertised URIs so namespaces no longer overlap, then retry URI-only resolution.","Disconnect or remove one of the conflicting servers if it is redundant."],"exampleFix":"// before\nmanager.read_resource_by_uri(\"docs://api/intro\")  // ambiguous: docs_a, docs_b\n// after\nmanager.read_resource(\"docs_b\", \"docs://api/intro\")","handlingStrategy":"validation","validationCode":"fn owning_servers(manager: &McpManager, uri: &str) -> Vec<String> {\n    manager.clients.keys().filter(|s|\n        manager.list_resources(s).map(|rs| rs.iter().any(|r| r.uri == uri)).unwrap_or(false)\n    ).cloned().collect()\n}\n// if owning_servers(...).len() > 1, require an explicit server choice before reading","typeGuard":null,"tryCatchPattern":"match manager.read_resource_by_uri(uri) {\n    Err(e) if e.to_string().contains(\"is ambiguous across MCP servers\") => {\n        let server = config.default_resource_server\n            .ok_or_else(|| anyhow!(\"{e}; configure a default server\"))?;\n        manager.read_resource(&server, uri)\n    }\n    other => other,\n}","preventionTips":["Namespace resource URIs per server so the same URI never appears twice.","Keep a user/config-level default server for shared URI schemes.","Detect overlapping URIs at connect time and surface a config warning."],"tags":["mcp","resource-uri","ambiguity"],"backgroundTag":"invalid-identifier-format","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"}