@noodleseed/one 0.95.1 → 0.96.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/dist/commands/auth-live-doctor.d.ts +1 -0
- package/dist/commands/auth-live-doctor.d.ts.map +1 -1
- package/dist/commands/auth-live-doctor.js +7 -6
- package/dist/commands/auth-live-doctor.js.map +1 -1
- package/dist/commands/auth-metadata-readiness.d.ts +2 -0
- package/dist/commands/auth-metadata-readiness.d.ts.map +1 -1
- package/dist/commands/auth-metadata-readiness.js +7 -0
- package/dist/commands/auth-metadata-readiness.js.map +1 -1
- package/dist/commands/auth-ops.d.ts +1 -0
- package/dist/commands/auth-ops.d.ts.map +1 -1
- package/dist/commands/auth-ops.js +26 -7
- package/dist/commands/auth-ops.js.map +1 -1
- package/dist/commands/author-loop.d.ts.map +1 -1
- package/dist/commands/author-loop.js +3 -2
- package/dist/commands/author-loop.js.map +1 -1
- package/dist/commands/catalog-data-auth-discovery.d.ts.map +1 -1
- package/dist/commands/catalog-data-auth-discovery.js +7 -0
- package/dist/commands/catalog-data-auth-discovery.js.map +1 -1
- package/dist/commands/connect-oauth.d.ts.map +1 -1
- package/dist/commands/connect-oauth.js +1 -0
- package/dist/commands/connect-oauth.js.map +1 -1
- package/dist/dev.d.ts +6 -1
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +120 -34
- package/dist/dev.js.map +1 -1
- package/dist/device-login.js +1 -0
- package/dist/device-login.js.map +1 -1
- package/dist/devtools-preview.d.ts.map +1 -1
- package/dist/devtools-preview.js +82 -8
- package/dist/devtools-preview.js.map +1 -1
- package/dist/plugin-mode/build-readiness-server.d.ts +1 -1
- package/dist/plugin-mode/build-readiness-server.d.ts.map +1 -1
- package/dist/plugin-mode/build-readiness-server.js +3 -4
- package/dist/plugin-mode/build-readiness-server.js.map +1 -1
- package/dist/plugin-mode/plugin-operation-contract.d.ts +1 -1
- package/dist/plugin-mode/plugin-operation-contract.d.ts.map +1 -1
- package/dist/plugin-mode/plugin-operation-tools.d.ts +1 -2
- package/dist/plugin-mode/plugin-operation-tools.d.ts.map +1 -1
- package/dist/plugin-mode/plugin-operation-tools.js.map +1 -1
- package/dist/saas-scaffold-template.d.ts.map +1 -1
- package/dist/saas-scaffold-template.js +2 -1
- package/dist/saas-scaffold-template.js.map +1 -1
- package/node_modules/@modelcontextprotocol/client/LICENSE +216 -0
- package/node_modules/@modelcontextprotocol/client/README.md +26 -0
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-1b6pVpkg.cjs +7531 -0
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-1b6pVpkg.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-97rDpkRx.mjs +7514 -0
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-97rDpkRx.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-FOQRM7up.d.cts +1071 -0
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-FOQRM7up.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-INpkxUi1.d.mts +1071 -0
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-INpkxUi1.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-B3ZJEoRM.d.mts +74 -0
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-B3ZJEoRM.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-B3dvjU3F.cjs +986 -0
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-B3dvjU3F.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-BylNJ1R5.mjs +981 -0
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-BylNJ1R5.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-doTkZbTr.d.cts +74 -0
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-doTkZbTr.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/chunk-Bnu9O96Y.cjs +60 -0
- package/node_modules/@modelcontextprotocol/client/dist/chunk-Br0eD_fh.mjs +42 -0
- package/node_modules/@modelcontextprotocol/client/dist/dialects-BGO_ZrYF.cjs +46 -0
- package/node_modules/@modelcontextprotocol/client/dist/dialects-BGO_ZrYF.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/dialects-BOhdv1Fc.mjs +34 -0
- package/node_modules/@modelcontextprotocol/client/dist/dialects-BOhdv1Fc.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-CHhhk6PQ.d.cts +2526 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-CHhhk6PQ.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-D4xIIEF6.d.mts +2523 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-D4xIIEF6.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs +5690 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts +3252 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts +3252 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs +5481 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.cjs +14 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.cts +13 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.mts +13 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.mjs +13 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.cjs +14 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.cts +13 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.mts +13 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.mjs +13 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +21 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.cts +13 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.mts +13 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +20 -0
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/src-D_zzAWoS.mjs +7063 -0
- package/node_modules/@modelcontextprotocol/client/dist/src-D_zzAWoS.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/src-NAgB4Mp8.cjs +7431 -0
- package/node_modules/@modelcontextprotocol/client/dist/src-NAgB4Mp8.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +217 -0
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.cts +96 -0
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.mts +96 -0
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +212 -0
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/types-DsbMXNFL.d.cts +1099 -0
- package/node_modules/@modelcontextprotocol/client/dist/types-DsbMXNFL.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/types-mS0yxCL0.d.mts +1099 -0
- package/node_modules/@modelcontextprotocol/client/dist/types-mS0yxCL0.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.cjs +5 -0
- package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.d.cts +2 -0
- package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.d.mts +2 -0
- package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.mjs +3 -0
- package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.cjs +3 -0
- package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.d.cts +2 -0
- package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.d.mts +2 -0
- package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.mjs +3 -0
- package/node_modules/@modelcontextprotocol/client/package.json +166 -0
- package/node_modules/@modelcontextprotocol/core/LICENSE +216 -0
- package/node_modules/@modelcontextprotocol/core/README.md +40 -0
- package/node_modules/@modelcontextprotocol/core/dist/auth-BWdKR39I.d.mts +8501 -0
- package/node_modules/@modelcontextprotocol/core/dist/auth-BWdKR39I.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/core/dist/auth-CUe6YdwF.mjs +1678 -0
- package/node_modules/@modelcontextprotocol/core/dist/auth-CUe6YdwF.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/core/dist/auth-CfDMXiII.cjs +2899 -0
- package/node_modules/@modelcontextprotocol/core/dist/auth-CfDMXiII.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/core/dist/auth-hYtaIUZm.d.cts +8501 -0
- package/node_modules/@modelcontextprotocol/core/dist/auth-hYtaIUZm.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/core/dist/index.cjs +175 -0
- package/node_modules/@modelcontextprotocol/core/dist/index.d.cts +2 -0
- package/node_modules/@modelcontextprotocol/core/dist/index.d.mts +2 -0
- package/node_modules/@modelcontextprotocol/core/dist/index.mjs +3 -0
- package/node_modules/@modelcontextprotocol/core/dist/internal.cjs +201 -0
- package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts +99 -0
- package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts +99 -0
- package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/core/dist/internal.mjs +3 -0
- package/node_modules/@modelcontextprotocol/core/package.json +85 -0
- package/node_modules/@modelcontextprotocol/server/LICENSE +216 -0
- package/node_modules/@modelcontextprotocol/server/README.md +30 -0
- package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CEoC__sr.mjs +7514 -0
- package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CEoC__sr.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CgI-5L6O.d.mts +1071 -0
- package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CgI-5L6O.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-FOQRM7up.d.cts +1071 -0
- package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-FOQRM7up.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-ZaoO9afR.cjs +7531 -0
- package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-ZaoO9afR.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-BwbPzsdI.cjs +986 -0
- package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-BwbPzsdI.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-C03CSigr.d.mts +74 -0
- package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-C03CSigr.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-doTkZbTr.d.cts +74 -0
- package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-doTkZbTr.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-p3WaZPqB.mjs +981 -0
- package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-p3WaZPqB.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/chunk-Bnu9O96Y.cjs +60 -0
- package/node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs +42 -0
- package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-CLhGwQTn.d.mts +4043 -0
- package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-CLhGwQTn.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-dBHMsxwf.d.cts +4045 -0
- package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-dBHMsxwf.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/dialects-D8eXzoGv.cjs +46 -0
- package/node_modules/@modelcontextprotocol/server/dist/dialects-D8eXzoGv.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/dialects-DoSzNhcb.mjs +34 -0
- package/node_modules/@modelcontextprotocol/server/dist/dialects-DoSzNhcb.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/index.cjs +2055 -0
- package/node_modules/@modelcontextprotocol/server/dist/index.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/index.d.cts +739 -0
- package/node_modules/@modelcontextprotocol/server/dist/index.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/index.d.mts +739 -0
- package/node_modules/@modelcontextprotocol/server/dist/index.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/index.mjs +1870 -0
- package/node_modules/@modelcontextprotocol/server/dist/index.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/mcp-D7GmuPnv.cjs +2022 -0
- package/node_modules/@modelcontextprotocol/server/dist/mcp-D7GmuPnv.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/mcp-DXXb3Vv3.mjs +1931 -0
- package/node_modules/@modelcontextprotocol/server/dist/mcp-DXXb3Vv3.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.cjs +23 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.cts +11 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.mts +11 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.mjs +22 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsNode.cjs +12 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsNode.d.cts +3 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsNode.d.mts +3 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsNode.mjs +4 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.cjs +30 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.cts +10 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.mts +10 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.mjs +29 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/src-CX2iR2pK.mjs +7606 -0
- package/node_modules/@modelcontextprotocol/server/dist/src-CX2iR2pK.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/src-STyD_Vvf.cjs +8104 -0
- package/node_modules/@modelcontextprotocol/server/dist/src-STyD_Vvf.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/stdio.cjs +564 -0
- package/node_modules/@modelcontextprotocol/server/dist/stdio.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/stdio.d.cts +107 -0
- package/node_modules/@modelcontextprotocol/server/dist/stdio.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/stdio.d.mts +107 -0
- package/node_modules/@modelcontextprotocol/server/dist/stdio.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/stdio.mjs +562 -0
- package/node_modules/@modelcontextprotocol/server/dist/stdio.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/types-DUs7mGBv.d.mts +1099 -0
- package/node_modules/@modelcontextprotocol/server/dist/types-DUs7mGBv.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/types-DsbMXNFL.d.cts +1099 -0
- package/node_modules/@modelcontextprotocol/server/dist/types-DsbMXNFL.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.cjs +5 -0
- package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.d.cts +2 -0
- package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.d.mts +2 -0
- package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.mjs +3 -0
- package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.cjs +3 -0
- package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.d.cts +2 -0
- package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.d.mts +2 -0
- package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.mjs +3 -0
- package/node_modules/@modelcontextprotocol/server/package.json +160 -0
- package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js +4 -4
- package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-authoring-auth-ref.js +3 -3
- package/node_modules/@noodle-borg/agent-kit/dist/skill-authoring-auth-ref.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-server-playbook-ref.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-server-playbook-ref.js +1 -0
- package/node_modules/@noodle-borg/agent-kit/dist/skill-server-playbook-ref.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
- package/node_modules/@noodle-borg/capabilities/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/capabilities/dist/index.js +11 -4
- package/node_modules/@noodle-borg/capabilities/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/developer-mcp/dist/prompts.d.ts +1 -1
- package/node_modules/@noodle-borg/developer-mcp/dist/prompts.d.ts.map +1 -1
- package/node_modules/@noodle-borg/developer-mcp/dist/resources.d.ts +1 -1
- package/node_modules/@noodle-borg/developer-mcp/dist/resources.d.ts.map +1 -1
- package/node_modules/@noodle-borg/developer-mcp/dist/server.d.ts +1 -1
- package/node_modules/@noodle-borg/developer-mcp/dist/server.d.ts.map +1 -1
- package/node_modules/@noodle-borg/developer-mcp/dist/server.js +3 -1
- package/node_modules/@noodle-borg/developer-mcp/dist/server.js.map +1 -1
- package/node_modules/@noodle-borg/developer-mcp/package.json +2 -1
- package/node_modules/@noodle-borg/module/dist/contract.d.ts +3 -1
- package/node_modules/@noodle-borg/module/dist/contract.d.ts.map +1 -1
- package/node_modules/@noodle-borg/module/dist/contract.js.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/error-codes.d.ts +11 -0
- package/node_modules/@noodle-borg/protocol/dist/error-codes.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/error-codes.js +11 -0
- package/node_modules/@noodle-borg/protocol/dist/error-codes.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/prompts.d.ts +6 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/prompts.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/prompts.js +31 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/prompts.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/resources.d.ts +6 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/resources.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/resources.js +50 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/resources.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/tools.d.ts +6 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/tools.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/tools.js +126 -0
- package/node_modules/@noodle-borg/protocol/dist/handlers/tools.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/index.d.ts +6 -2
- package/node_modules/@noodle-borg/protocol/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/index.js +4 -1
- package/node_modules/@noodle-borg/protocol/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/interaction-envelope.d.ts +10 -0
- package/node_modules/@noodle-borg/protocol/dist/interaction-envelope.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/interaction-envelope.js +66 -0
- package/node_modules/@noodle-borg/protocol/dist/interaction-envelope.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/jsonrpc.d.ts +1 -0
- package/node_modules/@noodle-borg/protocol/dist/jsonrpc.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/jsonrpc.js +1 -0
- package/node_modules/@noodle-borg/protocol/dist/jsonrpc.js.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/observation.d.ts +27 -0
- package/node_modules/@noodle-borg/protocol/dist/observation.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/observation.js +20 -0
- package/node_modules/@noodle-borg/protocol/dist/observation.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/request-deps.d.ts +6 -0
- package/node_modules/@noodle-borg/protocol/dist/request-deps.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/request-deps.js +16 -0
- package/node_modules/@noodle-borg/protocol/dist/request-deps.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/request-state.d.ts +50 -0
- package/node_modules/@noodle-borg/protocol/dist/request-state.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/request-state.js +195 -0
- package/node_modules/@noodle-borg/protocol/dist/request-state.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/sdk-server.d.ts +16 -23
- package/node_modules/@noodle-borg/protocol/dist/sdk-server.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/sdk-server.js +7 -341
- package/node_modules/@noodle-borg/protocol/dist/sdk-server.js.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/tool-authorization.d.ts +1 -1
- package/node_modules/@noodle-borg/protocol/dist/tool-authorization.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/tool-authorization.js +1 -1
- package/node_modules/@noodle-borg/protocol/dist/tool-authorization.js.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/tool-interaction.d.ts +7 -2
- package/node_modules/@noodle-borg/protocol/dist/tool-interaction.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/tool-interaction.js +8 -1
- package/node_modules/@noodle-borg/protocol/dist/tool-interaction.js.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/tool-results.d.ts +7 -0
- package/node_modules/@noodle-borg/protocol/dist/tool-results.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/tool-results.js +49 -0
- package/node_modules/@noodle-borg/protocol/dist/tool-results.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/cache-hints.d.ts +11 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/cache-hints.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/cache-hints.js +14 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/cache-hints.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/confirmation.d.ts +16 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/confirmation.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/confirmation.js +57 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/confirmation.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/handler.d.ts +11 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/handler.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/handler.js +154 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/handler.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/input-required.d.ts +12 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/input-required.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/input-required.js +78 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/input-required.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/server.d.ts +5 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/server.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/server.js +314 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/server.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/tool-list.d.ts +4 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/tool-list.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/tool-list.js +25 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/tool-list.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/versions.d.ts +6 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/versions.d.ts.map +1 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/versions.js +11 -0
- package/node_modules/@noodle-borg/protocol/dist/v2/versions.js.map +1 -0
- package/node_modules/@noodle-borg/protocol/package.json +3 -0
- package/node_modules/@noodle-borg/service/dist/billing/usage-identity.d.ts +2 -0
- package/node_modules/@noodle-borg/service/dist/billing/usage-identity.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/billing/usage-identity.js +15 -7
- package/node_modules/@noodle-borg/service/dist/billing/usage-identity.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/customer-auth-audience-binding.d.ts +37 -0
- package/node_modules/@noodle-borg/service/dist/customer-auth-audience-binding.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/customer-auth-audience-binding.js +182 -0
- package/node_modules/@noodle-borg/service/dist/customer-auth-audience-binding.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/customer-auth-audience-quarantine.d.ts +5 -0
- package/node_modules/@noodle-borg/service/dist/customer-auth-audience-quarantine.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/customer-auth-audience-quarantine.js +14 -0
- package/node_modules/@noodle-borg/service/dist/customer-auth-audience-quarantine.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/customer-verifier.js +5 -4
- package/node_modules/@noodle-borg/service/dist/customer-verifier.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/developer-mcp/mount.d.ts +2 -1
- package/node_modules/@noodle-borg/service/dist/developer-mcp/mount.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/developer-mcp/mount.js +16 -14
- package/node_modules/@noodle-borg/service/dist/developer-mcp/mount.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/developer-mcp/service-options.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/developer-mcp/service-options.js +1 -0
- package/node_modules/@noodle-borg/service/dist/developer-mcp/service-options.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/index.d.ts +2 -0
- package/node_modules/@noodle-borg/service/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/index.js +2 -0
- package/node_modules/@noodle-borg/service/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/main.js +3 -0
- package/node_modules/@noodle-borg/service/dist/main.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/mcp-confirmation-nonce-postgres.d.ts +14 -0
- package/node_modules/@noodle-borg/service/dist/mcp-confirmation-nonce-postgres.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/mcp-confirmation-nonce-postgres.js +35 -0
- package/node_modules/@noodle-borg/service/dist/mcp-confirmation-nonce-postgres.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/mcp-protocol-runtime.d.ts +16 -0
- package/node_modules/@noodle-borg/service/dist/mcp-protocol-runtime.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/mcp-protocol-runtime.js +21 -0
- package/node_modules/@noodle-borg/service/dist/mcp-protocol-runtime.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/oauth/app.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/app.js +47 -0
- package/node_modules/@noodle-borg/service/dist/oauth/app.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/authorization-response.d.ts +4 -0
- package/node_modules/@noodle-borg/service/dist/oauth/authorization-response.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/oauth/authorization-response.js +6 -0
- package/node_modules/@noodle-borg/service/dist/oauth/authorization-response.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/oauth/consent-decision.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/consent-decision.js +2 -1
- package/node_modules/@noodle-borg/service/dist/oauth/consent-decision.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/developer-grant-flow.js +2 -1
- package/node_modules/@noodle-borg/service/dist/oauth/developer-grant-flow.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/first-party-client.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/first-party-client.js +1 -0
- package/node_modules/@noodle-borg/service/dist/oauth/first-party-client.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/metadata.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/metadata.js +1 -0
- package/node_modules/@noodle-borg/service/dist/oauth/metadata.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/provider.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/provider.js +1 -0
- package/node_modules/@noodle-borg/service/dist/oauth/provider.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/token-issuer.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/token-issuer.js +2 -1
- package/node_modules/@noodle-borg/service/dist/oauth/token-issuer.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-handler.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-handler.js +1 -0
- package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-handler.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-support.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-support.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-support.js +2 -1
- package/node_modules/@noodle-borg/service/dist/oauth/upstream-callback-support.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/options.d.ts +10 -3
- package/node_modules/@noodle-borg/service/dist/options.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/platform-account-reset-quarantine-postgres.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/platform-account-reset-quarantine-postgres.js +20 -8
- package/node_modules/@noodle-borg/service/dist/platform-account-reset-quarantine-postgres.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.d.ts +2 -0
- package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.js +58 -13
- package/node_modules/@noodle-borg/service/dist/platform-account-reset-rollback-postgres.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.js +3 -0
- package/node_modules/@noodle-borg/service/dist/platform-auth-inventory-source-fence-transaction-postgres.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/platform-auth-operator.d.ts +24 -24
- package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.d.ts +2 -1
- package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.js +4 -1
- package/node_modules/@noodle-borg/service/dist/platform-auth-runtime.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-access.d.ts +5 -1
- package/node_modules/@noodle-borg/service/dist/registry-access.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-access.js +64 -15
- package/node_modules/@noodle-borg/service/dist/registry-access.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-rollback.d.ts +19 -0
- package/node_modules/@noodle-borg/service/dist/registry-rollback.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/registry-rollback.js +91 -0
- package/node_modules/@noodle-borg/service/dist/registry-rollback.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/registry-state.d.ts +18 -2
- package/node_modules/@noodle-borg/service/dist/registry-state.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-state.js +83 -7
- package/node_modules/@noodle-borg/service/dist/registry-state.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-targets.d.ts +8 -0
- package/node_modules/@noodle-borg/service/dist/registry-targets.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-targets.js +24 -0
- package/node_modules/@noodle-borg/service/dist/registry-targets.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-types.d.ts +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-types.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry.d.ts +2 -1
- package/node_modules/@noodle-borg/service/dist/registry.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry.js +72 -83
- package/node_modules/@noodle-borg/service/dist/registry.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/archive.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/archive.js +14 -0
- package/node_modules/@noodle-borg/service/dist/routes/archive.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/auth-doctor-dispatch.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/auth-doctor-dispatch.js +4 -0
- package/node_modules/@noodle-borg/service/dist/routes/auth-doctor-dispatch.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/auth-doctor-live.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/auth-doctor-live.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/auth-doctor-live.js +17 -4
- package/node_modules/@noodle-borg/service/dist/routes/auth-doctor-live.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/contracts.d.ts +9 -9
- package/node_modules/@noodle-borg/service/dist/routes/private-platform-auth-dispatch.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/private-platform-auth-dispatch.js +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/private-platform-auth-dispatch.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/serve.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/serve.js +19 -2
- package/node_modules/@noodle-borg/service/dist/serve.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/service.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/service.js +5 -0
- package/node_modules/@noodle-borg/service/dist/service.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/in-memory.d.ts +5 -2
- package/node_modules/@noodle-borg/service/dist/store/in-memory.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/in-memory.js +51 -8
- package/node_modules/@noodle-borg/service/dist/store/in-memory.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/json-file.d.ts +5 -2
- package/node_modules/@noodle-borg/service/dist/store/json-file.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/json-file.js +55 -6
- package/node_modules/@noodle-borg/service/dist/store/json-file.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-apps.d.ts +2 -2
- package/node_modules/@noodle-borg/service/dist/store/postgres-apps.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-apps.js +30 -15
- package/node_modules/@noodle-borg/service/dist/store/postgres-apps.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-customer-auth-audience-schema.d.ts +16 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-customer-auth-audience-schema.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-customer-auth-audience-schema.js +329 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-customer-auth-audience-schema.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-customer-auth-audience.d.ts +5 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-customer-auth-audience.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-customer-auth-audience.js +24 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-customer-auth-audience.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-deploy-records.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-deploy-records.js +2 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-deploy-records.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-deployment-access.d.ts +9 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-deployment-access.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-deployment-access.js +53 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-deployment-access.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.js +2 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-github-runs.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-rows.d.ts +2 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-rows.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-rows.js +2 -24
- package/node_modules/@noodle-borg/service/dist/store/postgres-rows.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-schema.d.ts +2 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js +3 -0
- package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres.d.ts +7 -2
- package/node_modules/@noodle-borg/service/dist/store/postgres.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres.js +27 -31
- package/node_modules/@noodle-borg/service/dist/store/postgres.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/request-events-postgres.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/request-events-postgres.js +9 -2
- package/node_modules/@noodle-borg/service/dist/store/request-events-postgres.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/request-events.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/request-events.js +1 -0
- package/node_modules/@noodle-borg/service/dist/store/request-events.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store.d.ts +20 -1
- package/node_modules/@noodle-borg/service/dist/store.d.ts.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/handler.d.ts +19 -67
- package/node_modules/@noodle-borg/transport-http/dist/handler.d.ts.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/handler.js +12 -281
- package/node_modules/@noodle-borg/transport-http/dist/handler.js.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/index.d.ts +2 -1
- package/node_modules/@noodle-borg/transport-http/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/index.js +1 -0
- package/node_modules/@noodle-borg/transport-http/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/request-capture.d.ts.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/request-capture.js +38 -4
- package/node_modules/@noodle-borg/transport-http/dist/request-capture.js.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/responses.d.ts +28 -0
- package/node_modules/@noodle-borg/transport-http/dist/responses.d.ts.map +1 -0
- package/node_modules/@noodle-borg/transport-http/dist/responses.js +50 -0
- package/node_modules/@noodle-borg/transport-http/dist/responses.js.map +1 -0
- package/node_modules/@noodle-borg/transport-http/dist/routing.d.ts +28 -0
- package/node_modules/@noodle-borg/transport-http/dist/routing.d.ts.map +1 -0
- package/node_modules/@noodle-borg/transport-http/dist/routing.js +52 -0
- package/node_modules/@noodle-borg/transport-http/dist/routing.js.map +1 -0
- package/node_modules/@noodle-borg/transport-http/dist/serve-request.d.ts +35 -0
- package/node_modules/@noodle-borg/transport-http/dist/serve-request.d.ts.map +1 -0
- package/node_modules/@noodle-borg/transport-http/dist/serve-request.js +190 -0
- package/node_modules/@noodle-borg/transport-http/dist/serve-request.js.map +1 -0
- package/node_modules/@noodle-borg/transport-http/dist/tool-dispatch.d.ts +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/tool-dispatch.d.ts.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/tool-dispatch.js +17 -5
- package/node_modules/@noodle-borg/transport-http/dist/tool-dispatch.js.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/web-bridge.d.ts +9 -0
- package/node_modules/@noodle-borg/transport-http/dist/web-bridge.d.ts.map +1 -0
- package/node_modules/@noodle-borg/transport-http/dist/web-bridge.js +61 -0
- package/node_modules/@noodle-borg/transport-http/dist/web-bridge.js.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,3252 @@
|
|
|
1
|
+
import { $ as withInputRequired, $i as TRACESTATE_META_KEY, $n as Notification, $r as SetLevelRequest, $t as GetTaskResult, A as SpecTypes, Ai as UnsubscribeRequest, An as ListPromptsRequest, Ar as RequestTypeMap, At as CreateMessageRequestParamsWithTools, B as isJSONRPCNotification, Bi as INVALID_PARAMS, Bn as ListToolsRequest, Br as Result, Bt as ElicitRequestURLParams, C as ServerContext, Ca as StoredOAuthTokens, Ci as Tool, Cn as JSONRPCResponse, Cr as Request, Ct as CompleteRequestPrompt, D as TransportSendOptions, Di as ToolListChangedNotification, Dn as ListChangedCallback, Dr as RequestMetaObject, Dt as CreateMessageRequest, E as Transport, Ei as ToolExecution, En as LegacyTitledEnumSchema, Er as RequestMetaEnvelope, Et as ContentBlock, F as isCallToolResult, Fi as BAGGAGE_META_KEY, Fn as ListResourcesResult, Fr as ResourceRequestParams, Ft as DiscoverRequest, G as parseJSONRPCMessage, Gi as METHOD_NOT_FOUND, Gn as MessageClassification, Gr as RootsListChangedNotification, Gt as EmptyResult, H as isJSONRPCResponse, Hi as JSONRPC_VERSION, Hn as LoggingLevel, Hr as ResultTypeMap, Ht as ElicitationCompleteNotification, I as isInitializeRequest, Ii as CLIENT_CAPABILITIES_META_KEY, In as ListRootsRequest, Ir as ResourceTemplateReference, It as DiscoverResult, J as ResourceNotFoundError, Ji as RELATED_TASK_META_KEY, Jn as MethodNotFoundError, Jr as SamplingMessageContentBlock, Jt as GetPromptRequestParams, K as MissingRequiredClientCapabilityError, Ki as PARSE_ERROR, Kn as MessageExtraInfo, Kr as SamplingContent, Kt as EnumSchema, L as isInitializedNotification, Li as CLIENT_INFO_META_KEY, Ln as ListRootsResult, Lr as ResourceTemplateType, Lt as ElicitRequest, M as specTypeSchemas, Mi as UnsupportedProtocolVersionErrorData, Mn as ListResourceTemplatesRequest, Mr as ResourceContents, Mt as CreateMessageResultWithTools, N as assertCompleteRequestPrompt, Ni as UntitledMultiSelectEnumSchema, Nn as ListResourceTemplatesResult, Nr as ResourceLink, Nt as CreateTaskResult, O as createFetchWithInit, Oi as ToolResultContent, On as ListChangedHandlers, Or as RequestMethod, Ot as CreateMessageRequestParams, P as assertCompleteRequestResourceTemplate, Pi as UntitledSingleSelectEnumSchema, Pn as ListResourcesRequest, Pr as ResourceListChangedNotification, Pt as Cursor, Q as InputRequiredOptions, Qi as TRACEPARENT_META_KEY, Qn as MultiSelectEnumSchema, Qr as ServerResult, Qt as GetTaskRequest, R as isInputRequiredResult, Ri as DEFAULT_NEGOTIATED_PROTOCOL_VERSION, Rn as ListTasksRequest, Rr as ResourceUpdatedNotification, Rt as ElicitRequestFormParams, S as RequestStateAccessor, Sa as StoredOAuthClientInformation, Si as TitledSingleSelectEnumSchema, Sn as JSONRPCRequest, Sr as RelatedTaskMetadata, St as CompleteRequestParams, T as FetchLike, Ti as ToolChoice, Tn as JSONValue, Tr as RequestMeta, Tt as CompleteResult, U as isJSONRPCResultResponse, Ui as LATEST_PROTOCOL_VERSION, Un as LoggingMessageNotification, Ur as Role, Ut as ElicitationCompleteNotificationParams, V as isJSONRPCRequest, Vi as INVALID_REQUEST, Vn as ListToolsResult, Vr as ResultMetaObject, Vt as ElicitResult, W as isTaskAugmentedRequestParams, Wi as LOG_LEVEL_META_KEY, Wn as LoggingMessageNotificationParams, Wr as Root, Wt as EmbeddedResource, X as UrlElicitationRequiredError, Xi as SUBSCRIPTION_ID_META_KEY, Xn as ModelHint, Xr as ServerNotification, Xt as GetTaskPayloadRequest, Y as UnsupportedProtocolVersionError, Yi as SERVER_INFO_META_KEY, Yn as MissingRequiredClientCapabilityErrorData, Yr as ServerCapabilities, Yt as GetPromptResult, Z as ProtocolErrorCode, Zi as SUPPORTED_PROTOCOL_VERSIONS, Zn as ModelPreferences, Zr as ServerRequest, Zt as GetTaskPayloadResult, _ as ProgressCallback, _a as OAuthProtectedResourceMetadata, _i as TaskStatusNotification, _n as JSONArray, _r as PromptMessage, _t as ClientNotification, a as ReadBuffer, aa as SdkHttpErrorData, ai as SubscriptionFilter, an as InitializeRequest, ar as PaginatedRequestParams, at as AuthInfo, b as RequestHandlerSchemas, ba as OpenIdProviderDiscoveryMetadata, bi as TextResourceContents, bn as JSONRPCMessage, br as ReadResourceRequestParams, bt as CompatibilityCallToolResult, c as serializeMessage, ca as AuthorizationServerMetadata, ci as SubscriptionsListenRequest, cn as InitializedNotification, cr as PingRequest, ct as BooleanSchema, d as isJsonContentType, da as OAuthClientInformationFull, di as SubscriptionsListenResultMeta, dn as InputRequiredResult, dr as ProgressNotification, dt as CallToolResult, ea as checkResourceAllowed, ei as SetLevelRequestParams, en as HandlerResultTypeMap, er as NotificationMethod, et as StandardSchemaV1, f as BaseContext, fa as OAuthClientInformationMixed, fi as Task, fn as InputResponse, fr as ProgressNotificationParams, ft as CancelTaskRequest, g as NotificationOptions, ga as OAuthMetadata, gi as TaskStatus, gn as InvalidRequestError, gr as PromptListChangedNotification, gt as ClientCapabilities, h as NonCompleteResultFlow, ha as OAuthErrorResponse, hi as TaskMetadata, hn as InvalidParamsError, hr as PromptArgument, ht as CancelledNotificationParams, i as Variables, ia as SdkHttpError, ii as SubscribeRequestParams, in as Implementation, ir as PaginatedRequest, it as AudioContent, j as isSpecType, ji as UnsubscribeRequestParams, jn as ListPromptsResult, jr as Resource, jt as CreateMessageResult, k as SpecTypeName, ki as ToolUseContent, kn as ListChangedOptions, kr as RequestParams, kt as CreateMessageRequestParamsBase, l as ProtocolEra, la as IdJagTokenExchangeResponse, li as SubscriptionsListenRequestParams, ln as InputRequest, lr as PrimitiveSchemaDefinition, lt as CallToolRequest, m as DEFAULT_REQUEST_TIMEOUT_MSEC, ma as OAuthClientRegistrationError, mi as TaskCreationParams, mn as InternalError, mr as Prompt, mt as CancelledNotification, n as InMemoryTransport, na as SdkError, ni as StringSchema, nn as Icons, nr as NotificationTypeMap, nt as StandardSchemaWithJSON, o as STDIO_DEFAULT_MAX_BUFFER_SIZE, oa as OAuthError, oi as SubscriptionsAcknowledgedNotification, on as InitializeRequestParams, or as PaginatedResult, ot as BaseMetadata, p as ClientContext, pa as OAuthClientMetadata, pi as TaskAugmentedRequestParams, pn as InputResponses, pr as ProgressToken, pt as CancelTaskResult, q as ProtocolError, qi as PROTOCOL_VERSION_META_KEY, qn as MetaObject, qr as SamplingMessage, qt as GetPromptRequest, r as UriTemplate, ra as SdkErrorCode, ri as SubscribeRequest, rn as ImageContent, rr as NumberSchema, rt as Annotations, s as deserializeMessage, sa as OAuthErrorCode, si as SubscriptionsAcknowledgedNotificationParams, sn as InitializeResult, sr as ParseError, st as BlobResourceContents, t as preloadSchemas, ta as resourceUrlFromServerUrl, ti as SingleSelectEnumSchema, tn as Icon, tr as NotificationParams, tt as StandardSchemaV1Sync, u as getDisplayName, ua as OAuthClientInformation, ui as SubscriptionsListenResult, un as InputRequests, ur as Progress, ut as CallToolRequestParams, v as Protocol, va as OAuthTokenRevocationRequest, vi as TaskStatusNotificationParams, vn as JSONObject, vr as PromptReference, vt as ClientRequest, w as mergeCapabilities, wi as ToolAnnotations, wn as JSONRPCResultResponse, wr as RequestId, wt as CompleteRequestResourceTemplate, x as RequestOptions, xa as OpenIdProviderMetadata, xi as TitledMultiSelectEnumSchema, xn as JSONRPCNotification, xr as ReadResourceResult, xt as CompleteRequest, y as ProtocolOptions, ya as OAuthTokens, yi as TextContent, yn as JSONRPCErrorResponse, yr as ReadResourceRequest, yt as ClientResult, z as isJSONRPCErrorResponse, zi as INTERNAL_ERROR, zn as ListTasksResult, zr as ResourceUpdatedNotificationParams, zt as ElicitRequestParams } from "./index-D4xIIEF6.mjs";
|
|
2
|
+
import { i as jsonSchemaValidator, n as JsonSchemaValidator, r as JsonSchemaValidatorResult, t as JsonSchemaType } from "./types-mS0yxCL0.mjs";
|
|
3
|
+
import { ErrorEvent, EventSourceInit } from "eventsource";
|
|
4
|
+
|
|
5
|
+
//#region src/client/authErrors.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Base class for the OAuth-client-flow error family. Concrete subclasses are
|
|
9
|
+
* added to this module alongside the SEP-2468/837/2207/2350/2352 behavior
|
|
10
|
+
* changes that throw them, so callers can catch the whole family with a single
|
|
11
|
+
* `instanceof OAuthClientFlowError` guard once those land.
|
|
12
|
+
*
|
|
13
|
+
* @remarks Nothing in the SDK throws this base class directly. In the release
|
|
14
|
+
* that introduces it no subclass exists yet — the guard is a forward-compat
|
|
15
|
+
* hook and will not match anything until the first behavior change ships.
|
|
16
|
+
*/
|
|
17
|
+
declare class OAuthClientFlowError extends Error {
|
|
18
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Brand-based type guard: equivalent to `value instanceof this`, as an
|
|
21
|
+
* explicit static predicate (the axios/AWS-SDK `isInstance` style). Reads
|
|
22
|
+
* the caller's own brand via `this`, so every branded subclass gets a
|
|
23
|
+
* correctly-scoped guard by inheritance. Must be invoked on the class —
|
|
24
|
+
* in callback position write `v => SdkError.isInstance(v)`, not
|
|
25
|
+
* `.filter(SdkError.isInstance)` (detached calls throw rather than
|
|
26
|
+
* silently matching nothing).
|
|
27
|
+
*/
|
|
28
|
+
static isInstance<T extends abstract new (...args: never[]) => unknown>(this: T, value: unknown): value is InstanceType<T>;
|
|
29
|
+
constructor(message: string);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Thrown when an authorization-server issuer identifier fails validation.
|
|
33
|
+
*
|
|
34
|
+
* Two checks raise this error, distinguished by {@linkcode IssuerMismatchError.kind | kind}:
|
|
35
|
+
* - `'metadata'` — the `issuer` in fetched authorization-server metadata does
|
|
36
|
+
* not match the issuer identifier the well-known URL was constructed from
|
|
37
|
+
* (RFC 8414 §3.3 / OpenID Connect Discovery §4.3).
|
|
38
|
+
* - `'authorization_response'` — the `iss` parameter on the authorization
|
|
39
|
+
* callback failed RFC 9207 §2.4 validation against the recorded issuer.
|
|
40
|
+
*
|
|
41
|
+
* Intentionally does **not** extend `OAuthError`: the `auth()`
|
|
42
|
+
* orchestrator's `OAuthError` retry block must not swallow this — a mix-up
|
|
43
|
+
* indication is fatal for the flow, not a retryable credential problem.
|
|
44
|
+
*
|
|
45
|
+
* On the `'authorization_response'` path the {@linkcode IssuerMismatchError.received | received}
|
|
46
|
+
* value is attacker-controllable in a mix-up attack; callers **MUST NOT** display
|
|
47
|
+
* it (or any `error`/`error_description`/`error_uri` from the same callback) to
|
|
48
|
+
* end users. The values are JSON-encoded in the message to neutralize log-injection.
|
|
49
|
+
*/
|
|
50
|
+
declare class IssuerMismatchError extends OAuthClientFlowError {
|
|
51
|
+
/** Which check failed — metadata echo (RFC 8414 §3.3) or authorization-response `iss` (RFC 9207). */
|
|
52
|
+
readonly kind: 'metadata' | 'authorization_response';
|
|
53
|
+
/** The issuer the client expected (from validated metadata / discovery input). */
|
|
54
|
+
readonly expected: string | undefined;
|
|
55
|
+
/** The issuer value that was received. Attacker-controllable on the `'authorization_response'` path. */
|
|
56
|
+
readonly received: string | undefined;
|
|
57
|
+
constructor(kind: 'metadata' | 'authorization_response', expected: string | undefined, received: string | undefined);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Thrown by `registerClient()` when the authorization server rejects a
|
|
61
|
+
* Dynamic Client Registration request. Carries the HTTP status, the raw
|
|
62
|
+
* response body, and the metadata that was submitted, so callers can inspect
|
|
63
|
+
* the AS's `error` / `error_description` and retry with adjusted metadata
|
|
64
|
+
* (for example a different `application_type`) per SEP-837.
|
|
65
|
+
*
|
|
66
|
+
* The `body` is the raw RFC 7591 error JSON; compare `JSON.parse(body).error`
|
|
67
|
+
* against `OAuthErrorCode` (e.g. `OAuthErrorCode.InvalidRedirectUri`,
|
|
68
|
+
* `OAuthErrorCode.InvalidClientMetadata`).
|
|
69
|
+
*
|
|
70
|
+
* Intentionally does **not** extend `OAuthError`: registration rejection is
|
|
71
|
+
* not a recoverable-by-credential-invalidation condition, and staying outside
|
|
72
|
+
* that hierarchy keeps it from being caught by `auth()`'s `OAuthError` retry
|
|
73
|
+
* path.
|
|
74
|
+
*/
|
|
75
|
+
declare class RegistrationRejectedError extends OAuthClientFlowError {
|
|
76
|
+
/** HTTP status code returned by the registration endpoint. */
|
|
77
|
+
readonly status: number;
|
|
78
|
+
/** Raw response body text (typically an RFC 7591 error JSON document). */
|
|
79
|
+
readonly body: string;
|
|
80
|
+
/** The exact client metadata that was POSTed (after SDK defaults were applied). */
|
|
81
|
+
readonly submittedMetadata: OAuthClientMetadata;
|
|
82
|
+
constructor(args: {
|
|
83
|
+
status: number;
|
|
84
|
+
body: string;
|
|
85
|
+
submittedMetadata: OAuthClientMetadata;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Thrown by the token-exchange and refresh paths when the resolved token
|
|
90
|
+
* endpoint is not `https:` and is not a loopback host (SEP-2207). This is a
|
|
91
|
+
* configuration error — re-authorizing cannot fix it — so it intentionally does
|
|
92
|
+
* **not** extend `OAuthError` and `auth()`'s refresh branch rethrows it instead
|
|
93
|
+
* of falling through to a fresh `/authorize` redirect.
|
|
94
|
+
*/
|
|
95
|
+
declare class InsecureTokenEndpointError extends OAuthClientFlowError {
|
|
96
|
+
/** The token endpoint URL that was rejected. */
|
|
97
|
+
readonly tokenEndpoint: string;
|
|
98
|
+
constructor(tokenEndpoint: string);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Thrown by the HTTP client transport when the server responds with
|
|
102
|
+
* `403 Forbidden` and `WWW-Authenticate: Bearer error="insufficient_scope"`,
|
|
103
|
+
* and either (a) the transport's `onInsufficientScope` option is `'throw'`, or
|
|
104
|
+
* (b) `onInsufficientScope` is the default `'reauthorize'` but the transport
|
|
105
|
+
* has no {@linkcode index.OAuthClientProvider | OAuthClientProvider} to drive
|
|
106
|
+
* step-up (e.g. a minimal `AuthProvider`, `requestInit`-only headers, or no
|
|
107
|
+
* `authProvider`).
|
|
108
|
+
*
|
|
109
|
+
* Carries the challenge parameters so the host can decide whether to initiate
|
|
110
|
+
* step-up authorization itself (e.g., behind a UX gate) or surface the error.
|
|
111
|
+
*
|
|
112
|
+
* Does **not** extend `OAuthError`: that class represents OAuth protocol errors
|
|
113
|
+
* from the authorization server; this is a resource-server challenge surfaced
|
|
114
|
+
* at the transport layer.
|
|
115
|
+
*
|
|
116
|
+
* All fields originate from the resource server's `WWW-Authenticate` header;
|
|
117
|
+
* treat them as untrusted input when displaying or logging (this includes
|
|
118
|
+
* `requiredScope`, which appears in the error message).
|
|
119
|
+
*/
|
|
120
|
+
/**
|
|
121
|
+
* Thrown by `auth()` on the authorization-code callback leg when the
|
|
122
|
+
* authorization server resolved by discovery differs from the one recorded in
|
|
123
|
+
* `discoveryState()` at redirect time. The `authorization_code` and PKCE
|
|
124
|
+
* `code_verifier` are bound to the AS that minted the code (RFC 7636); sending
|
|
125
|
+
* them to a different AS's token endpoint is a credential-exfiltration vector.
|
|
126
|
+
*
|
|
127
|
+
* This is the only runtime check left in the SEP-2352 model — stored tokens and
|
|
128
|
+
* client credentials are protected structurally by the `issuer` stamp instead.
|
|
129
|
+
*/
|
|
130
|
+
declare class AuthorizationServerMismatchError extends OAuthClientFlowError {
|
|
131
|
+
/** The issuer recorded in `discoveryState()` when the authorization redirect was issued. */
|
|
132
|
+
readonly recordedIssuer: string;
|
|
133
|
+
/** The issuer resolved by discovery on this call. */
|
|
134
|
+
readonly currentIssuer: string;
|
|
135
|
+
constructor(/** The issuer recorded in `discoveryState()` when the authorization redirect was issued. */
|
|
136
|
+
recordedIssuer: string, /** The issuer resolved by discovery on this call. */
|
|
137
|
+
currentIssuer: string);
|
|
138
|
+
}
|
|
139
|
+
declare class InsufficientScopeError extends OAuthClientFlowError {
|
|
140
|
+
/** The `scope` value from the `WWW-Authenticate` challenge — the scopes the resource server says are required. */
|
|
141
|
+
readonly requiredScope?: string;
|
|
142
|
+
/** The `resource_metadata` URL from the `WWW-Authenticate` challenge, if present. */
|
|
143
|
+
readonly resourceMetadataUrl?: URL;
|
|
144
|
+
/** The `error_description` from the `WWW-Authenticate` challenge, if present. */
|
|
145
|
+
readonly errorDescription?: string;
|
|
146
|
+
constructor(init: {
|
|
147
|
+
requiredScope?: string;
|
|
148
|
+
resourceMetadataUrl?: URL;
|
|
149
|
+
errorDescription?: string;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/client/auth.d.ts
|
|
154
|
+
/**
|
|
155
|
+
* Function type for adding client authentication to token requests.
|
|
156
|
+
*/
|
|
157
|
+
type AddClientAuthentication = (headers: Headers, params: URLSearchParams, url: string | URL, metadata?: AuthorizationServerMetadata) => void | Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Context passed to {@linkcode AuthProvider.onUnauthorized} when the server
|
|
160
|
+
* responds with 401. Provides everything needed to refresh credentials.
|
|
161
|
+
*/
|
|
162
|
+
interface UnauthorizedContext {
|
|
163
|
+
/** The 401 response — inspect `WWW-Authenticate` for resource metadata, scope, etc. */
|
|
164
|
+
response: Response;
|
|
165
|
+
/** The MCP server URL, for passing to {@linkcode auth} or discovery helpers. */
|
|
166
|
+
serverUrl: URL;
|
|
167
|
+
/** Fetch function configured with the transport's `requestInit`, for making auth requests. */
|
|
168
|
+
fetchFn: FetchLike;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Minimal interface for authenticating MCP client transports with bearer tokens.
|
|
172
|
+
*
|
|
173
|
+
* Transports call {@linkcode AuthProvider.token | token()} before every request
|
|
174
|
+
* to obtain the current token, and {@linkcode AuthProvider.onUnauthorized | onUnauthorized()}
|
|
175
|
+
* (if provided) when the server responds with 401, giving the provider a chance
|
|
176
|
+
* to refresh credentials before the transport retries once.
|
|
177
|
+
*
|
|
178
|
+
* For simple cases (API keys, gateway-managed tokens), implement only `token()`:
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const authProvider: AuthProvider = { token: async () => process.env.API_KEY };
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* For OAuth flows, pass an {@linkcode OAuthClientProvider} directly — transports
|
|
184
|
+
* accept either shape and adapt OAuth providers automatically via {@linkcode adaptOAuthProvider}.
|
|
185
|
+
*/
|
|
186
|
+
interface AuthProvider {
|
|
187
|
+
/**
|
|
188
|
+
* Returns the current bearer token, or `undefined` if no token is available.
|
|
189
|
+
* Called before every request.
|
|
190
|
+
*/
|
|
191
|
+
token(): Promise<string | undefined>;
|
|
192
|
+
/**
|
|
193
|
+
* Called when the server responds with 401. If provided, the transport will
|
|
194
|
+
* await this, then retry the request once. If the retry also gets 401, or if
|
|
195
|
+
* this method is not provided, the transport throws {@linkcode UnauthorizedError}.
|
|
196
|
+
*
|
|
197
|
+
* Implementations should refresh tokens, re-authenticate, etc. — whatever is
|
|
198
|
+
* needed so the next `token()` call returns a valid token.
|
|
199
|
+
*/
|
|
200
|
+
onUnauthorized?(ctx: UnauthorizedContext): Promise<void>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Context passed to the credential-persistence methods on
|
|
204
|
+
* {@linkcode OAuthClientProvider} — `clientInformation` / `saveClientInformation`
|
|
205
|
+
* and `tokens` / `saveTokens`. Carries the resolved authorization-server `issuer`
|
|
206
|
+
* so provider implementations can key persisted credentials per authorization
|
|
207
|
+
* server (RFC 6749 §2.2 — client identifiers are unique to the AS that issued
|
|
208
|
+
* them). Providers that store a single credential set may ignore it.
|
|
209
|
+
*/
|
|
210
|
+
interface OAuthClientInformationContext {
|
|
211
|
+
/**
|
|
212
|
+
* The authorization server's `issuer` identifier from its validated metadata
|
|
213
|
+
* document, used as the binding key for persisted credentials.
|
|
214
|
+
*/
|
|
215
|
+
issuer: string;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Implements an end-to-end OAuth client to be used with one MCP server.
|
|
219
|
+
*
|
|
220
|
+
* This client relies upon a concept of an authorized "session," the exact
|
|
221
|
+
* meaning of which is application-defined. Tokens, authorization codes, and
|
|
222
|
+
* code verifiers should not cross different sessions.
|
|
223
|
+
*
|
|
224
|
+
* Transports accept `OAuthClientProvider` directly via the `authProvider` option —
|
|
225
|
+
* they adapt it to {@linkcode AuthProvider} internally via {@linkcode adaptOAuthProvider}.
|
|
226
|
+
* No changes are needed to existing implementations.
|
|
227
|
+
*/
|
|
228
|
+
interface OAuthClientProvider {
|
|
229
|
+
/**
|
|
230
|
+
* The URL to redirect the user agent to after authorization.
|
|
231
|
+
* Return `undefined` for non-interactive flows that don't require user interaction
|
|
232
|
+
* (e.g., `client_credentials`, `jwt-bearer`).
|
|
233
|
+
*/
|
|
234
|
+
get redirectUrl(): string | URL | undefined;
|
|
235
|
+
/**
|
|
236
|
+
* External URL the server should use to fetch client metadata document
|
|
237
|
+
*/
|
|
238
|
+
clientMetadataUrl?: string;
|
|
239
|
+
/**
|
|
240
|
+
* Metadata about this OAuth client.
|
|
241
|
+
*/
|
|
242
|
+
get clientMetadata(): OAuthClientMetadata;
|
|
243
|
+
/**
|
|
244
|
+
* Returns an OAuth2 state parameter.
|
|
245
|
+
*/
|
|
246
|
+
state?(): string | Promise<string>;
|
|
247
|
+
/**
|
|
248
|
+
* Loads information about this OAuth client, as registered already with the
|
|
249
|
+
* server, or returns `undefined` if the client is not registered with the
|
|
250
|
+
* server.
|
|
251
|
+
*
|
|
252
|
+
* @param ctx - Carries the resolved authorization-server `issuer`. Providers
|
|
253
|
+
* that persist credentials per authorization server should return the entry
|
|
254
|
+
* keyed by `ctx.issuer`. Providers with a single credential set may ignore it.
|
|
255
|
+
*/
|
|
256
|
+
clientInformation(ctx?: OAuthClientInformationContext): StoredOAuthClientInformation | undefined | Promise<StoredOAuthClientInformation | undefined>;
|
|
257
|
+
/**
|
|
258
|
+
* If implemented, this permits the OAuth client to dynamically register with
|
|
259
|
+
* the server. Client information saved this way should later be read via
|
|
260
|
+
* {@linkcode OAuthClientProvider.clientInformation | clientInformation()}.
|
|
261
|
+
*
|
|
262
|
+
* This method is not required to be implemented if client information is
|
|
263
|
+
* statically known (e.g., pre-registered).
|
|
264
|
+
*
|
|
265
|
+
* @param ctx - Carries the resolved authorization-server `issuer`. Providers
|
|
266
|
+
* that persist credentials per authorization server should store the entry
|
|
267
|
+
* keyed by `ctx.issuer`.
|
|
268
|
+
*/
|
|
269
|
+
saveClientInformation?(clientInformation: StoredOAuthClientInformation, ctx?: OAuthClientInformationContext): void | Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* Loads any existing OAuth tokens for the current session, or returns
|
|
272
|
+
* `undefined` if there are no saved tokens.
|
|
273
|
+
*
|
|
274
|
+
* @param ctx - Carries the resolved authorization-server `issuer`. Providers
|
|
275
|
+
* that persist tokens per authorization server should return the entry
|
|
276
|
+
* keyed by `ctx.issuer`. Providers with a single token set may ignore it.
|
|
277
|
+
* When called with no `ctx` — the transport's per-request bearer-token
|
|
278
|
+
* read — return the most-recently-saved token set; do not return
|
|
279
|
+
* `undefined` for `ctx === undefined`.
|
|
280
|
+
*/
|
|
281
|
+
tokens(ctx?: OAuthClientInformationContext): StoredOAuthTokens | undefined | Promise<StoredOAuthTokens | undefined>;
|
|
282
|
+
/**
|
|
283
|
+
* Stores new OAuth tokens for the current session, after a successful
|
|
284
|
+
* authorization.
|
|
285
|
+
*
|
|
286
|
+
* @param ctx - Carries the resolved authorization-server `issuer`. Providers
|
|
287
|
+
* that persist tokens per authorization server should store the entry
|
|
288
|
+
* keyed by `ctx.issuer`.
|
|
289
|
+
*/
|
|
290
|
+
saveTokens(tokens: StoredOAuthTokens, ctx?: OAuthClientInformationContext): void | Promise<void>;
|
|
291
|
+
/**
|
|
292
|
+
* Invoked to redirect the user agent to the given URL to begin the authorization flow.
|
|
293
|
+
*/
|
|
294
|
+
redirectToAuthorization(authorizationUrl: URL): void | Promise<void>;
|
|
295
|
+
/**
|
|
296
|
+
* Saves a PKCE code verifier for the current session, before redirecting to
|
|
297
|
+
* the authorization flow.
|
|
298
|
+
*/
|
|
299
|
+
saveCodeVerifier(codeVerifier: string): void | Promise<void>;
|
|
300
|
+
/**
|
|
301
|
+
* Loads the PKCE code verifier for the current session, necessary to validate
|
|
302
|
+
* the authorization result.
|
|
303
|
+
*/
|
|
304
|
+
codeVerifier(): string | Promise<string>;
|
|
305
|
+
/**
|
|
306
|
+
* Adds custom client authentication to OAuth token requests.
|
|
307
|
+
*
|
|
308
|
+
* This optional method allows implementations to customize how client credentials
|
|
309
|
+
* are included in token exchange and refresh requests. When provided, this method
|
|
310
|
+
* is called instead of the default authentication logic, giving full control over
|
|
311
|
+
* the authentication mechanism.
|
|
312
|
+
*
|
|
313
|
+
* Common use cases include:
|
|
314
|
+
* - Supporting authentication methods beyond the standard OAuth 2.0 methods
|
|
315
|
+
* - Adding custom headers for proprietary authentication schemes
|
|
316
|
+
* - Implementing client assertion-based authentication (e.g., JWT bearer tokens)
|
|
317
|
+
*
|
|
318
|
+
* @param headers - The request headers (can be modified to add authentication)
|
|
319
|
+
* @param params - The request body parameters (can be modified to add credentials)
|
|
320
|
+
* @param url - The token endpoint URL being called
|
|
321
|
+
* @param metadata - Optional OAuth metadata for the server, which may include supported authentication methods
|
|
322
|
+
*/
|
|
323
|
+
addClientAuthentication?: AddClientAuthentication;
|
|
324
|
+
/**
|
|
325
|
+
* If defined, overrides the selection and validation of the
|
|
326
|
+
* RFC 8707 Resource Indicator. If left undefined, default
|
|
327
|
+
* validation behavior will be used.
|
|
328
|
+
*
|
|
329
|
+
* Implementations must verify the returned resource matches the MCP server.
|
|
330
|
+
*/
|
|
331
|
+
validateResourceURL?(serverUrl: string | URL, resource?: string): Promise<URL | undefined>;
|
|
332
|
+
/**
|
|
333
|
+
* If implemented, provides a way for the client to invalidate (e.g. delete) the specified
|
|
334
|
+
* credentials, in the case where the server has indicated that they are no longer valid.
|
|
335
|
+
* This avoids requiring the user to intervene manually.
|
|
336
|
+
*/
|
|
337
|
+
invalidateCredentials?(scope: 'all' | 'client' | 'tokens' | 'verifier' | 'discovery'): void | Promise<void>;
|
|
338
|
+
/**
|
|
339
|
+
* Prepares grant-specific parameters for a token request.
|
|
340
|
+
*
|
|
341
|
+
* This optional method allows providers to customize the token request based on
|
|
342
|
+
* the grant type they support. When implemented, it returns the grant type and
|
|
343
|
+
* any grant-specific parameters needed for the token exchange.
|
|
344
|
+
*
|
|
345
|
+
* If not implemented, the default behavior depends on the flow:
|
|
346
|
+
* - For authorization code flow: uses `code`, `code_verifier`, and `redirect_uri`
|
|
347
|
+
* - For `client_credentials`: detected via `grant_types` in {@linkcode OAuthClientProvider.clientMetadata | clientMetadata}
|
|
348
|
+
*
|
|
349
|
+
* @param scope - Optional scope to request
|
|
350
|
+
* @returns Grant type and parameters, or `undefined` to use default behavior
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* // For client_credentials grant:
|
|
354
|
+
* prepareTokenRequest(scope) {
|
|
355
|
+
* return {
|
|
356
|
+
* grantType: 'client_credentials',
|
|
357
|
+
* params: scope ? { scope } : {}
|
|
358
|
+
* };
|
|
359
|
+
* }
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* // For authorization_code grant (default behavior):
|
|
363
|
+
* async prepareTokenRequest() {
|
|
364
|
+
* return {
|
|
365
|
+
* grantType: 'authorization_code',
|
|
366
|
+
* params: {
|
|
367
|
+
* code: this.authorizationCode,
|
|
368
|
+
* code_verifier: await this.codeVerifier(),
|
|
369
|
+
* redirect_uri: String(this.redirectUrl)
|
|
370
|
+
* }
|
|
371
|
+
* };
|
|
372
|
+
* }
|
|
373
|
+
*/
|
|
374
|
+
prepareTokenRequest?(scope?: string): URLSearchParams | Promise<URLSearchParams | undefined> | undefined;
|
|
375
|
+
/**
|
|
376
|
+
* Saves the resolved authorization-server **issuer**. Called after a successful
|
|
377
|
+
* token exchange (timing changed in v2: was post-discovery, now post-`saveTokens`).
|
|
378
|
+
*
|
|
379
|
+
* @deprecated Superseded by the `issuer` stamp on stored tokens / client credentials
|
|
380
|
+
* (SEP-2352). {@linkcode auth} still **writes** this for back-compat with providers
|
|
381
|
+
* that read it (e.g. Cross-App Access), but the SDK never reads it. Prefer reading
|
|
382
|
+
* the `issuer` field on the value passed to {@linkcode saveTokens} /
|
|
383
|
+
* {@linkcode saveClientInformation}, or the `ctx.issuer` argument.
|
|
384
|
+
*/
|
|
385
|
+
saveAuthorizationServerUrl?(authorizationServerUrl: string): void | Promise<void>;
|
|
386
|
+
/**
|
|
387
|
+
* Returns the previously saved authorization server URL, if available.
|
|
388
|
+
*
|
|
389
|
+
* @deprecated Superseded by the `issuer` stamp on stored tokens / client credentials
|
|
390
|
+
* (SEP-2352). The SDK never reads this method; it remains for provider implementations
|
|
391
|
+
* that consume the value internally (e.g. Cross-App Access).
|
|
392
|
+
*/
|
|
393
|
+
authorizationServerUrl?(): string | undefined | Promise<string | undefined>;
|
|
394
|
+
/**
|
|
395
|
+
* Saves the resource URL after RFC 9728 discovery.
|
|
396
|
+
* This method is called by {@linkcode auth} after successful discovery of the
|
|
397
|
+
* resource metadata.
|
|
398
|
+
*
|
|
399
|
+
* Providers implementing Cross-App Access or other flows that need access to
|
|
400
|
+
* the discovered resource URL should implement this method.
|
|
401
|
+
*
|
|
402
|
+
* @param resourceUrl - The resource URL discovered via RFC 9728
|
|
403
|
+
*/
|
|
404
|
+
saveResourceUrl?(resourceUrl: string): void | Promise<void>;
|
|
405
|
+
/**
|
|
406
|
+
* Returns the previously saved resource URL, if available.
|
|
407
|
+
*
|
|
408
|
+
* Providers implementing Cross-App Access can use this to access the
|
|
409
|
+
* resource URL discovered during the OAuth flow.
|
|
410
|
+
*
|
|
411
|
+
* @returns The resource URL, or `undefined` if not available
|
|
412
|
+
*/
|
|
413
|
+
resourceUrl?(): string | undefined | Promise<string | undefined>;
|
|
414
|
+
/**
|
|
415
|
+
* Saves the OAuth discovery state after RFC 9728 and authorization server metadata
|
|
416
|
+
* discovery. Providers can persist this state to avoid redundant discovery requests
|
|
417
|
+
* on subsequent {@linkcode auth} calls.
|
|
418
|
+
*
|
|
419
|
+
* This state can also be provided out-of-band (e.g., from a previous session or
|
|
420
|
+
* external configuration) to bootstrap the OAuth flow without discovery.
|
|
421
|
+
*
|
|
422
|
+
* Called by {@linkcode auth} after successful discovery.
|
|
423
|
+
*
|
|
424
|
+
* MUST persist with the same durability as `codeVerifier` (survives the redirect
|
|
425
|
+
* round-trip).
|
|
426
|
+
*/
|
|
427
|
+
saveDiscoveryState?(state: OAuthDiscoveryState): void | Promise<void>;
|
|
428
|
+
/**
|
|
429
|
+
* Returns previously saved discovery state, or `undefined` if none is cached.
|
|
430
|
+
*
|
|
431
|
+
* When available, {@linkcode auth} restores the discovery state (authorization server
|
|
432
|
+
* URL, resource metadata, etc.) instead of performing RFC 9728 discovery, reducing
|
|
433
|
+
* latency on subsequent calls.
|
|
434
|
+
*
|
|
435
|
+
* Hosts should call {@linkcode invalidateCredentials} with scope `'discovery'`
|
|
436
|
+
* on repeated 401s so a changed `authorization_servers` list is picked up; the
|
|
437
|
+
* SDK does not invoke that scope itself.
|
|
438
|
+
*
|
|
439
|
+
* MUST persist with the same durability as `codeVerifier` (survives the redirect
|
|
440
|
+
* round-trip).
|
|
441
|
+
*/
|
|
442
|
+
discoveryState?(): OAuthDiscoveryState | undefined | Promise<OAuthDiscoveryState | undefined>;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Discovery state that can be persisted across sessions by an {@linkcode OAuthClientProvider}.
|
|
446
|
+
*
|
|
447
|
+
* Contains the results of RFC 9728 protected resource metadata discovery and
|
|
448
|
+
* authorization server metadata discovery. Persisting this state avoids
|
|
449
|
+
* redundant discovery HTTP requests on subsequent {@linkcode auth} calls.
|
|
450
|
+
*/
|
|
451
|
+
interface OAuthDiscoveryState extends OAuthServerInfo {
|
|
452
|
+
/** The URL at which the protected resource metadata was found, if available. */
|
|
453
|
+
resourceMetadataUrl?: string;
|
|
454
|
+
}
|
|
455
|
+
type AuthResult = 'AUTHORIZED' | 'REDIRECT';
|
|
456
|
+
declare class UnauthorizedError extends Error {
|
|
457
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Brand-based type guard: equivalent to `value instanceof this`, as an
|
|
460
|
+
* explicit static predicate (the axios/AWS-SDK `isInstance` style). Reads
|
|
461
|
+
* the caller's own brand via `this`, so every branded subclass gets a
|
|
462
|
+
* correctly-scoped guard by inheritance. Must be invoked on the class —
|
|
463
|
+
* in callback position write `v => SdkError.isInstance(v)`, not
|
|
464
|
+
* `.filter(SdkError.isInstance)` (detached calls throw rather than
|
|
465
|
+
* silently matching nothing).
|
|
466
|
+
*/
|
|
467
|
+
static isInstance<T extends abstract new (...args: never[]) => unknown>(this: T, value: unknown): value is InstanceType<T>;
|
|
468
|
+
constructor(message?: string);
|
|
469
|
+
}
|
|
470
|
+
declare function validateAuthorizationResponseIssuer({
|
|
471
|
+
iss,
|
|
472
|
+
expectedIssuer,
|
|
473
|
+
issParameterSupported
|
|
474
|
+
}: {
|
|
475
|
+
/** The form-urldecoded `iss` query parameter from the authorization callback, or `undefined` if absent. */
|
|
476
|
+
iss: string | undefined;
|
|
477
|
+
/** The `issuer` value from the authorization server's validated metadata document. */
|
|
478
|
+
expectedIssuer: string | undefined;
|
|
479
|
+
/** Whether the metadata advertised `authorization_response_iss_parameter_supported: true`. */
|
|
480
|
+
issParameterSupported: boolean;
|
|
481
|
+
}): void;
|
|
482
|
+
/**
|
|
483
|
+
* Computes the union of one or more OAuth `scope` strings.
|
|
484
|
+
*
|
|
485
|
+
* Each argument is a space-delimited scope string per RFC 6749 §3.3, or
|
|
486
|
+
* `undefined`. The result is a single space-delimited string containing each
|
|
487
|
+
* distinct scope token exactly once, in first-seen order, or `undefined` if
|
|
488
|
+
* every input is empty/undefined.
|
|
489
|
+
*
|
|
490
|
+
* No hierarchical deduplication is performed: a union may contain semantically
|
|
491
|
+
* redundant entries (e.g., a broad scope alongside a narrower one it implies).
|
|
492
|
+
* Authorization servers normalize such redundancy during token issuance; the
|
|
493
|
+
* spec's step-up flow does not require clients to.
|
|
494
|
+
*
|
|
495
|
+
* Used by the transport's `403 insufficient_scope` step-up path to accumulate
|
|
496
|
+
* previously-requested scopes with newly-challenged scopes so re-authorization
|
|
497
|
+
* does not lose previously-granted permissions.
|
|
498
|
+
*/
|
|
499
|
+
declare function computeScopeUnion(...scopes: ReadonlyArray<string | undefined>): string | undefined;
|
|
500
|
+
/**
|
|
501
|
+
* Whether `union` contains at least one scope token not present in `current`.
|
|
502
|
+
* Both arguments are space-delimited scope strings per RFC 6749 §3.3.
|
|
503
|
+
*
|
|
504
|
+
* Used to gate the step-up refresh bypass: when the union of previously-requested
|
|
505
|
+
* and newly-challenged scopes is a strict superset of the current token's
|
|
506
|
+
* granted scope, refreshing cannot widen the grant (RFC 6749 §6), so the
|
|
507
|
+
* transport must force a fresh authorization request instead. When the current
|
|
508
|
+
* token already covers the union, refresh remains valid.
|
|
509
|
+
*
|
|
510
|
+
* An undefined or empty `current` is treated as the empty set, so any non-empty
|
|
511
|
+
* `union` is a strict superset. Note that per RFC 6749 §3.3 an authorization
|
|
512
|
+
* server MAY omit the token's `scope` field when it equals the requested scope;
|
|
513
|
+
* this helper is conservative and treats an absent token `scope` as empty, so
|
|
514
|
+
* step-up always forces a fresh authorization request in that case rather than
|
|
515
|
+
* risking a refresh that silently drops the widened scope.
|
|
516
|
+
*/
|
|
517
|
+
declare function isStrictScopeSuperset(union: string | undefined, current: string | undefined): boolean;
|
|
518
|
+
type ClientAuthMethod = 'client_secret_basic' | 'client_secret_post' | 'none';
|
|
519
|
+
/**
|
|
520
|
+
* Determines the best client authentication method to use based on server support and client configuration.
|
|
521
|
+
*
|
|
522
|
+
* Priority order (highest to lowest):
|
|
523
|
+
* 1. `client_secret_basic` (if client secret is available)
|
|
524
|
+
* 2. `client_secret_post` (if client secret is available)
|
|
525
|
+
* 3. `none` (for public clients)
|
|
526
|
+
*
|
|
527
|
+
* @param clientInformation - OAuth client information containing credentials
|
|
528
|
+
* @param supportedMethods - Authentication methods supported by the authorization server
|
|
529
|
+
* @returns The selected authentication method
|
|
530
|
+
*/
|
|
531
|
+
declare function selectClientAuthMethod(clientInformation: OAuthClientInformationMixed, supportedMethods: string[]): ClientAuthMethod;
|
|
532
|
+
/**
|
|
533
|
+
* SEP-2207: refuse to send credentials to a non-TLS, non-loopback token endpoint.
|
|
534
|
+
* Throws {@linkcode InsecureTokenEndpointError}. Loopback hosts are exempt.
|
|
535
|
+
*/
|
|
536
|
+
declare function assertSecureTokenEndpoint(tokenEndpoint: string | URL): URL;
|
|
537
|
+
/**
|
|
538
|
+
* Reads {@linkcode OAuthClientProvider.clientMetadata | clientMetadata} from the
|
|
539
|
+
* provider and fills the SEP-837 / SEP-2207 defaults the SDK relies on, so
|
|
540
|
+
* {@linkcode registerClient} sees a consistent, fully-populated document.
|
|
541
|
+
*
|
|
542
|
+
* - `grant_types` defaults to `['authorization_code', 'refresh_token']` for
|
|
543
|
+
* interactive providers (those with a {@linkcode OAuthClientProvider.redirectUrl | redirectUrl})
|
|
544
|
+
* so authorization servers that gate refresh-token issuance on the registered
|
|
545
|
+
* grant types issue one (SEP-2207). Non-interactive providers (no
|
|
546
|
+
* `redirectUrl`) get no `grant_types` default. This default applies to the
|
|
547
|
+
* Dynamic Client Registration body only — it does **not** drive
|
|
548
|
+
* {@linkcode determineScope}'s `offline_access` augmentation.
|
|
549
|
+
* - `application_type` defaults from `redirect_uris`: loopback redirect hosts
|
|
550
|
+
* and custom URI schemes → `'native'`, otherwise `'web'` (SEP-837 / RFC 8252).
|
|
551
|
+
*
|
|
552
|
+
* A field the consumer set explicitly is **never** overwritten. {@linkcode auth}
|
|
553
|
+
* calls this once at the top of the flow; direct callers of
|
|
554
|
+
* {@linkcode registerClient} that want the same defaults should pass the result
|
|
555
|
+
* of this function as `clientMetadata`.
|
|
556
|
+
*/
|
|
557
|
+
declare function resolveClientMetadata(provider: Pick<OAuthClientProvider, 'clientMetadata' | 'redirectUrl'>): OAuthClientMetadata;
|
|
558
|
+
/**
|
|
559
|
+
* Parses an OAuth error response from a string or Response object.
|
|
560
|
+
*
|
|
561
|
+
* If the input is a standard OAuth2.0 error response, it will be parsed according to the spec
|
|
562
|
+
* and an {@linkcode OAuthError} will be returned with the appropriate error code.
|
|
563
|
+
* If parsing fails, it falls back to a generic {@linkcode OAuthErrorCode.ServerError | ServerError} that includes
|
|
564
|
+
* the response status (if available) and original content.
|
|
565
|
+
*
|
|
566
|
+
* @param input - A Response object or string containing the error response
|
|
567
|
+
* @returns A Promise that resolves to an {@linkcode OAuthError} instance
|
|
568
|
+
*/
|
|
569
|
+
declare function parseErrorResponse(input: Response | string): Promise<OAuthError>;
|
|
570
|
+
/**
|
|
571
|
+
* Options for {@linkcode auth}. The full OAuth flow orchestrator's input.
|
|
572
|
+
*/
|
|
573
|
+
interface AuthOptions {
|
|
574
|
+
/** The MCP server URL — the protected resource the flow authorizes against. */
|
|
575
|
+
serverUrl: string | URL;
|
|
576
|
+
/**
|
|
577
|
+
* The authorization code returned by the authorization server on the redirect
|
|
578
|
+
* callback. When set, {@linkcode auth} exchanges it for tokens; when unset,
|
|
579
|
+
* {@linkcode auth} runs discovery and either refreshes or initiates redirect.
|
|
580
|
+
*/
|
|
581
|
+
authorizationCode?: string;
|
|
582
|
+
/**
|
|
583
|
+
* The form-urldecoded `iss` query parameter from the authorization callback,
|
|
584
|
+
* if present. Passed through to RFC 9207 §2.4 issuer validation alongside
|
|
585
|
+
* `authorizationCode`. Validated against the recorded issuer per RFC 9207
|
|
586
|
+
* §2.4 before the code is redeemed — see
|
|
587
|
+
* {@linkcode validateAuthorizationResponseIssuer} and the migration guide's
|
|
588
|
+
* *Authorization-server mix-up defense* section.
|
|
589
|
+
*/
|
|
590
|
+
iss?: string;
|
|
591
|
+
/** Scope to request; computed by Scope Selection Strategy when omitted. */
|
|
592
|
+
scope?: string;
|
|
593
|
+
/** Explicit `resource_metadata` URL from a `WWW-Authenticate` challenge. */
|
|
594
|
+
resourceMetadataUrl?: URL;
|
|
595
|
+
/** Custom `fetch` implementation. */
|
|
596
|
+
fetchFn?: FetchLike;
|
|
597
|
+
/**
|
|
598
|
+
* Opt-out for the RFC 8414 §3.3 issuer-echo check during authorization
|
|
599
|
+
* server discovery. Disabling it is **security-weakening** and intended only
|
|
600
|
+
* for authorization servers known to publish a mismatched `issuer`.
|
|
601
|
+
*
|
|
602
|
+
* @default false
|
|
603
|
+
*/
|
|
604
|
+
skipIssuerMetadataValidation?: boolean;
|
|
605
|
+
/**
|
|
606
|
+
* When `true`, {@linkcode auth} skips the refresh-token branch even when a
|
|
607
|
+
* `refresh_token` is available, and proceeds directly to a fresh
|
|
608
|
+
* authorization request ({@linkcode startAuthorization}).
|
|
609
|
+
*
|
|
610
|
+
* Set by the transport's `403 insufficient_scope` step-up path when the
|
|
611
|
+
* required scope is a strict superset of the current token's granted scope:
|
|
612
|
+
* the refresh grant cannot widen scope (RFC 6749 §6), so refreshing would
|
|
613
|
+
* silently drop the new scope and the next request would 403 again. Forcing
|
|
614
|
+
* a fresh authorization request ensures the widened scope reaches the
|
|
615
|
+
* authorization server.
|
|
616
|
+
*
|
|
617
|
+
* Hosts driving step-up themselves (with `onInsufficientScope: 'throw'`)
|
|
618
|
+
* should set this when {@linkcode isStrictScopeSuperset} of the union over
|
|
619
|
+
* the current token's `scope` is `true`.
|
|
620
|
+
*
|
|
621
|
+
* @default false
|
|
622
|
+
*/
|
|
623
|
+
forceReauthorization?: boolean;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Orchestrates the full auth flow with a server.
|
|
627
|
+
*
|
|
628
|
+
* This can be used as a single entry point for all authorization functionality,
|
|
629
|
+
* instead of linking together the other lower-level functions in this module.
|
|
630
|
+
*/
|
|
631
|
+
declare function auth(provider: OAuthClientProvider, options: AuthOptions): Promise<AuthResult>;
|
|
632
|
+
/**
|
|
633
|
+
* Validates that the given `clientMetadataUrl` is a valid HTTPS URL with a non-root pathname.
|
|
634
|
+
*
|
|
635
|
+
* No-op when `url` is `undefined` or empty (providers that do not use URL-based client IDs
|
|
636
|
+
* are unaffected). When the value is defined but invalid, throws an {@linkcode OAuthError}
|
|
637
|
+
* with code {@linkcode OAuthErrorCode.InvalidClientMetadata}.
|
|
638
|
+
*
|
|
639
|
+
* {@linkcode OAuthClientProvider} implementations that accept a `clientMetadataUrl` should
|
|
640
|
+
* call this in their constructors for early validation.
|
|
641
|
+
*
|
|
642
|
+
* @param url - The `clientMetadataUrl` value to validate (from `OAuthClientProvider.clientMetadataUrl`)
|
|
643
|
+
* @throws {OAuthError} When `url` is defined but is not a valid HTTPS URL with a non-root pathname
|
|
644
|
+
*/
|
|
645
|
+
declare function validateClientMetadataUrl(url: string | undefined): void;
|
|
646
|
+
/**
|
|
647
|
+
* SEP-991: URL-based Client IDs
|
|
648
|
+
* Validate that the `client_id` is a valid URL with `https` scheme
|
|
649
|
+
*/
|
|
650
|
+
declare function isHttpsUrl(value?: string): boolean;
|
|
651
|
+
declare function selectResourceURL(serverUrl: string | URL, provider: OAuthClientProvider, resourceMetadata?: OAuthProtectedResourceMetadata): Promise<URL | undefined>;
|
|
652
|
+
/**
|
|
653
|
+
* Extract `resource_metadata`, `scope`, `error`, and `error_description` from a
|
|
654
|
+
* `WWW-Authenticate` header.
|
|
655
|
+
*/
|
|
656
|
+
declare function extractWWWAuthenticateParams(res: Response): {
|
|
657
|
+
resourceMetadataUrl?: URL;
|
|
658
|
+
scope?: string;
|
|
659
|
+
error?: string;
|
|
660
|
+
errorDescription?: string;
|
|
661
|
+
};
|
|
662
|
+
/**
|
|
663
|
+
* Extract `resource_metadata` from response header.
|
|
664
|
+
* @deprecated Use {@linkcode extractWWWAuthenticateParams} instead.
|
|
665
|
+
*/
|
|
666
|
+
declare function extractResourceMetadataUrl(res: Response): URL | undefined;
|
|
667
|
+
/**
|
|
668
|
+
* Looks up {@link https://datatracker.ietf.org/doc/html/rfc9728 | RFC 9728}
|
|
669
|
+
* OAuth 2.0 Protected Resource Metadata.
|
|
670
|
+
*
|
|
671
|
+
* If the server returns a 404 for the well-known endpoint, this function will
|
|
672
|
+
* return `undefined`. Any other errors will be thrown as exceptions.
|
|
673
|
+
*/
|
|
674
|
+
declare function discoverOAuthProtectedResourceMetadata(serverUrl: string | URL, opts?: {
|
|
675
|
+
protocolVersion?: string;
|
|
676
|
+
resourceMetadataUrl?: string | URL;
|
|
677
|
+
}, fetchFn?: FetchLike): Promise<OAuthProtectedResourceMetadata>;
|
|
678
|
+
/**
|
|
679
|
+
* Looks up RFC 8414 OAuth 2.0 Authorization Server Metadata.
|
|
680
|
+
*
|
|
681
|
+
* If the server returns a 404 for the well-known endpoint, this function will
|
|
682
|
+
* return `undefined`. Any other errors will be thrown as exceptions.
|
|
683
|
+
*
|
|
684
|
+
* @deprecated This function is deprecated in favor of {@linkcode discoverAuthorizationServerMetadata}.
|
|
685
|
+
*/
|
|
686
|
+
declare function discoverOAuthMetadata(issuer: string | URL, {
|
|
687
|
+
authorizationServerUrl,
|
|
688
|
+
protocolVersion
|
|
689
|
+
}?: {
|
|
690
|
+
authorizationServerUrl?: string | URL;
|
|
691
|
+
protocolVersion?: string;
|
|
692
|
+
}, fetchFn?: FetchLike): Promise<OAuthMetadata | undefined>;
|
|
693
|
+
/**
|
|
694
|
+
* Builds a list of discovery URLs to try for authorization server metadata.
|
|
695
|
+
* URLs are returned in priority order:
|
|
696
|
+
* 1. OAuth metadata at the given URL
|
|
697
|
+
* 2. OIDC metadata endpoints at the given URL
|
|
698
|
+
*/
|
|
699
|
+
declare function buildDiscoveryUrls(authorizationServerUrl: string | URL): {
|
|
700
|
+
url: URL;
|
|
701
|
+
type: 'oauth' | 'oidc';
|
|
702
|
+
}[];
|
|
703
|
+
/**
|
|
704
|
+
* Discovers authorization server metadata with support for
|
|
705
|
+
* {@link https://datatracker.ietf.org/doc/html/rfc8414 | RFC 8414} OAuth 2.0
|
|
706
|
+
* Authorization Server Metadata and
|
|
707
|
+
* {@link https://openid.net/specs/openid-connect-discovery-1_0.html | OpenID Connect Discovery 1.0}
|
|
708
|
+
* specifications.
|
|
709
|
+
*
|
|
710
|
+
* This function implements a fallback strategy for authorization server discovery:
|
|
711
|
+
* 1. Attempts RFC 8414 OAuth metadata discovery first
|
|
712
|
+
* 2. If OAuth discovery fails, falls back to OpenID Connect Discovery
|
|
713
|
+
*
|
|
714
|
+
* @param authorizationServerUrl - The authorization server URL obtained from the MCP Server's
|
|
715
|
+
* protected resource metadata, or the MCP server's URL if the
|
|
716
|
+
* metadata was not found.
|
|
717
|
+
* The returned metadata's `issuer` is validated against `authorizationServerUrl`
|
|
718
|
+
* per RFC 8414 §3.3 (and OIDC Discovery §4.3): if they differ the metadata is
|
|
719
|
+
* **rejected** with {@linkcode IssuerMismatchError} and not returned. Set
|
|
720
|
+
* `skipIssuerValidation: true` to suppress this check — **security-weakening**,
|
|
721
|
+
* intended only for known-misconfigured authorization servers.
|
|
722
|
+
*
|
|
723
|
+
* @param options - Configuration options
|
|
724
|
+
* @param options.fetchFn - Optional fetch function for making HTTP requests, defaults to global fetch
|
|
725
|
+
* @param options.protocolVersion - MCP protocol version to use, defaults to {@linkcode LATEST_PROTOCOL_VERSION}
|
|
726
|
+
* @param options.skipIssuerValidation - Skip the RFC 8414 §3.3 `issuer` echo check. **Security-weakening.**
|
|
727
|
+
* @returns Promise resolving to authorization server metadata, or undefined if discovery fails
|
|
728
|
+
* @throws {IssuerMismatchError} when the metadata's `issuer` does not match `authorizationServerUrl`
|
|
729
|
+
*/
|
|
730
|
+
declare function discoverAuthorizationServerMetadata(authorizationServerUrl: string | URL, {
|
|
731
|
+
fetchFn,
|
|
732
|
+
protocolVersion,
|
|
733
|
+
skipIssuerValidation
|
|
734
|
+
}?: {
|
|
735
|
+
fetchFn?: FetchLike;
|
|
736
|
+
protocolVersion?: string;
|
|
737
|
+
skipIssuerValidation?: boolean;
|
|
738
|
+
}): Promise<AuthorizationServerMetadata | undefined>;
|
|
739
|
+
/**
|
|
740
|
+
* Result of {@linkcode discoverOAuthServerInfo}.
|
|
741
|
+
*/
|
|
742
|
+
interface OAuthServerInfo {
|
|
743
|
+
/**
|
|
744
|
+
* The authorization server URL, either discovered via RFC 9728
|
|
745
|
+
* or derived from the MCP server URL as a fallback.
|
|
746
|
+
*/
|
|
747
|
+
authorizationServerUrl: string;
|
|
748
|
+
/**
|
|
749
|
+
* The authorization server metadata (endpoints, capabilities),
|
|
750
|
+
* or `undefined` if metadata discovery failed.
|
|
751
|
+
*/
|
|
752
|
+
authorizationServerMetadata?: AuthorizationServerMetadata;
|
|
753
|
+
/**
|
|
754
|
+
* The OAuth 2.0 Protected Resource Metadata from RFC 9728,
|
|
755
|
+
* or `undefined` if the server does not support it.
|
|
756
|
+
*/
|
|
757
|
+
resourceMetadata?: OAuthProtectedResourceMetadata;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Discovers the authorization server for an MCP server following
|
|
761
|
+
* {@link https://datatracker.ietf.org/doc/html/rfc9728 | RFC 9728} (OAuth 2.0 Protected
|
|
762
|
+
* Resource Metadata), with fallback to treating the server URL as the
|
|
763
|
+
* authorization server.
|
|
764
|
+
*
|
|
765
|
+
* This function combines two discovery steps into one call:
|
|
766
|
+
* 1. Probes `/.well-known/oauth-protected-resource` on the MCP server to find the
|
|
767
|
+
* authorization server URL (RFC 9728).
|
|
768
|
+
* 2. Fetches authorization server metadata from that URL (RFC 8414 / OpenID Connect Discovery).
|
|
769
|
+
*
|
|
770
|
+
* Use this when you need the authorization server metadata for operations outside the
|
|
771
|
+
* {@linkcode auth} orchestrator, such as token refresh or token revocation.
|
|
772
|
+
*
|
|
773
|
+
* @param serverUrl - The MCP resource server URL
|
|
774
|
+
* @param opts - Optional configuration
|
|
775
|
+
* @param opts.resourceMetadataUrl - Override URL for the protected resource metadata endpoint
|
|
776
|
+
* @param opts.fetchFn - Custom fetch function for HTTP requests
|
|
777
|
+
* @returns Authorization server URL, metadata, and resource metadata (if available)
|
|
778
|
+
*/
|
|
779
|
+
declare function discoverOAuthServerInfo(serverUrl: string | URL, opts?: {
|
|
780
|
+
resourceMetadataUrl?: URL;
|
|
781
|
+
fetchFn?: FetchLike;
|
|
782
|
+
/**
|
|
783
|
+
* Forwarded to {@linkcode discoverAuthorizationServerMetadata} as
|
|
784
|
+
* `skipIssuerValidation`. **Security-weakening** — see {@linkcode AuthOptions.skipIssuerMetadataValidation}.
|
|
785
|
+
*/
|
|
786
|
+
skipIssuerMetadataValidation?: boolean;
|
|
787
|
+
}): Promise<OAuthServerInfo>;
|
|
788
|
+
/**
|
|
789
|
+
* Begins the authorization flow with the given server, by generating a PKCE challenge and constructing the authorization URL.
|
|
790
|
+
*/
|
|
791
|
+
declare function startAuthorization(authorizationServerUrl: string | URL, {
|
|
792
|
+
metadata,
|
|
793
|
+
clientInformation,
|
|
794
|
+
redirectUrl,
|
|
795
|
+
scope,
|
|
796
|
+
state,
|
|
797
|
+
resource
|
|
798
|
+
}: {
|
|
799
|
+
metadata?: AuthorizationServerMetadata;
|
|
800
|
+
clientInformation: OAuthClientInformationMixed;
|
|
801
|
+
redirectUrl: string | URL;
|
|
802
|
+
scope?: string;
|
|
803
|
+
state?: string;
|
|
804
|
+
resource?: URL;
|
|
805
|
+
}): Promise<{
|
|
806
|
+
authorizationUrl: URL;
|
|
807
|
+
codeVerifier: string;
|
|
808
|
+
}>;
|
|
809
|
+
/**
|
|
810
|
+
* Prepares token request parameters for an authorization code exchange.
|
|
811
|
+
*
|
|
812
|
+
* This is the default implementation used by {@linkcode fetchToken} when the provider
|
|
813
|
+
* doesn't implement {@linkcode OAuthClientProvider.prepareTokenRequest | prepareTokenRequest}.
|
|
814
|
+
*
|
|
815
|
+
* @param authorizationCode - The authorization code received from the authorization endpoint
|
|
816
|
+
* @param codeVerifier - The PKCE code verifier
|
|
817
|
+
* @param redirectUri - The redirect URI used in the authorization request
|
|
818
|
+
* @returns URLSearchParams for the `authorization_code` grant
|
|
819
|
+
*/
|
|
820
|
+
declare function prepareAuthorizationCodeRequest(authorizationCode: string, codeVerifier: string, redirectUri: string | URL): URLSearchParams;
|
|
821
|
+
/**
|
|
822
|
+
* Exchanges an authorization code for an access token with the given server.
|
|
823
|
+
*
|
|
824
|
+
* Supports multiple client authentication methods as specified in OAuth 2.1:
|
|
825
|
+
* - Automatically selects the best authentication method based on server support
|
|
826
|
+
* - Falls back to appropriate defaults when server metadata is unavailable
|
|
827
|
+
*
|
|
828
|
+
* @param authorizationServerUrl - The authorization server's base URL
|
|
829
|
+
* @param options - Configuration object containing client info, auth code, etc.
|
|
830
|
+
* @returns Promise resolving to OAuth tokens
|
|
831
|
+
* @throws {Error} When token exchange fails or authentication is invalid
|
|
832
|
+
*/
|
|
833
|
+
declare function exchangeAuthorization(authorizationServerUrl: string | URL, {
|
|
834
|
+
metadata,
|
|
835
|
+
clientInformation,
|
|
836
|
+
authorizationCode,
|
|
837
|
+
iss,
|
|
838
|
+
codeVerifier,
|
|
839
|
+
redirectUri,
|
|
840
|
+
resource,
|
|
841
|
+
addClientAuthentication,
|
|
842
|
+
fetchFn
|
|
843
|
+
}: {
|
|
844
|
+
metadata?: AuthorizationServerMetadata;
|
|
845
|
+
clientInformation: OAuthClientInformationMixed;
|
|
846
|
+
authorizationCode: string;
|
|
847
|
+
/**
|
|
848
|
+
* The form-urldecoded `iss` query parameter from the authorization callback.
|
|
849
|
+
* Validated per RFC 9207 §2.4 against `metadata.issuer` before the code is
|
|
850
|
+
* redeemed; see {@linkcode validateAuthorizationResponseIssuer}.
|
|
851
|
+
*/
|
|
852
|
+
iss?: string;
|
|
853
|
+
codeVerifier: string;
|
|
854
|
+
redirectUri: string | URL;
|
|
855
|
+
resource?: URL;
|
|
856
|
+
addClientAuthentication?: OAuthClientProvider['addClientAuthentication'];
|
|
857
|
+
fetchFn?: FetchLike;
|
|
858
|
+
}): Promise<OAuthTokens>;
|
|
859
|
+
/**
|
|
860
|
+
* Exchange a refresh token for an updated access token.
|
|
861
|
+
*
|
|
862
|
+
* Supports multiple client authentication methods as specified in OAuth 2.1:
|
|
863
|
+
* - Automatically selects the best authentication method based on server support
|
|
864
|
+
* - Preserves the original refresh token if a new one is not returned
|
|
865
|
+
*
|
|
866
|
+
* @param authorizationServerUrl - The authorization server's base URL
|
|
867
|
+
* @param options - Configuration object containing client info, refresh token, etc.
|
|
868
|
+
* @returns Promise resolving to OAuth tokens (preserves original `refresh_token` if not replaced)
|
|
869
|
+
* @throws {Error} When token refresh fails or authentication is invalid
|
|
870
|
+
*/
|
|
871
|
+
declare function refreshAuthorization(authorizationServerUrl: string | URL, {
|
|
872
|
+
metadata,
|
|
873
|
+
clientInformation,
|
|
874
|
+
refreshToken,
|
|
875
|
+
resource,
|
|
876
|
+
addClientAuthentication,
|
|
877
|
+
fetchFn
|
|
878
|
+
}: {
|
|
879
|
+
metadata?: AuthorizationServerMetadata;
|
|
880
|
+
clientInformation: OAuthClientInformationMixed;
|
|
881
|
+
refreshToken: string;
|
|
882
|
+
resource?: URL;
|
|
883
|
+
addClientAuthentication?: OAuthClientProvider['addClientAuthentication'];
|
|
884
|
+
fetchFn?: FetchLike;
|
|
885
|
+
}): Promise<OAuthTokens>;
|
|
886
|
+
/**
|
|
887
|
+
* Unified token fetching that works with any grant type via {@linkcode OAuthClientProvider.prepareTokenRequest | prepareTokenRequest()}.
|
|
888
|
+
*
|
|
889
|
+
* This function provides a single entry point for obtaining tokens regardless of the
|
|
890
|
+
* OAuth grant type. The provider's `prepareTokenRequest()` method determines which grant
|
|
891
|
+
* to use and supplies the grant-specific parameters.
|
|
892
|
+
*
|
|
893
|
+
* @param provider - OAuth client provider that implements `prepareTokenRequest()`
|
|
894
|
+
* @param authorizationServerUrl - The authorization server's base URL
|
|
895
|
+
* @param options - Configuration for the token request
|
|
896
|
+
* @returns Promise resolving to OAuth tokens
|
|
897
|
+
* @throws {Error} When provider doesn't implement `prepareTokenRequest` or token fetch fails
|
|
898
|
+
*
|
|
899
|
+
* @example
|
|
900
|
+
* ```ts source="./auth.examples.ts#fetchToken_clientCredentials"
|
|
901
|
+
* // Provider for client_credentials:
|
|
902
|
+
* class MyProvider extends MyProviderBase implements OAuthClientProvider {
|
|
903
|
+
* prepareTokenRequest(scope?: string) {
|
|
904
|
+
* const params = new URLSearchParams({ grant_type: 'client_credentials' });
|
|
905
|
+
* if (scope) params.set('scope', scope);
|
|
906
|
+
* return params;
|
|
907
|
+
* }
|
|
908
|
+
* }
|
|
909
|
+
*
|
|
910
|
+
* const tokens = await fetchToken(new MyProvider(), authServerUrl, { metadata });
|
|
911
|
+
* ```
|
|
912
|
+
*/
|
|
913
|
+
declare function fetchToken(provider: OAuthClientProvider, authorizationServerUrl: string | URL, {
|
|
914
|
+
metadata,
|
|
915
|
+
resource,
|
|
916
|
+
authorizationCode,
|
|
917
|
+
iss,
|
|
918
|
+
scope,
|
|
919
|
+
fetchFn
|
|
920
|
+
}?: {
|
|
921
|
+
metadata?: AuthorizationServerMetadata;
|
|
922
|
+
resource?: URL;
|
|
923
|
+
/** Authorization code for the default `authorization_code` grant flow */
|
|
924
|
+
authorizationCode?: string;
|
|
925
|
+
/**
|
|
926
|
+
* The form-urldecoded `iss` query parameter from the authorization callback.
|
|
927
|
+
* Validated per RFC 9207 §2.4 when `authorizationCode` is present;
|
|
928
|
+
* see {@linkcode validateAuthorizationResponseIssuer}.
|
|
929
|
+
*/
|
|
930
|
+
iss?: string;
|
|
931
|
+
/** Optional scope parameter from auth() options */
|
|
932
|
+
scope?: string;
|
|
933
|
+
fetchFn?: FetchLike;
|
|
934
|
+
}): Promise<OAuthTokens>;
|
|
935
|
+
/**
|
|
936
|
+
* Performs OAuth 2.0 Dynamic Client Registration according to
|
|
937
|
+
* {@link https://datatracker.ietf.org/doc/html/rfc7591 | RFC 7591}.
|
|
938
|
+
*
|
|
939
|
+
* If `scope` is provided, it overrides `clientMetadata.scope` in the registration
|
|
940
|
+
* request body. This allows callers to apply the Scope Selection Strategy (SEP-835)
|
|
941
|
+
* consistently across both DCR and the subsequent authorization request.
|
|
942
|
+
*
|
|
943
|
+
* @deprecated Dynamic Client Registration is deprecated as of protocol version
|
|
944
|
+
* 2026-07-28 (SEP-2577) in favor of Client ID Metadata Documents (SEP-991).
|
|
945
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
946
|
+
* Prefer a CIMD URL `client_id` when the authorization server advertises
|
|
947
|
+
* `client_id_metadata_document_supported`; the SDK already gates on this for you.
|
|
948
|
+
*/
|
|
949
|
+
declare function registerClient(authorizationServerUrl: string | URL, {
|
|
950
|
+
metadata,
|
|
951
|
+
clientMetadata,
|
|
952
|
+
scope,
|
|
953
|
+
fetchFn
|
|
954
|
+
}: {
|
|
955
|
+
metadata?: AuthorizationServerMetadata;
|
|
956
|
+
clientMetadata: OAuthClientMetadata;
|
|
957
|
+
scope?: string;
|
|
958
|
+
fetchFn?: FetchLike;
|
|
959
|
+
}): Promise<OAuthClientInformationFull>;
|
|
960
|
+
//#endregion
|
|
961
|
+
//#region src/client/authExtensions.d.ts
|
|
962
|
+
/**
|
|
963
|
+
* Helper to produce a `private_key_jwt` client authentication function.
|
|
964
|
+
*
|
|
965
|
+
* @example
|
|
966
|
+
* ```ts source="./authExtensions.examples.ts#createPrivateKeyJwtAuth_basicUsage"
|
|
967
|
+
* const addClientAuth = createPrivateKeyJwtAuth({
|
|
968
|
+
* issuer: 'my-client',
|
|
969
|
+
* subject: 'my-client',
|
|
970
|
+
* privateKey: pemEncodedPrivateKey,
|
|
971
|
+
* alg: 'RS256'
|
|
972
|
+
* });
|
|
973
|
+
* // pass addClientAuth as provider.addClientAuthentication implementation
|
|
974
|
+
* ```
|
|
975
|
+
*/
|
|
976
|
+
declare function createPrivateKeyJwtAuth(options: {
|
|
977
|
+
issuer: string;
|
|
978
|
+
subject: string;
|
|
979
|
+
privateKey: string | Uint8Array | Record<string, unknown>;
|
|
980
|
+
alg: string;
|
|
981
|
+
audience?: string | URL;
|
|
982
|
+
lifetimeSeconds?: number;
|
|
983
|
+
claims?: Record<string, unknown>;
|
|
984
|
+
}): AddClientAuthentication;
|
|
985
|
+
/**
|
|
986
|
+
* Options for creating a {@linkcode ClientCredentialsProvider}.
|
|
987
|
+
*/
|
|
988
|
+
interface ClientCredentialsProviderOptions {
|
|
989
|
+
/**
|
|
990
|
+
* The `client_id` for this OAuth client.
|
|
991
|
+
*/
|
|
992
|
+
clientId: string;
|
|
993
|
+
/**
|
|
994
|
+
* The `client_secret` for `client_secret_basic` authentication.
|
|
995
|
+
*/
|
|
996
|
+
clientSecret: string;
|
|
997
|
+
/**
|
|
998
|
+
* Optional client name for metadata.
|
|
999
|
+
*/
|
|
1000
|
+
clientName?: string;
|
|
1001
|
+
/**
|
|
1002
|
+
* Space-separated scopes values requested by the client.
|
|
1003
|
+
*/
|
|
1004
|
+
scope?: string;
|
|
1005
|
+
/**
|
|
1006
|
+
* The authorization server's `issuer` identifier these credentials were registered with.
|
|
1007
|
+
* Stamped onto the stored client information so `auth()`'s SEP-2352 issuer check
|
|
1008
|
+
* refuses to send the credential to any other authorization server. Hosts supplying
|
|
1009
|
+
* static client credentials SHOULD set this; omitting it preserves the legacy
|
|
1010
|
+
* (no-binding) behaviour for back-compat.
|
|
1011
|
+
*/
|
|
1012
|
+
expectedIssuer?: string;
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* OAuth provider for `client_credentials` grant with `client_secret_basic` authentication.
|
|
1016
|
+
*
|
|
1017
|
+
* This provider is designed for machine-to-machine authentication where
|
|
1018
|
+
* the client authenticates using a `client_id` and `client_secret`.
|
|
1019
|
+
*
|
|
1020
|
+
* @example
|
|
1021
|
+
* ```ts source="./authExtensions.examples.ts#ClientCredentialsProvider_basicUsage"
|
|
1022
|
+
* const provider = new ClientCredentialsProvider({
|
|
1023
|
+
* clientId: 'my-client',
|
|
1024
|
+
* clientSecret: 'my-secret'
|
|
1025
|
+
* });
|
|
1026
|
+
*
|
|
1027
|
+
* const transport = new StreamableHTTPClientTransport(serverUrl, {
|
|
1028
|
+
* authProvider: provider
|
|
1029
|
+
* });
|
|
1030
|
+
* ```
|
|
1031
|
+
*/
|
|
1032
|
+
declare class ClientCredentialsProvider implements OAuthClientProvider {
|
|
1033
|
+
private _tokens?;
|
|
1034
|
+
private _clientInfo;
|
|
1035
|
+
private _clientMetadata;
|
|
1036
|
+
constructor(options: ClientCredentialsProviderOptions);
|
|
1037
|
+
get redirectUrl(): undefined;
|
|
1038
|
+
get clientMetadata(): OAuthClientMetadata;
|
|
1039
|
+
clientInformation(): StoredOAuthClientInformation;
|
|
1040
|
+
tokens(): StoredOAuthTokens | undefined;
|
|
1041
|
+
saveTokens(tokens: StoredOAuthTokens): void;
|
|
1042
|
+
redirectToAuthorization(): void;
|
|
1043
|
+
saveCodeVerifier(): void;
|
|
1044
|
+
codeVerifier(): string;
|
|
1045
|
+
prepareTokenRequest(scope?: string): URLSearchParams;
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Options for creating a {@linkcode PrivateKeyJwtProvider}.
|
|
1049
|
+
*/
|
|
1050
|
+
interface PrivateKeyJwtProviderOptions {
|
|
1051
|
+
/**
|
|
1052
|
+
* The `client_id` for this OAuth client.
|
|
1053
|
+
*/
|
|
1054
|
+
clientId: string;
|
|
1055
|
+
/**
|
|
1056
|
+
* The private key for signing JWT assertions.
|
|
1057
|
+
* Can be a PEM string, Uint8Array, or JWK object.
|
|
1058
|
+
*/
|
|
1059
|
+
privateKey: string | Uint8Array | Record<string, unknown>;
|
|
1060
|
+
/**
|
|
1061
|
+
* The algorithm to use for signing (e.g., 'RS256', 'ES256').
|
|
1062
|
+
*/
|
|
1063
|
+
algorithm: string;
|
|
1064
|
+
/**
|
|
1065
|
+
* Optional client name for metadata.
|
|
1066
|
+
*/
|
|
1067
|
+
clientName?: string;
|
|
1068
|
+
/**
|
|
1069
|
+
* Optional JWT lifetime in seconds (default: 300).
|
|
1070
|
+
*/
|
|
1071
|
+
jwtLifetimeSeconds?: number;
|
|
1072
|
+
/**
|
|
1073
|
+
* Space-separated scopes values requested by the client.
|
|
1074
|
+
*/
|
|
1075
|
+
scope?: string;
|
|
1076
|
+
/**
|
|
1077
|
+
* Optional custom claims to include in the JWT assertion.
|
|
1078
|
+
* These are merged with the standard claims (`iss`, `sub`, `aud`, `exp`, `iat`, `jti`),
|
|
1079
|
+
* with custom claims taking precedence for any overlapping keys.
|
|
1080
|
+
*
|
|
1081
|
+
* Useful for including additional claims that help scope the access token
|
|
1082
|
+
* with finer granularity than what scopes alone allow.
|
|
1083
|
+
*/
|
|
1084
|
+
claims?: Record<string, unknown>;
|
|
1085
|
+
/**
|
|
1086
|
+
* The authorization server's `issuer` identifier these credentials were registered with.
|
|
1087
|
+
* Seeds the SEP-2352 issuer stamp — see {@linkcode ClientCredentialsProviderOptions.expectedIssuer}.
|
|
1088
|
+
*/
|
|
1089
|
+
expectedIssuer?: string;
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* OAuth provider for `client_credentials` grant with `private_key_jwt` authentication.
|
|
1093
|
+
*
|
|
1094
|
+
* This provider is designed for machine-to-machine authentication where
|
|
1095
|
+
* the client authenticates using a signed JWT assertion
|
|
1096
|
+
* ({@link https://datatracker.ietf.org/doc/html/rfc7523#section-2.2 | RFC 7523 Section 2.2}).
|
|
1097
|
+
*
|
|
1098
|
+
* @example
|
|
1099
|
+
* ```ts source="./authExtensions.examples.ts#PrivateKeyJwtProvider_basicUsage"
|
|
1100
|
+
* const provider = new PrivateKeyJwtProvider({
|
|
1101
|
+
* clientId: 'my-client',
|
|
1102
|
+
* privateKey: pemEncodedPrivateKey,
|
|
1103
|
+
* algorithm: 'RS256'
|
|
1104
|
+
* });
|
|
1105
|
+
*
|
|
1106
|
+
* const transport = new StreamableHTTPClientTransport(serverUrl, {
|
|
1107
|
+
* authProvider: provider
|
|
1108
|
+
* });
|
|
1109
|
+
* ```
|
|
1110
|
+
*/
|
|
1111
|
+
declare class PrivateKeyJwtProvider implements OAuthClientProvider {
|
|
1112
|
+
private _tokens?;
|
|
1113
|
+
private _clientInfo;
|
|
1114
|
+
private _clientMetadata;
|
|
1115
|
+
addClientAuthentication: AddClientAuthentication;
|
|
1116
|
+
constructor(options: PrivateKeyJwtProviderOptions);
|
|
1117
|
+
get redirectUrl(): undefined;
|
|
1118
|
+
get clientMetadata(): OAuthClientMetadata;
|
|
1119
|
+
clientInformation(): StoredOAuthClientInformation;
|
|
1120
|
+
tokens(): StoredOAuthTokens | undefined;
|
|
1121
|
+
saveTokens(tokens: StoredOAuthTokens): void;
|
|
1122
|
+
redirectToAuthorization(): void;
|
|
1123
|
+
saveCodeVerifier(): void;
|
|
1124
|
+
codeVerifier(): string;
|
|
1125
|
+
prepareTokenRequest(scope?: string): URLSearchParams;
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Options for creating a {@linkcode StaticPrivateKeyJwtProvider}.
|
|
1129
|
+
*/
|
|
1130
|
+
interface StaticPrivateKeyJwtProviderOptions {
|
|
1131
|
+
/**
|
|
1132
|
+
* The `client_id` for this OAuth client.
|
|
1133
|
+
*/
|
|
1134
|
+
clientId: string;
|
|
1135
|
+
/**
|
|
1136
|
+
* A pre-built JWT client assertion to use for authentication.
|
|
1137
|
+
*
|
|
1138
|
+
* This token should already contain the appropriate claims
|
|
1139
|
+
* (`iss`, `sub`, `aud`, `exp`, etc.) and be signed by the client's key.
|
|
1140
|
+
*/
|
|
1141
|
+
jwtBearerAssertion: string;
|
|
1142
|
+
/**
|
|
1143
|
+
* Optional client name for metadata.
|
|
1144
|
+
*/
|
|
1145
|
+
clientName?: string;
|
|
1146
|
+
/**
|
|
1147
|
+
* Space-separated scopes values requested by the client.
|
|
1148
|
+
*/
|
|
1149
|
+
scope?: string;
|
|
1150
|
+
/**
|
|
1151
|
+
* The authorization server's `issuer` identifier this assertion was minted for.
|
|
1152
|
+
* Seeds the SEP-2352 issuer stamp — see {@linkcode ClientCredentialsProviderOptions.expectedIssuer}.
|
|
1153
|
+
*/
|
|
1154
|
+
expectedIssuer?: string;
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* OAuth provider for `client_credentials` grant with a static `private_key_jwt` assertion.
|
|
1158
|
+
*
|
|
1159
|
+
* This provider mirrors {@linkcode PrivateKeyJwtProvider} but instead of constructing and
|
|
1160
|
+
* signing a JWT on each request, it accepts a pre-built JWT assertion string and
|
|
1161
|
+
* uses it directly for authentication.
|
|
1162
|
+
*/
|
|
1163
|
+
declare class StaticPrivateKeyJwtProvider implements OAuthClientProvider {
|
|
1164
|
+
private _tokens?;
|
|
1165
|
+
private _clientInfo;
|
|
1166
|
+
private _clientMetadata;
|
|
1167
|
+
addClientAuthentication: AddClientAuthentication;
|
|
1168
|
+
constructor(options: StaticPrivateKeyJwtProviderOptions);
|
|
1169
|
+
get redirectUrl(): undefined;
|
|
1170
|
+
get clientMetadata(): OAuthClientMetadata;
|
|
1171
|
+
clientInformation(): StoredOAuthClientInformation;
|
|
1172
|
+
tokens(): StoredOAuthTokens | undefined;
|
|
1173
|
+
saveTokens(tokens: StoredOAuthTokens): void;
|
|
1174
|
+
redirectToAuthorization(): void;
|
|
1175
|
+
saveCodeVerifier(): void;
|
|
1176
|
+
codeVerifier(): string;
|
|
1177
|
+
prepareTokenRequest(scope?: string): URLSearchParams;
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Context provided to the assertion callback in {@linkcode CrossAppAccessProvider}.
|
|
1181
|
+
* Contains orchestrator-discovered information needed for JWT Authorization Grant requests.
|
|
1182
|
+
*/
|
|
1183
|
+
interface CrossAppAccessContext {
|
|
1184
|
+
/**
|
|
1185
|
+
* The authorization server URL of the target MCP server.
|
|
1186
|
+
* Discovered via RFC 9728 protected resource metadata.
|
|
1187
|
+
*/
|
|
1188
|
+
authorizationServerUrl: string;
|
|
1189
|
+
/**
|
|
1190
|
+
* The resource URL of the target MCP server.
|
|
1191
|
+
* Discovered via RFC 9728 protected resource metadata.
|
|
1192
|
+
*/
|
|
1193
|
+
resourceUrl: string;
|
|
1194
|
+
/**
|
|
1195
|
+
* Optional scope being requested for the MCP server.
|
|
1196
|
+
*/
|
|
1197
|
+
scope?: string;
|
|
1198
|
+
/**
|
|
1199
|
+
* Fetch function to use for HTTP requests (e.g., for IdP token exchange).
|
|
1200
|
+
*/
|
|
1201
|
+
fetchFn: FetchLike;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Callback function type that provides a JWT Authorization Grant (ID-JAG).
|
|
1205
|
+
*
|
|
1206
|
+
* The callback receives context about the target MCP server (authorization server URL,
|
|
1207
|
+
* resource URL, scope) and should return a JWT Authorization Grant that will be used
|
|
1208
|
+
* to obtain an access token from the MCP server.
|
|
1209
|
+
*/
|
|
1210
|
+
type AssertionCallback = (context: CrossAppAccessContext) => string | Promise<string>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Options for creating a {@linkcode CrossAppAccessProvider}.
|
|
1213
|
+
*/
|
|
1214
|
+
interface CrossAppAccessProviderOptions {
|
|
1215
|
+
/**
|
|
1216
|
+
* Callback function that provides a JWT Authorization Grant (ID-JAG).
|
|
1217
|
+
*
|
|
1218
|
+
* The callback receives the MCP server's authorization server URL, resource URL,
|
|
1219
|
+
* and requested scope, and should return a JWT Authorization Grant obtained from
|
|
1220
|
+
* the enterprise IdP via RFC 8693 token exchange.
|
|
1221
|
+
*
|
|
1222
|
+
* You can use the utility functions from the `crossAppAccess` module
|
|
1223
|
+
* for standard flows, or implement custom logic.
|
|
1224
|
+
*
|
|
1225
|
+
* @example
|
|
1226
|
+
* ```ts
|
|
1227
|
+
* assertion: async (ctx) => {
|
|
1228
|
+
* const result = await discoverAndRequestJwtAuthGrant({
|
|
1229
|
+
* idpUrl: 'https://idp.example.com',
|
|
1230
|
+
* audience: ctx.authorizationServerUrl,
|
|
1231
|
+
* resource: ctx.resourceUrl,
|
|
1232
|
+
* idToken: await getIdToken(),
|
|
1233
|
+
* clientId: 'my-idp-client',
|
|
1234
|
+
* clientSecret: 'my-idp-secret',
|
|
1235
|
+
* scope: ctx.scope,
|
|
1236
|
+
* fetchFn: ctx.fetchFn
|
|
1237
|
+
* });
|
|
1238
|
+
* return result.jwtAuthGrant;
|
|
1239
|
+
* }
|
|
1240
|
+
* ```
|
|
1241
|
+
*/
|
|
1242
|
+
assertion: AssertionCallback;
|
|
1243
|
+
/**
|
|
1244
|
+
* The `client_id` registered with the MCP server's authorization server.
|
|
1245
|
+
*/
|
|
1246
|
+
clientId: string;
|
|
1247
|
+
/**
|
|
1248
|
+
* The `client_secret` for authenticating with the MCP server's authorization server.
|
|
1249
|
+
*/
|
|
1250
|
+
clientSecret: string;
|
|
1251
|
+
/**
|
|
1252
|
+
* Optional client name for metadata.
|
|
1253
|
+
*/
|
|
1254
|
+
clientName?: string;
|
|
1255
|
+
/**
|
|
1256
|
+
* Custom fetch implementation. Defaults to global fetch.
|
|
1257
|
+
*/
|
|
1258
|
+
fetchFn?: FetchLike;
|
|
1259
|
+
/**
|
|
1260
|
+
* The MCP authorization server's `issuer` identifier these credentials were registered with.
|
|
1261
|
+
* Seeds the SEP-2352 issuer stamp — see {@linkcode ClientCredentialsProviderOptions.expectedIssuer}.
|
|
1262
|
+
*/
|
|
1263
|
+
expectedIssuer?: string;
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* OAuth provider for Cross-App Access (Enterprise Managed Authorization) using JWT Authorization Grant.
|
|
1267
|
+
*
|
|
1268
|
+
* This provider implements the Enterprise Managed Authorization flow (SEP-990) where:
|
|
1269
|
+
* 1. User authenticates with an enterprise IdP and the client obtains an ID Token
|
|
1270
|
+
* 2. Client exchanges the ID Token for a JWT Authorization Grant (ID-JAG) via RFC 8693 token exchange
|
|
1271
|
+
* 3. Client uses the JAG to obtain an access token from the MCP server via RFC 7523 JWT bearer grant
|
|
1272
|
+
*
|
|
1273
|
+
* The provider handles steps 2-3 automatically, with the JAG acquisition delegated to
|
|
1274
|
+
* a callback function that you provide. This allows flexibility in how you obtain and
|
|
1275
|
+
* cache ID Tokens from the IdP.
|
|
1276
|
+
*
|
|
1277
|
+
* @see https://github.com/modelcontextprotocol/ext-auth/blob/main/specification/stable/enterprise-managed-authorization.mdx
|
|
1278
|
+
*
|
|
1279
|
+
* @example
|
|
1280
|
+
* ```ts
|
|
1281
|
+
* const provider = new CrossAppAccessProvider({
|
|
1282
|
+
* assertion: async (ctx) => {
|
|
1283
|
+
* const result = await discoverAndRequestJwtAuthGrant({
|
|
1284
|
+
* idpUrl: 'https://idp.example.com',
|
|
1285
|
+
* audience: ctx.authorizationServerUrl,
|
|
1286
|
+
* resource: ctx.resourceUrl,
|
|
1287
|
+
* idToken: await getIdToken(), // Your function to get ID token
|
|
1288
|
+
* clientId: 'my-idp-client',
|
|
1289
|
+
* clientSecret: 'my-idp-secret',
|
|
1290
|
+
* scope: ctx.scope,
|
|
1291
|
+
* fetchFn: ctx.fetchFn
|
|
1292
|
+
* });
|
|
1293
|
+
* return result.jwtAuthGrant;
|
|
1294
|
+
* },
|
|
1295
|
+
* clientId: 'my-mcp-client',
|
|
1296
|
+
* clientSecret: 'my-mcp-secret'
|
|
1297
|
+
* });
|
|
1298
|
+
*
|
|
1299
|
+
* const transport = new StreamableHTTPClientTransport(serverUrl, {
|
|
1300
|
+
* authProvider: provider
|
|
1301
|
+
* });
|
|
1302
|
+
* ```
|
|
1303
|
+
*/
|
|
1304
|
+
declare class CrossAppAccessProvider implements OAuthClientProvider {
|
|
1305
|
+
private _tokens?;
|
|
1306
|
+
private _clientInfo;
|
|
1307
|
+
private _clientMetadata;
|
|
1308
|
+
private _assertionCallback;
|
|
1309
|
+
private _fetchFn;
|
|
1310
|
+
private _authorizationServerUrl?;
|
|
1311
|
+
private _resourceUrl?;
|
|
1312
|
+
private _scope?;
|
|
1313
|
+
constructor(options: CrossAppAccessProviderOptions);
|
|
1314
|
+
get redirectUrl(): undefined;
|
|
1315
|
+
get clientMetadata(): OAuthClientMetadata;
|
|
1316
|
+
clientInformation(): StoredOAuthClientInformation;
|
|
1317
|
+
tokens(): StoredOAuthTokens | undefined;
|
|
1318
|
+
saveTokens(tokens: StoredOAuthTokens): void;
|
|
1319
|
+
redirectToAuthorization(): void;
|
|
1320
|
+
saveCodeVerifier(): void;
|
|
1321
|
+
codeVerifier(): string;
|
|
1322
|
+
/**
|
|
1323
|
+
* Saves the authorization server URL discovered during OAuth flow.
|
|
1324
|
+
* This is called by the auth() function after RFC 9728 discovery.
|
|
1325
|
+
*/
|
|
1326
|
+
saveAuthorizationServerUrl(authorizationServerUrl: string): void;
|
|
1327
|
+
/**
|
|
1328
|
+
* Returns the cached authorization server URL if available.
|
|
1329
|
+
*/
|
|
1330
|
+
authorizationServerUrl(): string | undefined;
|
|
1331
|
+
/**
|
|
1332
|
+
* Saves the resource URL discovered during OAuth flow.
|
|
1333
|
+
* This is called by the auth() function after RFC 9728 discovery.
|
|
1334
|
+
*/
|
|
1335
|
+
saveResourceUrl?(resourceUrl: string): void;
|
|
1336
|
+
/**
|
|
1337
|
+
* Returns the cached resource URL if available.
|
|
1338
|
+
*/
|
|
1339
|
+
resourceUrl?(): string | undefined;
|
|
1340
|
+
prepareTokenRequest(scope?: string): Promise<URLSearchParams>;
|
|
1341
|
+
}
|
|
1342
|
+
//#endregion
|
|
1343
|
+
//#region src/client/probeClassifier.d.ts
|
|
1344
|
+
/**
|
|
1345
|
+
* A cached era verdict for `connect({ prior })` — the persistable subset of
|
|
1346
|
+
* the {@linkcode ProbeVerdict} vocabulary (`'modern'` = speaks 2026-07-28+,
|
|
1347
|
+
* `'legacy'` = 2025-era `initialize` only). Freshness is the supplying host's
|
|
1348
|
+
* responsibility: a stale modern verdict fails loudly at the first request,
|
|
1349
|
+
* but a stale legacy verdict succeeds silently forever (an upgraded server
|
|
1350
|
+
* still answers `initialize`) — date cached legacy verdicts in your own
|
|
1351
|
+
* storage and stop supplying them past your policy horizon. Full recipe:
|
|
1352
|
+
* the gateway guide (`docs/advanced/gateway.md`).
|
|
1353
|
+
*/
|
|
1354
|
+
type PriorDiscovery = /** Adopt `discover` directly: zero round trips. */
|
|
1355
|
+
{
|
|
1356
|
+
kind: 'modern';
|
|
1357
|
+
discover: DiscoverResult;
|
|
1358
|
+
}
|
|
1359
|
+
/** Known-legacy server: skip the `server/discover` probe and run the plain legacy `initialize` handshake. */ | {
|
|
1360
|
+
kind: 'legacy';
|
|
1361
|
+
};
|
|
1362
|
+
//#endregion
|
|
1363
|
+
//#region src/client/responseCache.d.ts
|
|
1364
|
+
/**
|
|
1365
|
+
* Client-side response cache for SEP-2549 (`CacheableResult`) freshness hints.
|
|
1366
|
+
*
|
|
1367
|
+
* The store is a dumb keyed-value carrier: every freshness, scope and
|
|
1368
|
+
* invalidation decision lives in the {@linkcode ClientResponseCache} (the
|
|
1369
|
+
* `Client`'s single cache-coordination collaborator). The `stamp` field is
|
|
1370
|
+
* mcp.d's re-derivation key — a derived view (e.g. the `name → Tool` index)
|
|
1371
|
+
* re-computes only when the backing entry's stamp changes.
|
|
1372
|
+
*
|
|
1373
|
+
* Reference design: mcp.d `client/cache.d` / `client/client.d` (`CacheStore`,
|
|
1374
|
+
* `cachedTool`, `cachedFetch`, `invalidateLogical`).
|
|
1375
|
+
*/
|
|
1376
|
+
/** A value or a promise of one. The store interface is async-ready; the in-memory default returns plain values. */
|
|
1377
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
1378
|
+
/** The freshness scope of a cached entry (SEP-2549 `cacheHints.scope`). */
|
|
1379
|
+
type CacheScope = 'public' | 'private';
|
|
1380
|
+
/**
|
|
1381
|
+
* Per-call cache disposition for the cacheable verbs (`listTools()` /
|
|
1382
|
+
* `listPrompts()` / `listResources()` / `listResourceTemplates()` /
|
|
1383
|
+
* `readResource()`):
|
|
1384
|
+
*
|
|
1385
|
+
* - `'use'` (the default) — serve a still-fresh cached entry without a round
|
|
1386
|
+
* trip; on miss/stale, fetch and write.
|
|
1387
|
+
* - `'refresh'` — always fetch (ignore any held entry) and write the fresh
|
|
1388
|
+
* result.
|
|
1389
|
+
* - `'bypass'` — fetch without consulting OR writing the cache (the result is
|
|
1390
|
+
* not stored). The `tools/list`-derived index (mirroring / output
|
|
1391
|
+
* validation) is therefore unaffected by a `'bypass'` call.
|
|
1392
|
+
*/
|
|
1393
|
+
type CacheMode = 'use' | 'refresh' | 'bypass';
|
|
1394
|
+
/**
|
|
1395
|
+
* A logical cache address. `params` is the canonical result-affecting params
|
|
1396
|
+
* key (`''` for the four list ops, the `uri` for `resources/read`); omitted is
|
|
1397
|
+
* equivalent to `''`. `partition` namespaces the entry by connected-server
|
|
1398
|
+
* identity AND per-principal scope: the `Client` writes a JSON-encoded
|
|
1399
|
+
* `[serverIdentity, principal]` pair (so a server-controlled `serverInfo`
|
|
1400
|
+
* string cannot bleed into the principal slot regardless of what characters
|
|
1401
|
+
* it contains). A `'public'`-scoped entry lives at `[serverIdentity, '']`; a
|
|
1402
|
+
* `'private'`-scoped entry at `[serverIdentity, cachePartition]`. Omitted is
|
|
1403
|
+
* equivalent to `''`.
|
|
1404
|
+
*/
|
|
1405
|
+
interface CacheKey {
|
|
1406
|
+
readonly method: string;
|
|
1407
|
+
readonly params?: string;
|
|
1408
|
+
readonly partition?: string;
|
|
1409
|
+
}
|
|
1410
|
+
/**
|
|
1411
|
+
* One cached response body. `value` is the JSON-serialized result document —
|
|
1412
|
+
* a store is a dumb string carrier and persists it verbatim; the cache owns
|
|
1413
|
+
* both codec halves. `stamp` is the store-generated monotonically increasing write counter —
|
|
1414
|
+
* opaque to callers. Derived views (e.g. a `name → Tool` index) memoize
|
|
1415
|
+
* against it and re-derive only when it changes. `expiresAt` (absolute ms
|
|
1416
|
+
* epoch, `now + ttlMs`) and `scope` are the client-computed freshness
|
|
1417
|
+
* metadata; the store MUST persist them and hand them back on `get` so the
|
|
1418
|
+
* read path can decide freshness and gate the shared-partition fallback on
|
|
1419
|
+
* `scope === 'public'`.
|
|
1420
|
+
*/
|
|
1421
|
+
interface CacheEntry {
|
|
1422
|
+
readonly value: string;
|
|
1423
|
+
readonly stamp: number;
|
|
1424
|
+
readonly expiresAt?: number;
|
|
1425
|
+
readonly scope?: CacheScope;
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* The pluggable response-cache store. The interface is intentionally narrow;
|
|
1429
|
+
* the in-memory default is the only implementation the SDK ships.
|
|
1430
|
+
*
|
|
1431
|
+
* Every method is async-ready ({@linkcode MaybePromise}) so a Redis-style
|
|
1432
|
+
* store can implement the same interface without a later breaking change; the
|
|
1433
|
+
* in-memory default stays synchronous (plain values are valid under
|
|
1434
|
+
* `MaybePromise`). The `Client` `await`s every call site.
|
|
1435
|
+
*
|
|
1436
|
+
* Entries are keyed by `{method, params, partition}` where `partition` is the
|
|
1437
|
+
* `Client`-derived `[serverIdentity, principal]` JSON pair, so one store
|
|
1438
|
+
* instance is safe to share across `Client` instances connected to different
|
|
1439
|
+
* servers and/or principals: writes from distinct connections never collide,
|
|
1440
|
+
* the shared-partition read fallback is gated on the stored
|
|
1441
|
+
* `scope === 'public'`, and `list_changed` / `HEADER_MISMATCH` evictions are
|
|
1442
|
+
* scoped to the connected server's two partitions — co-tenants on a shared
|
|
1443
|
+
* store are unaffected. The `Client` constructor still allocates a fresh
|
|
1444
|
+
* {@linkcode InMemoryResponseCacheStore} per instance by default; supply your
|
|
1445
|
+
* own to share or persist.
|
|
1446
|
+
*/
|
|
1447
|
+
interface ResponseCacheStore {
|
|
1448
|
+
get(key: CacheKey): MaybePromise<CacheEntry | undefined>;
|
|
1449
|
+
/**
|
|
1450
|
+
* Writes `entry` under `key` and returns the store-generated stamp the
|
|
1451
|
+
* resulting {@linkcode CacheEntry} carries. The store owns the stamp
|
|
1452
|
+
* counter; callers do not supply one. The caller owns `expiresAt` and
|
|
1453
|
+
* `scope` (the client-computed freshness metadata); the store MUST persist
|
|
1454
|
+
* them and hand them back on `get`.
|
|
1455
|
+
*/
|
|
1456
|
+
set(key: CacheKey, entry: {
|
|
1457
|
+
value: string;
|
|
1458
|
+
expiresAt?: number;
|
|
1459
|
+
scope?: CacheScope;
|
|
1460
|
+
}): MaybePromise<number>;
|
|
1461
|
+
/**
|
|
1462
|
+
* Drop the single entry under `key` (no-op if absent). Called for both
|
|
1463
|
+
* `notifications/resources/updated` (per-URI) and the `list_changed`
|
|
1464
|
+
* notifications (the list singletons live at `{method, params: '', partition}`).
|
|
1465
|
+
*/
|
|
1466
|
+
delete(key: CacheKey): MaybePromise<void>;
|
|
1467
|
+
/**
|
|
1468
|
+
* Drop every entry for `method` across every partition. The `Client` does
|
|
1469
|
+
* NOT call this (its `list_changed` path issues two partition-scoped
|
|
1470
|
+
* `delete()` calls so co-tenants on a shared store keep their entries);
|
|
1471
|
+
* kept on the interface for callers that want a method-wide bulk-clear.
|
|
1472
|
+
*/
|
|
1473
|
+
evict(method: string): MaybePromise<void>;
|
|
1474
|
+
/** Drop every entry (connection reset). */
|
|
1475
|
+
clear(): MaybePromise<void>;
|
|
1476
|
+
}
|
|
1477
|
+
/** Options for {@linkcode InMemoryResponseCacheStore}. */
|
|
1478
|
+
interface InMemoryResponseCacheStoreOptions {
|
|
1479
|
+
/**
|
|
1480
|
+
* Maximum number of held `resources/read` entries (the only
|
|
1481
|
+
* unbounded-keyspace method). When inserting a new `resources/read` key
|
|
1482
|
+
* would exceed this, the oldest such entry (by insertion order) is
|
|
1483
|
+
* evicted first. The list-singleton methods (`tools/list`,
|
|
1484
|
+
* `prompts/list`, `resources/list`, `resources/templates/list`,
|
|
1485
|
+
* `server/discover`) are **exempt** — they hold at most one entry per
|
|
1486
|
+
* partition and back the `tools/list`-derived index, so an unbounded URI
|
|
1487
|
+
* working set never displaces them. The default of `512` bounds growth on
|
|
1488
|
+
* a long-lived client against template-expanded URIs. `0` disables the
|
|
1489
|
+
* bound.
|
|
1490
|
+
*/
|
|
1491
|
+
maxEntries?: number;
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* In-memory default. Bounded by an insertion-ordered size cap (default `512`;
|
|
1495
|
+
* see {@linkcode InMemoryResponseCacheStoreOptions.maxEntries}) on the
|
|
1496
|
+
* `resources/read` keyspace so an unbounded stream of distinct URIs cannot
|
|
1497
|
+
* grow it without limit; the list-singleton methods are exempt and never
|
|
1498
|
+
* evicted by the cap. `Map` preserves insertion order, so the oldest live
|
|
1499
|
+
* capped key is the first matching iteration entry.
|
|
1500
|
+
*/
|
|
1501
|
+
declare class InMemoryResponseCacheStore implements ResponseCacheStore {
|
|
1502
|
+
private readonly _entries;
|
|
1503
|
+
private readonly _maxEntries;
|
|
1504
|
+
private _stamp;
|
|
1505
|
+
/** Count of held entries that are subject to the cap (i.e. not in {@linkcode CAP_EXEMPT_METHODS}). */
|
|
1506
|
+
private _cappedSize;
|
|
1507
|
+
constructor(options?: InMemoryResponseCacheStoreOptions);
|
|
1508
|
+
/** Number of held entries (for diagnostics / bounding tests). */
|
|
1509
|
+
get size(): number;
|
|
1510
|
+
get(key: CacheKey): CacheEntry | undefined;
|
|
1511
|
+
set(key: CacheKey, entry: {
|
|
1512
|
+
value: string;
|
|
1513
|
+
expiresAt?: number;
|
|
1514
|
+
scope?: CacheScope;
|
|
1515
|
+
}): number;
|
|
1516
|
+
delete(key: CacheKey): void;
|
|
1517
|
+
evict(method: string): void;
|
|
1518
|
+
clear(): void;
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* Upper bound on the server-supplied `ttlMs` honoured by
|
|
1522
|
+
* {@linkcode ClientResponseCache} (24h). A server cannot pin an entry
|
|
1523
|
+
* indefinitely.
|
|
1524
|
+
*/
|
|
1525
|
+
declare const MAX_CACHE_TTL_MS = 86400000;
|
|
1526
|
+
//#endregion
|
|
1527
|
+
//#region src/client/versionNegotiation.d.ts
|
|
1528
|
+
/**
|
|
1529
|
+
* Probe policy for `'auto'` and pinned negotiation modes.
|
|
1530
|
+
*
|
|
1531
|
+
* There is no special probe timeout opinion: the probe inherits the client's
|
|
1532
|
+
* STANDARD request timeout unless `timeoutMs` overrides it.
|
|
1533
|
+
*/
|
|
1534
|
+
interface VersionNegotiationProbeOptions {
|
|
1535
|
+
/**
|
|
1536
|
+
* Timeout for the probe exchange, in milliseconds.
|
|
1537
|
+
*
|
|
1538
|
+
* The timeout verdict is transport-aware: on stdio, a probe that gets no
|
|
1539
|
+
* response within the timeout indicates a legacy server and falls back to
|
|
1540
|
+
* the `initialize` handshake (measured on the disposable sibling for the
|
|
1541
|
+
* SDK's own stdio transport, with the fallback running on the session
|
|
1542
|
+
* child's fresh pipe; in place for custom stdio-shaped transports); on
|
|
1543
|
+
* HTTP, where a deployed server answers and silence means an outage,
|
|
1544
|
+
* `connect()` rejects with the standard typed timeout error instead.
|
|
1545
|
+
*
|
|
1546
|
+
* @default the standard request timeout (`DEFAULT_REQUEST_TIMEOUT_MSEC`, or the `timeout` passed to `connect()`)
|
|
1547
|
+
*/
|
|
1548
|
+
timeoutMs?: number;
|
|
1549
|
+
/**
|
|
1550
|
+
* Number of times to re-send the probe after a timeout before reaching the
|
|
1551
|
+
* timeout verdict. Governs timeout re-sends only — the spec-mandated
|
|
1552
|
+
* `-32022` corrective continuation (select-and-continue with a mutual
|
|
1553
|
+
* version) is a separate negotiation step and is never counted against
|
|
1554
|
+
* `maxRetries`.
|
|
1555
|
+
*
|
|
1556
|
+
* @default 0 (no retries)
|
|
1557
|
+
*/
|
|
1558
|
+
maxRetries?: number;
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Negotiation mode:
|
|
1562
|
+
*
|
|
1563
|
+
* - `'legacy'` — no negotiation: the plain 2025 connect sequence, byte-identical
|
|
1564
|
+
* to a client without this option.
|
|
1565
|
+
* - `'auto'` — probe with `server/discover` at connect; conservative fallback to
|
|
1566
|
+
* the plain legacy `initialize` handshake unless the outcome is definitive
|
|
1567
|
+
* modern evidence. Network outage rejects with a typed connect error; a
|
|
1568
|
+
* probe timeout falls back to `initialize` on stdio (a silent server on a
|
|
1569
|
+
* local pipe is a legacy server) and rejects with a typed timeout error on
|
|
1570
|
+
* HTTP (silence there is an outage). On the SDK's stdio transport (the base
|
|
1571
|
+
* `StdioClientTransport` exactly; subclasses probe in place) the probe
|
|
1572
|
+
* runs on a short-lived sibling process spawned from the same parameters
|
|
1573
|
+
* (its stderr is discarded) and the caller's transport starts once, after
|
|
1574
|
+
* the era is known — so a child that exits on the unrecognized probe, the
|
|
1575
|
+
* shape of servers built on SDKs that terminate on any pre-`initialize`
|
|
1576
|
+
* request, is simply a legacy server. A mid-probe connection close on HTTP
|
|
1577
|
+
* (or on a custom stdio-shaped transport, which probes in place) rejects
|
|
1578
|
+
* with the typed connect error.
|
|
1579
|
+
* - `{ pin: '<version>' }` — modern era at exactly the pinned revision: the
|
|
1580
|
+
* connect-time `server/discover` must offer it. No fallback — anything else
|
|
1581
|
+
* fails loudly with a typed error.
|
|
1582
|
+
*/
|
|
1583
|
+
type VersionNegotiationMode = 'legacy' | 'auto' | {
|
|
1584
|
+
pin: string;
|
|
1585
|
+
};
|
|
1586
|
+
/**
|
|
1587
|
+
* Opt-in protocol version negotiation, configured on
|
|
1588
|
+
* `ClientOptions.versionNegotiation`.
|
|
1589
|
+
*/
|
|
1590
|
+
interface VersionNegotiationOptions {
|
|
1591
|
+
/**
|
|
1592
|
+
* @default 'legacy'
|
|
1593
|
+
*/
|
|
1594
|
+
mode?: VersionNegotiationMode;
|
|
1595
|
+
/**
|
|
1596
|
+
* Probe timeout/retry policy (only consulted by the probing modes).
|
|
1597
|
+
*/
|
|
1598
|
+
probe?: VersionNegotiationProbeOptions;
|
|
1599
|
+
}
|
|
1600
|
+
//#endregion
|
|
1601
|
+
//#region src/client/client.d.ts
|
|
1602
|
+
/**
|
|
1603
|
+
* Determines which elicitation modes are supported based on declared client capabilities.
|
|
1604
|
+
*
|
|
1605
|
+
* According to the spec:
|
|
1606
|
+
* - An empty elicitation capability object defaults to form mode support (backwards compatibility)
|
|
1607
|
+
* - URL mode is only supported if explicitly declared
|
|
1608
|
+
*
|
|
1609
|
+
* @param capabilities - The client's elicitation capabilities
|
|
1610
|
+
* @returns An object indicating which modes are supported
|
|
1611
|
+
*/
|
|
1612
|
+
declare function getSupportedElicitationModes(capabilities: ClientCapabilities['elicitation']): {
|
|
1613
|
+
supportsFormMode: boolean;
|
|
1614
|
+
supportsUrlMode: boolean;
|
|
1615
|
+
};
|
|
1616
|
+
type ClientOptions = ProtocolOptions & {
|
|
1617
|
+
/**
|
|
1618
|
+
* Capabilities to advertise as being supported by this client.
|
|
1619
|
+
*/
|
|
1620
|
+
capabilities?: ClientCapabilities;
|
|
1621
|
+
/**
|
|
1622
|
+
* JSON Schema validator for tool output validation.
|
|
1623
|
+
*
|
|
1624
|
+
* The validator is used to validate structured content returned by tools
|
|
1625
|
+
* against their declared output schemas.
|
|
1626
|
+
*
|
|
1627
|
+
* @default Runtime-selected validator (AJV-backed on Node.js, `@cfworker/json-schema`-backed on browser/workerd runtimes)
|
|
1628
|
+
*/
|
|
1629
|
+
jsonSchemaValidator?: jsonSchemaValidator;
|
|
1630
|
+
/**
|
|
1631
|
+
* Opt-in protocol version negotiation (protocol revision 2026-07-28 and later).
|
|
1632
|
+
*
|
|
1633
|
+
* **The default is `'legacy'`**: absent (or `mode: 'legacy'`), `connect()`
|
|
1634
|
+
* runs the plain 2025 sequence, byte-identical to today's behavior (no
|
|
1635
|
+
* probe, no new headers). Opt into `'auto'` or pin to talk to a 2026-07-28
|
|
1636
|
+
* server.
|
|
1637
|
+
*
|
|
1638
|
+
* - `mode: 'auto'` — `connect()` probes the server with `server/discover` first:
|
|
1639
|
+
* definitive modern evidence selects the modern era; definitive legacy signals
|
|
1640
|
+
* (and anything unrecognized) fall back to the plain legacy `initialize`
|
|
1641
|
+
* handshake, byte-equivalent to a 2025 client. On the SDK's own stdio
|
|
1642
|
+
* transport (the base `StdioClientTransport` exactly; subclasses probe in
|
|
1643
|
+
* place) the probe runs on a short-lived sibling process spawned from the
|
|
1644
|
+
* same parameters (one extra spawn per connect; its stderr is discarded) and
|
|
1645
|
+
* the caller's transport starts once, after the era is known; HTTP — and
|
|
1646
|
+
* custom or subclassed stdio-shaped transports — probe on the connection itself. A
|
|
1647
|
+
* network outage rejects with a typed connect error. A probe timeout is
|
|
1648
|
+
* transport-aware: on stdio it indicates a legacy server (some legacy servers
|
|
1649
|
+
* never answer unknown pre-`initialize` requests) and falls back to
|
|
1650
|
+
* `initialize`; on HTTP it rejects with a typed timeout
|
|
1651
|
+
* error (silence on a deployed server is an outage, not a legacy signal).
|
|
1652
|
+
* - `mode: { pin: '2026-07-28' }` — modern era at exactly the pinned revision;
|
|
1653
|
+
* no probe-and-fallback: anything else fails loudly.
|
|
1654
|
+
*
|
|
1655
|
+
* Probe policy lives under `probe: { timeoutMs?, maxRetries? }`; the probe
|
|
1656
|
+
* inherits the client's standard request timeout unless overridden, and
|
|
1657
|
+
* `maxRetries` (default `0`) governs timeout re-sends only — the
|
|
1658
|
+
* spec-mandated `-32022` corrective continuation is never counted against it.
|
|
1659
|
+
*
|
|
1660
|
+
* Once a modern era is negotiated, the client automatically attaches the
|
|
1661
|
+
* per-request `_meta` envelope (the reserved protocol-version / client-info /
|
|
1662
|
+
* client-capabilities keys) to every outgoing request and notification;
|
|
1663
|
+
* user-supplied `_meta` keys take precedence over the auto-attached ones.
|
|
1664
|
+
*/
|
|
1665
|
+
versionNegotiation?: VersionNegotiationOptions;
|
|
1666
|
+
/**
|
|
1667
|
+
* Multi-round-trip auto-fulfilment (protocol revision 2026-07-28).
|
|
1668
|
+
*
|
|
1669
|
+
* On the 2026-07-28 era, servers obtain client input (elicitation,
|
|
1670
|
+
* sampling, roots) by answering `tools/call`, `prompts/get`, or
|
|
1671
|
+
* `resources/read` with an `input_required` result instead of sending a
|
|
1672
|
+
* server→client request. By default the client fulfils those embedded
|
|
1673
|
+
* requests automatically through the SAME handlers registered via
|
|
1674
|
+
* {@linkcode Client.setRequestHandler | setRequestHandler} (e.g.
|
|
1675
|
+
* `elicitation/create`), then retries the original call with the
|
|
1676
|
+
* collected `inputResponses` and a byte-exact echo of the opaque
|
|
1677
|
+
* `requestState`, on a fresh request id, up to `maxRounds` rounds.
|
|
1678
|
+
* `client.callTool()` (and its siblings) keep returning their plain
|
|
1679
|
+
* result type — the interactive rounds happen inside the call.
|
|
1680
|
+
*
|
|
1681
|
+
* Set `autoFulfill: false` for manual mode: an `input_required` response
|
|
1682
|
+
* then surfaces as a typed error unless the individual call passes
|
|
1683
|
+
* `allowInputRequired: true` (pair it with `withInputRequired()` on the
|
|
1684
|
+
* explicit-schema path to type both outcomes).
|
|
1685
|
+
*
|
|
1686
|
+
* Has no effect on 2025-era connections, which have no `input_required`
|
|
1687
|
+
* vocabulary.
|
|
1688
|
+
*/
|
|
1689
|
+
inputRequired?: InputRequiredOptions;
|
|
1690
|
+
/**
|
|
1691
|
+
* Configure handlers for list changed notifications (tools, prompts, resources).
|
|
1692
|
+
*
|
|
1693
|
+
* @example
|
|
1694
|
+
* ```ts source="./client.examples.ts#ClientOptions_listChanged"
|
|
1695
|
+
* const client = new Client(
|
|
1696
|
+
* { name: 'my-client', version: '1.0.0' },
|
|
1697
|
+
* {
|
|
1698
|
+
* listChanged: {
|
|
1699
|
+
* tools: {
|
|
1700
|
+
* onChanged: (error, tools) => {
|
|
1701
|
+
* if (error) {
|
|
1702
|
+
* console.error('Failed to refresh tools:', error);
|
|
1703
|
+
* return;
|
|
1704
|
+
* }
|
|
1705
|
+
* console.log('Tools updated:', tools);
|
|
1706
|
+
* }
|
|
1707
|
+
* },
|
|
1708
|
+
* prompts: {
|
|
1709
|
+
* onChanged: (error, prompts) => console.log('Prompts updated:', prompts)
|
|
1710
|
+
* }
|
|
1711
|
+
* }
|
|
1712
|
+
* }
|
|
1713
|
+
* );
|
|
1714
|
+
* ```
|
|
1715
|
+
*/
|
|
1716
|
+
listChanged?: ListChangedHandlers;
|
|
1717
|
+
/**
|
|
1718
|
+
* Cap on the number of pages the auto-aggregating
|
|
1719
|
+
* {@linkcode Client.listTools | listTools()} /
|
|
1720
|
+
* {@linkcode Client.listPrompts | listPrompts()} /
|
|
1721
|
+
* {@linkcode Client.listResources | listResources()} /
|
|
1722
|
+
* {@linkcode Client.listResourceTemplates | listResourceTemplates()} walk
|
|
1723
|
+
* fetches before throwing (a defence against a server whose `nextCursor`
|
|
1724
|
+
* never converges). `0` disables the cap. Default: `64`. Applies only to
|
|
1725
|
+
* the no-argument auto-aggregate path; an explicit-`cursor` per-page call
|
|
1726
|
+
* is never capped.
|
|
1727
|
+
*/
|
|
1728
|
+
listMaxPages?: number;
|
|
1729
|
+
/**
|
|
1730
|
+
* The response-cache store backing the client's derived views (the cached
|
|
1731
|
+
* `tools/list` result that {@linkcode Client.callTool | callTool}'s output
|
|
1732
|
+
* validation and SEP-2243 header mirroring read) and the SEP-2549
|
|
1733
|
+
* cache-hint serving on the cacheable verbs. Defaults to a fresh
|
|
1734
|
+
* {@linkcode InMemoryResponseCacheStore} per client.
|
|
1735
|
+
*
|
|
1736
|
+
* Entries are automatically scoped by connected-server identity (derived
|
|
1737
|
+
* from `serverInfo` after connect) AND, for `'private'`-scoped results,
|
|
1738
|
+
* by `cachePartition` — encoded collision-free via `JSON.stringify`, so a
|
|
1739
|
+
* server cannot craft a `serverInfo` that bleeds into another server's
|
|
1740
|
+
* namespace or another principal's slot. One store may therefore back
|
|
1741
|
+
* several clients (e.g. a host pool against the same server, or one
|
|
1742
|
+
* persistent KV across servers); `list_changed` evictions are scoped to
|
|
1743
|
+
* the connected server's partitions, so co-tenants are unaffected. Set
|
|
1744
|
+
* `cachePartition` to your principal identifier (e.g. the auth subject)
|
|
1745
|
+
* when sharing across principals. Note `serverInfo` is self-reported — a
|
|
1746
|
+
* server that deliberately impersonates
|
|
1747
|
+
* another's `name`/`version` shares its `'public'` slot; the
|
|
1748
|
+
* per-principal isolation via `cachePartition` holds regardless.
|
|
1749
|
+
*/
|
|
1750
|
+
responseCacheStore?: ResponseCacheStore;
|
|
1751
|
+
/**
|
|
1752
|
+
* Opaque per-principal identifier for response-cache writes whose
|
|
1753
|
+
* server-reported `cacheScope` is `'private'` (the spec's "MUST NOT share
|
|
1754
|
+
* across authorization contexts"). Within the connected server's
|
|
1755
|
+
* namespace, `'public'`-scoped entries live at the shared
|
|
1756
|
+
* `[serverIdentity, '']` partition and `'private'`-scoped entries at
|
|
1757
|
+
* `[serverIdentity, cachePartition]`. Set this to a stable identity of
|
|
1758
|
+
* the authorization context (e.g. the auth subject) when one
|
|
1759
|
+
* `responseCacheStore` backs several principals; with the
|
|
1760
|
+
* default `''` every entry — public or private — lives at the server's
|
|
1761
|
+
* shared partition, which is the safe single-tenant posture.
|
|
1762
|
+
*/
|
|
1763
|
+
cachePartition?: string;
|
|
1764
|
+
/**
|
|
1765
|
+
* TTL (ms) applied when a cacheable result arrives without a `ttlMs`
|
|
1766
|
+
* field. Default `0` — a result without an explicit hint is never served
|
|
1767
|
+
* from cache (every call refetches), but it is still **stored** so the
|
|
1768
|
+
* `tools/list`-derived index that {@linkcode Client.callTool | callTool}'s
|
|
1769
|
+
* SEP-2243 mirroring and output-schema validation read keeps working
|
|
1770
|
+
* regardless. The spec defines absent-or-≤0 as "immediately stale".
|
|
1771
|
+
*/
|
|
1772
|
+
defaultCacheTtlMs?: number;
|
|
1773
|
+
};
|
|
1774
|
+
/**
|
|
1775
|
+
* Options for {@linkcode Client.connect}. Extends {@linkcode RequestOptions}
|
|
1776
|
+
* (the timeout/signal apply to the connect-time handshake or probe) with the
|
|
1777
|
+
* cached-era-verdict knob.
|
|
1778
|
+
*/
|
|
1779
|
+
type ConnectOptions = RequestOptions & {
|
|
1780
|
+
/**
|
|
1781
|
+
* A cached era verdict, taking precedence over `versionNegotiation`:
|
|
1782
|
+
* `{ kind: 'modern', discover }` adopts a prior {@linkcode DiscoverResult}
|
|
1783
|
+
* with zero round trips (throws `SdkError(EraNegotiationFailed)` on no
|
|
1784
|
+
* 2026-07-28+ overlap); `{ kind: 'legacy' }` skips the probe and runs the
|
|
1785
|
+
* plain legacy `initialize` handshake. Freshness is the supplying host's
|
|
1786
|
+
* responsibility — see {@linkcode PriorDiscovery}. Reuse only within one
|
|
1787
|
+
* authorization context.
|
|
1788
|
+
*/
|
|
1789
|
+
prior?: PriorDiscovery;
|
|
1790
|
+
};
|
|
1791
|
+
/**
|
|
1792
|
+
* {@linkcode RequestOptions} extended with the per-call cache disposition for
|
|
1793
|
+
* the cacheable verbs (`listTools()` / `listPrompts()` / `listResources()` /
|
|
1794
|
+
* `listResourceTemplates()` / `readResource()`). See {@linkcode CacheMode}.
|
|
1795
|
+
*/
|
|
1796
|
+
type CacheableRequestOptions = RequestOptions & {
|
|
1797
|
+
/**
|
|
1798
|
+
* `'use'` (default) serves a still-fresh cached entry without a round
|
|
1799
|
+
* trip; `'refresh'` always fetches and re-stores; `'bypass'` fetches
|
|
1800
|
+
* without consulting or writing the cache. Applies to the no-`cursor`
|
|
1801
|
+
* auto-aggregate path on the list verbs and to `readResource`; ignored
|
|
1802
|
+
* elsewhere.
|
|
1803
|
+
*/
|
|
1804
|
+
cacheMode?: CacheMode;
|
|
1805
|
+
};
|
|
1806
|
+
/**
|
|
1807
|
+
* Options for {@linkcode Client.callTool}. Extends {@linkcode RequestOptions}
|
|
1808
|
+
* with an escape hatch for callers that already hold the tool definition
|
|
1809
|
+
* (e.g. from a previous session or configuration) — pass it via
|
|
1810
|
+
* `toolDefinition` so SEP-2243 `Mcp-Param-*` header mirroring can run without a
|
|
1811
|
+
* prior `tools/list`.
|
|
1812
|
+
*/
|
|
1813
|
+
type CallToolRequestOptions = RequestOptions & {
|
|
1814
|
+
/**
|
|
1815
|
+
* The tool definition to use for SEP-2243 `Mcp-Param-*` header mirroring on
|
|
1816
|
+
* a 2026-07-28 connection over Streamable HTTP, AND for output-schema
|
|
1817
|
+
* validation of the result. When set, the client uses this definition's
|
|
1818
|
+
* `inputSchema` and `outputSchema` instead of (and without consulting) the
|
|
1819
|
+
* cached `tools/list` result, so the two derived views agree.
|
|
1820
|
+
*/
|
|
1821
|
+
toolDefinition?: Tool;
|
|
1822
|
+
};
|
|
1823
|
+
/**
|
|
1824
|
+
* A handle to an open `subscriptions/listen` stream (protocol revision
|
|
1825
|
+
* 2026-07-28). Change notifications delivered on the stream dispatch to the
|
|
1826
|
+
* existing {@linkcode Client.setNotificationHandler} registrations.
|
|
1827
|
+
*/
|
|
1828
|
+
interface McpSubscription {
|
|
1829
|
+
/**
|
|
1830
|
+
* The subset of the requested filter the server agreed to honor (from
|
|
1831
|
+
* `notifications/subscriptions/acknowledged`).
|
|
1832
|
+
*/
|
|
1833
|
+
readonly honoredFilter: SubscriptionFilter;
|
|
1834
|
+
/**
|
|
1835
|
+
* Tears the subscription down. Idempotent. Aborts the listen request's
|
|
1836
|
+
* stream (where the transport supports it) AND sends
|
|
1837
|
+
* `notifications/cancelled` referencing the listen request id — both,
|
|
1838
|
+
* always, so close works on any transport.
|
|
1839
|
+
*/
|
|
1840
|
+
close(): Promise<void>;
|
|
1841
|
+
/**
|
|
1842
|
+
* Resolves exactly once when the subscription has terminated. Never
|
|
1843
|
+
* rejects — this is an observation, not an operation.
|
|
1844
|
+
*
|
|
1845
|
+
* - `'local'` — you called {@linkcode close} (or aborted the
|
|
1846
|
+
* `RequestOptions.signal` you passed to `listen()`).
|
|
1847
|
+
* - `'graceful'` — the server ended the subscription deliberately by
|
|
1848
|
+
* sending the empty `subscriptions/listen` response (e.g. on shutdown).
|
|
1849
|
+
* - `'remote'` — the stream ended without a response, or the transport
|
|
1850
|
+
* dropped — an unexpected disconnect. Re-listen if you still want
|
|
1851
|
+
* events.
|
|
1852
|
+
*/
|
|
1853
|
+
readonly closed: Promise<'local' | 'graceful' | 'remote'>;
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* An MCP client on top of a pluggable transport.
|
|
1857
|
+
*
|
|
1858
|
+
* The client will automatically begin the initialization flow with the server when {@linkcode connect} is called.
|
|
1859
|
+
*
|
|
1860
|
+
* To handle server-initiated requests (sampling, elicitation, roots), call {@linkcode setRequestHandler}.
|
|
1861
|
+
* The client must declare the corresponding capability for the handler to be accepted. For
|
|
1862
|
+
* `sampling/createMessage` and `elicitation/create`, the handler is automatically wrapped with
|
|
1863
|
+
* schema validation for both the incoming request and the returned result.
|
|
1864
|
+
*
|
|
1865
|
+
* Note: the `roots/list` and `sampling/createMessage` handler surfaces (and the corresponding
|
|
1866
|
+
* `roots` and `sampling` capabilities) are deprecated as of protocol version 2026-07-28
|
|
1867
|
+
* (SEP-2577). They remain functional during the deprecation window (at least twelve months).
|
|
1868
|
+
* Migrate sampling to calling LLM provider APIs directly, and roots to passing paths via tool
|
|
1869
|
+
* parameters, resource URIs, or configuration.
|
|
1870
|
+
*
|
|
1871
|
+
* @example Handling a sampling request
|
|
1872
|
+
* ```ts source="./client.examples.ts#Client_setRequestHandler_sampling"
|
|
1873
|
+
* client.setRequestHandler('sampling/createMessage', async request => {
|
|
1874
|
+
* const lastMessage = request.params.messages.at(-1);
|
|
1875
|
+
* console.log('Sampling request:', lastMessage);
|
|
1876
|
+
*
|
|
1877
|
+
* // In production, send messages to your LLM here
|
|
1878
|
+
* return {
|
|
1879
|
+
* model: 'my-model',
|
|
1880
|
+
* role: 'assistant' as const,
|
|
1881
|
+
* content: {
|
|
1882
|
+
* type: 'text' as const,
|
|
1883
|
+
* text: 'Response from the model'
|
|
1884
|
+
* }
|
|
1885
|
+
* };
|
|
1886
|
+
* });
|
|
1887
|
+
* ```
|
|
1888
|
+
*/
|
|
1889
|
+
declare class Client extends Protocol<ClientContext> {
|
|
1890
|
+
private _clientInfo;
|
|
1891
|
+
private _serverCapabilities?;
|
|
1892
|
+
private _serverVersion?;
|
|
1893
|
+
private _capabilities;
|
|
1894
|
+
private _instructions?;
|
|
1895
|
+
private _jsonSchemaValidator;
|
|
1896
|
+
/**
|
|
1897
|
+
* The response-cache substrate. Owns the backing store, the per-method
|
|
1898
|
+
* eviction-generation counter, the user-supplied/default flag, and the
|
|
1899
|
+
* stamp-memoized derived `name → Tool` / `name → output-validator`
|
|
1900
|
+
* indices — the cache-coordination state that used to live as separate
|
|
1901
|
+
* private fields here. The internal aggregating walk writes one entry per
|
|
1902
|
+
* list verb; `list_changed` evicts the matching method;
|
|
1903
|
+
* `_resetConnectionState` resets the lot. {@linkcode callTool}'s
|
|
1904
|
+
* output-schema validation reads the derived `outputValidator` index (the
|
|
1905
|
+
* substrate's first production caller); the stacked SEP-2243 PR wires
|
|
1906
|
+
* `Mcp-Param-*` mirroring through `toolDefinition` on top.
|
|
1907
|
+
*/
|
|
1908
|
+
private readonly _cache;
|
|
1909
|
+
private readonly _defaultCacheTtlMs;
|
|
1910
|
+
private readonly _listMaxPages;
|
|
1911
|
+
private _listChangedDebounceTimers;
|
|
1912
|
+
/**
|
|
1913
|
+
* The constructor `listChanged` configuration. Durable across reconnects:
|
|
1914
|
+
* read fresh on every connect (legacy or modern), never consumed.
|
|
1915
|
+
*/
|
|
1916
|
+
private readonly _listChangedConfig?;
|
|
1917
|
+
private _enforceStrictCapabilities;
|
|
1918
|
+
private _versionNegotiation?;
|
|
1919
|
+
private _supportedProtocolVersionsOption?;
|
|
1920
|
+
private _inputRequiredDriverConfig;
|
|
1921
|
+
/**
|
|
1922
|
+
* Active subscriptions/listen state, keyed by subscription id (= the
|
|
1923
|
+
* listen request's JSON-RPC id verbatim). The id is a STRING from a
|
|
1924
|
+
* Client-owned counter (`'listen:' + N`) — JSON-RPC permits string ids,
|
|
1925
|
+
* and Protocol's numeric `_requestMessageId` counter only ever issues
|
|
1926
|
+
* numbers, so listen ids cannot collide with ordinary request ids.
|
|
1927
|
+
*/
|
|
1928
|
+
private _listenState;
|
|
1929
|
+
private _nextListenId;
|
|
1930
|
+
/** The auto-opened subscription backing ClientOptions.listChanged on a modern connection. */
|
|
1931
|
+
private _autoOpenedSubscription?;
|
|
1932
|
+
/** Backing store for {@linkcode getDiscoverResult}. Per-connection. */
|
|
1933
|
+
private _discoverResult?;
|
|
1934
|
+
/**
|
|
1935
|
+
* Clears every per-connection field in one place. Called at the start of
|
|
1936
|
+
* each fresh (non-resuming) connect and from `close()`, so a stale
|
|
1937
|
+
* negotiated era / server identity / auto-opened subscription cannot
|
|
1938
|
+
* survive a reconnect.
|
|
1939
|
+
*/
|
|
1940
|
+
private _resetConnectionState;
|
|
1941
|
+
close(): Promise<void>;
|
|
1942
|
+
/**
|
|
1943
|
+
* Initializes this client with the given name and version information.
|
|
1944
|
+
*/
|
|
1945
|
+
constructor(_clientInfo: Implementation, options?: ClientOptions);
|
|
1946
|
+
protected buildContext(ctx: BaseContext, _transportInfo?: MessageExtraInfo): ClientContext;
|
|
1947
|
+
/**
|
|
1948
|
+
* Era-keyed direction enforcement for inbound traffic on channels whose
|
|
1949
|
+
* transport does not classify (e.g. stdio): the 2026-07-28 era has no
|
|
1950
|
+
* server→client JSON-RPC request channel — server-to-client interactions
|
|
1951
|
+
* are carried in-band in `input_required` results — and on stdio the
|
|
1952
|
+
* client must never write JSON-RPC responses. An inbound request arriving
|
|
1953
|
+
* on a connection that negotiated a modern era is therefore dropped
|
|
1954
|
+
* (surfaced via `onerror`) rather than answered. Connections on a legacy
|
|
1955
|
+
* era — and all responses and notifications — keep today's dispatch path.
|
|
1956
|
+
*/
|
|
1957
|
+
protected _shouldDropInbound(message: JSONRPCRequest | JSONRPCNotification): 'drop' | undefined;
|
|
1958
|
+
/**
|
|
1959
|
+
* Per-request `_meta` envelope auto-emission (protocol revision 2026-07-28):
|
|
1960
|
+
* on a connection that negotiated a modern era — auto-negotiated or pinned —
|
|
1961
|
+
* every outgoing request and notification automatically carries the reserved
|
|
1962
|
+
* protocol-version / client-info / client-capabilities `_meta` keys (the
|
|
1963
|
+
* same envelope the connect-time `server/discover` probe sends).
|
|
1964
|
+
* User-supplied `_meta` keys take precedence over the auto-attached ones.
|
|
1965
|
+
*
|
|
1966
|
+
* Legacy-era connections return `undefined`: the envelope seam is a no-op
|
|
1967
|
+
* and outbound traffic is byte-identical to a 2025 client (the legacy
|
|
1968
|
+
* `'auto'` fallback included).
|
|
1969
|
+
*/
|
|
1970
|
+
protected _outboundMetaEnvelope(): Readonly<Record<string, unknown>> | undefined;
|
|
1971
|
+
/**
|
|
1972
|
+
* Wires the multi-round-trip auto-fulfilment engine (protocol revision
|
|
1973
|
+
* 2026-07-28) into the response funnel: an `input_required` answer is
|
|
1974
|
+
* fulfilled through the registered elicitation/sampling/roots handlers
|
|
1975
|
+
* and the original request retried via `flow.retry`, up to
|
|
1976
|
+
* `inputRequired.maxRounds` rounds. With auto-fulfilment disabled the
|
|
1977
|
+
* response surfaces as a typed error steering to manual mode.
|
|
1978
|
+
*/
|
|
1979
|
+
protected _resolveNonCompleteResult<T extends StandardSchemaV1>(decoded: {
|
|
1980
|
+
kind: 'input_required';
|
|
1981
|
+
inputRequests: Record<string, unknown>;
|
|
1982
|
+
requestState?: string;
|
|
1983
|
+
}, flow: NonCompleteResultFlow<T>): Promise<unknown>;
|
|
1984
|
+
/**
|
|
1985
|
+
* Set up handlers for list changed notifications based on config and server capabilities.
|
|
1986
|
+
* This should only be called after initialization when server capabilities are known.
|
|
1987
|
+
* Handlers are silently skipped if the server doesn't advertise the corresponding listChanged capability.
|
|
1988
|
+
* @internal
|
|
1989
|
+
*/
|
|
1990
|
+
private _setupListChangedHandlers;
|
|
1991
|
+
/**
|
|
1992
|
+
* Registers new capabilities. This can only be called before connecting to a transport.
|
|
1993
|
+
*
|
|
1994
|
+
* The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
|
|
1995
|
+
*/
|
|
1996
|
+
registerCapabilities(capabilities: ClientCapabilities): void;
|
|
1997
|
+
/**
|
|
1998
|
+
* Configure protocol version negotiation before connecting (equivalent to
|
|
1999
|
+
* passing `versionNegotiation` at construction time). Can only be called
|
|
2000
|
+
* before connecting to a transport. Passing `undefined` clears a previously
|
|
2001
|
+
* configured negotiation, restoring the default `'legacy'` posture.
|
|
2002
|
+
*
|
|
2003
|
+
* See {@linkcode ClientOptions | ClientOptions.versionNegotiation} for the mode semantics.
|
|
2004
|
+
*/
|
|
2005
|
+
setVersionNegotiation(options: VersionNegotiationOptions | undefined): void;
|
|
2006
|
+
/**
|
|
2007
|
+
* Enforces client-side validation for `elicitation/create` and `sampling/createMessage`
|
|
2008
|
+
* regardless of how the handler was registered.
|
|
2009
|
+
*/
|
|
2010
|
+
protected _wrapHandler(method: string, handler: (request: JSONRPCRequest, ctx: ClientContext) => Promise<Result>): (request: JSONRPCRequest, ctx: ClientContext) => Promise<Result>;
|
|
2011
|
+
protected assertCapability(capability: keyof ServerCapabilities, method: string): void;
|
|
2012
|
+
/**
|
|
2013
|
+
* Connects to a server via the given transport and performs the MCP initialization handshake.
|
|
2014
|
+
*
|
|
2015
|
+
* @example Basic usage (stdio)
|
|
2016
|
+
* ```ts source="./client.examples.ts#Client_connect_stdio"
|
|
2017
|
+
* const client = new Client({ name: 'my-client', version: '1.0.0' });
|
|
2018
|
+
* const transport = new StdioClientTransport({ command: 'my-mcp-server' });
|
|
2019
|
+
* await client.connect(transport);
|
|
2020
|
+
* ```
|
|
2021
|
+
*
|
|
2022
|
+
* @example Streamable HTTP with SSE fallback
|
|
2023
|
+
* ```ts source="./client.examples.ts#Client_connect_sseFallback"
|
|
2024
|
+
* const baseUrl = new URL(url);
|
|
2025
|
+
*
|
|
2026
|
+
* try {
|
|
2027
|
+
* // Try modern Streamable HTTP transport first
|
|
2028
|
+
* const client = new Client({ name: 'my-client', version: '1.0.0' });
|
|
2029
|
+
* const transport = new StreamableHTTPClientTransport(baseUrl);
|
|
2030
|
+
* await client.connect(transport);
|
|
2031
|
+
* return { client, transport };
|
|
2032
|
+
* } catch {
|
|
2033
|
+
* // Fall back to legacy SSE transport
|
|
2034
|
+
* const client = new Client({ name: 'my-client', version: '1.0.0' });
|
|
2035
|
+
* const transport = new SSEClientTransport(baseUrl);
|
|
2036
|
+
* await client.connect(transport);
|
|
2037
|
+
* return { client, transport };
|
|
2038
|
+
* }
|
|
2039
|
+
* ```
|
|
2040
|
+
*/
|
|
2041
|
+
connect(transport: Transport, options?: ConnectOptions): Promise<void>;
|
|
2042
|
+
/**
|
|
2043
|
+
* Plain legacy connect — the pinned 2025 sequence, byte-untouched. The
|
|
2044
|
+
* `mode: 'legacy'` connect body, shared with the `prior` legacy verdict.
|
|
2045
|
+
*/
|
|
2046
|
+
private _connectPlainLegacy;
|
|
2047
|
+
/**
|
|
2048
|
+
* The 2025 `initialize` handshake — the body of the plain legacy connect and
|
|
2049
|
+
* the `'auto'`-mode fallback path (same `initialize` body, zero 2026 headers;
|
|
2050
|
+
* on the stdio sibling path it opens the session child's fresh pipe, in the
|
|
2051
|
+
* in-place modes it rides the probed connection). Callers clear the negotiated protocol version before
|
|
2052
|
+
* the handshake; its completion sets the negotiated (legacy) version.
|
|
2053
|
+
*/
|
|
2054
|
+
private _legacyHandshake;
|
|
2055
|
+
/**
|
|
2056
|
+
* Negotiated connect (mode `'auto'` or `{ pin }`): probe with `server/discover`
|
|
2057
|
+
* before the Protocol machinery attaches — on a disposable sibling process for
|
|
2058
|
+
* the SDK's stdio transport, in place otherwise — then either establish the
|
|
2059
|
+
* modern era or perform the plain legacy handshake.
|
|
2060
|
+
*/
|
|
2061
|
+
private _connectNegotiated;
|
|
2062
|
+
/**
|
|
2063
|
+
* Connect from a validated {@linkcode PriorDiscovery}: the modern arm
|
|
2064
|
+
* adopts the `DiscoverResult` (zero round trips; `EraNegotiationFailed`
|
|
2065
|
+
* on no 2026-07-28+ overlap), the legacy arm runs the plain legacy connect.
|
|
2066
|
+
*/
|
|
2067
|
+
private _connectFromPrior;
|
|
2068
|
+
/**
|
|
2069
|
+
* After initialization has completed, this will be populated with the server's reported capabilities.
|
|
2070
|
+
*/
|
|
2071
|
+
getServerCapabilities(): ServerCapabilities | undefined;
|
|
2072
|
+
/**
|
|
2073
|
+
* The connected server's self-reported name and version, when it
|
|
2074
|
+
* identified itself: required on the legacy `initialize` result; a spec
|
|
2075
|
+
* SHOULD in the discover result's `_meta` on 2026-07-28, so a successful
|
|
2076
|
+
* modern connect against an anonymous server leaves this `undefined`.
|
|
2077
|
+
*/
|
|
2078
|
+
getServerVersion(): Implementation | undefined;
|
|
2079
|
+
/**
|
|
2080
|
+
* The connected server's identity for response-cache partitioning. The
|
|
2081
|
+
* `serverInfo` `name@version` pair when available (required on
|
|
2082
|
+
* `initialize`; a SHOULD in the discover result's `_meta` since spec PR
|
|
2083
|
+
* #3002); falls back to the transport's `sessionId`, then to a
|
|
2084
|
+
* per-connection surrogate. The surrogate matters since #3002 made
|
|
2085
|
+
* identity optional: without it, two identity-less servers reached over
|
|
2086
|
+
* sessionId-less transports would share the cache's pre-connect `''`
|
|
2087
|
+
* partition and read each other's entries — no stable identity means no
|
|
2088
|
+
* cross-connection cache reuse. The value itself is server-controlled —
|
|
2089
|
+
* the collision-safety of the storage partition comes from
|
|
2090
|
+
* {@linkcode ClientResponseCache}'s JSON-array encoding around it, not
|
|
2091
|
+
* from any character it does or does not contain.
|
|
2092
|
+
*/
|
|
2093
|
+
private _deriveServerIdentity;
|
|
2094
|
+
/**
|
|
2095
|
+
* After initialization has completed, this will be populated with the protocol version negotiated
|
|
2096
|
+
* during the initialize handshake. When manually reconstructing a transport for reconnection, pass this
|
|
2097
|
+
* value to the new transport so it continues sending the required `mcp-protocol-version` header.
|
|
2098
|
+
*/
|
|
2099
|
+
getNegotiatedProtocolVersion(): string | undefined;
|
|
2100
|
+
/**
|
|
2101
|
+
* After initialization has completed, this returns the protocol era of the
|
|
2102
|
+
* connection: `'modern'` when the connection negotiated a 2026-07-28+
|
|
2103
|
+
* revision (via `server/discover`), `'legacy'` for the 2025-era
|
|
2104
|
+
* `initialize` handshake, or `undefined` before the connection is
|
|
2105
|
+
* established.
|
|
2106
|
+
*/
|
|
2107
|
+
getProtocolEra(): ProtocolEra | undefined;
|
|
2108
|
+
/**
|
|
2109
|
+
* After initialization has completed, this may be populated with information about the server's instructions.
|
|
2110
|
+
*/
|
|
2111
|
+
getInstructions(): string | undefined;
|
|
2112
|
+
/**
|
|
2113
|
+
* The {@linkcode DiscoverResult} from the last `'auto'`/pinned probe,
|
|
2114
|
+
* {@linkcode discover} call, or `connect({ prior })` that adopted a
|
|
2115
|
+
* modern verdict (a legacy verdict leaves this `undefined` — there is no
|
|
2116
|
+
* `DiscoverResult` on that path). Persistable via `JSON.stringify`; wrap
|
|
2117
|
+
* as `{ kind: 'modern', discover }` and feed to {@linkcode ConnectOptions}
|
|
2118
|
+
* `prior`.
|
|
2119
|
+
*/
|
|
2120
|
+
getDiscoverResult(): DiscoverResult | undefined;
|
|
2121
|
+
protected assertCapabilityForMethod(method: RequestMethod | string): void;
|
|
2122
|
+
protected assertNotificationCapability(method: NotificationMethod | string): void;
|
|
2123
|
+
protected assertRequestHandlerCapability(method: string): void;
|
|
2124
|
+
ping(options?: RequestOptions): Promise<EmptyResult>;
|
|
2125
|
+
/**
|
|
2126
|
+
* Send `server/discover` (2026-07-28+) and record the result for
|
|
2127
|
+
* {@linkcode getDiscoverResult}.
|
|
2128
|
+
*/
|
|
2129
|
+
discover(options?: RequestOptions): Promise<DiscoverResult>;
|
|
2130
|
+
/** Requests argument autocompletion suggestions from the server for a prompt or resource. */
|
|
2131
|
+
complete(params: CompleteRequest['params'], options?: RequestOptions): Promise<CompleteResult>;
|
|
2132
|
+
/**
|
|
2133
|
+
* Sets the minimum severity level for log messages sent by the server.
|
|
2134
|
+
*
|
|
2135
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
2136
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
2137
|
+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
|
|
2138
|
+
*/
|
|
2139
|
+
setLoggingLevel(level: LoggingLevel, options?: RequestOptions): Promise<EmptyResult>;
|
|
2140
|
+
/** Retrieves a prompt by name from the server, passing the given arguments for template substitution. */
|
|
2141
|
+
getPrompt(params: GetPromptRequest['params'], options?: RequestOptions): Promise<GetPromptResult>;
|
|
2142
|
+
/**
|
|
2143
|
+
* Lists available prompts.
|
|
2144
|
+
*
|
|
2145
|
+
* Called without a `cursor` (the common case), this walks every page and
|
|
2146
|
+
* returns the complete aggregated list with no `nextCursor`; the
|
|
2147
|
+
* aggregate is also written to the {@linkcode ResponseCacheStore}. Pass an
|
|
2148
|
+
* explicit `{ cursor }` to fetch a single page and walk pagination
|
|
2149
|
+
* yourself — the per-page path returns the server's raw page (with
|
|
2150
|
+
* `nextCursor` for the next call) and does not write the response cache.
|
|
2151
|
+
* The auto-aggregate path is capped by
|
|
2152
|
+
* {@linkcode ClientOptions | ClientOptions.listMaxPages} (default 64); the per-page path
|
|
2153
|
+
* is not.
|
|
2154
|
+
*
|
|
2155
|
+
* Returns an empty list if the server does not advertise prompts capability
|
|
2156
|
+
* (or throws if {@linkcode ClientOptions.enforceStrictCapabilities} is enabled).
|
|
2157
|
+
*
|
|
2158
|
+
* @example
|
|
2159
|
+
* ```ts source="./client.examples.ts#Client_listPrompts_pagination"
|
|
2160
|
+
* // No cursor → all pages aggregated for you.
|
|
2161
|
+
* const { prompts } = await client.listPrompts();
|
|
2162
|
+
* console.log(
|
|
2163
|
+
* 'Available prompts:',
|
|
2164
|
+
* prompts.map(p => p.name)
|
|
2165
|
+
* );
|
|
2166
|
+
* ```
|
|
2167
|
+
*/
|
|
2168
|
+
listPrompts(params?: ListPromptsRequest['params'], options?: CacheableRequestOptions): Promise<ListPromptsResult>;
|
|
2169
|
+
/**
|
|
2170
|
+
* Lists available resources.
|
|
2171
|
+
*
|
|
2172
|
+
* Called without a `cursor` (the common case), this walks every page and
|
|
2173
|
+
* returns the complete aggregated list with no `nextCursor`; the
|
|
2174
|
+
* aggregate is also written to the {@linkcode ResponseCacheStore}. Pass an
|
|
2175
|
+
* explicit `{ cursor }` to fetch a single page and walk pagination
|
|
2176
|
+
* yourself — the per-page path returns the server's raw page (with
|
|
2177
|
+
* `nextCursor` for the next call) and does not write the response cache.
|
|
2178
|
+
* The auto-aggregate path is capped by
|
|
2179
|
+
* {@linkcode ClientOptions | ClientOptions.listMaxPages} (default 64); the per-page path
|
|
2180
|
+
* is not.
|
|
2181
|
+
*
|
|
2182
|
+
* Returns an empty list if the server does not advertise resources capability
|
|
2183
|
+
* (or throws if {@linkcode ClientOptions.enforceStrictCapabilities} is enabled).
|
|
2184
|
+
*
|
|
2185
|
+
* @example
|
|
2186
|
+
* ```ts source="./client.examples.ts#Client_listResources_pagination"
|
|
2187
|
+
* // No cursor → all pages aggregated for you.
|
|
2188
|
+
* const { resources } = await client.listResources();
|
|
2189
|
+
* console.log(
|
|
2190
|
+
* 'Available resources:',
|
|
2191
|
+
* resources.map(r => r.name)
|
|
2192
|
+
* );
|
|
2193
|
+
* ```
|
|
2194
|
+
*/
|
|
2195
|
+
listResources(params?: ListResourcesRequest['params'], options?: CacheableRequestOptions): Promise<ListResourcesResult>;
|
|
2196
|
+
/**
|
|
2197
|
+
* Lists available resource URI templates for dynamic resources.
|
|
2198
|
+
*
|
|
2199
|
+
* Called without a `cursor`, this walks every page and returns the
|
|
2200
|
+
* complete aggregated list with no `nextCursor`; the aggregate is
|
|
2201
|
+
* also written to the {@linkcode ResponseCacheStore}. Pass an explicit
|
|
2202
|
+
* `{ cursor }` to fetch a single page — see
|
|
2203
|
+
* {@linkcode listResources | listResources()} for the per-page contract.
|
|
2204
|
+
*
|
|
2205
|
+
* Returns an empty list if the server does not advertise resources capability
|
|
2206
|
+
* (or throws if {@linkcode ClientOptions.enforceStrictCapabilities} is enabled).
|
|
2207
|
+
*/
|
|
2208
|
+
listResourceTemplates(params?: ListResourceTemplatesRequest['params'], options?: CacheableRequestOptions): Promise<ListResourceTemplatesResult>;
|
|
2209
|
+
/**
|
|
2210
|
+
* Walk every page of a paginated list verb, aggregate, and write ONE
|
|
2211
|
+
* entry to the response cache. Internal — backs the public `list*`
|
|
2212
|
+
* methods' no-`cursor` auto-aggregate path. Page 1's result object is
|
|
2213
|
+
* mutated in place (its items array is extended; `nextCursor` is
|
|
2214
|
+
* cleared); page-1 metadata (`ttlMs`, `cacheScope`, `_meta`) is preserved.
|
|
2215
|
+
* A `nextCursor` that repeats stops the walk (defence against a
|
|
2216
|
+
* non-converging server, mcp.d's `drainList` guard);
|
|
2217
|
+
* {@linkcode ClientOptions.listMaxPages} is a hard cap — hitting it
|
|
2218
|
+
* throws, so a partial aggregate is never cached. The
|
|
2219
|
+
* captured-generation guard skips the write when a `list_changed` landed
|
|
2220
|
+
* mid-walk, so the eviction is never overwritten by a stale aggregate.
|
|
2221
|
+
* `finalize` runs on the complete aggregate before the cache write — the
|
|
2222
|
+
* SEP-2243 invalid-`x-mcp-header` exclusion hooks here so the cached
|
|
2223
|
+
* `tools/list` entry is already filtered.
|
|
2224
|
+
*
|
|
2225
|
+
* The caller's `baseParams` (everything except `cursor`) is threaded into
|
|
2226
|
+
* every page request — page 1 sends `{...baseParams}`, later pages
|
|
2227
|
+
* `{...baseParams, cursor}` — so a typed, documented `_meta` (e.g. W3C
|
|
2228
|
+
* trace context) supplied to the public `list*()` reaches every wire
|
|
2229
|
+
* request the walk issues.
|
|
2230
|
+
*/
|
|
2231
|
+
private _listAllPages;
|
|
2232
|
+
/**
|
|
2233
|
+
* Compute the {@linkcode ClientResponseCache.write} freshness payload from
|
|
2234
|
+
* a cacheable result body. The single seam through which the client reads
|
|
2235
|
+
* `ttlMs`/`cacheScope` (mcp.d's `cachedFetch` engine). The fields pass
|
|
2236
|
+
* through the loose result schema, so they are read off the runtime body;
|
|
2237
|
+
* a missing `ttlMs` falls back to
|
|
2238
|
+
* {@linkcode ClientOptions | ClientOptions.defaultCacheTtlMs}; an explicit server-sent
|
|
2239
|
+
* `ttlMs` (including `0` — the spec's "immediately stale") is honoured
|
|
2240
|
+
* as-is. The default of `0` means `expiresAt === now()` ⇒ never served,
|
|
2241
|
+
* only stored. A missing `cacheScope` is treated as `'private'` — the
|
|
2242
|
+
* spec's `'public'` grant ("any client … MAY serve to any user") is too
|
|
2243
|
+
* strong to infer by default, and matches this SDK's server-side stamp
|
|
2244
|
+
* default.
|
|
2245
|
+
*/
|
|
2246
|
+
private _freshness;
|
|
2247
|
+
/**
|
|
2248
|
+
* The cache-serving front of every cacheable verb (mcp.d's `cachedFetch`
|
|
2249
|
+
* read half): under `cacheMode: 'use'` (the default), a fresh held entry
|
|
2250
|
+
* is served and the round trip is skipped. `'refresh'` and `'bypass'`
|
|
2251
|
+
* always fetch (the caller decides whether to write). Freshness and
|
|
2252
|
+
* decoding live in {@linkcode ClientResponseCache.read}; every hit is
|
|
2253
|
+
* freshly parsed, so the caller owns it outright. A custom store
|
|
2254
|
+
* whose `get()` rejects is routed to `onerror` and treated as a miss —
|
|
2255
|
+
* cache bookkeeping never blocks a request from reaching the wire.
|
|
2256
|
+
*/
|
|
2257
|
+
private _serveFromCache;
|
|
2258
|
+
/** Route a custom-store failure to `onerror` without aborting the surrounding dispatch. */
|
|
2259
|
+
private _reportStoreError;
|
|
2260
|
+
/**
|
|
2261
|
+
* Compile a single tool's `outputSchema`. Passed as the compile callback to
|
|
2262
|
+
* {@linkcode ClientResponseCache.outputValidator} so the cache class stays
|
|
2263
|
+
* free of any validator-provider dependency, and called directly for the
|
|
2264
|
+
* `options.toolDefinition` path of {@linkcode callTool} (a one-off
|
|
2265
|
+
* caller-supplied definition is compiled in isolation and never enters the
|
|
2266
|
+
* cache, so it cannot poison the listed tool of the same name).
|
|
2267
|
+
*
|
|
2268
|
+
* Returns `undefined` when the tool has no `outputSchema`, or a
|
|
2269
|
+
* discriminated `{ok}` result otherwise. SEP-2106: ANY throw from the
|
|
2270
|
+
* validator engine — unsupported `$schema` dialect, invalid `pattern`
|
|
2271
|
+
* regex, unresolvable `$ref`, or any other engine error — is captured as
|
|
2272
|
+
* `{ok: false, compileError}` so one bad schema does not poison the rest
|
|
2273
|
+
* of the listing; `callTool()` surfaces it as an `InvalidParams` error
|
|
2274
|
+
* before the request. The `{ok}` discriminator (not
|
|
2275
|
+
* `compileError !== undefined`) means a custom provider that does
|
|
2276
|
+
* `throw undefined` is still treated as a captured failure.
|
|
2277
|
+
*/
|
|
2278
|
+
private _compileOutputValidator;
|
|
2279
|
+
/**
|
|
2280
|
+
* Resolve the SEP-2243 `x-mcp-header` declaration scan for a tool name.
|
|
2281
|
+
*
|
|
2282
|
+
* The caller-supplied `toolDefinition` escape hatch wins; otherwise the
|
|
2283
|
+
* cached `tools/list` entry (via the cache's `toolDefinition`) is the
|
|
2284
|
+
* source. Freshness is the response cache's lifecycle: `list_changed`
|
|
2285
|
+
* evicts, otherwise the held schema is the best information available
|
|
2286
|
+
* regardless of age, and a stale schema is recovered through the
|
|
2287
|
+
* `HEADER_MISMATCH` → evict-refetch-retry path in {@linkcode callTool}.
|
|
2288
|
+
* On a miss the call proceeds without `Mcp-Param-*` headers (the spec's
|
|
2289
|
+
* "client SHOULD send without custom headers" guidance) and relies on the
|
|
2290
|
+
* same recovery.
|
|
2291
|
+
*/
|
|
2292
|
+
private _resolveXMcpHeaderScan;
|
|
2293
|
+
/**
|
|
2294
|
+
* Reads the contents of a resource by URI.
|
|
2295
|
+
*
|
|
2296
|
+
* Honours the result's `ttlMs`/`cacheScope` (SEP-2549): a still-fresh
|
|
2297
|
+
* cached body for the same `uri` is returned without a round trip
|
|
2298
|
+
* (`cacheMode: 'use'`, the default). The cache key is `{method, uri}`
|
|
2299
|
+
* partitioned by the resolved scope — `'private'` (the default when the
|
|
2300
|
+
* server omits the field) is stored under this client's
|
|
2301
|
+
* {@linkcode ClientOptions | ClientOptions.cachePartition}, so a shared
|
|
2302
|
+
* store cannot serve one principal's resource body to another. Unlike the
|
|
2303
|
+
* list verbs, a result whose resolved TTL is ≤0 is **not** stored
|
|
2304
|
+
* (`resources/read` has no derived index and the URI keyspace is
|
|
2305
|
+
* unbounded).
|
|
2306
|
+
*/
|
|
2307
|
+
readResource(params: ReadResourceRequest['params'], options?: CacheableRequestOptions): Promise<ReadResourceResult>;
|
|
2308
|
+
/** Subscribes to change notifications for a resource. The server must support resource subscriptions. */
|
|
2309
|
+
subscribeResource(params: SubscribeRequest['params'], options?: RequestOptions): Promise<EmptyResult>;
|
|
2310
|
+
/** Unsubscribes from change notifications for a resource. */
|
|
2311
|
+
unsubscribeResource(params: UnsubscribeRequest['params'], options?: RequestOptions): Promise<EmptyResult>;
|
|
2312
|
+
/**
|
|
2313
|
+
* Opens a `subscriptions/listen` stream (protocol revision 2026-07-28).
|
|
2314
|
+
*
|
|
2315
|
+
* Resolves once the server's `notifications/subscriptions/acknowledged`
|
|
2316
|
+
* arrives (the standard request timeout applies to this ack phase). Change
|
|
2317
|
+
* notifications delivered on the stream are dispatched to the existing
|
|
2318
|
+
* {@linkcode setNotificationHandler} registrations — the same handlers the
|
|
2319
|
+
* 2025-era unsolicited notifications fire on a legacy connection — so
|
|
2320
|
+
* `listen()` is era-transparent for consumers that already register those.
|
|
2321
|
+
*
|
|
2322
|
+
* `close()` tears the subscription down by aborting the listen request's
|
|
2323
|
+
* `requestSignal` (closes the SSE stream where the transport honors it)
|
|
2324
|
+
* AND sending `notifications/cancelled` referencing the listen request id
|
|
2325
|
+
* — both, unconditionally, so any spec-compliant server on any transport
|
|
2326
|
+
* sees the cancel. No automatic re-listen — call `listen()` again to
|
|
2327
|
+
* re-establish.
|
|
2328
|
+
*
|
|
2329
|
+
* On a 2025-era connection this throws a typed
|
|
2330
|
+
* {@linkcode SdkErrorCode.MethodNotSupportedByProtocolVersion} steering to
|
|
2331
|
+
* `resources/subscribe` and `ClientOptions.listChanged` (the legacy
|
|
2332
|
+
* unsolicited delivery model still applies there); no transparent shim.
|
|
2333
|
+
*/
|
|
2334
|
+
listen(filter: SubscriptionFilter, options?: RequestOptions): Promise<McpSubscription>;
|
|
2335
|
+
/**
|
|
2336
|
+
* The subscription auto-opened by `ClientOptions.listChanged` on a modern
|
|
2337
|
+
* connection — the listen filter is the intersection of the configured
|
|
2338
|
+
* sub-options and the server-advertised `listChanged` capabilities.
|
|
2339
|
+
* `undefined` on a legacy connection, before connect, or when that
|
|
2340
|
+
* intersection is empty (auto-open skipped). Exposed so the consumer can
|
|
2341
|
+
* `close()` it.
|
|
2342
|
+
*/
|
|
2343
|
+
get autoOpenedSubscription(): McpSubscription | undefined;
|
|
2344
|
+
/**
|
|
2345
|
+
* Transport-level demux for `subscriptions/listen` notifications, before
|
|
2346
|
+
* any decoding/era-gating/handler dispatch. Consumes the leading
|
|
2347
|
+
* `notifications/subscriptions/acknowledged` referencing a live
|
|
2348
|
+
* subscription id (resolves the ack waiter) and an inbound
|
|
2349
|
+
* `notifications/cancelled` referencing a live string-typed subscription
|
|
2350
|
+
* id (server-side teardown on stdio). Change notifications carrying a
|
|
2351
|
+
* subscription id pass through to the existing registered handlers via
|
|
2352
|
+
* `super`. An unmatched ack/cancelled is NOT consumed: it reaches
|
|
2353
|
+
* `setNotificationHandler` / `fallbackNotificationHandler` instead of
|
|
2354
|
+
* being silently swallowed.
|
|
2355
|
+
*/
|
|
2356
|
+
protected _onnotification(raw: JSONRPCNotification, extra?: MessageExtraInfo): void;
|
|
2357
|
+
/**
|
|
2358
|
+
* Transport-level demux for `subscriptions/listen` responses. A JSON-RPC
|
|
2359
|
+
* ERROR for the listen id is the server's pre-ack capacity/params
|
|
2360
|
+
* rejection; a JSON-RPC RESULT for the listen id is the spec's
|
|
2361
|
+
* `SubscriptionsListenResult` — the server's GRACEFUL-close signal (sent
|
|
2362
|
+
* on shutdown). A string-id response that matches a live `_listenState`
|
|
2363
|
+
* entry is consumed here (Protocol's `_responseHandlers` map is keyed by
|
|
2364
|
+
* NUMBER and never holds a listen id, so passing a string-id response
|
|
2365
|
+
* through would surface as "unknown message ID" via `onerror`).
|
|
2366
|
+
*/
|
|
2367
|
+
protected _onresponse(response: JSONRPCResponse): void;
|
|
2368
|
+
/**
|
|
2369
|
+
* Settle every live per-listen state machine on a transport-initiated
|
|
2370
|
+
* close (the server dropping the connection on stdio/InMemory) before
|
|
2371
|
+
* Protocol's `_onclose` tears the transport down. The base
|
|
2372
|
+
* `_responseHandlers` settlement does not reach `_listenState` (listen
|
|
2373
|
+
* ids are never registered there), so without this override a remote
|
|
2374
|
+
* close would leave an in-flight `listen()` / open `McpSubscription`
|
|
2375
|
+
* hanging.
|
|
2376
|
+
*/
|
|
2377
|
+
protected _onclose(): void;
|
|
2378
|
+
/**
|
|
2379
|
+
* Calls a tool on the connected server and returns the result. Automatically validates structured output
|
|
2380
|
+
* if the tool has an `outputSchema`.
|
|
2381
|
+
*
|
|
2382
|
+
* Tool results have two error surfaces: `result.isError` for tool-level failures (the tool ran but reported
|
|
2383
|
+
* a problem), and thrown {@linkcode ProtocolError} for protocol-level failures or {@linkcode SdkError} for
|
|
2384
|
+
* SDK-level issues (timeouts, missing capabilities).
|
|
2385
|
+
*
|
|
2386
|
+
* @example Basic usage
|
|
2387
|
+
* ```ts source="./client.examples.ts#Client_callTool_basic"
|
|
2388
|
+
* const result = await client.callTool({
|
|
2389
|
+
* name: 'calculate-bmi',
|
|
2390
|
+
* arguments: { weightKg: 70, heightM: 1.75 }
|
|
2391
|
+
* });
|
|
2392
|
+
*
|
|
2393
|
+
* // Tool-level errors are returned in the result, not thrown
|
|
2394
|
+
* if (result.isError) {
|
|
2395
|
+
* console.error('Tool error:', result.content);
|
|
2396
|
+
* return;
|
|
2397
|
+
* }
|
|
2398
|
+
*
|
|
2399
|
+
* console.log(result.content);
|
|
2400
|
+
* ```
|
|
2401
|
+
*
|
|
2402
|
+
* @example Structured output
|
|
2403
|
+
* ```ts source="./client.examples.ts#Client_callTool_structuredOutput"
|
|
2404
|
+
* const result = await client.callTool({
|
|
2405
|
+
* name: 'calculate-bmi',
|
|
2406
|
+
* arguments: { weightKg: 70, heightM: 1.75 }
|
|
2407
|
+
* });
|
|
2408
|
+
*
|
|
2409
|
+
* // Machine-readable output for the client application. SEP-2106: structuredContent is
|
|
2410
|
+
* // `unknown` (any JSON value). Check for presence with `!== undefined` and narrow before use.
|
|
2411
|
+
* if (result.structuredContent !== undefined) {
|
|
2412
|
+
* const sc: unknown = result.structuredContent; // e.g. { bmi: 22.86 }
|
|
2413
|
+
* if (typeof sc === 'object' && sc !== null && 'bmi' in sc) {
|
|
2414
|
+
* console.log(sc.bmi);
|
|
2415
|
+
* }
|
|
2416
|
+
* }
|
|
2417
|
+
* ```
|
|
2418
|
+
*/
|
|
2419
|
+
callTool(params: CallToolRequest['params'], options?: CallToolRequestOptions): Promise<CallToolResult>;
|
|
2420
|
+
/**
|
|
2421
|
+
* Lists available tools.
|
|
2422
|
+
*
|
|
2423
|
+
* Called without a `cursor` (the common case), this walks every page and
|
|
2424
|
+
* returns the complete aggregated list with no `nextCursor`; the
|
|
2425
|
+
* aggregate is also written to the {@linkcode ResponseCacheStore} (the
|
|
2426
|
+
* source for {@linkcode callTool | callTool()}'s output-schema validation
|
|
2427
|
+
* and SEP-2243 `Mcp-Param-*` header mirroring). Pass an explicit
|
|
2428
|
+
* `{ cursor }` to fetch a single page and walk pagination yourself — the
|
|
2429
|
+
* per-page path returns the server's raw page (with `nextCursor` for the
|
|
2430
|
+
* next call) and does not write the response cache. The auto-aggregate
|
|
2431
|
+
* path is capped by {@linkcode ClientOptions | ClientOptions.listMaxPages} (default 64);
|
|
2432
|
+
* the per-page path is not.
|
|
2433
|
+
*
|
|
2434
|
+
* Returns an empty list if the server does not advertise tools capability
|
|
2435
|
+
* (or throws if {@linkcode ClientOptions.enforceStrictCapabilities} is enabled).
|
|
2436
|
+
*
|
|
2437
|
+
* @example
|
|
2438
|
+
* ```ts source="./client.examples.ts#Client_listTools_pagination"
|
|
2439
|
+
* // No cursor → all pages aggregated for you.
|
|
2440
|
+
* const { tools } = await client.listTools();
|
|
2441
|
+
* console.log(
|
|
2442
|
+
* 'Available tools:',
|
|
2443
|
+
* tools.map(t => t.name)
|
|
2444
|
+
* );
|
|
2445
|
+
* ```
|
|
2446
|
+
*/
|
|
2447
|
+
listTools(params?: ListToolsRequest['params'], options?: CacheableRequestOptions): Promise<ListToolsResult>;
|
|
2448
|
+
/**
|
|
2449
|
+
* SEP-2243 (protocol revision 2026-07-28): a Streamable HTTP client MUST
|
|
2450
|
+
* exclude tool definitions whose `x-mcp-header` declarations violate the
|
|
2451
|
+
* constraints, and SHOULD log a warning naming the tool and the reason.
|
|
2452
|
+
* Applied to the CACHED aggregated `tools/list` result (so the entry
|
|
2453
|
+
* mirroring reads never holds an unmirrorable tool) AND to every public
|
|
2454
|
+
* per-page {@linkcode listTools | listTools()} return (the spec's MUST
|
|
2455
|
+
* has no carve-out for paginated reads). The gate is era-only on
|
|
2456
|
+
* non-stdio transports — `detectProbeTransportKind` cannot distinguish a
|
|
2457
|
+
* real HTTP transport from in-memory/custom transports (it only
|
|
2458
|
+
* positively recognizes stdio), and over-excluding on a non-HTTP modern
|
|
2459
|
+
* connection is harmless: those transports never carry per-request
|
|
2460
|
+
* headers, so an excluded tool would have been uncallable on a Streamable
|
|
2461
|
+
* HTTP arm of the same server. Mutates `result.tools` in place.
|
|
2462
|
+
*/
|
|
2463
|
+
private _excludeInvalidXMcpHeaderTools;
|
|
2464
|
+
/**
|
|
2465
|
+
* Set up a single list changed handler.
|
|
2466
|
+
* @internal
|
|
2467
|
+
*/
|
|
2468
|
+
private _setupListChangedHandler;
|
|
2469
|
+
/**
|
|
2470
|
+
* Notifies the server that the client's root list has changed. Requires the `roots.listChanged` capability.
|
|
2471
|
+
*
|
|
2472
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
2473
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
2474
|
+
* Migrate to passing paths via tool parameters, resource URIs, or configuration.
|
|
2475
|
+
*/
|
|
2476
|
+
sendRootsListChanged(): Promise<void>;
|
|
2477
|
+
}
|
|
2478
|
+
//#endregion
|
|
2479
|
+
//#region src/client/crossAppAccess.d.ts
|
|
2480
|
+
/**
|
|
2481
|
+
* Options for requesting a JWT Authorization Grant via RFC 8693 Token Exchange.
|
|
2482
|
+
*/
|
|
2483
|
+
interface RequestJwtAuthGrantOptions {
|
|
2484
|
+
/**
|
|
2485
|
+
* The IdP's token endpoint URL where the token exchange request will be sent.
|
|
2486
|
+
*/
|
|
2487
|
+
tokenEndpoint: string | URL;
|
|
2488
|
+
/**
|
|
2489
|
+
* The authorization server URL of the target MCP server (used as `audience` in the token exchange request).
|
|
2490
|
+
*/
|
|
2491
|
+
audience: string | URL;
|
|
2492
|
+
/**
|
|
2493
|
+
* The resource identifier of the target MCP server (RFC 9728).
|
|
2494
|
+
*/
|
|
2495
|
+
resource: string | URL;
|
|
2496
|
+
/**
|
|
2497
|
+
* The identity assertion (ID Token) from the enterprise IdP.
|
|
2498
|
+
* This should be the OpenID Connect ID Token obtained during user authentication.
|
|
2499
|
+
*/
|
|
2500
|
+
idToken: string;
|
|
2501
|
+
/**
|
|
2502
|
+
* The client ID registered with the IdP for token exchange.
|
|
2503
|
+
*/
|
|
2504
|
+
clientId: string;
|
|
2505
|
+
/**
|
|
2506
|
+
* The client secret for authenticating with the IdP.
|
|
2507
|
+
*
|
|
2508
|
+
* Optional: the IdP may register the MCP client as a public client. RFC 8693 does
|
|
2509
|
+
* not mandate confidential clients for token exchange. Omitting this parameter
|
|
2510
|
+
* omits `client_secret` from the request body.
|
|
2511
|
+
*/
|
|
2512
|
+
clientSecret?: string;
|
|
2513
|
+
/**
|
|
2514
|
+
* Optional space-separated list of scopes to request for the target MCP server.
|
|
2515
|
+
*/
|
|
2516
|
+
scope?: string;
|
|
2517
|
+
/**
|
|
2518
|
+
* Custom fetch implementation. Defaults to global fetch.
|
|
2519
|
+
*/
|
|
2520
|
+
fetchFn?: FetchLike;
|
|
2521
|
+
}
|
|
2522
|
+
/**
|
|
2523
|
+
* Options for discovering the IdP's token endpoint and requesting a JWT Authorization Grant.
|
|
2524
|
+
* Extends {@linkcode RequestJwtAuthGrantOptions} with IdP discovery.
|
|
2525
|
+
*/
|
|
2526
|
+
interface DiscoverAndRequestJwtAuthGrantOptions extends Omit<RequestJwtAuthGrantOptions, 'tokenEndpoint'> {
|
|
2527
|
+
/**
|
|
2528
|
+
* The IdP's issuer URL for OAuth metadata discovery.
|
|
2529
|
+
* Will be used to discover the token endpoint via `.well-known/oauth-authorization-server`.
|
|
2530
|
+
*/
|
|
2531
|
+
idpUrl: string | URL;
|
|
2532
|
+
}
|
|
2533
|
+
/**
|
|
2534
|
+
* Result from a successful JWT Authorization Grant token exchange.
|
|
2535
|
+
*/
|
|
2536
|
+
interface JwtAuthGrantResult {
|
|
2537
|
+
/**
|
|
2538
|
+
* The JWT Authorization Grant (ID-JAG) that can be used to request an access token from the MCP server.
|
|
2539
|
+
*/
|
|
2540
|
+
jwtAuthGrant: string;
|
|
2541
|
+
/**
|
|
2542
|
+
* Optional expiration time in seconds for the JWT Authorization Grant.
|
|
2543
|
+
*/
|
|
2544
|
+
expiresIn?: number;
|
|
2545
|
+
/**
|
|
2546
|
+
* Optional scope granted by the IdP (may differ from requested scope).
|
|
2547
|
+
*/
|
|
2548
|
+
scope?: string;
|
|
2549
|
+
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Requests a JWT Authorization Grant (ID-JAG) from an enterprise IdP using RFC 8693 Token Exchange.
|
|
2552
|
+
*
|
|
2553
|
+
* This function performs step 2 of the Enterprise Managed Authorization flow:
|
|
2554
|
+
* exchanges an ID Token for a JWT Authorization Grant that can be used with the target MCP server.
|
|
2555
|
+
*
|
|
2556
|
+
* @param options - Configuration for the token exchange request
|
|
2557
|
+
* @returns The JWT Authorization Grant and related metadata
|
|
2558
|
+
* @throws {Error} If the token exchange fails or returns an error response
|
|
2559
|
+
*
|
|
2560
|
+
* @example
|
|
2561
|
+
* ```ts
|
|
2562
|
+
* const result = await requestJwtAuthorizationGrant({
|
|
2563
|
+
* tokenEndpoint: 'https://idp.example.com/token',
|
|
2564
|
+
* audience: 'https://auth.chat.example/',
|
|
2565
|
+
* resource: 'https://mcp.chat.example/',
|
|
2566
|
+
* idToken: 'eyJhbGciOiJS...',
|
|
2567
|
+
* clientId: 'my-idp-client',
|
|
2568
|
+
* clientSecret: 'my-idp-secret',
|
|
2569
|
+
* scope: 'chat.read chat.history'
|
|
2570
|
+
* });
|
|
2571
|
+
*
|
|
2572
|
+
* // Use result.jwtAuthGrant with the MCP server's authorization server
|
|
2573
|
+
* ```
|
|
2574
|
+
*/
|
|
2575
|
+
declare function requestJwtAuthorizationGrant(options: RequestJwtAuthGrantOptions): Promise<JwtAuthGrantResult>;
|
|
2576
|
+
/**
|
|
2577
|
+
* Discovers the IdP's token endpoint and requests a JWT Authorization Grant.
|
|
2578
|
+
*
|
|
2579
|
+
* This is a convenience wrapper around {@linkcode requestJwtAuthorizationGrant} that
|
|
2580
|
+
* first performs OAuth metadata discovery to find the token endpoint.
|
|
2581
|
+
*
|
|
2582
|
+
* @param options - Configuration including IdP URL for discovery
|
|
2583
|
+
* @returns The JWT Authorization Grant and related metadata
|
|
2584
|
+
* @throws {Error} If discovery fails or the token exchange fails
|
|
2585
|
+
*
|
|
2586
|
+
* @example
|
|
2587
|
+
* ```ts
|
|
2588
|
+
* const result = await discoverAndRequestJwtAuthGrant({
|
|
2589
|
+
* idpUrl: 'https://idp.example.com',
|
|
2590
|
+
* audience: 'https://auth.chat.example/',
|
|
2591
|
+
* resource: 'https://mcp.chat.example/',
|
|
2592
|
+
* idToken: await getIdToken(),
|
|
2593
|
+
* clientId: 'my-idp-client',
|
|
2594
|
+
* clientSecret: 'my-idp-secret'
|
|
2595
|
+
* });
|
|
2596
|
+
* ```
|
|
2597
|
+
*/
|
|
2598
|
+
declare function discoverAndRequestJwtAuthGrant(options: DiscoverAndRequestJwtAuthGrantOptions): Promise<JwtAuthGrantResult>;
|
|
2599
|
+
/**
|
|
2600
|
+
* Exchanges a JWT Authorization Grant for an access token at the MCP server's authorization server.
|
|
2601
|
+
*
|
|
2602
|
+
* This function performs step 3 of the Enterprise Managed Authorization flow:
|
|
2603
|
+
* uses the JWT Authorization Grant to obtain an access token from the MCP server.
|
|
2604
|
+
*
|
|
2605
|
+
* @param options - Configuration for the JWT grant exchange
|
|
2606
|
+
* @returns OAuth tokens (access token, token type, etc.)
|
|
2607
|
+
* @throws {Error} If the exchange fails or returns an error response
|
|
2608
|
+
*
|
|
2609
|
+
* Defaults to `client_secret_basic` (HTTP Basic Authorization header), matching
|
|
2610
|
+
* `CrossAppAccessProvider`'s declared `token_endpoint_auth_method` and the
|
|
2611
|
+
* SEP-990 conformance test requirements. Use `authMethod: 'client_secret_post'` only
|
|
2612
|
+
* when the authorization server explicitly requires it.
|
|
2613
|
+
*
|
|
2614
|
+
* @example
|
|
2615
|
+
* ```ts
|
|
2616
|
+
* const tokens = await exchangeJwtAuthGrant({
|
|
2617
|
+
* tokenEndpoint: 'https://auth.chat.example/token',
|
|
2618
|
+
* jwtAuthGrant: 'eyJhbGci...',
|
|
2619
|
+
* clientId: 'my-mcp-client',
|
|
2620
|
+
* clientSecret: 'my-mcp-secret'
|
|
2621
|
+
* });
|
|
2622
|
+
*
|
|
2623
|
+
* // Use tokens.access_token to access the MCP server
|
|
2624
|
+
* ```
|
|
2625
|
+
*/
|
|
2626
|
+
declare function exchangeJwtAuthGrant(options: {
|
|
2627
|
+
tokenEndpoint: string | URL;
|
|
2628
|
+
jwtAuthGrant: string;
|
|
2629
|
+
clientId: string;
|
|
2630
|
+
clientSecret?: string;
|
|
2631
|
+
/**
|
|
2632
|
+
* Client authentication method. Defaults to `'client_secret_basic'` to align with
|
|
2633
|
+
* `CrossAppAccessProvider` and SEP-990 conformance requirements.
|
|
2634
|
+
* Callers with no `clientSecret` should pass `'none'` for public-client auth.
|
|
2635
|
+
*/
|
|
2636
|
+
authMethod?: ClientAuthMethod;
|
|
2637
|
+
fetchFn?: FetchLike;
|
|
2638
|
+
}): Promise<{
|
|
2639
|
+
access_token: string;
|
|
2640
|
+
token_type: string;
|
|
2641
|
+
expires_in?: number;
|
|
2642
|
+
scope?: string;
|
|
2643
|
+
}>;
|
|
2644
|
+
//#endregion
|
|
2645
|
+
//#region src/client/middleware.d.ts
|
|
2646
|
+
/**
|
|
2647
|
+
* Middleware function that wraps and enhances fetch functionality.
|
|
2648
|
+
* Takes a fetch handler and returns an enhanced fetch handler.
|
|
2649
|
+
*/
|
|
2650
|
+
type Middleware = (next: FetchLike) => FetchLike;
|
|
2651
|
+
/**
|
|
2652
|
+
* Creates a fetch wrapper that handles OAuth authentication automatically.
|
|
2653
|
+
*
|
|
2654
|
+
* This wrapper will:
|
|
2655
|
+
* - Add `Authorization` headers with access tokens
|
|
2656
|
+
* - Handle 401 responses by attempting re-authentication
|
|
2657
|
+
* - Retry the original request after successful auth
|
|
2658
|
+
* - Handle OAuth errors appropriately ({@linkcode index.OAuthErrorCode.InvalidClient | OAuthErrorCode.InvalidClient}, etc.)
|
|
2659
|
+
*
|
|
2660
|
+
* The `baseUrl` parameter is optional and defaults to using the domain from the request URL.
|
|
2661
|
+
* However, you should explicitly provide `baseUrl` when:
|
|
2662
|
+
* - Making requests to multiple subdomains (e.g., api.example.com, cdn.example.com)
|
|
2663
|
+
* - Using API paths that differ from OAuth discovery paths (e.g., requesting /api/v1/data but OAuth is at /)
|
|
2664
|
+
* - The OAuth server is on a different domain than your API requests
|
|
2665
|
+
* - You want to ensure consistent OAuth behavior regardless of request URLs
|
|
2666
|
+
*
|
|
2667
|
+
* For MCP transports, set `baseUrl` to the same URL you pass to the transport constructor.
|
|
2668
|
+
*
|
|
2669
|
+
* Note: This wrapper is designed for general-purpose fetch operations.
|
|
2670
|
+
* MCP transports (SSE and StreamableHTTP) already have built-in OAuth handling
|
|
2671
|
+
* and should not need this wrapper.
|
|
2672
|
+
*
|
|
2673
|
+
* @param provider - OAuth client provider for authentication
|
|
2674
|
+
* @param baseUrl - Base URL for OAuth server discovery (defaults to request URL domain)
|
|
2675
|
+
* @returns A fetch middleware function
|
|
2676
|
+
*/
|
|
2677
|
+
declare const withOAuth: (provider: OAuthClientProvider, baseUrl?: string | URL) => Middleware;
|
|
2678
|
+
/**
|
|
2679
|
+
* Logger function type for HTTP requests
|
|
2680
|
+
*/
|
|
2681
|
+
type RequestLogger = (input: {
|
|
2682
|
+
method: string;
|
|
2683
|
+
url: string | URL;
|
|
2684
|
+
status: number;
|
|
2685
|
+
statusText: string;
|
|
2686
|
+
duration: number;
|
|
2687
|
+
requestHeaders?: Headers;
|
|
2688
|
+
responseHeaders?: Headers;
|
|
2689
|
+
error?: Error;
|
|
2690
|
+
}) => void;
|
|
2691
|
+
/**
|
|
2692
|
+
* Configuration options for the logging middleware
|
|
2693
|
+
*/
|
|
2694
|
+
type LoggingOptions = {
|
|
2695
|
+
/**
|
|
2696
|
+
* Custom logger function, defaults to console logging
|
|
2697
|
+
*/
|
|
2698
|
+
logger?: RequestLogger;
|
|
2699
|
+
/**
|
|
2700
|
+
* Whether to include request headers in logs
|
|
2701
|
+
* @default false
|
|
2702
|
+
*/
|
|
2703
|
+
includeRequestHeaders?: boolean;
|
|
2704
|
+
/**
|
|
2705
|
+
* Whether to include response headers in logs
|
|
2706
|
+
* @default false
|
|
2707
|
+
*/
|
|
2708
|
+
includeResponseHeaders?: boolean;
|
|
2709
|
+
/**
|
|
2710
|
+
* Status level filter - only log requests with status >= this value
|
|
2711
|
+
* Set to `0` to log all requests, `400` to log only errors
|
|
2712
|
+
* @default 0
|
|
2713
|
+
*/
|
|
2714
|
+
statusLevel?: number;
|
|
2715
|
+
};
|
|
2716
|
+
/**
|
|
2717
|
+
* Creates a fetch middleware that logs HTTP requests and responses.
|
|
2718
|
+
*
|
|
2719
|
+
* When called without arguments `withLogging()`, it uses the default logger that:
|
|
2720
|
+
* - Logs successful requests (2xx) to `console.log`
|
|
2721
|
+
* - Logs error responses (4xx/5xx) and network errors to `console.error`
|
|
2722
|
+
* - Logs all requests regardless of status (`statusLevel: 0`)
|
|
2723
|
+
* - Does not include request or response headers in logs
|
|
2724
|
+
* - Measures and displays request duration in milliseconds
|
|
2725
|
+
*
|
|
2726
|
+
* Important: the default logger uses both `console.log` and `console.error` so it should not be used with
|
|
2727
|
+
* `stdio` transports and applications.
|
|
2728
|
+
*
|
|
2729
|
+
* @param options - Logging configuration options
|
|
2730
|
+
* @returns A fetch middleware function
|
|
2731
|
+
*/
|
|
2732
|
+
declare const withLogging: (options?: LoggingOptions) => Middleware;
|
|
2733
|
+
/**
|
|
2734
|
+
* Composes multiple fetch middleware functions into a single middleware pipeline.
|
|
2735
|
+
* Middleware are applied in the order they appear, creating a chain of handlers.
|
|
2736
|
+
*
|
|
2737
|
+
* @example
|
|
2738
|
+
* ```ts source="./middleware.examples.ts#applyMiddlewares_basicUsage"
|
|
2739
|
+
* // Create a middleware pipeline that handles both OAuth and logging
|
|
2740
|
+
* const enhancedFetch = applyMiddlewares(withOAuth(oauthProvider, 'https://api.example.com'), withLogging({ statusLevel: 400 }))(fetch);
|
|
2741
|
+
*
|
|
2742
|
+
* // Use the enhanced fetch - it will handle auth and log errors
|
|
2743
|
+
* const response = await enhancedFetch('https://api.example.com/data');
|
|
2744
|
+
* ```
|
|
2745
|
+
*
|
|
2746
|
+
* @param middleware - Array of fetch middleware to compose into a pipeline
|
|
2747
|
+
* @returns A single composed middleware function
|
|
2748
|
+
*/
|
|
2749
|
+
declare const applyMiddlewares: (...middleware: Middleware[]) => Middleware;
|
|
2750
|
+
/**
|
|
2751
|
+
* Helper function to create custom fetch middleware with cleaner syntax.
|
|
2752
|
+
* Provides the next handler and request details as separate parameters for easier access.
|
|
2753
|
+
*
|
|
2754
|
+
* @example
|
|
2755
|
+
* ```ts source="./middleware.examples.ts#createMiddleware_examples"
|
|
2756
|
+
* // Create custom authentication middleware
|
|
2757
|
+
* const customAuthMiddleware = createMiddleware(async (next, input, init) => {
|
|
2758
|
+
* const headers = new Headers(init?.headers);
|
|
2759
|
+
* headers.set('X-Custom-Auth', 'my-token');
|
|
2760
|
+
*
|
|
2761
|
+
* const response = await next(input, { ...init, headers });
|
|
2762
|
+
*
|
|
2763
|
+
* if (response.status === 401) {
|
|
2764
|
+
* console.log('Authentication failed');
|
|
2765
|
+
* }
|
|
2766
|
+
*
|
|
2767
|
+
* return response;
|
|
2768
|
+
* });
|
|
2769
|
+
*
|
|
2770
|
+
* // Create conditional middleware
|
|
2771
|
+
* const conditionalMiddleware = createMiddleware(async (next, input, init) => {
|
|
2772
|
+
* const url = typeof input === 'string' ? input : input.toString();
|
|
2773
|
+
*
|
|
2774
|
+
* // Only add headers for API routes
|
|
2775
|
+
* if (url.includes('/api/')) {
|
|
2776
|
+
* const headers = new Headers(init?.headers);
|
|
2777
|
+
* headers.set('X-API-Version', 'v2');
|
|
2778
|
+
* return next(input, { ...init, headers });
|
|
2779
|
+
* }
|
|
2780
|
+
*
|
|
2781
|
+
* // Pass through for non-API routes
|
|
2782
|
+
* return next(input, init);
|
|
2783
|
+
* });
|
|
2784
|
+
*
|
|
2785
|
+
* // Create caching middleware
|
|
2786
|
+
* const cacheMiddleware = createMiddleware(async (next, input, init) => {
|
|
2787
|
+
* const cacheKey = typeof input === 'string' ? input : input.toString();
|
|
2788
|
+
*
|
|
2789
|
+
* // Check cache first
|
|
2790
|
+
* const cached = await getFromCache(cacheKey);
|
|
2791
|
+
* if (cached) {
|
|
2792
|
+
* return new Response(cached, { status: 200 });
|
|
2793
|
+
* }
|
|
2794
|
+
*
|
|
2795
|
+
* // Make request and cache result
|
|
2796
|
+
* const response = await next(input, init);
|
|
2797
|
+
* if (response.ok) {
|
|
2798
|
+
* await saveToCache(cacheKey, await response.clone().text());
|
|
2799
|
+
* }
|
|
2800
|
+
*
|
|
2801
|
+
* return response;
|
|
2802
|
+
* });
|
|
2803
|
+
* ```
|
|
2804
|
+
*
|
|
2805
|
+
* @param handler - Function that receives the next handler and request parameters
|
|
2806
|
+
* @returns A fetch middleware function
|
|
2807
|
+
*/
|
|
2808
|
+
declare const createMiddleware: (handler: (next: FetchLike, input: string | URL, init?: RequestInit) => Promise<Response>) => Middleware;
|
|
2809
|
+
//#endregion
|
|
2810
|
+
//#region src/client/sse.d.ts
|
|
2811
|
+
declare class SseError extends Error {
|
|
2812
|
+
readonly code: number | undefined;
|
|
2813
|
+
readonly event: ErrorEvent;
|
|
2814
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
2815
|
+
/**
|
|
2816
|
+
* Brand-based type guard: equivalent to `value instanceof this`, as an
|
|
2817
|
+
* explicit static predicate (the axios/AWS-SDK `isInstance` style). Reads
|
|
2818
|
+
* the caller's own brand via `this`, so every branded subclass gets a
|
|
2819
|
+
* correctly-scoped guard by inheritance. Must be invoked on the class —
|
|
2820
|
+
* in callback position write `v => SdkError.isInstance(v)`, not
|
|
2821
|
+
* `.filter(SdkError.isInstance)` (detached calls throw rather than
|
|
2822
|
+
* silently matching nothing).
|
|
2823
|
+
*/
|
|
2824
|
+
static isInstance<T extends abstract new (...args: never[]) => unknown>(this: T, value: unknown): value is InstanceType<T>;
|
|
2825
|
+
constructor(code: number | undefined, message: string | undefined, event: ErrorEvent);
|
|
2826
|
+
}
|
|
2827
|
+
/**
|
|
2828
|
+
* Configuration options for the {@linkcode SSEClientTransport}.
|
|
2829
|
+
*/
|
|
2830
|
+
type SSEClientTransportOptions = {
|
|
2831
|
+
/**
|
|
2832
|
+
* An OAuth client provider to use for authentication.
|
|
2833
|
+
*
|
|
2834
|
+
* {@linkcode AuthProvider.token | token()} is called before every request to obtain the
|
|
2835
|
+
* bearer token. When the server responds with 401, {@linkcode AuthProvider.onUnauthorized | onUnauthorized()}
|
|
2836
|
+
* is called (if provided) to refresh credentials, then the request is retried once. If
|
|
2837
|
+
* the retry also gets 401, or `onUnauthorized` is not provided, {@linkcode UnauthorizedError}
|
|
2838
|
+
* is thrown.
|
|
2839
|
+
*
|
|
2840
|
+
* For simple bearer tokens: `{ token: async () => myApiKey }`.
|
|
2841
|
+
*
|
|
2842
|
+
* For OAuth flows, pass an {@linkcode index.OAuthClientProvider | OAuthClientProvider} implementation.
|
|
2843
|
+
* Interactive flows: after {@linkcode UnauthorizedError}, redirect the user, then call
|
|
2844
|
+
* {@linkcode SSEClientTransport.finishAuth | finishAuth} with the authorization code before reconnecting.
|
|
2845
|
+
*/
|
|
2846
|
+
authProvider?: AuthProvider | OAuthClientProvider;
|
|
2847
|
+
/**
|
|
2848
|
+
* Opt-out for the RFC 8414 §3.3 issuer-echo check during authorization-server
|
|
2849
|
+
* metadata discovery. **Security-weakening** — see
|
|
2850
|
+
* {@linkcode index.AuthOptions.skipIssuerMetadataValidation | AuthOptions.skipIssuerMetadataValidation}.
|
|
2851
|
+
* Only honoured when {@linkcode SSEClientTransportOptions.authProvider | authProvider}
|
|
2852
|
+
* is an `OAuthClientProvider`.
|
|
2853
|
+
*/
|
|
2854
|
+
skipIssuerMetadataValidation?: boolean;
|
|
2855
|
+
/**
|
|
2856
|
+
* Customizes the initial SSE request to the server (the request that begins the stream).
|
|
2857
|
+
*
|
|
2858
|
+
* NOTE: Setting this property will prevent an `Authorization` header from
|
|
2859
|
+
* being automatically attached to the SSE request, if an {@linkcode SSEClientTransportOptions.authProvider | authProvider} is
|
|
2860
|
+
* also given. This can be worked around by setting the `Authorization` header
|
|
2861
|
+
* manually.
|
|
2862
|
+
*/
|
|
2863
|
+
eventSourceInit?: EventSourceInit;
|
|
2864
|
+
/**
|
|
2865
|
+
* Customizes recurring `POST` requests to the server.
|
|
2866
|
+
*/
|
|
2867
|
+
requestInit?: RequestInit;
|
|
2868
|
+
/**
|
|
2869
|
+
* Custom fetch implementation used for all network requests.
|
|
2870
|
+
*/
|
|
2871
|
+
fetch?: FetchLike;
|
|
2872
|
+
};
|
|
2873
|
+
/**
|
|
2874
|
+
* Client transport for SSE: this will connect to a server using Server-Sent Events for receiving
|
|
2875
|
+
* messages and make separate `POST` requests for sending messages.
|
|
2876
|
+
* @deprecated SSEClientTransport is deprecated. Prefer to use {@linkcode index.StreamableHTTPClientTransport | StreamableHTTPClientTransport} where possible instead. Note that because some servers are still using SSE, clients may need to support both transports during the migration period.
|
|
2877
|
+
*/
|
|
2878
|
+
declare class SSEClientTransport implements Transport {
|
|
2879
|
+
private _eventSource?;
|
|
2880
|
+
private _endpoint?;
|
|
2881
|
+
private _abortController?;
|
|
2882
|
+
private _url;
|
|
2883
|
+
private _resourceMetadataUrl?;
|
|
2884
|
+
private _scope?;
|
|
2885
|
+
private _eventSourceInit?;
|
|
2886
|
+
private _requestInit?;
|
|
2887
|
+
private _authProvider?;
|
|
2888
|
+
private _oauthProvider?;
|
|
2889
|
+
private _skipIssuerMetadataValidation?;
|
|
2890
|
+
private _fetch?;
|
|
2891
|
+
private _fetchWithInit;
|
|
2892
|
+
private _protocolVersion?;
|
|
2893
|
+
onclose?: () => void;
|
|
2894
|
+
onerror?: (error: Error) => void;
|
|
2895
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
2896
|
+
constructor(url: URL, opts?: SSEClientTransportOptions);
|
|
2897
|
+
private _last401Response?;
|
|
2898
|
+
private _commonHeaders;
|
|
2899
|
+
private _startOrAuth;
|
|
2900
|
+
start(): Promise<void>;
|
|
2901
|
+
/**
|
|
2902
|
+
* Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
|
|
2903
|
+
*
|
|
2904
|
+
* **Preferred:** pass the callback URL's `searchParams` directly. The SDK extracts `code`
|
|
2905
|
+
* and `iss`, validates `iss` against the recorded issuer (RFC 9207) **before** reading any
|
|
2906
|
+
* other parameter, and on mismatch throws an {@linkcode IssuerMismatchError} that carries
|
|
2907
|
+
* none of the callback's `error`/`error_description`/`error_uri` text. The `(code, iss?)`
|
|
2908
|
+
* positional form remains supported for back-compat.
|
|
2909
|
+
*
|
|
2910
|
+
* The SDK does **not** validate `state`; compare it to your stored value before calling
|
|
2911
|
+
* `finishAuth`.
|
|
2912
|
+
*
|
|
2913
|
+
* @param callbackParams - The `URLSearchParams` from the authorization callback URL
|
|
2914
|
+
* (e.g. `new URL(callbackUrl).searchParams`). `code` and `iss` are read from it.
|
|
2915
|
+
*/
|
|
2916
|
+
finishAuth(callbackParams: URLSearchParams): Promise<void>;
|
|
2917
|
+
/**
|
|
2918
|
+
* @param authorizationCode - The `code` query parameter from the authorization callback URL.
|
|
2919
|
+
* @param iss - The form-urldecoded `iss` query parameter from the same callback URL, if
|
|
2920
|
+
* present. Validated per RFC 9207 against the recorded issuer before the code is redeemed.
|
|
2921
|
+
*/
|
|
2922
|
+
finishAuth(authorizationCode: string, iss?: string): Promise<void>;
|
|
2923
|
+
close(): Promise<void>;
|
|
2924
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
2925
|
+
private _send;
|
|
2926
|
+
setProtocolVersion(version: string): void;
|
|
2927
|
+
}
|
|
2928
|
+
//#endregion
|
|
2929
|
+
//#region src/client/streamableHttp.d.ts
|
|
2930
|
+
/**
|
|
2931
|
+
* Options for starting or authenticating an SSE connection
|
|
2932
|
+
*/
|
|
2933
|
+
interface StartSSEOptions {
|
|
2934
|
+
/**
|
|
2935
|
+
* The resumption token used to continue long-running requests that were interrupted.
|
|
2936
|
+
*
|
|
2937
|
+
* This allows clients to reconnect and continue from where they left off.
|
|
2938
|
+
*/
|
|
2939
|
+
resumptionToken?: string;
|
|
2940
|
+
/**
|
|
2941
|
+
* A callback that is invoked when the resumption token changes.
|
|
2942
|
+
*
|
|
2943
|
+
* This allows clients to persist the latest token for potential reconnection.
|
|
2944
|
+
*/
|
|
2945
|
+
onresumptiontoken?: (token: string) => void;
|
|
2946
|
+
/**
|
|
2947
|
+
* Override Message ID to associate with the replay message
|
|
2948
|
+
* so that the response can be associated with the new resumed request.
|
|
2949
|
+
*/
|
|
2950
|
+
replayMessageId?: string | number;
|
|
2951
|
+
/**
|
|
2952
|
+
* The per-request abort signal supplied by the caller via
|
|
2953
|
+
* `TransportSendOptions.requestSignal`. When this signal is aborted the
|
|
2954
|
+
* originating POST and its SSE response stream are torn down
|
|
2955
|
+
* intentionally — `_handleSseStream` treats it exactly like the
|
|
2956
|
+
* transport-level abort: no `onerror`, no reconnect.
|
|
2957
|
+
*/
|
|
2958
|
+
requestSignal?: AbortSignal;
|
|
2959
|
+
/**
|
|
2960
|
+
* The per-request stream-end callback supplied via
|
|
2961
|
+
* `TransportSendOptions.onRequestStreamEnd`. Fired when the SSE response
|
|
2962
|
+
* stream for the originating POST ends or errors for any non-deliberate
|
|
2963
|
+
* reason (server closed, network dropped, reconnection exhausted) — never
|
|
2964
|
+
* when `requestSignal` was aborted.
|
|
2965
|
+
*/
|
|
2966
|
+
onRequestStreamEnd?: () => void;
|
|
2967
|
+
}
|
|
2968
|
+
/**
|
|
2969
|
+
* Configuration options for reconnection behavior of the {@linkcode StreamableHTTPClientTransport}.
|
|
2970
|
+
*/
|
|
2971
|
+
interface StreamableHTTPReconnectionOptions {
|
|
2972
|
+
/**
|
|
2973
|
+
* Maximum backoff time between reconnection attempts in milliseconds.
|
|
2974
|
+
* Default is 30000 (30 seconds).
|
|
2975
|
+
*/
|
|
2976
|
+
maxReconnectionDelay: number;
|
|
2977
|
+
/**
|
|
2978
|
+
* Initial backoff time between reconnection attempts in milliseconds.
|
|
2979
|
+
* Default is 1000 (1 second).
|
|
2980
|
+
*/
|
|
2981
|
+
initialReconnectionDelay: number;
|
|
2982
|
+
/**
|
|
2983
|
+
* The factor by which the reconnection delay increases after each attempt.
|
|
2984
|
+
* Default is 1.5.
|
|
2985
|
+
*/
|
|
2986
|
+
reconnectionDelayGrowFactor: number;
|
|
2987
|
+
/**
|
|
2988
|
+
* Maximum number of reconnection attempts before giving up.
|
|
2989
|
+
* Default is 2.
|
|
2990
|
+
*/
|
|
2991
|
+
maxRetries: number;
|
|
2992
|
+
}
|
|
2993
|
+
/**
|
|
2994
|
+
* Custom scheduler for SSE stream reconnection attempts.
|
|
2995
|
+
*
|
|
2996
|
+
* Called instead of `setTimeout` when the transport needs to schedule a reconnection.
|
|
2997
|
+
* Useful in environments where `setTimeout` is unsuitable (serverless functions that
|
|
2998
|
+
* terminate before the timer fires, mobile apps that need platform background scheduling,
|
|
2999
|
+
* desktop apps handling sleep/wake).
|
|
3000
|
+
*
|
|
3001
|
+
* @param reconnect - Call this to perform the reconnection attempt.
|
|
3002
|
+
* @param delay - Suggested delay in milliseconds (from backoff calculation).
|
|
3003
|
+
* @param attemptCount - Zero-indexed retry attempt number.
|
|
3004
|
+
* @returns An optional cancel function. If returned, it will be called on
|
|
3005
|
+
* {@linkcode StreamableHTTPClientTransport.close | transport.close()} to abort the
|
|
3006
|
+
* pending reconnection.
|
|
3007
|
+
*
|
|
3008
|
+
* @example
|
|
3009
|
+
* ```ts source="./streamableHttp.examples.ts#ReconnectionScheduler_basicUsage"
|
|
3010
|
+
* const scheduler: ReconnectionScheduler = (reconnect, delay) => {
|
|
3011
|
+
* const id = platformBackgroundTask.schedule(reconnect, delay);
|
|
3012
|
+
* return () => platformBackgroundTask.cancel(id);
|
|
3013
|
+
* };
|
|
3014
|
+
* ```
|
|
3015
|
+
*/
|
|
3016
|
+
type ReconnectionScheduler = (reconnect: () => void, delay: number, attemptCount: number) => (() => void) | void;
|
|
3017
|
+
/**
|
|
3018
|
+
* Configuration options for the {@linkcode StreamableHTTPClientTransport}.
|
|
3019
|
+
*/
|
|
3020
|
+
type StreamableHTTPClientTransportOptions = {
|
|
3021
|
+
/**
|
|
3022
|
+
* An OAuth client provider to use for authentication.
|
|
3023
|
+
*
|
|
3024
|
+
* {@linkcode AuthProvider.token | token()} is called before every request to obtain the
|
|
3025
|
+
* bearer token. When the server responds with 401, {@linkcode AuthProvider.onUnauthorized | onUnauthorized()}
|
|
3026
|
+
* is called (if provided) to refresh credentials, then the request is retried once. If
|
|
3027
|
+
* the retry also gets 401, or `onUnauthorized` is not provided, {@linkcode UnauthorizedError}
|
|
3028
|
+
* is thrown.
|
|
3029
|
+
*
|
|
3030
|
+
* For simple bearer tokens: `{ token: async () => myApiKey }`.
|
|
3031
|
+
*
|
|
3032
|
+
* For OAuth flows, pass an {@linkcode index.OAuthClientProvider | OAuthClientProvider} implementation
|
|
3033
|
+
* directly — the transport adapts it to `AuthProvider` internally. Interactive flows: after
|
|
3034
|
+
* {@linkcode UnauthorizedError}, redirect the user, then call
|
|
3035
|
+
* {@linkcode StreamableHTTPClientTransport.finishAuth | finishAuth} with the authorization code before
|
|
3036
|
+
* reconnecting.
|
|
3037
|
+
*/
|
|
3038
|
+
authProvider?: AuthProvider | OAuthClientProvider;
|
|
3039
|
+
/**
|
|
3040
|
+
* Opt-out for the RFC 8414 §3.3 issuer-echo check during authorization-server
|
|
3041
|
+
* metadata discovery. **Security-weakening** — see
|
|
3042
|
+
* {@linkcode index.AuthOptions.skipIssuerMetadataValidation | AuthOptions.skipIssuerMetadataValidation}.
|
|
3043
|
+
* Only honoured when {@linkcode StreamableHTTPClientTransportOptions.authProvider | authProvider}
|
|
3044
|
+
* is an `OAuthClientProvider`.
|
|
3045
|
+
*/
|
|
3046
|
+
skipIssuerMetadataValidation?: boolean;
|
|
3047
|
+
/**
|
|
3048
|
+
* Customizes HTTP requests to the server.
|
|
3049
|
+
*/
|
|
3050
|
+
requestInit?: RequestInit;
|
|
3051
|
+
/**
|
|
3052
|
+
* Custom fetch implementation used for all network requests.
|
|
3053
|
+
*/
|
|
3054
|
+
fetch?: FetchLike;
|
|
3055
|
+
/**
|
|
3056
|
+
* Options to configure the reconnection behavior.
|
|
3057
|
+
*/
|
|
3058
|
+
reconnectionOptions?: StreamableHTTPReconnectionOptions;
|
|
3059
|
+
/**
|
|
3060
|
+
* Custom scheduler for reconnection attempts. If not provided, `setTimeout` is used.
|
|
3061
|
+
* See {@linkcode ReconnectionScheduler}.
|
|
3062
|
+
*/
|
|
3063
|
+
reconnectionScheduler?: ReconnectionScheduler;
|
|
3064
|
+
/**
|
|
3065
|
+
* Session ID for the connection. This is used to identify the session on the server.
|
|
3066
|
+
* When not provided and connecting to a server that supports session IDs, the server will generate a new session ID.
|
|
3067
|
+
*/
|
|
3068
|
+
sessionId?: string;
|
|
3069
|
+
/**
|
|
3070
|
+
* The MCP protocol version to include in the `mcp-protocol-version` header on all requests.
|
|
3071
|
+
* When reconnecting with a preserved `sessionId`, set this to the version negotiated during the original
|
|
3072
|
+
* handshake so the reconnected transport continues sending the required header.
|
|
3073
|
+
*/
|
|
3074
|
+
protocolVersion?: string;
|
|
3075
|
+
/**
|
|
3076
|
+
* How the transport reacts to a `403 Forbidden` response carrying
|
|
3077
|
+
* `WWW-Authenticate: Bearer error="insufficient_scope"`.
|
|
3078
|
+
*
|
|
3079
|
+
* - `'reauthorize'` (default): the transport runs the step-up authorization
|
|
3080
|
+
* flow — computes the union of the previously-requested scope and the
|
|
3081
|
+
* challenged scope, calls {@linkcode index.auth | auth()} (forcing a
|
|
3082
|
+
* fresh authorization request when the union strictly exceeds the current
|
|
3083
|
+
* token's granted scope, since refresh cannot widen scope per RFC 6749
|
|
3084
|
+
* §6), and retries the request once. Retries are bounded by
|
|
3085
|
+
* {@linkcode StreamableHTTPClientTransportOptions.maxStepUpRetries | maxStepUpRetries}.
|
|
3086
|
+
* If no {@linkcode index.OAuthClientProvider | OAuthClientProvider} is
|
|
3087
|
+
* configured, step-up cannot run and the transport throws
|
|
3088
|
+
* {@linkcode index.InsufficientScopeError | InsufficientScopeError} instead.
|
|
3089
|
+
* - `'throw'`: the transport throws {@linkcode index.InsufficientScopeError | InsufficientScopeError}
|
|
3090
|
+
* carrying the challenge parameters and does not re-authorize. Use this
|
|
3091
|
+
* for `client_credentials` / m2m clients where re-authorization cannot
|
|
3092
|
+
* widen scope, or for interactive clients that want to gate the consent
|
|
3093
|
+
* prompt behind UX.
|
|
3094
|
+
*
|
|
3095
|
+
* @default 'reauthorize'
|
|
3096
|
+
*/
|
|
3097
|
+
onInsufficientScope?: 'reauthorize' | 'throw';
|
|
3098
|
+
/**
|
|
3099
|
+
* Maximum number of step-up re-authorization attempts the transport makes
|
|
3100
|
+
* per send (and per GET stream open) before giving up. Only consulted when
|
|
3101
|
+
* {@linkcode StreamableHTTPClientTransportOptions.onInsufficientScope | onInsufficientScope}
|
|
3102
|
+
* is `'reauthorize'`. Cross-request tracking ("this resource+operation
|
|
3103
|
+
* already failed N times across the session") is host responsibility.
|
|
3104
|
+
*
|
|
3105
|
+
* @default 1
|
|
3106
|
+
*/
|
|
3107
|
+
maxStepUpRetries?: number;
|
|
3108
|
+
};
|
|
3109
|
+
/**
|
|
3110
|
+
* Client transport for Streamable HTTP: this implements the MCP Streamable HTTP transport specification.
|
|
3111
|
+
* It will connect to a server using HTTP `POST` for sending messages and HTTP `GET` with Server-Sent Events
|
|
3112
|
+
* for receiving messages.
|
|
3113
|
+
*/
|
|
3114
|
+
declare class StreamableHTTPClientTransport implements Transport {
|
|
3115
|
+
private _abortController?;
|
|
3116
|
+
private _url;
|
|
3117
|
+
private _resourceMetadataUrl?;
|
|
3118
|
+
private _scope?;
|
|
3119
|
+
private _requestInit?;
|
|
3120
|
+
private _authProvider?;
|
|
3121
|
+
private _oauthProvider?;
|
|
3122
|
+
private _skipIssuerMetadataValidation?;
|
|
3123
|
+
private _fetch?;
|
|
3124
|
+
private _fetchWithInit;
|
|
3125
|
+
private _sessionId?;
|
|
3126
|
+
private _reconnectionOptions;
|
|
3127
|
+
private _protocolVersion?;
|
|
3128
|
+
private _onInsufficientScope;
|
|
3129
|
+
private _maxStepUpRetries;
|
|
3130
|
+
private _serverRetryMs?;
|
|
3131
|
+
private readonly _reconnectionScheduler?;
|
|
3132
|
+
private _cancelReconnection?;
|
|
3133
|
+
onclose?: () => void;
|
|
3134
|
+
onerror?: (error: Error) => void;
|
|
3135
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
3136
|
+
/**
|
|
3137
|
+
* Streamable HTTP opens one POST (and SSE response stream) per outbound
|
|
3138
|
+
* request and honors `TransportSendOptions.requestSignal`. On a 2026-era
|
|
3139
|
+
* connection the protocol layer aborts that per-request stream as the
|
|
3140
|
+
* spec cancellation signal instead of POSTing `notifications/cancelled`.
|
|
3141
|
+
*/
|
|
3142
|
+
readonly hasPerRequestStream = true;
|
|
3143
|
+
constructor(url: URL, opts?: StreamableHTTPClientTransportOptions);
|
|
3144
|
+
/**
|
|
3145
|
+
* SEP-2350 step-up: compute the union scope, decide whether refresh must be
|
|
3146
|
+
* bypassed, and run {@linkcode auth}. Returns the auth result so the caller
|
|
3147
|
+
* can decide whether to retry. Shared by the POST `_send` path and the GET
|
|
3148
|
+
* `_startOrAuthSse` path so both apply the same `'throw'` short-circuit,
|
|
3149
|
+
* the same superset-gated refresh bypass, and the same retry cap.
|
|
3150
|
+
*/
|
|
3151
|
+
private _stepUpAuthorize;
|
|
3152
|
+
private _stepUpAuthorizeInner;
|
|
3153
|
+
private _commonHeaders;
|
|
3154
|
+
/**
|
|
3155
|
+
* Body-derived per-request headers: when an outgoing request carries a
|
|
3156
|
+
* protocol-version claim in its `_meta` envelope (the version negotiation
|
|
3157
|
+
* probe is the first such sender), `MCP-Protocol-Version` and `Mcp-Method`
|
|
3158
|
+
* derive from the message itself. The connection-level version slot is
|
|
3159
|
+
* neither consulted nor mutated; messages without an envelope claim are
|
|
3160
|
+
* untouched, so no 2026 header can appear on a legacy exchange.
|
|
3161
|
+
*/
|
|
3162
|
+
private _applyBodyDerivedHeaders;
|
|
3163
|
+
/**
|
|
3164
|
+
* `true` when the outbound message is a single request carrying a
|
|
3165
|
+
* modern-era protocol-version envelope claim — the same predicate that
|
|
3166
|
+
* gates body-derived `mcp-method`/`mcp-name` emission. Used to confine the
|
|
3167
|
+
* 400-body-as-ProtocolError delivery to modern-era exchanges only.
|
|
3168
|
+
*/
|
|
3169
|
+
private _isModernEnvelopedRequest;
|
|
3170
|
+
private _startOrAuthSse;
|
|
3171
|
+
/**
|
|
3172
|
+
* Calculates the next reconnection delay using a backoff algorithm
|
|
3173
|
+
*
|
|
3174
|
+
* @param attempt Current reconnection attempt count for the specific stream
|
|
3175
|
+
* @returns Time to wait in milliseconds before next reconnection attempt
|
|
3176
|
+
*/
|
|
3177
|
+
private _getNextReconnectionDelay;
|
|
3178
|
+
/**
|
|
3179
|
+
* Schedule a reconnection attempt using server-provided retry interval or backoff
|
|
3180
|
+
*
|
|
3181
|
+
* @param lastEventId The ID of the last received event for resumability
|
|
3182
|
+
* @param attemptCount Current reconnection attempt count for this specific stream
|
|
3183
|
+
*/
|
|
3184
|
+
private _scheduleReconnection;
|
|
3185
|
+
private _handleSseStream;
|
|
3186
|
+
start(): Promise<void>;
|
|
3187
|
+
/**
|
|
3188
|
+
* Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
|
|
3189
|
+
*
|
|
3190
|
+
* **Preferred:** pass the callback URL's `searchParams` directly. The SDK extracts `code`
|
|
3191
|
+
* and `iss`, validates `iss` against the recorded issuer (RFC 9207) **before** reading any
|
|
3192
|
+
* other parameter, and on mismatch throws an {@linkcode IssuerMismatchError} that carries
|
|
3193
|
+
* none of the callback's `error`/`error_description`/`error_uri` text — those are
|
|
3194
|
+
* attacker-controlled in a mix-up attack and MUST NOT be displayed. The `(code, iss?)`
|
|
3195
|
+
* positional form remains supported for back-compat.
|
|
3196
|
+
*
|
|
3197
|
+
* The SDK does **not** validate `state`; compare it to your stored value before calling
|
|
3198
|
+
* `finishAuth`.
|
|
3199
|
+
*
|
|
3200
|
+
* @param callbackParams - The `URLSearchParams` from the authorization callback URL
|
|
3201
|
+
* (e.g. `new URL(callbackUrl).searchParams`). `code` and `iss` are read from it.
|
|
3202
|
+
*/
|
|
3203
|
+
finishAuth(callbackParams: URLSearchParams): Promise<void>;
|
|
3204
|
+
/**
|
|
3205
|
+
* @param authorizationCode - The `code` query parameter from the authorization callback URL.
|
|
3206
|
+
* @param iss - The form-urldecoded `iss` query parameter from the same callback URL, if
|
|
3207
|
+
* present. Validated per RFC 9207 against the recorded issuer before the code is redeemed.
|
|
3208
|
+
* When the authorization server advertises `authorization_response_iss_parameter_supported: true`,
|
|
3209
|
+
* omitting this causes the exchange to be **rejected** with {@linkcode IssuerMismatchError}.
|
|
3210
|
+
*/
|
|
3211
|
+
finishAuth(authorizationCode: string, iss?: string): Promise<void>;
|
|
3212
|
+
close(): Promise<void>;
|
|
3213
|
+
send(message: JSONRPCMessage | JSONRPCMessage[], options?: {
|
|
3214
|
+
resumptionToken?: string;
|
|
3215
|
+
onresumptiontoken?: (token: string) => void;
|
|
3216
|
+
requestSignal?: AbortSignal;
|
|
3217
|
+
onRequestStreamEnd?: () => void;
|
|
3218
|
+
headers?: Readonly<Record<string, string>>;
|
|
3219
|
+
}): Promise<void>;
|
|
3220
|
+
private _send;
|
|
3221
|
+
get sessionId(): string | undefined;
|
|
3222
|
+
/**
|
|
3223
|
+
* Terminates the current session by sending a `DELETE` request to the server.
|
|
3224
|
+
*
|
|
3225
|
+
* Clients that no longer need a particular session
|
|
3226
|
+
* (e.g., because the user is leaving the client application) SHOULD send an
|
|
3227
|
+
* HTTP `DELETE` to the MCP endpoint with the `Mcp-Session-Id` header to explicitly
|
|
3228
|
+
* terminate the session.
|
|
3229
|
+
*
|
|
3230
|
+
* The server MAY respond with HTTP `405 Method Not Allowed`, indicating that
|
|
3231
|
+
* the server does not allow clients to terminate sessions.
|
|
3232
|
+
*/
|
|
3233
|
+
terminateSession(): Promise<void>;
|
|
3234
|
+
setProtocolVersion(version: string): void;
|
|
3235
|
+
get protocolVersion(): string | undefined;
|
|
3236
|
+
/**
|
|
3237
|
+
* Resume an SSE stream from a previous event ID.
|
|
3238
|
+
* Opens a `GET` SSE connection with `Last-Event-ID` header to replay missed events.
|
|
3239
|
+
*
|
|
3240
|
+
* @param lastEventId The event ID to resume from
|
|
3241
|
+
* @param options Optional callback to receive new resumption tokens
|
|
3242
|
+
*/
|
|
3243
|
+
resumeStream(lastEventId: string, options?: {
|
|
3244
|
+
onresumptiontoken?: (token: string) => void;
|
|
3245
|
+
}): Promise<void>;
|
|
3246
|
+
}
|
|
3247
|
+
//#endregion
|
|
3248
|
+
//#region src/fromJsonSchema.d.ts
|
|
3249
|
+
declare function fromJsonSchema<T = unknown>(schema: JsonSchemaType, validator?: jsonSchemaValidator): StandardSchemaWithJSON<T, T>;
|
|
3250
|
+
//#endregion
|
|
3251
|
+
export { type AddClientAuthentication, Annotations, type AssertionCallback, AudioContent, AuthInfo, type AuthOptions, type AuthProvider, type AuthResult, type AuthorizationServerMetadata, AuthorizationServerMismatchError, BAGGAGE_META_KEY, type BaseContext, BaseMetadata, BlobResourceContents, BooleanSchema, CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, type CacheEntry, type CacheKey, type CacheMode, type CacheScope, type CacheableRequestOptions, CallToolRequest, type CallToolRequestOptions, CallToolRequestParams, CallToolResult, CancelTaskRequest, CancelTaskResult, CancelledNotification, CancelledNotificationParams, Client, type ClientAuthMethod, ClientCapabilities, type ClientContext, ClientCredentialsProvider, type ClientCredentialsProviderOptions, ClientNotification, type ClientOptions, ClientRequest, ClientResult, CompatibilityCallToolResult, CompleteRequest, CompleteRequestParams, CompleteRequestPrompt, CompleteRequestResourceTemplate, CompleteResult, type ConnectOptions, ContentBlock, CreateMessageRequest, CreateMessageRequestParams, CreateMessageRequestParamsBase, CreateMessageRequestParamsWithTools, CreateMessageResult, CreateMessageResultWithTools, CreateTaskResult, type CrossAppAccessContext, CrossAppAccessProvider, type CrossAppAccessProviderOptions, Cursor, DEFAULT_NEGOTIATED_PROTOCOL_VERSION, DEFAULT_REQUEST_TIMEOUT_MSEC, type DiscoverAndRequestJwtAuthGrantOptions, DiscoverRequest, DiscoverResult, ElicitRequest, ElicitRequestFormParams, ElicitRequestParams, ElicitRequestURLParams, ElicitResult, ElicitationCompleteNotification, ElicitationCompleteNotificationParams, EmbeddedResource, EmptyResult, EnumSchema, type FetchLike, GetPromptRequest, GetPromptRequestParams, GetPromptResult, GetTaskPayloadRequest, GetTaskPayloadResult, GetTaskRequest, GetTaskResult, HandlerResultTypeMap, INTERNAL_ERROR, INVALID_PARAMS, INVALID_REQUEST, Icon, Icons, type IdJagTokenExchangeResponse, ImageContent, Implementation, InMemoryResponseCacheStore, type InMemoryResponseCacheStoreOptions, InMemoryTransport, InitializeRequest, InitializeRequestParams, InitializeResult, InitializedNotification, InputRequest, InputRequests, type InputRequiredOptions, InputRequiredResult, InputResponse, InputResponses, InsecureTokenEndpointError, InsufficientScopeError, InternalError, InvalidParamsError, InvalidRequestError, IssuerMismatchError, JSONArray, JSONObject, JSONRPCErrorResponse, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONRPCResultResponse, JSONRPC_VERSION, JSONValue, type JsonSchemaType, type JsonSchemaValidator, type JsonSchemaValidatorResult, type JwtAuthGrantResult, LATEST_PROTOCOL_VERSION, LOG_LEVEL_META_KEY, LegacyTitledEnumSchema, ListChangedCallback, ListChangedHandlers, ListChangedOptions, ListPromptsRequest, ListPromptsResult, ListResourceTemplatesRequest, ListResourceTemplatesResult, ListResourcesRequest, ListResourcesResult, ListRootsRequest, ListRootsResult, ListTasksRequest, ListTasksResult, ListToolsRequest, ListToolsResult, LoggingLevel, LoggingMessageNotification, LoggingMessageNotificationParams, type LoggingOptions, MAX_CACHE_TTL_MS, METHOD_NOT_FOUND, type MaybePromise, type McpSubscription, MessageClassification, MessageExtraInfo, MetaObject, MethodNotFoundError, type Middleware, MissingRequiredClientCapabilityError, MissingRequiredClientCapabilityErrorData, ModelHint, ModelPreferences, MultiSelectEnumSchema, Notification, NotificationMethod, type NotificationOptions, NotificationParams, NotificationTypeMap, NumberSchema, OAuthClientFlowError, type OAuthClientInformation, type OAuthClientInformationContext, type OAuthClientInformationFull, type OAuthClientInformationMixed, type OAuthClientMetadata, type OAuthClientProvider, type OAuthClientRegistrationError, type OAuthDiscoveryState, OAuthError, OAuthErrorCode, type OAuthErrorResponse, type OAuthMetadata, type OAuthProtectedResourceMetadata, type OAuthServerInfo, type OAuthTokenRevocationRequest, type OAuthTokens, type OpenIdProviderDiscoveryMetadata, type OpenIdProviderMetadata, PARSE_ERROR, PROTOCOL_VERSION_META_KEY, PaginatedRequest, PaginatedRequestParams, PaginatedResult, ParseError, PingRequest, PrimitiveSchemaDefinition, type PriorDiscovery, PrivateKeyJwtProvider, type PrivateKeyJwtProviderOptions, Progress, type ProgressCallback, ProgressNotification, ProgressNotificationParams, ProgressToken, Prompt, PromptArgument, PromptListChangedNotification, PromptMessage, PromptReference, Protocol, type ProtocolEra, ProtocolError, ProtocolErrorCode, type ProtocolOptions, RELATED_TASK_META_KEY, ReadBuffer, ReadResourceRequest, ReadResourceRequestParams, ReadResourceResult, type ReconnectionScheduler, RegistrationRejectedError, RelatedTaskMetadata, Request, type RequestHandlerSchemas, RequestId, type RequestJwtAuthGrantOptions, type RequestLogger, RequestMeta, RequestMetaEnvelope, RequestMetaObject, RequestMethod, type RequestOptions, RequestParams, type RequestStateAccessor, RequestTypeMap, Resource, ResourceContents, ResourceLink, ResourceListChangedNotification, ResourceNotFoundError, ResourceRequestParams, ResourceTemplateReference, ResourceTemplateType, ResourceUpdatedNotification, ResourceUpdatedNotificationParams, type ResponseCacheStore, Result, ResultMetaObject, ResultTypeMap, Role, Root, RootsListChangedNotification, SERVER_INFO_META_KEY, SSEClientTransport, type SSEClientTransportOptions, STDIO_DEFAULT_MAX_BUFFER_SIZE, SUBSCRIPTION_ID_META_KEY, SUPPORTED_PROTOCOL_VERSIONS, SamplingContent, SamplingMessage, SamplingMessageContentBlock, SdkError, SdkErrorCode, SdkHttpError, type SdkHttpErrorData, ServerCapabilities, type ServerContext, ServerNotification, ServerRequest, ServerResult, SetLevelRequest, SetLevelRequestParams, SingleSelectEnumSchema, type SpecTypeName, type SpecTypes, SseError, type StandardSchemaV1, type StandardSchemaV1Sync, type StandardSchemaWithJSON, type StartSSEOptions, StaticPrivateKeyJwtProvider, type StaticPrivateKeyJwtProviderOptions, type StoredOAuthClientInformation, type StoredOAuthTokens, StreamableHTTPClientTransport, type StreamableHTTPClientTransportOptions, type StreamableHTTPReconnectionOptions, StringSchema, SubscribeRequest, SubscribeRequestParams, SubscriptionFilter, SubscriptionsAcknowledgedNotification, SubscriptionsAcknowledgedNotificationParams, SubscriptionsListenRequest, SubscriptionsListenRequestParams, SubscriptionsListenResult, SubscriptionsListenResultMeta, TRACEPARENT_META_KEY, TRACESTATE_META_KEY, Task, TaskAugmentedRequestParams, TaskCreationParams, TaskMetadata, TaskStatus, TaskStatusNotification, TaskStatusNotificationParams, TextContent, TextResourceContents, TitledMultiSelectEnumSchema, TitledSingleSelectEnumSchema, Tool, ToolAnnotations, ToolChoice, ToolExecution, ToolListChangedNotification, ToolResultContent, ToolUseContent, type Transport, type TransportSendOptions, UnauthorizedError, UnsubscribeRequest, UnsubscribeRequestParams, UnsupportedProtocolVersionError, UnsupportedProtocolVersionErrorData, UntitledMultiSelectEnumSchema, UntitledSingleSelectEnumSchema, UriTemplate, UrlElicitationRequiredError, type Variables, type VersionNegotiationMode, type VersionNegotiationOptions, type VersionNegotiationProbeOptions, applyMiddlewares, assertCompleteRequestPrompt, assertCompleteRequestResourceTemplate, assertSecureTokenEndpoint, auth, buildDiscoveryUrls, checkResourceAllowed, computeScopeUnion, createFetchWithInit, createMiddleware, createPrivateKeyJwtAuth, deserializeMessage, discoverAndRequestJwtAuthGrant, discoverAuthorizationServerMetadata, discoverOAuthMetadata, discoverOAuthProtectedResourceMetadata, discoverOAuthServerInfo, exchangeAuthorization, exchangeJwtAuthGrant, extractResourceMetadataUrl, extractWWWAuthenticateParams, fetchToken, fromJsonSchema, getDisplayName, getSupportedElicitationModes, isCallToolResult, isHttpsUrl, isInitializeRequest, isInitializedNotification, isInputRequiredResult, isJSONRPCErrorResponse, isJSONRPCNotification, isJSONRPCRequest, isJSONRPCResponse, isJSONRPCResultResponse, isJsonContentType, isSpecType, isStrictScopeSuperset, isTaskAugmentedRequestParams, type jsonSchemaValidator, mergeCapabilities, parseErrorResponse, parseJSONRPCMessage, preloadSchemas, prepareAuthorizationCodeRequest, refreshAuthorization, registerClient, requestJwtAuthorizationGrant, resolveClientMetadata, resourceUrlFromServerUrl, selectClientAuthMethod, selectResourceURL, serializeMessage, specTypeSchemas, startAuthorization, validateAuthorizationResponseIssuer, validateClientMetadataUrl, withInputRequired, withLogging, withOAuth };
|
|
3252
|
+
//# sourceMappingURL=index.d.mts.map
|