fix(mcp): prevent resource key collisions (#33596)

This commit is contained in:
Aiden Cline 2026-06-24 00:13:58 -05:00 committed by GitHub
parent fbfd725d73
commit 6c12c32fb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -100,9 +100,11 @@ export function fetch<T extends { name: string }>(
),
Effect.map((items) => {
const sanitizedClient = sanitize(clientName)
// Escape both the separator and escape marker so `server:uri` keys remain unambiguous.
const resourceClient = clientName.replaceAll("%", "%25").replaceAll(":", "%3A")
return Object.fromEntries(
items.map((item) => [
key ? clientName + ":" + key(item) : sanitizedClient + ":" + sanitize(item.name),
key ? resourceClient + ":" + key(item) : sanitizedClient + ":" + sanitize(item.name),
{ ...item, client: clientName },
]),
)