@dev-crowagent/pigeon-mcp 0.0.0-stage → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +143 -0
- package/README.md +256 -2
- package/THIRD_PARTY_NOTICES/modelcontextprotocol-typescript-sdk.txt +21 -0
- package/dist/auth-provider.d.ts +19 -0
- package/dist/auth-provider.d.ts.map +1 -0
- package/dist/auth-provider.js +2 -0
- package/dist/auth-provider.js.map +1 -0
- package/dist/client.d.ts +193 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +747 -0
- package/dist/client.js.map +1 -0
- package/dist/config-schema.d.ts +105 -0
- package/dist/config-schema.d.ts.map +1 -0
- package/dist/config-schema.js +101 -0
- package/dist/config-schema.js.map +1 -0
- package/dist/config.d.ts +57 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +160 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/input-schema.d.ts +7 -0
- package/dist/input-schema.d.ts.map +1 -0
- package/dist/input-schema.js +13 -0
- package/dist/input-schema.js.map +1 -0
- package/dist/model-content.d.ts +19 -0
- package/dist/model-content.d.ts.map +1 -0
- package/dist/model-content.js +67 -0
- package/dist/model-content.js.map +1 -0
- package/dist/naming.d.ts +23 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +37 -0
- package/dist/naming.js.map +1 -0
- package/dist/oauth/auth-provider.d.ts +52 -0
- package/dist/oauth/auth-provider.d.ts.map +1 -0
- package/dist/oauth/auth-provider.js +97 -0
- package/dist/oauth/auth-provider.js.map +1 -0
- package/dist/oauth/callback.d.ts +48 -0
- package/dist/oauth/callback.d.ts.map +1 -0
- package/dist/oauth/callback.js +121 -0
- package/dist/oauth/callback.js.map +1 -0
- package/dist/oauth/client-settings.d.ts +107 -0
- package/dist/oauth/client-settings.d.ts.map +1 -0
- package/dist/oauth/client-settings.js +114 -0
- package/dist/oauth/client-settings.js.map +1 -0
- package/dist/oauth/discovery.d.ts +30 -0
- package/dist/oauth/discovery.d.ts.map +1 -0
- package/dist/oauth/discovery.js +156 -0
- package/dist/oauth/discovery.js.map +1 -0
- package/dist/oauth/errors.d.ts +32 -0
- package/dist/oauth/errors.d.ts.map +1 -0
- package/dist/oauth/errors.js +58 -0
- package/dist/oauth/errors.js.map +1 -0
- package/dist/oauth/flow.d.ts +112 -0
- package/dist/oauth/flow.d.ts.map +1 -0
- package/dist/oauth/flow.js +360 -0
- package/dist/oauth/flow.js.map +1 -0
- package/dist/oauth/index.d.ts +11 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +9 -0
- package/dist/oauth/index.js.map +1 -0
- package/dist/oauth/loopback.d.ts +51 -0
- package/dist/oauth/loopback.d.ts.map +1 -0
- package/dist/oauth/loopback.js +98 -0
- package/dist/oauth/loopback.js.map +1 -0
- package/dist/oauth/provider.d.ts +62 -0
- package/dist/oauth/provider.d.ts.map +1 -0
- package/dist/oauth/provider.js +118 -0
- package/dist/oauth/provider.js.map +1 -0
- package/dist/oauth/sign-in.d.ts +73 -0
- package/dist/oauth/sign-in.d.ts.map +1 -0
- package/dist/oauth/sign-in.js +182 -0
- package/dist/oauth/sign-in.js.map +1 -0
- package/dist/oauth/types.d.ts +83 -0
- package/dist/oauth/types.d.ts.map +1 -0
- package/dist/oauth/types.js +113 -0
- package/dist/oauth/types.js.map +1 -0
- package/dist/output-limit.d.ts +24 -0
- package/dist/output-limit.d.ts.map +1 -0
- package/dist/output-limit.js +58 -0
- package/dist/output-limit.js.map +1 -0
- package/dist/protocol/content.d.ts +83 -0
- package/dist/protocol/content.d.ts.map +1 -0
- package/dist/protocol/content.js +41 -0
- package/dist/protocol/content.js.map +1 -0
- package/dist/protocol/http-headers.d.ts +31 -0
- package/dist/protocol/http-headers.d.ts.map +1 -0
- package/dist/protocol/http-headers.js +129 -0
- package/dist/protocol/http-headers.js.map +1 -0
- package/dist/protocol/jsonrpc.d.ts +64 -0
- package/dist/protocol/jsonrpc.d.ts.map +1 -0
- package/dist/protocol/jsonrpc.js +74 -0
- package/dist/protocol/jsonrpc.js.map +1 -0
- package/dist/protocol/stateless.d.ts +47 -0
- package/dist/protocol/stateless.d.ts.map +1 -0
- package/dist/protocol/stateless.js +102 -0
- package/dist/protocol/stateless.js.map +1 -0
- package/dist/protocol/types.d.ts +156 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/types.js +12 -0
- package/dist/protocol/types.js.map +1 -0
- package/dist/result-schema.d.ts +10 -0
- package/dist/result-schema.d.ts.map +1 -0
- package/dist/result-schema.js +78 -0
- package/dist/result-schema.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/transports/in-memory.d.ts +19 -0
- package/dist/transports/in-memory.d.ts.map +1 -0
- package/dist/transports/in-memory.js +50 -0
- package/dist/transports/in-memory.js.map +1 -0
- package/dist/transports/lines.d.ts +34 -0
- package/dist/transports/lines.d.ts.map +1 -0
- package/dist/transports/lines.js +85 -0
- package/dist/transports/lines.js.map +1 -0
- package/dist/transports/pipe.d.ts +49 -0
- package/dist/transports/pipe.d.ts.map +1 -0
- package/dist/transports/pipe.js +96 -0
- package/dist/transports/pipe.js.map +1 -0
- package/dist/transports/stdio.d.ts +29 -0
- package/dist/transports/stdio.d.ts.map +1 -0
- package/dist/transports/stdio.js +170 -0
- package/dist/transports/stdio.js.map +1 -0
- package/dist/transports/streamable-http.d.ts +113 -0
- package/dist/transports/streamable-http.d.ts.map +1 -0
- package/dist/transports/streamable-http.js +586 -0
- package/dist/transports/streamable-http.js.map +1 -0
- package/dist/transports/transport.d.ts +48 -0
- package/dist/transports/transport.d.ts.map +1 -0
- package/dist/transports/transport.js +38 -0
- package/dist/transports/transport.js.map +1 -0
- package/package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I,CAAC,UAAU,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,0GAA0G;IAClG,UAAU,CAAC,KAAY;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;QACtB,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1B,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;YAAE,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,SAAS;YAAE,OAAO;QACtB,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;YACjD,IAAI,CAAC;gBACJ,QAAQ,EAAE,CAAC;YACZ,CAAC;YAAC,OAAO,aAAa,EAAE,CAAC;gBACxB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;QACF,CAAC;IACF,CAAC;IAEO,SAAS,CAAC,KAAc;QAC/B,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAClC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,cAAc;YAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAClE,CAAC;IAEO,yBAAyB;QAChC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;YAAE,OAAO,EAAE,CAAC;IAC3D,CAAC;CACD","sourcesContent":["import type { CallToolResult } from \"./protocol/content.ts\";\nimport { type ToolHeaderBinding, toolHeaderBindings, toolParamHeaders } from \"./protocol/http-headers.ts\";\nimport {\n\tisJsonRpcId,\n\tisJsonRpcNotification,\n\tisJsonRpcRequest,\n\tisJsonRpcResponse,\n\tisObject,\n\tJSON_RPC_ERROR_CODES,\n\ttype JsonRpcId,\n\ttype JsonRpcMessage,\n\ttype JsonRpcRequest,\n\ttype JsonRpcResponse,\n\tMcpAbortError,\n\tMcpConnectionClosedError,\n\tMcpError,\n\tMcpTimeoutError,\n\tnormalizeOwnRequestId,\n\ttoError,\n} from \"./protocol/jsonrpc.ts\";\nimport {\n\tHEADER_MISMATCH_ERROR_CODE,\n\treadStatelessResult,\n\treadSubscriptionFilter,\n\tSTATELESS_ERROR_CODES,\n\ttype StatelessRequestMeta,\n\ttype StatelessResult,\n\tsubscriptionIdOf,\n\tvalidateDiscoverResult,\n\twithStatelessMeta,\n} from \"./protocol/stateless.ts\";\nimport {\n\ttype ClientCapabilities,\n\ttype Implementation,\n\ttype InitializeResult,\n\ttype InputRequest,\n\tLATEST_PROTOCOL_VERSION,\n\ttype ListResourcesResult,\n\ttype ListResourceTemplatesResult,\n\ttype LoggingLevel,\n\ttype McpProtocolMode,\n\ttype ProgressNotification,\n\ttype ReadResourceResult,\n\ttype Resource,\n\ttype ResourceTemplate,\n\ttype Root,\n\ttype ServerCapabilities,\n\tSTATELESS_PROTOCOL_VERSION,\n\tSUPPORTED_PROTOCOL_VERSIONS,\n\ttype SubscriptionFilter,\n\ttype SupportedProtocolVersion,\n\ttype Tool,\n} from \"./protocol/types.ts\";\nimport { jsonRpcErrorIn, McpHttpError } from \"./transports/streamable-http.ts\";\nimport type { McpTransport } from \"./transports/transport.ts\";\n\nconst DEFAULT_REQUEST_TIMEOUT_MS = 30_000;\nconst MAX_LIST_PAGES = 1_000;\n/**\n * Bounds `server/discover` after a rejected `initialize`. The server already answered once, so a\n * stateless server answers quickly; a legacy server that ignores the request must not hold up the error.\n */\nconst DISCOVER_AFTER_INITIALIZE_TIMEOUT_MS = 10_000;\n/**\n * Rounds of input a server may ask for before one request completes. Servers may ask again until they\n * have what they need; this bounds a server that never does.\n */\nconst MAX_INPUT_ROUNDS = 16;\n/** Methods whose results may ask for input in MCP 2026-07-28 (multi round-trip requests). */\nconst INPUT_METHODS = new Set([\"tools/call\", \"resources/read\", \"prompts/get\"]);\n\ntype ClientState = \"idle\" | \"connecting\" | \"connected\" | \"closed\";\ntype NotificationListener = (params: unknown) => void;\ntype ErrorListener = (error: Error) => void;\ntype CloseListener = () => void;\ntype RequestHandler = (params: unknown, context: { signal: AbortSignal }) => unknown | Promise<unknown>;\n\nexport interface McpClientOptions extends Implementation {\n\tcapabilities?: ClientCapabilities;\n\t/** Version the `initialize` handshake asks for. Default: {@link LATEST_PROTOCOL_VERSION}. */\n\tprotocolVersion?: SupportedProtocolVersion;\n\t/** How the protocol is picked (see {@link McpProtocolMode}). Default: `auto`. */\n\tprotocol?: McpProtocolMode;\n\t/**\n\t * Servers on the stateless revision send log messages (`notifications/message`) only for requests\n\t * that name a level, so every such request names this one. Without it, they send none.\n\t */\n\tlogLevel?: LoggingLevel;\n\trequestTimeoutMs?: number;\n\t/** Timeout of the request that opens the connection (`initialize` or `server/discover`). Default: `requestTimeoutMs`. */\n\tconnectTimeoutMs?: number;\n\troots?: readonly Root[] | (() => readonly Root[] | Promise<readonly Root[]>);\n}\n\n/**\n * Answers a result whose `resultType` an MCP extension defines (`upload_required`, say) and returns the\n * `requestState` to send the request again with. Throwing fails the request without sending it again.\n */\nexport type McpExtensionResultHandler = (\n\t/** The whole result, including `resultType`, as the server sent it (unchecked). */\n\tresult: Record<string, unknown>,\n\tcontext: { signal: AbortSignal },\n) => Promise<{ requestState: string }>;\n\nexport interface McpRequestOptions {\n\tsignal?: AbortSignal;\n\ttimeoutMs?: number;\n\tonProgress?: (progress: ProgressNotification) => void;\n\tonExtensionResult?: McpExtensionResultHandler;\n}\n\n/** An open `subscriptions/listen` stream of a server on the stateless revision. */\nexport interface McpSubscription {\n\t/** The notification types the server agreed to send. */\n\treadonly notifications: SubscriptionFilter;\n\t/**\n\t * Settles when the subscription ends: resolves when the server ended it or `close()` was called,\n\t * rejects when the connection or the stream failed.\n\t */\n\treadonly closed: Promise<void>;\n\tclose(): void;\n}\n\n/**\n * `connect()` failed after the server rejected `initialize`: `server/discover` on the same connection\n * failed too. Some stdio servers that only speak the stateless revision exit after rejecting\n * `initialize`, or refuse it on a process that saw `initialize`; a new process connected with\n * `protocol: \"2026-07-28\"` may still work.\n */\nexport class McpInitializeRejectedError extends Error {\n\t/** The server's answer to `initialize`. */\n\treadonly rejection: unknown;\n\t/** Why `server/discover` failed. */\n\treadonly discoverError: unknown;\n\n\tconstructor(message: string, rejection: unknown, discoverError: unknown) {\n\t\tsuper(message);\n\t\tthis.name = \"McpInitializeRejectedError\";\n\t\tthis.rejection = rejection;\n\t\tthis.discoverError = discoverError;\n\t}\n}\n\ninterface PendingRequest {\n\tresolve: (value: unknown) => void;\n\treject: (reason: unknown) => void;\n\ttimeoutMs: number;\n\ttimer: ReturnType<typeof setTimeout> | undefined;\n\tsignal: AbortSignal | undefined;\n\tonAbort: () => void;\n\t/** Aborted when the request settles, so the transport does not dispatch (or retry) it afterwards. */\n\tsendController: AbortController;\n\tcancellable: boolean;\n\tonProgress: ((progress: ProgressNotification) => void) | undefined;\n\tprogressToken: JsonRpcId | undefined;\n}\n\nfunction validateInitializeResult(value: unknown): InitializeResult {\n\tif (\n\t\t!isObject(value) ||\n\t\ttypeof value.protocolVersion !== \"string\" ||\n\t\t!isObject(value.capabilities) ||\n\t\t!isObject(value.serverInfo) ||\n\t\ttypeof value.serverInfo.name !== \"string\" ||\n\t\ttypeof value.serverInfo.version !== \"string\" ||\n\t\t(value.instructions !== undefined && typeof value.instructions !== \"string\")\n\t) {\n\t\tthrow new McpError(JSON_RPC_ERROR_CODES.invalidRequest, \"Invalid MCP initialize result\");\n\t}\n\treturn value as unknown as InitializeResult;\n}\n\nfunction invalid(message: string): McpError {\n\treturn new McpError(JSON_RPC_ERROR_CODES.invalidRequest, message);\n}\n\n/** One page of a paginated list: the items under `key`, each checked by `isItem`. */\nfunction validateListPage(\n\tmethod: string,\n\tkey: string,\n\tvalue: unknown,\n\tisItem: (item: Record<string, unknown>) => boolean,\n): { items: Record<string, unknown>[]; nextCursor?: string } {\n\tconst items = isObject(value) ? value[key] : undefined;\n\tif (!isObject(value) || !Array.isArray(items)) throw invalid(`Invalid MCP ${method} result`);\n\tfor (const item of items) {\n\t\tif (!isObject(item) || !isItem(item)) throw invalid(`Invalid entry in MCP ${method} result`);\n\t}\n\t// Some servers end pagination with `null` or `\"\"` instead of omitting the cursor.\n\tconst nextCursor = value.nextCursor === null || value.nextCursor === \"\" ? undefined : value.nextCursor;\n\tif (nextCursor !== undefined && typeof nextCursor !== \"string\") throw invalid(`Invalid MCP ${method} cursor`);\n\treturn { items, ...(nextCursor === undefined ? {} : { nextCursor }) };\n}\n\nconst isTool = (tool: Record<string, unknown>) => typeof tool.name === \"string\" && isObject(tool.inputSchema);\n// `name` is required by the spec, but some servers omit it; the URI stands in.\nconst isResource = (resource: Record<string, unknown>) =>\n\ttypeof resource.uri === \"string\" && (resource.name === undefined || typeof resource.name === \"string\");\nconst isResourceTemplate = (template: Record<string, unknown>) =>\n\ttypeof template.uriTemplate === \"string\" && (template.name === undefined || typeof template.name === \"string\");\n\nfunction toResource(item: Record<string, unknown>): Resource {\n\treturn { ...item, name: item.name ?? item.uri } as Resource;\n}\n\nfunction toResourceTemplate(item: Record<string, unknown>): ResourceTemplate {\n\treturn { ...item, name: item.name ?? item.uriTemplate } as ResourceTemplate;\n}\n\nfunction pageCursor(page: { nextCursor?: string }): { nextCursor?: string } {\n\treturn page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor };\n}\n\nfunction validateReadResourceResult(value: unknown): ReadResourceResult {\n\tif (!isObject(value) || !Array.isArray(value.contents)) throw invalid(\"Invalid MCP resources/read result\");\n\tfor (const contents of value.contents) {\n\t\tif (\n\t\t\t!isObject(contents) ||\n\t\t\ttypeof contents.uri !== \"string\" ||\n\t\t\t(typeof contents.text !== \"string\" && typeof contents.blob !== \"string\")\n\t\t) {\n\t\t\tthrow invalid(\"Invalid contents in MCP resources/read result\");\n\t\t}\n\t}\n\treturn value as unknown as ReadResourceResult;\n}\n\n/**\n * `content` is required by the spec, but servers that only return `structuredContent` omit it (the SDK defaults it too).\n * `structuredContent` may be any JSON value, as MCP 2026-07-28 allows.\n */\nfunction validateCallToolResult(value: unknown): CallToolResult {\n\tif (!isObject(value) || (value.content !== undefined && !Array.isArray(value.content))) {\n\t\tthrow new McpError(JSON_RPC_ERROR_CODES.invalidRequest, \"Invalid MCP tools/call result\");\n\t}\n\treturn (value.content === undefined ? { ...value, content: [] } : value) as unknown as CallToolResult;\n}\n\n/**\n * What a failed `initialize` tells about the server. Servers that only speak the stateless revision\n * reject it with a JSON-RPC error, over HTTP with a 400: `stateless` when the error has a code only that\n * revision uses, `unknown` for other such rejections, and undefined for failures that are no answer\n * (timeouts, closed connections, authorization).\n */\nfunction initializeRejection(error: unknown): \"stateless\" | \"unknown\" | undefined {\n\tconst code =\n\t\terror instanceof McpError\n\t\t\t? error.code\n\t\t\t: error instanceof McpHttpError && error.status === 400\n\t\t\t\t? jsonRpcErrorIn(error.body)?.code\n\t\t\t\t: null;\n\tif (code === null) return undefined;\n\treturn code !== undefined && STATELESS_ERROR_CODES.includes(code) ? \"stateless\" : \"unknown\";\n}\n\n/** The connection closed under a request: the transport closed, or the stdio server was gone when written to. */\nfunction isConnectionLost(error: unknown): boolean {\n\t// Node's write errors are the trust boundary here: `code` is all they carry.\n\treturn (\n\t\terror instanceof McpConnectionClosedError || (error instanceof Error && \"code\" in error && error.code === \"EPIPE\")\n\t);\n}\n\n/** Thrown for an `initialize` answered with the stateless revision, which has no handshake. */\nclass StatelessInitializeError extends Error {}\n\nexport class McpClient {\n\treadonly options: Readonly<McpClientOptions>;\n\tprivate state: ClientState = \"idle\";\n\tprivate transport: McpTransport | undefined;\n\tprivate nextRequestId = 1;\n\tprivate serverInfoValue: Implementation | undefined;\n\tprivate serverCapabilitiesValue: ServerCapabilities | undefined;\n\tprivate instructionsValue: string | undefined;\n\tprivate protocolVersionValue: string | undefined;\n\t/** Whether the connection speaks the stateless revision: every request carries {@link meta}. */\n\tprivate stateless = false;\n\tprivate readonly meta: StatelessRequestMeta;\n\t/** `Mcp-Param-*` bindings of the tools last listed, for servers on the stateless revision. */\n\tprivate toolHeaders = new Map<string, ToolHeaderBinding[]>();\n\t/** Open `subscriptions/listen` requests by id. */\n\tprivate subscriptions = new Map<JsonRpcId, { acknowledge(filter: SubscriptionFilter): void; end(): void }>();\n\tprivate pending = new Map<JsonRpcId, PendingRequest>();\n\tprivate progressRequests = new Map<JsonRpcId, JsonRpcId>();\n\tprivate incoming = new Map<JsonRpcId, AbortController>();\n\tprivate requestHandlers = new Map<string, RequestHandler>();\n\tprivate notificationListeners = new Map<string, Set<NotificationListener>>();\n\tprivate errorListeners = new Set<ErrorListener>();\n\tprivate closeListeners = new Set<CloseListener>();\n\tprivate disposers: (() => void)[] = [];\n\n\tconstructor(options: McpClientOptions) {\n\t\tthis.options = Object.freeze({ ...options });\n\t\tconst capabilities: ClientCapabilities = { ...options.capabilities };\n\t\tif (options.roots && capabilities.roots === undefined) capabilities.roots = {};\n\t\tthis.meta = {\n\t\t\tprotocolVersion: STATELESS_PROTOCOL_VERSION,\n\t\t\tclientInfo: {\n\t\t\t\tname: options.name,\n\t\t\t\tversion: options.version,\n\t\t\t\t...(options.title === undefined ? {} : { title: options.title }),\n\t\t\t},\n\t\t\tclientCapabilities: capabilities,\n\t\t\tlogLevel: options.logLevel,\n\t\t};\n\t\tthis.requestHandlers.set(\"ping\", () => ({}));\n\t\tconst roots = options.roots;\n\t\tif (roots) {\n\t\t\tthis.requestHandlers.set(\"roots/list\", async () => ({\n\t\t\t\troots: [...(typeof roots === \"function\" ? await roots() : roots)],\n\t\t\t}));\n\t\t}\n\t}\n\n\tget connectionState(): ClientState {\n\t\treturn this.state;\n\t}\n\n\tget serverInfo(): Implementation | undefined {\n\t\treturn this.serverInfoValue;\n\t}\n\n\tget serverCapabilities(): ServerCapabilities | undefined {\n\t\treturn this.serverCapabilitiesValue;\n\t}\n\n\tget instructions(): string | undefined {\n\t\treturn this.instructionsValue;\n\t}\n\n\tget protocolVersion(): string | undefined {\n\t\treturn this.protocolVersionValue;\n\t}\n\n\t/**\n\t * Connect over `transport`. Resolves to what the server reported about itself; for servers on the\n\t * stateless revision, a result in the shape of `initialize` built from `server/discover`.\n\t */\n\tasync connect(transport: McpTransport): Promise<InitializeResult> {\n\t\tif (this.state !== \"idle\") throw new Error(`Cannot connect MCP client in ${this.state} state`);\n\t\tthis.state = \"connecting\";\n\t\tthis.transport = transport;\n\t\tthis.disposers = [\n\t\t\ttransport.onMessage((message) => this.handleMessage(message)),\n\t\t\t// Transport errors are reported only. Pending requests fail when the transport closes.\n\t\t\ttransport.onError((error) => this.emitError(error)),\n\t\t\ttransport.onClose(() => this.handleTransportClose()),\n\t\t];\n\n\t\ttry {\n\t\t\tawait transport.start();\n\t\t\tconst result =\n\t\t\t\tthis.options.protocol === STATELESS_PROTOCOL_VERSION\n\t\t\t\t\t? await this.discover(transport, this.connectTimeoutMs())\n\t\t\t\t\t: await this.initializeOrDiscover(transport);\n\t\t\tthis.state = \"connected\";\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tawait this.close().catch(() => {});\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * `initialize` first, so servers of every earlier revision see what they always saw. Only a server\n\t * that rejects it is asked with `server/discover`. When that fails too, the error is an\n\t * {@link McpInitializeRejectedError} with the rejection's message, or with the message of\n\t * `server/discover` when the rejection proved a stateless server that is still there. Such a server\n\t * failing `server/discover` without answering it (sign-in required, say) fails with that error.\n\t */\n\tprivate async initializeOrDiscover(transport: McpTransport): Promise<InitializeResult> {\n\t\ttry {\n\t\t\treturn await this.initialize(transport);\n\t\t} catch (error) {\n\t\t\tconst rejection = error instanceof StatelessInitializeError ? \"stateless\" : initializeRejection(error);\n\t\t\tif (rejection === undefined) throw error;\n\t\t\tconst timeoutMs =\n\t\t\t\trejection === \"stateless\"\n\t\t\t\t\t? this.connectTimeoutMs()\n\t\t\t\t\t: Math.min(this.connectTimeoutMs(), DISCOVER_AFTER_INITIALIZE_TIMEOUT_MS);\n\t\t\ttry {\n\t\t\t\treturn await this.discover(transport, timeoutMs);\n\t\t\t} catch (discoverError) {\n\t\t\t\tconst answered = discoverError instanceof McpError;\n\t\t\t\tif (rejection === \"stateless\" && !answered && !isConnectionLost(discoverError)) throw discoverError;\n\t\t\t\tconst message = rejection === \"stateless\" && answered ? discoverError.message : toError(error).message;\n\t\t\t\tthrow new McpInitializeRejectedError(message, error, discoverError);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async initialize(transport: McpTransport): Promise<InitializeResult> {\n\t\tconst result = validateInitializeResult(\n\t\t\tawait this.requestInternal(\n\t\t\t\t\"initialize\",\n\t\t\t\t{\n\t\t\t\t\tprotocolVersion: this.options.protocolVersion ?? LATEST_PROTOCOL_VERSION,\n\t\t\t\t\tcapabilities: this.meta.clientCapabilities,\n\t\t\t\t\tclientInfo: this.meta.clientInfo,\n\t\t\t\t},\n\t\t\t\t{ timeoutMs: this.connectTimeoutMs() },\n\t\t\t\ttrue,\n\t\t\t),\n\t\t);\n\t\tif (result.protocolVersion === STATELESS_PROTOCOL_VERSION) {\n\t\t\tthrow new StatelessInitializeError(\"MCP server answered initialize with the stateless protocol revision\");\n\t\t}\n\t\tif (!(SUPPORTED_PROTOCOL_VERSIONS as readonly string[]).includes(result.protocolVersion)) {\n\t\t\tthrow new Error(`MCP server selected unsupported protocol version ${result.protocolVersion}`);\n\t\t}\n\t\tthis.protocolVersionValue = result.protocolVersion;\n\t\tthis.serverInfoValue = result.serverInfo;\n\t\tthis.serverCapabilitiesValue = result.capabilities;\n\t\tthis.instructionsValue = result.instructions;\n\t\ttransport.setProtocolVersion?.(result.protocolVersion);\n\t\tawait this.notifyInternal(\"notifications/initialized\", undefined, true);\n\t\treturn result;\n\t}\n\n\t/** Speak the stateless revision: no handshake, `server/discover` tells what the server offers. */\n\tprivate async discover(transport: McpTransport, timeoutMs: number): Promise<InitializeResult> {\n\t\tthis.stateless = true;\n\t\ttransport.setProtocolVersion?.(STATELESS_PROTOCOL_VERSION);\n\t\tconst { result, serverInfo } = validateDiscoverResult(\n\t\t\tawait this.requestInternal(\"server/discover\", undefined, { timeoutMs }, true),\n\t\t);\n\t\tif (!result.supportedVersions.includes(STATELESS_PROTOCOL_VERSION)) {\n\t\t\tthrow new Error(`MCP server supports none of this client's protocol versions: ${result.supportedVersions}`);\n\t\t}\n\t\tthis.protocolVersionValue = STATELESS_PROTOCOL_VERSION;\n\t\tthis.serverInfoValue = serverInfo;\n\t\tthis.serverCapabilitiesValue = result.capabilities;\n\t\tthis.instructionsValue = result.instructions;\n\t\treturn {\n\t\t\tprotocolVersion: STATELESS_PROTOCOL_VERSION,\n\t\t\tcapabilities: result.capabilities,\n\t\t\tserverInfo: serverInfo ?? { name: \"\", version: \"\" },\n\t\t\t...(result.instructions === undefined ? {} : { instructions: result.instructions }),\n\t\t};\n\t}\n\n\trequest<Result = unknown>(\n\t\tmethod: string,\n\t\tparams?: Record<string, unknown>,\n\t\toptions: McpRequestOptions = {},\n\t): Promise<Result> {\n\t\treturn this.requestConnected(method, params, options) as Promise<Result>;\n\t}\n\n\tnotify(method: string, params?: Record<string, unknown>): Promise<void> {\n\t\treturn this.notifyInternal(method, params, false);\n\t}\n\n\t/**\n\t * Answer requests of `method` from the server: requests a legacy server sends, and the input requests\n\t * of the same method that results of the stateless revision ask for (`roots/list`, say).\n\t */\n\tsetRequestHandler(method: string, handler: RequestHandler): () => void {\n\t\tthis.requestHandlers.set(method, handler);\n\t\treturn () => {\n\t\t\tif (this.requestHandlers.get(method) === handler) this.requestHandlers.delete(method);\n\t\t};\n\t}\n\n\tonNotification(method: string, listener: NotificationListener): () => void {\n\t\tconst listeners = this.notificationListeners.get(method) ?? new Set<NotificationListener>();\n\t\tthis.notificationListeners.set(method, listeners);\n\t\tlisteners.add(listener);\n\t\treturn () => {\n\t\t\tlisteners.delete(listener);\n\t\t\tif (listeners.size === 0) this.notificationListeners.delete(method);\n\t\t};\n\t}\n\n\tonError(listener: ErrorListener): () => void {\n\t\tthis.errorListeners.add(listener);\n\t\treturn () => this.errorListeners.delete(listener);\n\t}\n\n\t/** Called once when the connection closes, whether the transport dropped or `close()` was called. */\n\tonClose(listener: CloseListener): () => void {\n\t\tthis.closeListeners.add(listener);\n\t\treturn () => this.closeListeners.delete(listener);\n\t}\n\n\t/** Check that the server answers: `ping`, or `server/discover` on the stateless revision, which has no `ping`. */\n\tasync ping(options: McpRequestOptions = {}): Promise<void> {\n\t\tawait this.request(this.stateless ? \"server/discover\" : \"ping\", undefined, options);\n\t}\n\n\t/**\n\t * Every tool, following `nextCursor` through all pages. On the stateless revision over HTTP, tools\n\t * whose `x-mcp-header` annotations are invalid are left out and reported through `onError`.\n\t */\n\tasync listTools(options: McpRequestOptions = {}): Promise<Tool[]> {\n\t\tconst tools = (await this.listAll(\"tools/list\", \"tools\", isTool, options)) as unknown as Tool[];\n\t\tif (!this.stateless || !this.transport?.sendsHeaders) return tools;\n\t\tconst kept: Tool[] = [];\n\t\tconst headers = new Map<string, ToolHeaderBinding[]>();\n\t\tfor (const tool of tools) {\n\t\t\tconst bindings = toolHeaderBindings(tool.inputSchema);\n\t\t\tif (bindings.kind === \"invalid\") {\n\t\t\t\tthis.emitError(new Error(`Excluded MCP tool \"${tool.name}\": ${bindings.reason}`));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (bindings.bindings.length > 0) headers.set(tool.name, bindings.bindings);\n\t\t\tkept.push(tool);\n\t\t}\n\t\tthis.toolHeaders = headers;\n\t\treturn kept;\n\t}\n\n\t/** Every resource, following `nextCursor` through all pages. */\n\tasync listResources(options: McpRequestOptions = {}): Promise<Resource[]> {\n\t\treturn (await this.listAll(\"resources/list\", \"resources\", isResource, options)).map(toResource);\n\t}\n\n\t/** One page of resources, starting at `cursor`. */\n\tasync listResourcesPage(cursor?: string, options: McpRequestOptions = {}): Promise<ListResourcesResult> {\n\t\tconst page = await this.listPage(\"resources/list\", \"resources\", isResource, cursor, options);\n\t\treturn { resources: page.items.map(toResource), ...pageCursor(page) };\n\t}\n\n\t/** Every resource template, following `nextCursor` through all pages. */\n\tasync listResourceTemplates(options: McpRequestOptions = {}): Promise<ResourceTemplate[]> {\n\t\tconst templates = await this.listAll(\n\t\t\t\"resources/templates/list\",\n\t\t\t\"resourceTemplates\",\n\t\t\tisResourceTemplate,\n\t\t\toptions,\n\t\t);\n\t\treturn templates.map(toResourceTemplate);\n\t}\n\n\t/** One page of resource templates, starting at `cursor`. */\n\tasync listResourceTemplatesPage(\n\t\tcursor?: string,\n\t\toptions: McpRequestOptions = {},\n\t): Promise<ListResourceTemplatesResult> {\n\t\tconst page = await this.listPage(\n\t\t\t\"resources/templates/list\",\n\t\t\t\"resourceTemplates\",\n\t\t\tisResourceTemplate,\n\t\t\tcursor,\n\t\t\toptions,\n\t\t);\n\t\treturn { resourceTemplates: page.items.map(toResourceTemplate), ...pageCursor(page) };\n\t}\n\n\tasync readResource(uri: string, options: McpRequestOptions = {}): Promise<ReadResourceResult> {\n\t\treturn validateReadResourceResult(await this.request(\"resources/read\", { uri }, options));\n\t}\n\n\tprivate async listPage(\n\t\tmethod: string,\n\t\tkey: string,\n\t\tisItem: (item: Record<string, unknown>) => boolean,\n\t\tcursor: string | undefined,\n\t\toptions: McpRequestOptions,\n\t): Promise<{ items: Record<string, unknown>[]; nextCursor?: string }> {\n\t\treturn validateListPage(\n\t\t\tmethod,\n\t\t\tkey,\n\t\t\tawait this.request(method, cursor === undefined ? undefined : { cursor }, options),\n\t\t\tisItem,\n\t\t);\n\t}\n\n\t/** Every item of a paginated list method. */\n\tprivate async listAll(\n\t\tmethod: string,\n\t\tkey: string,\n\t\tisItem: (item: Record<string, unknown>) => boolean,\n\t\toptions: McpRequestOptions,\n\t): Promise<Record<string, unknown>[]> {\n\t\tconst items: Record<string, unknown>[] = [];\n\t\tconst cursors = new Set<string>();\n\t\tlet cursor: string | undefined;\n\t\tfor (let pageNumber = 0; pageNumber < MAX_LIST_PAGES; pageNumber++) {\n\t\t\tconst page = await this.listPage(method, key, isItem, cursor, options);\n\t\t\titems.push(...page.items);\n\t\t\tif (page.nextCursor === undefined) return items;\n\t\t\tif (cursors.has(page.nextCursor))\n\t\t\t\tthrow new Error(`MCP ${method} returned duplicate cursor: ${page.nextCursor}`);\n\t\t\tcursors.add(page.nextCursor);\n\t\t\tcursor = page.nextCursor;\n\t\t}\n\t\tthrow new Error(`MCP ${method} exceeded ${MAX_LIST_PAGES} pages`);\n\t}\n\n\t/**\n\t * Call a tool. On the stateless revision, arguments the tool marks with `x-mcp-header` go into\n\t * `Mcp-Param-*` headers too; when the server reports that they do not match, the tools are listed\n\t * again for their current annotations and the call is sent once more.\n\t */\n\tasync callTool(\n\t\tname: string,\n\t\targs?: Record<string, unknown>,\n\t\toptions: McpRequestOptions = {},\n\t): Promise<CallToolResult> {\n\t\tconst params = { name, ...(args === undefined ? {} : { arguments: args }) };\n\t\tconst call = async () => {\n\t\t\tconst bindings = this.toolHeaders.get(name);\n\t\t\tconst headers = bindings ? toolParamHeaders(bindings, args) : undefined;\n\t\t\treturn validateCallToolResult(await this.requestConnected(\"tools/call\", params, options, headers));\n\t\t};\n\t\ttry {\n\t\t\treturn await call();\n\t\t} catch (error) {\n\t\t\tif (!(this.stateless && error instanceof McpError && error.code === HEADER_MISMATCH_ERROR_CODE)) throw error;\n\t\t\tawait this.listTools(options.signal ? { signal: options.signal } : {});\n\t\t\treturn await call();\n\t\t}\n\t}\n\n\t/**\n\t * Open a `subscriptions/listen` stream of a server on the stateless revision, which delivers the\n\t * notifications `filter` names to `onNotification` listeners. Resolves once the server acknowledged\n\t * it; servers of earlier revisions send their notifications without one.\n\t */\n\tasync listen(filter: SubscriptionFilter, options: { signal?: AbortSignal } = {}): Promise<McpSubscription> {\n\t\tif (!this.stateless) throw new Error(\"subscriptions/listen needs a server on the stateless revision\");\n\t\tconst controller = new AbortController();\n\t\tconst close = () => controller.abort();\n\t\toptions.signal?.addEventListener(\"abort\", close, { once: true });\n\t\tlet id: JsonRpcId | undefined;\n\t\tlet endedByServer = false;\n\t\tlet acknowledge = (_notifications: SubscriptionFilter) => {};\n\t\tconst acknowledged = new Promise<SubscriptionFilter>((resolve) => {\n\t\t\tacknowledge = resolve;\n\t\t});\n\t\tconst request = this.requestInternal(\n\t\t\t\"subscriptions/listen\",\n\t\t\t{ notifications: filter },\n\t\t\t{ signal: controller.signal, timeoutMs: Number.POSITIVE_INFINITY },\n\t\t\tfalse,\n\t\t\t{\n\t\t\t\tonId: (requestId) => {\n\t\t\t\t\tid = requestId;\n\t\t\t\t\tconst end = () => {\n\t\t\t\t\t\tendedByServer = true;\n\t\t\t\t\t\tthis.cancelPending(requestId, new McpConnectionClosedError(\"MCP subscription ended\"), false);\n\t\t\t\t\t};\n\t\t\t\t\tthis.subscriptions.set(requestId, { acknowledge, end });\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t\t// The server ends a subscription with a result or `notifications/cancelled`; the client by aborting it.\n\t\tconst closed = request\n\t\t\t.then(\n\t\t\t\t() => undefined,\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tif (!endedByServer && !controller.signal.aborted) throw error;\n\t\t\t\t},\n\t\t\t)\n\t\t\t.finally(() => {\n\t\t\t\tif (id !== undefined) this.subscriptions.delete(id);\n\t\t\t\toptions.signal?.removeEventListener(\"abort\", close);\n\t\t\t});\n\t\tconst endedEarly = closed.then(() => {\n\t\t\tthrow new Error(\"MCP subscription ended before the server acknowledged it\");\n\t\t});\n\t\t// Only the race waits for it; once acknowledged, the caller waits for `closed`.\n\t\tendedEarly.catch(() => {});\n\t\treturn { notifications: await Promise.race([acknowledged, endedEarly]), closed, close };\n\t}\n\n\tasync close(): Promise<void> {\n\t\tconst transport = this.transport;\n\t\tthis.transport = undefined;\n\t\tthis.disposeTransportListeners();\n\t\tthis.markClosed(new McpConnectionClosedError());\n\t\tawait transport?.close();\n\t}\n\n\t/**\n\t * A request on the connection. On the stateless revision, a result that asks for input is answered\n\t * with the handlers of the input requests' methods, and one of an extension result type with\n\t * `onExtensionResult`; the request is sent again with the answers until it completes. Every attempt\n\t * is a new JSON-RPC request.\n\t */\n\tprivate async requestConnected(\n\t\tmethod: string,\n\t\tparams: Record<string, unknown> | undefined,\n\t\toptions: McpRequestOptions,\n\t\theaders?: Record<string, string>,\n\t): Promise<unknown> {\n\t\tif (!this.stateless) return this.requestInternal(method, params, options, false, { headers });\n\t\tlet input: Record<string, unknown> = {};\n\t\tfor (let round = 0; ; round++) {\n\t\t\tconst result = readStatelessResult(\n\t\t\t\tmethod,\n\t\t\t\tawait this.requestInternal(method, { ...params, ...input }, options, false, { headers }),\n\t\t\t);\n\t\t\tif (result.kind === \"complete\") return result.result;\n\t\t\tif (round + 1 >= MAX_INPUT_ROUNDS) {\n\t\t\t\tthrow new Error(`MCP ${method} still asks for input after ${MAX_INPUT_ROUNDS} rounds`);\n\t\t\t}\n\t\t\tinput = await this.answerResult(method, result, options);\n\t\t}\n\t}\n\n\t/** The params that answer a result asking for more, which the request is sent again with. */\n\tprivate async answerResult(\n\t\tmethod: string,\n\t\tresult: Exclude<StatelessResult, { kind: \"complete\" }>,\n\t\toptions: McpRequestOptions,\n\t): Promise<Record<string, unknown>> {\n\t\tconst signal = options.signal ?? new AbortController().signal;\n\t\tif (result.kind === \"extension\") {\n\t\t\tif (!options.onExtensionResult) throw invalid(`Unsupported MCP ${method} result type: ${result.resultType}`);\n\t\t\tconst { requestState } = await options.onExtensionResult(result.result, { signal });\n\t\t\treturn { requestState };\n\t\t}\n\t\tif (!INPUT_METHODS.has(method)) throw new Error(`MCP ${method} result asks for input, which it may not`);\n\t\treturn {\n\t\t\tinputResponses: await this.answerInputRequests(result.inputRequests, signal),\n\t\t\t...(result.requestState === undefined ? {} : { requestState: result.requestState }),\n\t\t};\n\t}\n\n\tprivate async answerInputRequests(\n\t\trequests: Record<string, InputRequest>,\n\t\tsignal: AbortSignal,\n\t): Promise<Record<string, unknown>> {\n\t\tconst responses: Record<string, unknown> = {};\n\t\tfor (const [key, request] of Object.entries(requests)) {\n\t\t\tconst handler = this.requestHandlers.get(request.method);\n\t\t\tif (!handler) throw new Error(`MCP server asked for input this client does not provide: ${request.method}`);\n\t\t\tresponses[key] = (await handler(request.params, { signal })) ?? {};\n\t\t}\n\t\treturn responses;\n\t}\n\n\tprivate requestTimeoutMs(): number {\n\t\treturn this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;\n\t}\n\n\tprivate connectTimeoutMs(): number {\n\t\treturn this.options.connectTimeoutMs ?? this.requestTimeoutMs();\n\t}\n\n\tprivate async requestInternal(\n\t\tmethod: string,\n\t\tparams: Record<string, unknown> | undefined,\n\t\toptions: McpRequestOptions,\n\t\tallowConnecting: boolean,\n\t\tsend: { headers?: Record<string, string> | undefined; onId?: (id: JsonRpcId) => void } = {},\n\t): Promise<unknown> {\n\t\tconst transport = this.requireTransport(allowConnecting);\n\t\tif (options.signal?.aborted) throw new McpAbortError();\n\t\tconst id = this.nextRequestId++;\n\t\tsend.onId?.(id);\n\t\tconst { headers } = send;\n\t\tconst progressToken = options.onProgress ? id : undefined;\n\t\tconst metaParams = this.stateless ? withStatelessMeta(params, this.meta) : params;\n\t\tconst requestParams =\n\t\t\tprogressToken === undefined\n\t\t\t\t? metaParams\n\t\t\t\t: { ...metaParams, _meta: { ...(isObject(metaParams?._meta) ? metaParams._meta : {}), progressToken } };\n\t\tconst message: JsonRpcRequest = {\n\t\t\tjsonrpc: \"2.0\",\n\t\t\tid,\n\t\t\tmethod,\n\t\t\t...(requestParams === undefined ? {} : { params: requestParams }),\n\t\t};\n\t\treturn new Promise<unknown>((resolve, reject) => {\n\t\t\tconst entry: PendingRequest = {\n\t\t\t\tresolve,\n\t\t\t\treject,\n\t\t\t\ttimeoutMs: options.timeoutMs ?? this.requestTimeoutMs(),\n\t\t\t\ttimer: undefined,\n\t\t\t\tsignal: options.signal,\n\t\t\t\t// The spec forbids cancelling `initialize`.\n\t\t\t\tonAbort: () =>\n\t\t\t\t\tthis.cancelPending(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tnew McpAbortError(),\n\t\t\t\t\t\tmethod !== \"initialize\",\n\t\t\t\t\t\tString(options.signal?.reason ?? \"Aborted\"),\n\t\t\t\t\t),\n\t\t\t\tsendController: new AbortController(),\n\t\t\t\tcancellable: method !== \"initialize\",\n\t\t\t\tonProgress: options.onProgress,\n\t\t\t\tprogressToken,\n\t\t\t};\n\t\t\tthis.pending.set(id, entry);\n\t\t\tif (progressToken !== undefined) this.progressRequests.set(progressToken, id);\n\t\t\toptions.signal?.addEventListener(\"abort\", entry.onAbort, { once: true });\n\t\t\tthis.armTimeout(id, entry);\n\t\t\ttransport\n\t\t\t\t.send(message, { signal: entry.sendController.signal, ...(headers === undefined ? {} : { headers }) })\n\t\t\t\t.catch((error) => this.cancelPending(id, error, false));\n\t\t});\n\t}\n\n\tprivate async notifyInternal(\n\t\tmethod: string,\n\t\tparams: Record<string, unknown> | undefined,\n\t\tallowConnecting: boolean,\n\t): Promise<void> {\n\t\tawait this.requireTransport(allowConnecting).send({\n\t\t\tjsonrpc: \"2.0\",\n\t\t\tmethod,\n\t\t\t...(params === undefined ? {} : { params }),\n\t\t});\n\t}\n\n\tprivate requireTransport(allowConnecting: boolean): McpTransport {\n\t\tif (this.transport && (this.state === \"connected\" || (allowConnecting && this.state === \"connecting\"))) {\n\t\t\treturn this.transport;\n\t\t}\n\t\tthrow new McpConnectionClosedError(`MCP client is ${this.state}`);\n\t}\n\n\tprivate handleMessage(message: JsonRpcMessage): void {\n\t\tif (isJsonRpcResponse(message)) {\n\t\t\tthis.handleResponse(message);\n\t\t\treturn;\n\t\t}\n\t\tif (isJsonRpcRequest(message)) {\n\t\t\tvoid this.handleRequest(message);\n\t\t\treturn;\n\t\t}\n\t\tif (isJsonRpcNotification(message)) {\n\t\t\tthis.handleNotification(message.method, message.params);\n\t\t\treturn;\n\t\t}\n\t\tthis.emitError(new McpError(JSON_RPC_ERROR_CODES.invalidRequest, \"Received invalid JSON-RPC message\"));\n\t}\n\n\tprivate handleResponse(message: JsonRpcResponse): void {\n\t\tconst id = normalizeOwnRequestId(message.id);\n\t\tconst entry = this.pending.get(id);\n\t\tif (!entry) {\n\t\t\tthis.emitError(new Error(`Received response for unknown MCP request ${String(message.id)}`));\n\t\t\treturn;\n\t\t}\n\t\tthis.removePending(id, entry);\n\t\tif (\"error\" in message) entry.reject(new McpError(message.error.code, message.error.message, message.error.data));\n\t\telse entry.resolve(message.result);\n\t}\n\n\tprivate async handleRequest(message: JsonRpcRequest): Promise<void> {\n\t\tconst transport = this.transport;\n\t\tif (!transport) return;\n\t\tconst handler = this.requestHandlers.get(message.method);\n\t\tif (!handler) {\n\t\t\tawait transport\n\t\t\t\t.send({\n\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\tid: message.id,\n\t\t\t\t\terror: { code: JSON_RPC_ERROR_CODES.methodNotFound, message: `Method not found: ${message.method}` },\n\t\t\t\t})\n\t\t\t\t.catch((error) => this.emitError(error));\n\t\t\treturn;\n\t\t}\n\t\tconst controller = new AbortController();\n\t\tthis.incoming.set(message.id, controller);\n\t\ttry {\n\t\t\tconst result = await handler(message.params, { signal: controller.signal });\n\t\t\tawait transport.send({ jsonrpc: \"2.0\", id: message.id, result: result ?? {} });\n\t\t} catch (error) {\n\t\t\tconst responseError =\n\t\t\t\terror instanceof McpError\n\t\t\t\t\t? { code: error.code, message: error.message, data: error.data }\n\t\t\t\t\t: { code: JSON_RPC_ERROR_CODES.internalError, message: toError(error).message };\n\t\t\tawait transport\n\t\t\t\t.send({ jsonrpc: \"2.0\", id: message.id, error: responseError })\n\t\t\t\t.catch((sendError) => this.emitError(sendError));\n\t\t} finally {\n\t\t\tthis.incoming.delete(message.id);\n\t\t}\n\t}\n\n\tprivate handleNotification(method: string, params: unknown): void {\n\t\tif (method === \"notifications/progress\") this.handleProgress(params);\n\t\telse if (method === \"notifications/cancelled\") this.handleCancelled(params);\n\t\telse if (method === \"notifications/subscriptions/acknowledged\")\n\t\t\tthis.subscriptionOf(params)?.acknowledge(readSubscriptionFilter(params));\n\t\tfor (const listener of this.notificationListeners.get(method) ?? []) {\n\t\t\ttry {\n\t\t\t\tlistener(params);\n\t\t\t} catch (error) {\n\t\t\t\tthis.emitError(error);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleProgress(params: unknown): void {\n\t\tif (!isObject(params) || !isJsonRpcId(params.progressToken) || typeof params.progress !== \"number\") return;\n\t\tconst requestId = this.progressRequests.get(normalizeOwnRequestId(params.progressToken));\n\t\tconst entry = requestId === undefined ? undefined : this.pending.get(requestId);\n\t\tif (requestId === undefined || !entry) return;\n\t\tthis.armTimeout(requestId, entry);\n\t\ttry {\n\t\t\tentry.onProgress?.(params as unknown as ProgressNotification);\n\t\t} catch (error) {\n\t\t\tthis.emitError(error);\n\t\t}\n\t}\n\n\t/** Servers cancel requests they sent, and on the stateless revision end subscriptions this way. */\n\tprivate handleCancelled(params: unknown): void {\n\t\tif (!isObject(params) || !isJsonRpcId(params.requestId)) return;\n\t\tthis.incoming.get(params.requestId)?.abort(params.reason);\n\t\tthis.subscriptions.get(normalizeOwnRequestId(params.requestId))?.end();\n\t}\n\n\tprivate subscriptionOf(params: unknown) {\n\t\tconst id = subscriptionIdOf(params);\n\t\treturn isJsonRpcId(id) ? this.subscriptions.get(normalizeOwnRequestId(id)) : undefined;\n\t}\n\n\tprivate armTimeout(id: JsonRpcId, entry: PendingRequest): void {\n\t\tif (entry.timer) clearTimeout(entry.timer);\n\t\tif (!Number.isFinite(entry.timeoutMs) || entry.timeoutMs <= 0) return;\n\t\tentry.timer = setTimeout(() => {\n\t\t\tthis.cancelPending(id, new McpTimeoutError(entry.timeoutMs), entry.cancellable, \"Request timed out\");\n\t\t}, entry.timeoutMs);\n\t}\n\n\tprivate cancelPending(id: JsonRpcId, error: unknown, notifyServer: boolean, reason?: string): void {\n\t\tconst entry = this.pending.get(id);\n\t\tif (!entry) return;\n\t\tthis.removePending(id, entry);\n\t\tentry.reject(error);\n\t\tif (notifyServer && this.transport) {\n\t\t\tvoid this.transport\n\t\t\t\t.send({\n\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\tmethod: \"notifications/cancelled\",\n\t\t\t\t\tparams: { requestId: id, ...(reason ? { reason } : {}) },\n\t\t\t\t})\n\t\t\t\t.catch((sendError) => this.emitError(sendError));\n\t\t}\n\t}\n\n\tprivate removePending(id: JsonRpcId, entry: PendingRequest): void {\n\t\tthis.pending.delete(id);\n\t\tif (entry.timer) clearTimeout(entry.timer);\n\t\tif (entry.progressToken !== undefined) this.progressRequests.delete(entry.progressToken);\n\t\tentry.signal?.removeEventListener(\"abort\", entry.onAbort);\n\t\tentry.sendController.abort();\n\t}\n\n\tprivate rejectPending(error: unknown): void {\n\t\tfor (const [id, entry] of this.pending) {\n\t\t\tthis.removePending(id, entry);\n\t\t\tentry.reject(error);\n\t\t}\n\t}\n\n\tprivate handleTransportClose(): void {\n\t\tthis.markClosed(new McpConnectionClosedError());\n\t}\n\n\t/** Idempotent: rejects in-flight requests, aborts server requests we are serving, and flips the state. */\n\tprivate markClosed(error: Error): void {\n\t\tconst wasClosed = this.state === \"closed\";\n\t\tthis.state = \"closed\";\n\t\tthis.rejectPending(error);\n\t\tfor (const controller of this.incoming.values()) controller.abort(error);\n\t\tthis.incoming.clear();\n\t\tif (wasClosed) return;\n\t\tfor (const listener of [...this.closeListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch (listenerError) {\n\t\t\t\tthis.emitError(listenerError);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate emitError(error: unknown): void {\n\t\tconst normalized = toError(error);\n\t\tfor (const listener of this.errorListeners) listener(normalized);\n\t}\n\n\tprivate disposeTransportListeners(): void {\n\t\tfor (const dispose of this.disposers.splice(0)) dispose();\n\t}\n}\n"]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared `mcpServers` shape as a JSON Schema (pigeon-schema builders): the source of this package's
|
|
3
|
+
* configuration types (`Static`), and the parts an application composes into a published schema for
|
|
4
|
+
* its own config file, as pigeon does for `mcp.json`.
|
|
5
|
+
*
|
|
6
|
+
* `validateMcpServerConfig` in `config.ts` stays the trust boundary: it keeps unknown fields for the
|
|
7
|
+
* application and enforces the cross-field rules a schema cannot express (transport selection, port
|
|
8
|
+
* agreement, `cimd` restrictions). The assembled entry schemas are closed, which published schemas
|
|
9
|
+
* want so editors flag mistyped keys; an application that adds fields of its own spreads the
|
|
10
|
+
* property maps into its own objects. Their optional fields are pigeon-schema `opt()` values, which
|
|
11
|
+
* `obj()` recognizes by class, so the application must use the same `@dev-crowagent/pigeon-schema`
|
|
12
|
+
* copy as this package.
|
|
13
|
+
*/
|
|
14
|
+
import { type Static } from "@dev-crowagent/pigeon-schema";
|
|
15
|
+
/** Fields every server entry may have. */
|
|
16
|
+
export declare const mcpServerBaseProperties: {
|
|
17
|
+
description: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<string>>;
|
|
18
|
+
enabled: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<boolean>>;
|
|
19
|
+
timeout: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<number>>;
|
|
20
|
+
protocol: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<"2026-07-28" | "auto">>;
|
|
21
|
+
};
|
|
22
|
+
/** OAuth client settings for servers that do not support dynamic client registration. */
|
|
23
|
+
export declare const mcpOAuthProperties: {
|
|
24
|
+
clientId: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<string>>;
|
|
25
|
+
clientSecret: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<string>>;
|
|
26
|
+
callbackPort: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<number>>;
|
|
27
|
+
callbackUrl: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<string>>;
|
|
28
|
+
scope: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<string>>;
|
|
29
|
+
clientName: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<string>>;
|
|
30
|
+
clientRegistration: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<"auto" | "cimd" | "dcr">>;
|
|
31
|
+
authServerMetadataUrl: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<string>>;
|
|
32
|
+
};
|
|
33
|
+
export declare const McpOAuthSchema: import("@dev-crowagent/pigeon-schema").Schema<{
|
|
34
|
+
clientId?: string | undefined;
|
|
35
|
+
clientSecret?: string | undefined;
|
|
36
|
+
callbackPort?: number | undefined;
|
|
37
|
+
callbackUrl?: string | undefined;
|
|
38
|
+
scope?: string | undefined;
|
|
39
|
+
clientName?: string | undefined;
|
|
40
|
+
clientRegistration?: "auto" | "cimd" | "dcr" | undefined;
|
|
41
|
+
authServerMetadataUrl?: string | undefined;
|
|
42
|
+
}>;
|
|
43
|
+
/** Fields of a server started as a local program that speaks MCP over stdin and stdout. */
|
|
44
|
+
export declare const mcpStdioServerProperties: {
|
|
45
|
+
type: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<"stdio">>;
|
|
46
|
+
command: import("@dev-crowagent/pigeon-schema").Schema<string>;
|
|
47
|
+
args: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<string[]>>;
|
|
48
|
+
env: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<Record<string, string>>>;
|
|
49
|
+
cwd: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<string>>;
|
|
50
|
+
};
|
|
51
|
+
/** Fields of a server reached over Streamable HTTP. */
|
|
52
|
+
export declare const mcpHttpServerProperties: {
|
|
53
|
+
type: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<"http" | "streamable-http">>;
|
|
54
|
+
url: import("@dev-crowagent/pigeon-schema").Schema<string>;
|
|
55
|
+
headers: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<Record<string, string>>>;
|
|
56
|
+
oauth: import("@dev-crowagent/pigeon-schema").Optional<import("@dev-crowagent/pigeon-schema").Schema<{
|
|
57
|
+
clientId?: string | undefined;
|
|
58
|
+
clientSecret?: string | undefined;
|
|
59
|
+
callbackPort?: number | undefined;
|
|
60
|
+
callbackUrl?: string | undefined;
|
|
61
|
+
scope?: string | undefined;
|
|
62
|
+
clientName?: string | undefined;
|
|
63
|
+
clientRegistration?: "auto" | "cimd" | "dcr" | undefined;
|
|
64
|
+
authServerMetadataUrl?: string | undefined;
|
|
65
|
+
}>>;
|
|
66
|
+
};
|
|
67
|
+
export declare const McpStdioServerSchema: import("@dev-crowagent/pigeon-schema").Schema<{
|
|
68
|
+
description?: string | undefined;
|
|
69
|
+
enabled?: boolean | undefined;
|
|
70
|
+
timeout?: number | undefined;
|
|
71
|
+
protocol?: "2026-07-28" | "auto" | undefined;
|
|
72
|
+
type?: "stdio" | undefined;
|
|
73
|
+
command: string;
|
|
74
|
+
args?: string[] | undefined;
|
|
75
|
+
env?: Record<string, string> | undefined;
|
|
76
|
+
cwd?: string | undefined;
|
|
77
|
+
}>;
|
|
78
|
+
export declare const McpHttpServerSchema: import("@dev-crowagent/pigeon-schema").Schema<{
|
|
79
|
+
description?: string | undefined;
|
|
80
|
+
enabled?: boolean | undefined;
|
|
81
|
+
timeout?: number | undefined;
|
|
82
|
+
protocol?: "2026-07-28" | "auto" | undefined;
|
|
83
|
+
type?: "http" | "streamable-http" | undefined;
|
|
84
|
+
url: string;
|
|
85
|
+
headers?: Record<string, string> | undefined;
|
|
86
|
+
oauth?: {
|
|
87
|
+
clientId?: string | undefined;
|
|
88
|
+
clientSecret?: string | undefined;
|
|
89
|
+
callbackPort?: number | undefined;
|
|
90
|
+
callbackUrl?: string | undefined;
|
|
91
|
+
scope?: string | undefined;
|
|
92
|
+
clientName?: string | undefined;
|
|
93
|
+
clientRegistration?: "auto" | "cimd" | "dcr" | undefined;
|
|
94
|
+
authServerMetadataUrl?: string | undefined;
|
|
95
|
+
} | undefined;
|
|
96
|
+
}>;
|
|
97
|
+
/** OAuth client settings for servers that do not support dynamic client registration. */
|
|
98
|
+
export type McpOAuthConfig = Static<typeof McpOAuthSchema>;
|
|
99
|
+
/** A server started as a local program that speaks MCP over stdin and stdout. */
|
|
100
|
+
export type McpStdioServerConfig = Static<typeof McpStdioServerSchema>;
|
|
101
|
+
/** A server reached over Streamable HTTP. */
|
|
102
|
+
export type McpHttpServerConfig = Static<typeof McpHttpServerSchema>;
|
|
103
|
+
/** One entry of the `mcpServers` shape: a stdio or a Streamable HTTP server. */
|
|
104
|
+
export type McpServerConfig = McpStdioServerConfig | McpHttpServerConfig;
|
|
105
|
+
//# sourceMappingURL=config-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../src/config-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAUN,KAAK,MAAM,EAGX,MAAM,8BAA8B,CAAC;AAKtC,0CAA0C;AAC1C,eAAO,MAAM,uBAAuB;;;;;CAiBd,CAAC;AAEvB,yFAAyF;AACzF,eAAO,MAAM,kBAAkB;;;;;;;;;CAiET,CAAC;AAEvB,eAAO,MAAM,cAAc;;;;;;;;;EAEzB,CAAC;AAEH,2FAA2F;AAC3F,eAAO,MAAM,wBAAwB;;;;;;CAWf,CAAC;AAEvB,uDAAuD;AACvD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;CAYd,CAAC;AAEvB,eAAO,MAAM,oBAAoB;;;;;;;;;;EAGhC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;EAG/B,CAAC;AAEF,yFAAyF;AACzF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAE3D,iFAAiF;AACjF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEvE,6CAA6C;AAC7C,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE,gFAAgF;AAChF,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared `mcpServers` shape as a JSON Schema (pigeon-schema builders): the source of this package's
|
|
3
|
+
* configuration types (`Static`), and the parts an application composes into a published schema for
|
|
4
|
+
* its own config file, as pigeon does for `mcp.json`.
|
|
5
|
+
*
|
|
6
|
+
* `validateMcpServerConfig` in `config.ts` stays the trust boundary: it keeps unknown fields for the
|
|
7
|
+
* application and enforces the cross-field rules a schema cannot express (transport selection, port
|
|
8
|
+
* agreement, `cimd` restrictions). The assembled entry schemas are closed, which published schemas
|
|
9
|
+
* want so editors flag mistyped keys; an application that adds fields of its own spreads the
|
|
10
|
+
* property maps into its own objects. Their optional fields are pigeon-schema `opt()` values, which
|
|
11
|
+
* `obj()` recognizes by class, so the application must use the same `@dev-crowagent/pigeon-schema`
|
|
12
|
+
* copy as this package.
|
|
13
|
+
*/
|
|
14
|
+
// biome-ignore-all lint/suspicious/noTemplateCurlyInString: descriptions name the literal ${NAME} value syntax.
|
|
15
|
+
import { arr, bool, int, lit, map, num, obj, opt, str, union, } from "@dev-crowagent/pigeon-schema";
|
|
16
|
+
import { STATELESS_PROTOCOL_VERSION } from "./protocol/types.js";
|
|
17
|
+
const LOOPBACK_URL = "(localhost|127\\.0\\.0\\.1|\\[::1\\])";
|
|
18
|
+
/** Fields every server entry may have. */
|
|
19
|
+
export const mcpServerBaseProperties = {
|
|
20
|
+
description: opt(str({ description: "What the server offers, in a sentence." })),
|
|
21
|
+
enabled: opt(bool({ description: "Set to false to keep the entry without connecting.", default: true })),
|
|
22
|
+
timeout: opt(num({ exclusiveMinimum: 0, description: "Per-request timeout in seconds." })),
|
|
23
|
+
protocol: opt(union([
|
|
24
|
+
lit("auto", {
|
|
25
|
+
description: "initialize, and the stateless revision only for servers that reject it (default).",
|
|
26
|
+
}),
|
|
27
|
+
lit(STATELESS_PROTOCOL_VERSION, {
|
|
28
|
+
description: "Only the stateless revision, also for servers that speak both.",
|
|
29
|
+
}),
|
|
30
|
+
], { description: "MCP protocol revision to use.", default: "auto" })),
|
|
31
|
+
};
|
|
32
|
+
/** OAuth client settings for servers that do not support dynamic client registration. */
|
|
33
|
+
export const mcpOAuthProperties = {
|
|
34
|
+
clientId: opt(str({
|
|
35
|
+
description: "Pre-registered client id. Without it, the application registers a client with the authorization " +
|
|
36
|
+
"server.",
|
|
37
|
+
})),
|
|
38
|
+
clientSecret: opt(str({ description: "As configured; the application decides whether it may reference variables." })),
|
|
39
|
+
callbackPort: opt(int({
|
|
40
|
+
minimum: 1,
|
|
41
|
+
maximum: 65535,
|
|
42
|
+
description: "Port of the loopback callback server, for clients registered with a fixed redirect URI. Without " +
|
|
43
|
+
"callbackUrl, the redirect URI is http://127.0.0.1:<port>/callback.",
|
|
44
|
+
})),
|
|
45
|
+
callbackUrl: opt(str({
|
|
46
|
+
pattern: `^http://${LOOPBACK_URL}(:[0-9]+)?(/[^?#]*)?$`,
|
|
47
|
+
description: "Redirect URI registered for clientId: an http URI on localhost, 127.0.0.1, or [::1] without " +
|
|
48
|
+
"query or fragment. Without a port, the callback server listens on callbackPort or a free port, " +
|
|
49
|
+
"which is added to the URI; when both name a port, they must match.",
|
|
50
|
+
})),
|
|
51
|
+
scope: opt(str({ description: "Scopes to request, separated by spaces. Default: the scopes the server advertises." })),
|
|
52
|
+
clientName: opt(str({
|
|
53
|
+
pattern: "\\S",
|
|
54
|
+
description: "client_name sent with dynamic client registration. Default: the application's name.",
|
|
55
|
+
})),
|
|
56
|
+
clientRegistration: opt(union([
|
|
57
|
+
lit("auto", {
|
|
58
|
+
description: "The application's Client ID Metadata Document when the authorization server supports them " +
|
|
59
|
+
"for public clients, otherwise dynamic client registration (default).",
|
|
60
|
+
}),
|
|
61
|
+
lit("dcr", { description: "Always dynamic client registration." }),
|
|
62
|
+
lit("cimd", {
|
|
63
|
+
description: "Always the Client ID Metadata Document; sign-in fails without support. Cannot be combined " +
|
|
64
|
+
"with clientId or clientName.",
|
|
65
|
+
}),
|
|
66
|
+
], { description: "How the application identifies itself without clientId." })),
|
|
67
|
+
authServerMetadataUrl: opt(str({
|
|
68
|
+
pattern: `^(https://\\S|http://${LOOPBACK_URL}([:/]|$))`,
|
|
69
|
+
description: "Authorization server metadata document (RFC 8414 or OpenID Connect discovery) to use instead of " +
|
|
70
|
+
"discovery through the server, for servers that advertise a wrong authorization server or none. " +
|
|
71
|
+
"The document is trusted as configured. Must use https, except on loopback hosts.",
|
|
72
|
+
})),
|
|
73
|
+
};
|
|
74
|
+
export const McpOAuthSchema = obj(mcpOAuthProperties, {
|
|
75
|
+
description: "OAuth client settings for servers that do not support dynamic client registration.",
|
|
76
|
+
});
|
|
77
|
+
/** Fields of a server started as a local program that speaks MCP over stdin and stdout. */
|
|
78
|
+
export const mcpStdioServerProperties = {
|
|
79
|
+
type: opt(lit("stdio")),
|
|
80
|
+
command: str({ description: "One executable, not a shell command string; its arguments go in args." }),
|
|
81
|
+
args: opt(arr(str(), { description: "Arguments passed to command." })),
|
|
82
|
+
env: opt(map(str(), {
|
|
83
|
+
description: "Added to the environment. The application decides whether values may reference variables " + "(${NAME}).",
|
|
84
|
+
})),
|
|
85
|
+
cwd: opt(str({ description: "The application decides what relative paths resolve against." })),
|
|
86
|
+
};
|
|
87
|
+
/** Fields of a server reached over Streamable HTTP. */
|
|
88
|
+
export const mcpHttpServerProperties = {
|
|
89
|
+
type: opt(union([lit("http"), lit("streamable-http")])),
|
|
90
|
+
url: str({
|
|
91
|
+
pattern: "^https?://\\S",
|
|
92
|
+
description: "Streamable HTTP endpoint. The legacy SSE transport is not supported.",
|
|
93
|
+
}),
|
|
94
|
+
headers: opt(map(str(), {
|
|
95
|
+
description: "Sent with every request. The application decides whether values may reference variables.",
|
|
96
|
+
})),
|
|
97
|
+
oauth: opt(McpOAuthSchema),
|
|
98
|
+
};
|
|
99
|
+
export const McpStdioServerSchema = obj({ ...mcpStdioServerProperties, ...mcpServerBaseProperties }, { description: "A server started as a local program that speaks MCP over stdin and stdout." });
|
|
100
|
+
export const McpHttpServerSchema = obj({ ...mcpHttpServerProperties, ...mcpServerBaseProperties }, { description: "A server reached over Streamable HTTP." });
|
|
101
|
+
//# sourceMappingURL=config-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-schema.js","sourceRoot":"","sources":["../src/config-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,gHAAgH;AAEhH,OAAO,EACN,GAAG,EACH,IAAI,EACJ,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EAGH,GAAG,EACH,KAAK,GACL,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEjE,MAAM,YAAY,GAAG,uCAAuC,CAAC;AAE7D,0CAA0C;AAC1C,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC,CAAC;IAChF,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,oDAAoD,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACxG,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,EAA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GAAG,EAAE,EAAE;QACV,WAAW,EAAE,0FAA0F;KACvG,CAAC,CACF;IACD,KAAK,EAAE,GAAG,CAAC,cAAc,CAAC;CACL,CAAC;AAEvB,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CACtC,EAAE,GAAG,wBAAwB,EAAE,GAAG,uBAAuB,EAAE,EAC3D,EAAE,WAAW,EAAE,4EAA4E,EAAE,CAC7F,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CACrC,EAAE,GAAG,uBAAuB,EAAE,GAAG,uBAAuB,EAAE,EAC1D,EAAE,WAAW,EAAE,wCAAwC,EAAE,CACzD,CAAC","sourcesContent":["/**\n * The shared `mcpServers` shape as a JSON Schema (pigeon-schema builders): the source of this package's\n * configuration types (`Static`), and the parts an application composes into a published schema for\n * its own config file, as pigeon does for `mcp.json`.\n *\n * `validateMcpServerConfig` in `config.ts` stays the trust boundary: it keeps unknown fields for the\n * application and enforces the cross-field rules a schema cannot express (transport selection, port\n * agreement, `cimd` restrictions). The assembled entry schemas are closed, which published schemas\n * want so editors flag mistyped keys; an application that adds fields of its own spreads the\n * property maps into its own objects. Their optional fields are pigeon-schema `opt()` values, which\n * `obj()` recognizes by class, so the application must use the same `@dev-crowagent/pigeon-schema`\n * copy as this package.\n */\n\n// biome-ignore-all lint/suspicious/noTemplateCurlyInString: descriptions name the literal ${NAME} value syntax.\n\nimport {\n\tarr,\n\tbool,\n\tint,\n\tlit,\n\tmap,\n\tnum,\n\tobj,\n\topt,\n\ttype Properties,\n\ttype Static,\n\tstr,\n\tunion,\n} from \"@dev-crowagent/pigeon-schema\";\nimport { STATELESS_PROTOCOL_VERSION } from \"./protocol/types.ts\";\n\nconst LOOPBACK_URL = \"(localhost|127\\\\.0\\\\.0\\\\.1|\\\\[::1\\\\])\";\n\n/** Fields every server entry may have. */\nexport const mcpServerBaseProperties = {\n\tdescription: opt(str({ description: \"What the server offers, in a sentence.\" })),\n\tenabled: opt(bool({ description: \"Set to false to keep the entry without connecting.\", default: true })),\n\ttimeout: opt(num({ exclusiveMinimum: 0, description: \"Per-request timeout in seconds.\" })),\n\tprotocol: opt(\n\t\tunion(\n\t\t\t[\n\t\t\t\tlit(\"auto\", {\n\t\t\t\t\tdescription: \"initialize, and the stateless revision only for servers that reject it (default).\",\n\t\t\t\t}),\n\t\t\t\tlit(STATELESS_PROTOCOL_VERSION, {\n\t\t\t\t\tdescription: \"Only the stateless revision, also for servers that speak both.\",\n\t\t\t\t}),\n\t\t\t],\n\t\t\t{ description: \"MCP protocol revision to use.\", default: \"auto\" },\n\t\t),\n\t),\n} satisfies Properties;\n\n/** OAuth client settings for servers that do not support dynamic client registration. */\nexport const mcpOAuthProperties = {\n\tclientId: opt(\n\t\tstr({\n\t\t\tdescription:\n\t\t\t\t\"Pre-registered client id. Without it, the application registers a client with the authorization \" +\n\t\t\t\t\"server.\",\n\t\t}),\n\t),\n\tclientSecret: opt(\n\t\tstr({ description: \"As configured; the application decides whether it may reference variables.\" }),\n\t),\n\tcallbackPort: opt(\n\t\tint({\n\t\t\tminimum: 1,\n\t\t\tmaximum: 65535,\n\t\t\tdescription:\n\t\t\t\t\"Port of the loopback callback server, for clients registered with a fixed redirect URI. Without \" +\n\t\t\t\t\"callbackUrl, the redirect URI is http://127.0.0.1:<port>/callback.\",\n\t\t}),\n\t),\n\tcallbackUrl: opt(\n\t\tstr({\n\t\t\tpattern: `^http://${LOOPBACK_URL}(:[0-9]+)?(/[^?#]*)?$`,\n\t\t\tdescription:\n\t\t\t\t\"Redirect URI registered for clientId: an http URI on localhost, 127.0.0.1, or [::1] without \" +\n\t\t\t\t\"query or fragment. Without a port, the callback server listens on callbackPort or a free port, \" +\n\t\t\t\t\"which is added to the URI; when both name a port, they must match.\",\n\t\t}),\n\t),\n\tscope: opt(\n\t\tstr({ description: \"Scopes to request, separated by spaces. Default: the scopes the server advertises.\" }),\n\t),\n\tclientName: opt(\n\t\tstr({\n\t\t\tpattern: \"\\\\S\",\n\t\t\tdescription: \"client_name sent with dynamic client registration. Default: the application's name.\",\n\t\t}),\n\t),\n\tclientRegistration: opt(\n\t\tunion(\n\t\t\t[\n\t\t\t\tlit(\"auto\", {\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"The application's Client ID Metadata Document when the authorization server supports them \" +\n\t\t\t\t\t\t\"for public clients, otherwise dynamic client registration (default).\",\n\t\t\t\t}),\n\t\t\t\tlit(\"dcr\", { description: \"Always dynamic client registration.\" }),\n\t\t\t\tlit(\"cimd\", {\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Always the Client ID Metadata Document; sign-in fails without support. Cannot be combined \" +\n\t\t\t\t\t\t\"with clientId or clientName.\",\n\t\t\t\t}),\n\t\t\t],\n\t\t\t{ description: \"How the application identifies itself without clientId.\" },\n\t\t),\n\t),\n\tauthServerMetadataUrl: opt(\n\t\tstr({\n\t\t\tpattern: `^(https://\\\\S|http://${LOOPBACK_URL}([:/]|$))`,\n\t\t\tdescription:\n\t\t\t\t\"Authorization server metadata document (RFC 8414 or OpenID Connect discovery) to use instead of \" +\n\t\t\t\t\"discovery through the server, for servers that advertise a wrong authorization server or none. \" +\n\t\t\t\t\"The document is trusted as configured. Must use https, except on loopback hosts.\",\n\t\t}),\n\t),\n} satisfies Properties;\n\nexport const McpOAuthSchema = obj(mcpOAuthProperties, {\n\tdescription: \"OAuth client settings for servers that do not support dynamic client registration.\",\n});\n\n/** Fields of a server started as a local program that speaks MCP over stdin and stdout. */\nexport const mcpStdioServerProperties = {\n\ttype: opt(lit(\"stdio\")),\n\tcommand: str({ description: \"One executable, not a shell command string; its arguments go in args.\" }),\n\targs: opt(arr(str(), { description: \"Arguments passed to command.\" })),\n\tenv: opt(\n\t\tmap(str(), {\n\t\t\tdescription:\n\t\t\t\t\"Added to the environment. The application decides whether values may reference variables \" + \"(${NAME}).\",\n\t\t}),\n\t),\n\tcwd: opt(str({ description: \"The application decides what relative paths resolve against.\" })),\n} satisfies Properties;\n\n/** Fields of a server reached over Streamable HTTP. */\nexport const mcpHttpServerProperties = {\n\ttype: opt(union([lit(\"http\"), lit(\"streamable-http\")])),\n\turl: str({\n\t\tpattern: \"^https?://\\\\S\",\n\t\tdescription: \"Streamable HTTP endpoint. The legacy SSE transport is not supported.\",\n\t}),\n\theaders: opt(\n\t\tmap(str(), {\n\t\t\tdescription: \"Sent with every request. The application decides whether values may reference variables.\",\n\t\t}),\n\t),\n\toauth: opt(McpOAuthSchema),\n} satisfies Properties;\n\nexport const McpStdioServerSchema = obj(\n\t{ ...mcpStdioServerProperties, ...mcpServerBaseProperties },\n\t{ description: \"A server started as a local program that speaks MCP over stdin and stdout.\" },\n);\n\nexport const McpHttpServerSchema = obj(\n\t{ ...mcpHttpServerProperties, ...mcpServerBaseProperties },\n\t{ description: \"A server reached over Streamable HTTP.\" },\n);\n\n/** OAuth client settings for servers that do not support dynamic client registration. */\nexport type McpOAuthConfig = Static<typeof McpOAuthSchema>;\n\n/** A server started as a local program that speaks MCP over stdin and stdout. */\nexport type McpStdioServerConfig = Static<typeof McpStdioServerSchema>;\n\n/** A server reached over Streamable HTTP. */\nexport type McpHttpServerConfig = Static<typeof McpHttpServerSchema>;\n\n/** One entry of the `mcpServers` shape: a stdio or a Streamable HTTP server. */\nexport type McpServerConfig = McpStdioServerConfig | McpHttpServerConfig;\n"]}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `mcpServers` configuration shape that MCP clients share, so configurations can be copied between
|
|
3
|
+
* them: stdio servers (`command`, `args`, `env`, `cwd`), Streamable HTTP servers (`url`, `headers`,
|
|
4
|
+
* `oauth`), and `enabled`, `description`, `timeout` and `protocol` for both.
|
|
5
|
+
*
|
|
6
|
+
* ```json
|
|
7
|
+
* {
|
|
8
|
+
* "mcpServers": {
|
|
9
|
+
* "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "."] },
|
|
10
|
+
* "docs": { "url": "https://example.com/mcp", "headers": { "Authorization": "Bearer ${DOCS_TOKEN}" } }
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Applications add fields of their own: {@link validateMcpServerConfig} keeps fields it does not know
|
|
16
|
+
* for the caller to check afterwards.
|
|
17
|
+
*
|
|
18
|
+
* The shape itself lives in `config-schema.ts`: a JSON Schema the configuration types derive from,
|
|
19
|
+
* whose parts applications compose into published schemas for their config files.
|
|
20
|
+
*/
|
|
21
|
+
import type { McpHttpServerConfig, McpStdioServerConfig } from "./config-schema.ts";
|
|
22
|
+
export type { McpHttpServerConfig, McpOAuthConfig, McpServerConfig, McpStdioServerConfig, } from "./config-schema.ts";
|
|
23
|
+
/**
|
|
24
|
+
* A validated server entry, tagged with its transport, or why it is invalid. The config is the entry
|
|
25
|
+
* as given: fields the validator does not know are kept, unchecked, for the caller to check.
|
|
26
|
+
*/
|
|
27
|
+
export type McpServerConfigResult = {
|
|
28
|
+
kind: "stdio";
|
|
29
|
+
config: McpStdioServerConfig & Record<string, unknown>;
|
|
30
|
+
} | {
|
|
31
|
+
kind: "http";
|
|
32
|
+
config: McpHttpServerConfig & Record<string, unknown>;
|
|
33
|
+
} | {
|
|
34
|
+
kind: "invalid";
|
|
35
|
+
error: string;
|
|
36
|
+
};
|
|
37
|
+
/** What the application adds to the validation of server entries. */
|
|
38
|
+
export interface McpServerConfigOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Checks the `oauth.callbackUrl` (undefined: none configured) of an entry with
|
|
41
|
+
* `oauth.clientRegistration: "cimd"`: the application's Client ID Metadata Documents must list it.
|
|
42
|
+
* Returns an error message. Without this check, `"cimd"` is refused.
|
|
43
|
+
*/
|
|
44
|
+
checkMetadataDocumentCallback?(callbackUrl: string | undefined): string | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Validate one entry of the `mcpServers` shape (configuration files are a trust boundary). Server
|
|
48
|
+
* names are letters, digits, `_` and `-`, which tool names and namespaces are built from.
|
|
49
|
+
*/
|
|
50
|
+
export declare function validateMcpServerConfig(name: string, raw: unknown, options?: McpServerConfigOptions): McpServerConfigResult;
|
|
51
|
+
/**
|
|
52
|
+
* Whether an entry overrides a server defined elsewhere instead of defining one: it has no `command`,
|
|
53
|
+
* `url` or `type`. Applications let a less trusted file (a project's) override a few fields, such as
|
|
54
|
+
* `enabled`, of a server a trusted file defines; which fields is theirs to decide.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isMcpServerOverride(entry: Record<string, unknown>): boolean;
|
|
57
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGpF,YAAY,EACX,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,oBAAoB,GACpB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACzE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACvE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC,qEAAqE;AACrE,MAAM,WAAW,sBAAsB;IACtC;;;;OAIG;IACH,6BAA6B,CAAC,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;CACpF;AAID;;;GAGG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE,sBAA2B,GAClC,qBAAqB,CAsBvB;AAoGD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAE3E"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `mcpServers` configuration shape that MCP clients share, so configurations can be copied between
|
|
3
|
+
* them: stdio servers (`command`, `args`, `env`, `cwd`), Streamable HTTP servers (`url`, `headers`,
|
|
4
|
+
* `oauth`), and `enabled`, `description`, `timeout` and `protocol` for both.
|
|
5
|
+
*
|
|
6
|
+
* ```json
|
|
7
|
+
* {
|
|
8
|
+
* "mcpServers": {
|
|
9
|
+
* "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "."] },
|
|
10
|
+
* "docs": { "url": "https://example.com/mcp", "headers": { "Authorization": "Bearer ${DOCS_TOKEN}" } }
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Applications add fields of their own: {@link validateMcpServerConfig} keeps fields it does not know
|
|
16
|
+
* for the caller to check afterwards.
|
|
17
|
+
*
|
|
18
|
+
* The shape itself lives in `config-schema.ts`: a JSON Schema the configuration types derive from,
|
|
19
|
+
* whose parts applications compose into published schemas for their config files.
|
|
20
|
+
*/
|
|
21
|
+
import { STATELESS_PROTOCOL_VERSION } from "./protocol/types.js";
|
|
22
|
+
const SERVER_NAME = /^[A-Za-z0-9_-]+$/;
|
|
23
|
+
/**
|
|
24
|
+
* Validate one entry of the `mcpServers` shape (configuration files are a trust boundary). Server
|
|
25
|
+
* names are letters, digits, `_` and `-`, which tool names and namespaces are built from.
|
|
26
|
+
*/
|
|
27
|
+
export function validateMcpServerConfig(name, raw, options = {}) {
|
|
28
|
+
const invalid = (error) => ({ kind: "invalid", error });
|
|
29
|
+
if (!SERVER_NAME.test(name))
|
|
30
|
+
return invalid(`invalid server name "${name}" (use letters, digits, "_" and "-")`);
|
|
31
|
+
if (!isRecord(raw))
|
|
32
|
+
return invalid(`server "${name}" must be an object`);
|
|
33
|
+
const fieldsError = validateBaseFields(raw);
|
|
34
|
+
if (fieldsError)
|
|
35
|
+
return invalid(`server "${name}": ${fieldsError}`);
|
|
36
|
+
const { type, url, command } = raw;
|
|
37
|
+
if (type === "sse") {
|
|
38
|
+
return invalid(`server "${name}": legacy SSE transport is not supported; use the streamable HTTP URL`);
|
|
39
|
+
}
|
|
40
|
+
// The casts below hold because the fields were checked one by one, which the types cannot express.
|
|
41
|
+
if (typeof url === "string" && (type === undefined || type === "http" || type === "streamable-http")) {
|
|
42
|
+
const error = validateHttpFields(raw, url, options);
|
|
43
|
+
if (error)
|
|
44
|
+
return invalid(`server "${name}": ${error}`);
|
|
45
|
+
return { kind: "http", config: raw };
|
|
46
|
+
}
|
|
47
|
+
if (typeof command === "string" && (type === undefined || type === "stdio")) {
|
|
48
|
+
const error = validateStdioFields(raw);
|
|
49
|
+
if (error)
|
|
50
|
+
return invalid(`server "${name}": ${error}`);
|
|
51
|
+
return { kind: "stdio", config: raw };
|
|
52
|
+
}
|
|
53
|
+
return invalid(`server "${name}" needs either "command" (stdio) or "url" (streamable HTTP)`);
|
|
54
|
+
}
|
|
55
|
+
function isRecord(value) {
|
|
56
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
57
|
+
}
|
|
58
|
+
function validateBaseFields(entry) {
|
|
59
|
+
const { enabled, timeout, description, protocol } = entry;
|
|
60
|
+
if (enabled !== undefined && typeof enabled !== "boolean")
|
|
61
|
+
return "enabled must be a boolean";
|
|
62
|
+
if (protocol !== undefined && protocol !== "auto" && protocol !== STATELESS_PROTOCOL_VERSION) {
|
|
63
|
+
return `protocol must be "auto" or "${STATELESS_PROTOCOL_VERSION}"`;
|
|
64
|
+
}
|
|
65
|
+
if (description !== undefined && typeof description !== "string")
|
|
66
|
+
return "description must be a string";
|
|
67
|
+
if (timeout !== undefined && (typeof timeout !== "number" || !(timeout > 0))) {
|
|
68
|
+
return "timeout must be a positive number of seconds";
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
function validateHttpFields(entry, url, options) {
|
|
73
|
+
if (!URL.canParse(url) || !/^https?:$/.test(new URL(url).protocol))
|
|
74
|
+
return "url must be an http or https URL";
|
|
75
|
+
if (entry.headers !== undefined && !isStringRecord(entry.headers))
|
|
76
|
+
return "headers must map names to strings";
|
|
77
|
+
return validateOAuth(entry.oauth, options);
|
|
78
|
+
}
|
|
79
|
+
function validateStdioFields(entry) {
|
|
80
|
+
const { args, env, cwd } = entry;
|
|
81
|
+
if (args !== undefined && !(Array.isArray(args) && args.every((arg) => typeof arg === "string"))) {
|
|
82
|
+
return "args must be an array of strings";
|
|
83
|
+
}
|
|
84
|
+
if (env !== undefined && !isStringRecord(env))
|
|
85
|
+
return "env must map names to strings";
|
|
86
|
+
if (cwd !== undefined && typeof cwd !== "string")
|
|
87
|
+
return "cwd must be a string";
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
function isStringRecord(value) {
|
|
91
|
+
return isRecord(value) && Object.values(value).every((entry) => typeof entry === "string");
|
|
92
|
+
}
|
|
93
|
+
const LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "[::1]"];
|
|
94
|
+
function validateOAuth(value, options) {
|
|
95
|
+
if (value === undefined)
|
|
96
|
+
return undefined;
|
|
97
|
+
if (!isRecord(value))
|
|
98
|
+
return "oauth must be an object";
|
|
99
|
+
if (value.clientId !== undefined && typeof value.clientId !== "string")
|
|
100
|
+
return "oauth.clientId must be a string";
|
|
101
|
+
if (value.clientSecret !== undefined && typeof value.clientSecret !== "string") {
|
|
102
|
+
return "oauth.clientSecret must be a string";
|
|
103
|
+
}
|
|
104
|
+
const port = value.callbackPort;
|
|
105
|
+
if (port !== undefined && (typeof port !== "number" || !Number.isInteger(port) || port < 1 || port > 65535)) {
|
|
106
|
+
return "oauth.callbackPort must be a port number";
|
|
107
|
+
}
|
|
108
|
+
if (value.callbackUrl !== undefined) {
|
|
109
|
+
if (typeof value.callbackUrl !== "string" || !isLoopbackRedirectUri(value.callbackUrl)) {
|
|
110
|
+
return "oauth.callbackUrl must be an http URI on localhost, 127.0.0.1, or [::1] without query or fragment";
|
|
111
|
+
}
|
|
112
|
+
const urlPort = new URL(value.callbackUrl).port;
|
|
113
|
+
if (urlPort && port !== undefined && Number(urlPort) !== port) {
|
|
114
|
+
return "oauth.callbackUrl and oauth.callbackPort name different ports";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (value.scope !== undefined && typeof value.scope !== "string")
|
|
118
|
+
return "oauth.scope must be a string";
|
|
119
|
+
if (value.clientName !== undefined && (typeof value.clientName !== "string" || !value.clientName.trim())) {
|
|
120
|
+
return "oauth.clientName must be a non-empty string";
|
|
121
|
+
}
|
|
122
|
+
const registration = value.clientRegistration;
|
|
123
|
+
if (registration !== undefined && registration !== "auto" && registration !== "dcr") {
|
|
124
|
+
if (registration !== "cimd")
|
|
125
|
+
return 'oauth.clientRegistration must be "auto", "dcr", or "cimd"';
|
|
126
|
+
if (value.clientId !== undefined || value.clientName !== undefined) {
|
|
127
|
+
return 'oauth.clientRegistration "cimd" cannot be combined with oauth.clientId or oauth.clientName';
|
|
128
|
+
}
|
|
129
|
+
if (!options.checkMetadataDocumentCallback) {
|
|
130
|
+
return 'oauth.clientRegistration "cimd" is not supported: there are no Client ID Metadata Documents';
|
|
131
|
+
}
|
|
132
|
+
const callbackError = options.checkMetadataDocumentCallback(typeof value.callbackUrl === "string" ? value.callbackUrl : undefined);
|
|
133
|
+
if (callbackError)
|
|
134
|
+
return callbackError;
|
|
135
|
+
}
|
|
136
|
+
const metadataUrl = value.authServerMetadataUrl;
|
|
137
|
+
if (metadataUrl !== undefined) {
|
|
138
|
+
const url = typeof metadataUrl === "string" && URL.canParse(metadataUrl) ? new URL(metadataUrl) : undefined;
|
|
139
|
+
if (!url || !(url.protocol === "https:" || (url.protocol === "http:" && LOOPBACK_HOSTS.includes(url.hostname)))) {
|
|
140
|
+
return "oauth.authServerMetadataUrl must be an https URL, or http on localhost, 127.0.0.1, or [::1]";
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
/** Whether a redirect URI can be served by a loopback callback server. */
|
|
146
|
+
function isLoopbackRedirectUri(value) {
|
|
147
|
+
if (!URL.canParse(value))
|
|
148
|
+
return false;
|
|
149
|
+
const url = new URL(value);
|
|
150
|
+
return url.protocol === "http:" && LOOPBACK_HOSTS.includes(url.hostname) && url.search === "" && url.hash === "";
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Whether an entry overrides a server defined elsewhere instead of defining one: it has no `command`,
|
|
154
|
+
* `url` or `type`. Applications let a less trusted file (a project's) override a few fields, such as
|
|
155
|
+
* `enabled`, of a server a trusted file defines; which fields is theirs to decide.
|
|
156
|
+
*/
|
|
157
|
+
export function isMcpServerOverride(entry) {
|
|
158
|
+
return entry.command === undefined && entry.url === undefined && entry.type === undefined;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=config.js.map
|