Merge pull request #20 from xsa-dev/fix/resource-uri-prefix

fix: strip provider prefix from MCP resource URIs
This commit is contained in:
Sam Valladares 2026-03-30 12:14:28 -06:00 committed by GitHub
commit d921427106
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -811,10 +811,14 @@ impl McpServer {
};
let uri = &request.uri;
let content = if uri.starts_with("memory://") {
resources::memory::read(&self.storage, uri).await
} else if uri.starts_with("codebase://") {
resources::codebase::read(&self.storage, uri).await
// Normalize URI: strip provider prefix (e.g., "vestige/") for scheme matching
// OpenCode and other MCP clients may send "vestige/memory://recent"
// but we register resources as "memory://recent"
let normalized_uri = uri.strip_prefix("vestige/").unwrap_or(uri);
let content = if normalized_uri.starts_with("memory://") {
resources::memory::read(&self.storage, normalized_uri).await
} else if normalized_uri.starts_with("codebase://") {
resources::codebase::read(&self.storage, normalized_uri).await
} else {
Err(format!("Unknown resource scheme: {}", uri))
};