diff --git a/dist/index-BCNZS4Ap.d.mts b/dist/index-BCNZS4Ap.d.mts index 9dd0f80cfae3db66f0ad7762858d5e1fb217259f..3b19251c82368739993554ae37880e015b7e28a0 100644 --- a/dist/index-BCNZS4Ap.d.mts +++ b/dist/index-BCNZS4Ap.d.mts @@ -1861,6 +1861,11 @@ type RequestOptions = { * Default: `false`. */ allowInputRequired?: boolean; + /** + * Called with the request's JSON-RPC id right before it is sent. + * A `timeout` of `Infinity` disables the request timeout. + */ + onRequestId?: (id: number) => void; } & TransportSendOptions; /** * Flow context handed to {@linkcode Protocol._resolveNonCompleteResult}: the diff --git a/dist/index-eUeYt8-s.d.cts b/dist/index-eUeYt8-s.d.cts index 2050a30454739e753f91f627e23f52bb0dd7aaa8..ec97b3525b55e2bb6139aaf741003360a6155b2d 100644 --- a/dist/index-eUeYt8-s.d.cts +++ b/dist/index-eUeYt8-s.d.cts @@ -1864,6 +1864,11 @@ type RequestOptions = { * Default: `false`. */ allowInputRequired?: boolean; + /** + * Called with the request's JSON-RPC id right before it is sent. + * A `timeout` of `Infinity` disables the request timeout. + */ + onRequestId?: (id: number) => void; } & TransportSendOptions; /** * Flow context handed to {@linkcode Protocol._resolveNonCompleteResult}: the diff --git a/dist/public-C-9H-ftO.cjs b/dist/public-C-9H-ftO.cjs index 2427ea1fbf85eccf15bfb804aa80a8d7381232e7..0789ac0292e6ce5200fc73597bd5829083ab90d6 100644 --- a/dist/public-C-9H-ftO.cjs +++ b/dist/public-C-9H-ftO.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, @@ -2833,7 +2831,16 @@ var Client = class extends require_src.Protocol { })); return require_src.runInputRequiredFlow({ getRequestHandler: (method) => this._getRequestHandler(method), - buildContext: (baseCtx) => this.buildContext(baseCtx, void 0), + buildContext: (baseCtx) => this.buildContext({ + ...baseCtx, + mcpReq: { + ...baseCtx.mcpReq, + origin: { + request: flow.request, + options: flow.options + } + } + }, void 0), sessionId: this.transport?.sessionId }, this._inputRequiredDriverConfig, decoded, flow); } @@ -3992,7 +3999,7 @@ var Client = class extends require_src.Protocol { _excludeInvalidXMcpHeaderTools(result) { if (this.getProtocolEra() !== "modern" || !this.transport || detectProbeTransportKind(this.transport) === "stdio") return; const filtered = result.tools.filter((tool) => { - const scan = require_src.scanXMcpHeaderDeclarations(tool.inputSchema); + const scan = require_src.scanXMcpHeaderDeclarations(tool?.inputSchema); if (!scan.valid) { console.warn(`[mcp-sdk] excluding tool '${tool.name}' from tools/list: invalid x-mcp-header declaration — ${scan.reason}`); return false; diff --git a/dist/public-CvV4ZHkX.mjs b/dist/public-CvV4ZHkX.mjs index fdb69ef9ee42ad4e1019cb4c9c727617286fe916..dee9ecf8c451aa2e400efd823965565282e5bc5c 100644 --- a/dist/public-CvV4ZHkX.mjs +++ b/dist/public-CvV4ZHkX.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, @@ -2830,7 +2828,16 @@ var Client = class extends Protocol { })); return runInputRequiredFlow({ getRequestHandler: (method) => this._getRequestHandler(method), - buildContext: (baseCtx) => this.buildContext(baseCtx, void 0), + buildContext: (baseCtx) => this.buildContext({ + ...baseCtx, + mcpReq: { + ...baseCtx.mcpReq, + origin: { + request: flow.request, + options: flow.options + } + } + }, void 0), sessionId: this.transport?.sessionId }, this._inputRequiredDriverConfig, decoded, flow); } @@ -3989,7 +3996,7 @@ var Client = class extends Protocol { _excludeInvalidXMcpHeaderTools(result) { if (this.getProtocolEra() !== "modern" || !this.transport || detectProbeTransportKind(this.transport) === "stdio") return; const filtered = result.tools.filter((tool) => { - const scan = scanXMcpHeaderDeclarations(tool.inputSchema); + const scan = scanXMcpHeaderDeclarations(tool?.inputSchema); if (!scan.valid) { console.warn(`[mcp-sdk] excluding tool '${tool.name}' from tools/list: invalid x-mcp-header declaration — ${scan.reason}`); return false; diff --git a/dist/src-CeKsbNLO.mjs b/dist/src-CeKsbNLO.mjs index 4d390185ad2167d0e256fbf3aba1367a7e343bc0..ffae6fcf51807e0684e442a49bb6d601bd246be2 100644 --- a/dist/src-CeKsbNLO.mjs +++ b/dist/src-CeKsbNLO.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({ @@ -4713,7 +4709,11 @@ const MCP_NAME_HEADER_SOURCE = { "resources/read": "uri", "tasks/get": "taskId", "tasks/update": "taskId", - "tasks/cancel": "taskId" + "tasks/cancel": "taskId", + "events/poll": "name", + "events/stream": "name", + "events/subscribe": "name", + "events/unsubscribe": "name" }; /** * Resolve the `Mcp-Name` source for one request against @@ -5802,6 +5802,7 @@ var Protocol = class { this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason); } _setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) { + if (timeout === Infinity) return; this._timeoutInfo.set(messageId, { timeoutId: setTimeout(onTimeout, timeout), startTime: Date.now(), @@ -6179,6 +6180,7 @@ var Protocol = class { } const requestAbort = codec.era === MODERN_WIRE_REVISION && this._transport.hasPerRequestStream === true ? new AbortController() : void 0; const messageId = this._requestMessageId++; + options?.onRequestId?.(messageId); cleanupMessageId = messageId; const jsonrpcRequest = { ...request, diff --git a/dist/src-ohtppAR3.cjs b/dist/src-ohtppAR3.cjs index 7d9314447f98b6aea72649b4fed009fd306b8919..c7d8f6415c9279853169172e3a80983242c84ad4 100644 --- a/dist/src-ohtppAR3.cjs +++ b/dist/src-ohtppAR3.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({ @@ -4714,7 +4710,11 @@ const MCP_NAME_HEADER_SOURCE = { "resources/read": "uri", "tasks/get": "taskId", "tasks/update": "taskId", - "tasks/cancel": "taskId" + "tasks/cancel": "taskId", + "events/poll": "name", + "events/stream": "name", + "events/subscribe": "name", + "events/unsubscribe": "name" }; /** * Resolve the `Mcp-Name` source for one request against @@ -5803,6 +5803,7 @@ var Protocol = class { this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason); } _setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) { + if (timeout === Infinity) return; this._timeoutInfo.set(messageId, { timeoutId: setTimeout(onTimeout, timeout), startTime: Date.now(), @@ -6180,6 +6181,7 @@ var Protocol = class { } const requestAbort = codec.era === MODERN_WIRE_REVISION && this._transport.hasPerRequestStream === true ? new AbortController() : void 0; const messageId = this._requestMessageId++; + options?.onRequestId?.(messageId); cleanupMessageId = messageId; const jsonrpcRequest = { ...request,