فهرست منبع

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

Aiden Cline 2 ماه پیش
والد
کامیت
6c12c32fb1
1فایلهای تغییر یافته به همراه3 افزوده شده و 1 حذف شده
  1. 3 1
      packages/opencode/src/mcp/catalog.ts

+ 3 - 1
packages/opencode/src/mcp/catalog.ts

@@ -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 },
         ]),
       )