opencode/patches/@modelcontextprotocol%2Fclient@2.3.1.patch
Aiden Cline 3905c297a3 perf(core): check MCP tool lists by hand instead of with the SDK schema
Patch the SDK so tools/list items are not zod-checked, and check each tool with one plain pass in the client: skip tools with no usable name or input schema, and drop malformed optional fields instead of the whole tool.
2026-10-30 17:03:35 -05:00

128 lines
6.3 KiB
Diff

diff --git a/dist/index.cjs b/dist/index.cjs
index 71cf63076b073284aa14f63cd41efa653e8def0f..4c33e3b873b94f0f9392b23bf13c85b2b4fe9286 100644
--- a/dist/index.cjs
+++ b/dist/index.cjs
@@ -1038,7 +1038,6 @@ async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, o
else {
const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);
url = new URL(wellKnownPath, opts?.metadataServerUrl ?? issuer);
- url.search = issuer.search;
}
let response = await tryMetadataDiscovery(url, protocolVersion, fetchFn);
if (!opts?.metadataUrl && shouldAttemptFallback(response, issuer.pathname)) response = await tryMetadataDiscovery(new URL(`/.well-known/${wellKnownType}`, issuer), protocolVersion, fetchFn);
@@ -1222,7 +1221,6 @@ async function startAuthorization(authorizationServerUrl, { metadata, clientInfo
authorizationUrl.searchParams.set("redirect_uri", String(redirectUrl));
if (state) authorizationUrl.searchParams.set("state", state);
if (scope) authorizationUrl.searchParams.set("scope", scope);
- if (scope?.split(" ").includes("offline_access")) authorizationUrl.searchParams.append("prompt", "consent");
if (resource) authorizationUrl.searchParams.set("resource", resourceIndicatorToString(resource));
return {
authorizationUrl,
diff --git a/dist/index.mjs b/dist/index.mjs
index c1a09a82b8121d6a1b038ccc6d02bae46d55dbcf..f5b0e1d4d47965150a62f20f8c1282d1d4972b99 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -1035,7 +1035,6 @@ async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, o
else {
const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);
url = new URL(wellKnownPath, opts?.metadataServerUrl ?? issuer);
- url.search = issuer.search;
}
let response = await tryMetadataDiscovery(url, protocolVersion, fetchFn);
if (!opts?.metadataUrl && shouldAttemptFallback(response, issuer.pathname)) response = await tryMetadataDiscovery(new URL(`/.well-known/${wellKnownType}`, issuer), protocolVersion, fetchFn);
@@ -1219,7 +1218,6 @@ async function startAuthorization(authorizationServerUrl, { metadata, clientInfo
authorizationUrl.searchParams.set("redirect_uri", String(redirectUrl));
if (state) authorizationUrl.searchParams.set("state", state);
if (scope) authorizationUrl.searchParams.set("scope", scope);
- if (scope?.split(" ").includes("offline_access")) authorizationUrl.searchParams.append("prompt", "consent");
if (resource) authorizationUrl.searchParams.set("resource", resourceIndicatorToString(resource));
return {
authorizationUrl,
diff --git a/dist/src-DpAS0jfg.cjs b/dist/src-DpAS0jfg.cjs
index e2ffe6482e0d8eed88082215547ccde7b5ef2d37..1550d1d30cdbd79b35af59ef69a2e9e26d67290e 100644
--- a/dist/src-DpAS0jfg.cjs
+++ b/dist/src-DpAS0jfg.cjs
@@ -1093,11 +1093,7 @@ function build$1() {
properties: zod_v4.record(zod_v4.string(), JSONValueSchema$1).optional(),
required: zod_v4.array(zod_v4.string()).optional()
}).catchall(zod_v4.unknown()),
- outputSchema: zod_v4.object({
- type: zod_v4.literal("object"),
- properties: zod_v4.record(zod_v4.string(), JSONValueSchema$1).optional(),
- required: zod_v4.array(zod_v4.string()).optional()
- }).catchall(zod_v4.unknown()).optional(),
+ outputSchema: zod_v4.looseObject({ $schema: zod_v4.string().optional() }).optional(),
annotations: ToolAnnotationsSchema$1.optional(),
execution: ToolExecutionSchema$1.optional(),
_meta: zod_v4.record(zod_v4.string(), zod_v4.unknown()).optional()
@@ -1109,7 +1105,7 @@ function build$1() {
/**
* The server's response to a {@linkcode ListToolsRequest | tools/list} request from the client.
*/
- const ListToolsResultSchema$1 = PaginatedResultSchema$1.extend({ tools: zod_v4.array(ToolSchema$1) });
+ const ListToolsResultSchema$1 = PaginatedResultSchema$1.extend({ tools: zod_v4.array(zod_v4.unknown()) });
/**
* The server's response to a tool call.
*/
@@ -2859,7 +2855,7 @@ function build() {
const ListToolsResultSchema$1 = wireResult({
ttlMs: zod_v4.number().int().min(0),
cacheScope: zod_v4.enum(["public", "private"]),
- tools: zod_v4.array(ToolSchema$1),
+ tools: zod_v4.array(zod_v4.unknown()),
nextCursor: CursorSchema$1.optional()
});
const ListPromptsResultSchema$1 = wireResult({
@@ -3120,7 +3116,7 @@ function build() {
"tools/list": liftedResult({
ttlMs: zod_v4.number().int().min(0),
cacheScope: zod_v4.enum(["public", "private"]),
- tools: zod_v4.array(ToolSchema$1),
+ tools: zod_v4.array(zod_v4.unknown()),
nextCursor: CursorSchema$1.optional()
}),
"prompts/get": liftedResult({
diff --git a/dist/src-WCy6ifGf.mjs b/dist/src-WCy6ifGf.mjs
index 7a40fb418c402ffc6cac3e71192313a79c63be27..e9c090ae5e18531bb2fc5e225f0f072fddc67ab5 100644
--- a/dist/src-WCy6ifGf.mjs
+++ b/dist/src-WCy6ifGf.mjs
@@ -1092,11 +1092,7 @@ function build$1() {
properties: z.record(z.string(), JSONValueSchema$1).optional(),
required: z.array(z.string()).optional()
}).catchall(z.unknown()),
- outputSchema: z.object({
- type: z.literal("object"),
- properties: z.record(z.string(), JSONValueSchema$1).optional(),
- required: z.array(z.string()).optional()
- }).catchall(z.unknown()).optional(),
+ outputSchema: z.looseObject({ $schema: z.string().optional() }).optional(),
annotations: ToolAnnotationsSchema$1.optional(),
execution: ToolExecutionSchema$1.optional(),
_meta: z.record(z.string(), z.unknown()).optional()
@@ -1108,7 +1104,7 @@ function build$1() {
/**
* The server's response to a {@linkcode ListToolsRequest | tools/list} request from the client.
*/
- const ListToolsResultSchema$1 = PaginatedResultSchema$1.extend({ tools: z.array(ToolSchema$1) });
+ const ListToolsResultSchema$1 = PaginatedResultSchema$1.extend({ tools: z.array(z.unknown()) });
/**
* The server's response to a tool call.
*/
@@ -2858,7 +2854,7 @@ function build() {
const ListToolsResultSchema$1 = wireResult({
ttlMs: z.number().int().min(0),
cacheScope: z.enum(["public", "private"]),
- tools: z.array(ToolSchema$1),
+ tools: z.array(z.unknown()),
nextCursor: CursorSchema$1.optional()
});
const ListPromptsResultSchema$1 = wireResult({
@@ -3119,7 +3115,7 @@ function build() {
"tools/list": liftedResult({
ttlMs: z.number().int().min(0),
cacheScope: z.enum(["public", "private"]),
- tools: z.array(ToolSchema$1),
+ tools: z.array(z.unknown()),
nextCursor: CursorSchema$1.optional()
}),
"prompts/get": liftedResult({