Hmbown/CodeWhale · error

resource URI ' ' was not advertised by any running MCP…

Error message

resource URI '{}' was not advertised by any running MCP server

What it means

read_resource_by_uri looks up a resource URI among resources advertised by running servers. For a standard (non server-prefixed) URI, if no running server advertised it (and no server-embedded URI matches a running client), the library reports the URI is unknown.

Solutions

  1. Verify the URI against resources advertised by the running server
  2. Ensure the owning MCP server is running and registered
  3. Re-fetch the resource list after servers start

Example fix

// before
manager.read_resource_by_uri("file:///missing.txt", None)?
// after
let advertised = manager.list_resources()?;
if advertised.iter().any(|r| r.uri == uri) {
    manager.read_resource_by_uri(&uri, None)?
}
Defensive patterns

Strategy: validation

Validate before calling

if !manager.list_resources()?.iter().any(|r| r.uri == uri) { return Err("uri not advertised"); }

Try / catch

match manager.read_resource_by_uri(uri, server) { Err(e) if e.to_string().contains("was not advertised") => /* refresh resource list and retry */, other => other }

Prevention

When it happens

Trigger: Calling read_resource_by_uri with a URI that no running server advertised via resources/list, or where the embedded server name in the URI does not correspond to a running client.

Common situations: Typo in the URI; server that advertised the resource has been stopped/unregistered; resource listing cached before the server started; passing a raw server-prefixed URI when the server is not running.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/51236cdc0a26893e. Report an issue: GitHub.

Appendix: source

Thrown at crates/mcp/src/lib.rs:595

                .list_resources()?
                .iter()
                .any(|resource| resource.uri == uri)
            {
                matches.push(server_name.clone());
            }
        }

        match matches.len() {
            1 => self.read_resource(&matches[0], uri),
            0 => {
                // Preserve the pre-standard URI convention for clients whose
                // server does not implement resources/list.
                if let Some(server_name) = parse_server_from_uri(uri)
                    && self.clients.contains_key(&server_name)
                {
                    return self.read_resource(&server_name, uri);
                }
                bail!("resource URI '{uri}' was not advertised by any running MCP server")
            }
            _ => {
                matches.sort();
                bail!(
                    "resource URI '{uri}' is ambiguous across MCP servers: {}; pass the legacy \
                     server parameter to disambiguate",
                    matches.join(", ")
                )
            }
        }
    }

    /// Generate sandbox state update notices for all registered servers.
    pub fn update_sandbox_state(&self, sandbox_mode: &str, cwd: &str) -> Result<Vec<Value>> {
        let mut notices = Vec::new();
        for server_name in self.configs.keys() {
            notices.push(json!({
                "server_name": server_name,

View on GitHub (pinned to 433685b202)