fix(mcp): strip provider prefix from resource URIs

Handle 'vestige/memory://' and 'vestige/codebase://' URIs by stripping the
provider prefix before scheme matching. This fixes compatibility with
MCP clients like OpenCode that prepend the provider name to resource URIs.

Fixes #19
This commit is contained in:
Aleksei Savin 2026-03-29 16:43:53 +03:00
parent 760957f5ac
commit 37af5059c9

View file

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