@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,2022 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-Bnu9O96Y.cjs');
|
|
2
|
+
const require_src = require('./src-STyD_Vvf.cjs');
|
|
3
|
+
let _modelcontextprotocol_server__shims = require("@modelcontextprotocol/server/_shims");
|
|
4
|
+
let _modelcontextprotocol_core_internal = require("@modelcontextprotocol/core/internal");
|
|
5
|
+
|
|
6
|
+
//#region src/server/completable.ts
|
|
7
|
+
const COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
|
|
8
|
+
/**
|
|
9
|
+
* Wraps a schema to provide autocompletion capabilities. Useful for, e.g., prompt arguments in MCP.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts source="./completable.examples.ts#completable_basicUsage"
|
|
13
|
+
* server.registerPrompt(
|
|
14
|
+
* 'review-code',
|
|
15
|
+
* {
|
|
16
|
+
* title: 'Code Review',
|
|
17
|
+
* argsSchema: z.object({
|
|
18
|
+
* language: completable(z.string().describe('Programming language'), value =>
|
|
19
|
+
* ['typescript', 'javascript', 'python', 'rust', 'go'].filter(lang => lang.startsWith(value))
|
|
20
|
+
* )
|
|
21
|
+
* })
|
|
22
|
+
* },
|
|
23
|
+
* ({ language }) => ({
|
|
24
|
+
* messages: [
|
|
25
|
+
* {
|
|
26
|
+
* role: 'user' as const,
|
|
27
|
+
* content: {
|
|
28
|
+
* type: 'text' as const,
|
|
29
|
+
* text: `Review this ${language} code.`
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ]
|
|
33
|
+
* })
|
|
34
|
+
* );
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @see {@linkcode server/mcp.McpServer.registerPrompt | McpServer.registerPrompt} for using completable schemas in prompt argument definitions
|
|
38
|
+
*/
|
|
39
|
+
function completable(schema, complete) {
|
|
40
|
+
Object.defineProperty(schema, COMPLETABLE_SYMBOL, {
|
|
41
|
+
value: { complete },
|
|
42
|
+
enumerable: false,
|
|
43
|
+
writable: false,
|
|
44
|
+
configurable: false
|
|
45
|
+
});
|
|
46
|
+
return schema;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a schema is completable (has completion metadata).
|
|
50
|
+
*/
|
|
51
|
+
function isCompletable(schema) {
|
|
52
|
+
return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets the completer callback from a completable schema, if it exists.
|
|
56
|
+
*/
|
|
57
|
+
function getCompleter(schema) {
|
|
58
|
+
return schema[COMPLETABLE_SYMBOL]?.complete;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/server/sseKeepAlive.ts
|
|
63
|
+
/** Default interval between SSE keep-alive comment frames. */
|
|
64
|
+
const DEFAULT_SSE_KEEP_ALIVE_MS = 15e3;
|
|
65
|
+
const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
|
|
66
|
+
/** Arms an unref'd timer, or disables keep-alive for invalid delays. */
|
|
67
|
+
function armSseKeepAlive(intervalMs, onTick) {
|
|
68
|
+
if (!Number.isFinite(intervalMs) || intervalMs < 1) return;
|
|
69
|
+
const timer = setInterval(onTick, Math.min(intervalMs, MAX_TIMER_DELAY_MS));
|
|
70
|
+
timer.unref?.();
|
|
71
|
+
return timer;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/server/serverEventBus.ts
|
|
76
|
+
/**
|
|
77
|
+
* A `ServerEventBus` backed by an in-process listener set.
|
|
78
|
+
*
|
|
79
|
+
* `publish()` delivers synchronously to the live listener set (a listener
|
|
80
|
+
* unsubscribing itself mid-dispatch is safe; the entry's listen-router
|
|
81
|
+
* listeners never unsubscribe peers). A throwing listener does not stop
|
|
82
|
+
* delivery to the others.
|
|
83
|
+
*/
|
|
84
|
+
var InMemoryServerEventBus = class {
|
|
85
|
+
_listeners = /* @__PURE__ */ new Set();
|
|
86
|
+
/**
|
|
87
|
+
* @param onerror - Optional callback for errors thrown by listeners
|
|
88
|
+
* during dispatch.
|
|
89
|
+
*/
|
|
90
|
+
constructor(onerror) {
|
|
91
|
+
this.onerror = onerror;
|
|
92
|
+
}
|
|
93
|
+
publish(event) {
|
|
94
|
+
for (const listener of this._listeners) try {
|
|
95
|
+
listener(event);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
this.onerror?.(error instanceof Error ? error : new Error(String(error)));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
subscribe(listener) {
|
|
101
|
+
this._listeners.add(listener);
|
|
102
|
+
let live = true;
|
|
103
|
+
return () => {
|
|
104
|
+
if (!live) return;
|
|
105
|
+
live = false;
|
|
106
|
+
this._listeners.delete(listener);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** The number of currently registered listeners (test/introspection only — the routers track capacity via their own open-subscription set). */
|
|
110
|
+
get listenerCount() {
|
|
111
|
+
return this._listeners.size;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/** Build a {@linkcode ServerNotifier} over a bus. */
|
|
115
|
+
function createServerNotifier(bus) {
|
|
116
|
+
return {
|
|
117
|
+
toolsChanged: () => bus.publish({ kind: "tools_list_changed" }),
|
|
118
|
+
promptsChanged: () => bus.publish({ kind: "prompts_list_changed" }),
|
|
119
|
+
resourcesChanged: () => bus.publish({ kind: "resources_list_changed" }),
|
|
120
|
+
resourceUpdated: (uri) => bus.publish({
|
|
121
|
+
kind: "resource_updated",
|
|
122
|
+
uri
|
|
123
|
+
})
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Whether a `subscriptions/listen` filter accepts a given change event.
|
|
128
|
+
*
|
|
129
|
+
* Pure: no I/O, no mutation. The filter governs ONLY the four
|
|
130
|
+
* subscription-gated change types — non-gated notifications never reach the
|
|
131
|
+
* bus and are not modeled here.
|
|
132
|
+
*
|
|
133
|
+
* `resource_updated` matches only when `resourceSubscriptions` is present and
|
|
134
|
+
* contains the event's URI exactly (per the spec: "for these resource URIs").
|
|
135
|
+
*/
|
|
136
|
+
function listenFilterAccepts(filter, event) {
|
|
137
|
+
switch (event.kind) {
|
|
138
|
+
case "tools_list_changed": return filter.toolsListChanged === true;
|
|
139
|
+
case "prompts_list_changed": return filter.promptsListChanged === true;
|
|
140
|
+
case "resources_list_changed": return filter.resourcesListChanged === true;
|
|
141
|
+
case "resource_updated": return filter.resourceSubscriptions !== void 0 && filter.resourceSubscriptions.includes(event.uri);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The honored subset of a requested filter: keeps only the fields the client
|
|
146
|
+
* explicitly opted in to (drops `false` and absent fields), narrowed against
|
|
147
|
+
* the server's declared capabilities when supplied. The serving entry sends
|
|
148
|
+
* this back in `notifications/subscriptions/acknowledged` so the ack reflects
|
|
149
|
+
* what the server can actually deliver.
|
|
150
|
+
*
|
|
151
|
+
* - `toolsListChanged` is honored only when `capabilities.tools.listChanged`
|
|
152
|
+
* is advertised; likewise `promptsListChanged` / `resourcesListChanged`.
|
|
153
|
+
* - `resourceSubscriptions` is honored only when
|
|
154
|
+
* `capabilities.resources.subscribe` is advertised.
|
|
155
|
+
*
|
|
156
|
+
* `capabilities` is optional on this pure helper for test convenience only —
|
|
157
|
+
* both wired routers REQUIRE capabilities at the call site (the HTTP router's
|
|
158
|
+
* `serve()` takes a required parameter; `StdioListenRouter.serve()` throws
|
|
159
|
+
* before `setServerCapabilities()` was called), so the fail-open
|
|
160
|
+
* `undefined → honor everything` branch is never reachable on a wired entry.
|
|
161
|
+
*/
|
|
162
|
+
function honoredSubset(requested, capabilities) {
|
|
163
|
+
const honored = {};
|
|
164
|
+
const allow = (bit) => capabilities === void 0 || bit === true;
|
|
165
|
+
if (requested.toolsListChanged === true && allow(capabilities?.tools?.listChanged)) honored.toolsListChanged = true;
|
|
166
|
+
if (requested.promptsListChanged === true && allow(capabilities?.prompts?.listChanged)) honored.promptsListChanged = true;
|
|
167
|
+
if (requested.resourcesListChanged === true && allow(capabilities?.resources?.listChanged)) honored.resourcesListChanged = true;
|
|
168
|
+
if (requested.resourceSubscriptions !== void 0 && requested.resourceSubscriptions.length > 0 && allow(capabilities?.resources?.subscribe)) honored.resourceSubscriptions = [...requested.resourceSubscriptions];
|
|
169
|
+
return honored;
|
|
170
|
+
}
|
|
171
|
+
/** Map a {@linkcode ServerEvent} onto its wire notification `{method, params}`. */
|
|
172
|
+
function serverEventToNotification(event) {
|
|
173
|
+
switch (event.kind) {
|
|
174
|
+
case "tools_list_changed": return { method: "notifications/tools/list_changed" };
|
|
175
|
+
case "prompts_list_changed": return { method: "notifications/prompts/list_changed" };
|
|
176
|
+
case "resources_list_changed": return { method: "notifications/resources/list_changed" };
|
|
177
|
+
case "resource_updated": return {
|
|
178
|
+
method: "notifications/resources/updated",
|
|
179
|
+
params: { uri: event.uri }
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/server/listenRouter.ts
|
|
186
|
+
/** Default capacity guard: refuse a new subscription when this many are already open. */
|
|
187
|
+
const DEFAULT_MAX_SUBSCRIPTIONS = 1024;
|
|
188
|
+
function jsonRpcError(id, code, message) {
|
|
189
|
+
return Response.json({
|
|
190
|
+
jsonrpc: "2.0",
|
|
191
|
+
error: {
|
|
192
|
+
code,
|
|
193
|
+
message
|
|
194
|
+
},
|
|
195
|
+
id
|
|
196
|
+
}, { status: 200 });
|
|
197
|
+
}
|
|
198
|
+
/** Stamp the subscription id onto a notification's `_meta`. Non-mutating. */
|
|
199
|
+
function stampSubscriptionId(notification, subscriptionId) {
|
|
200
|
+
return {
|
|
201
|
+
method: notification.method,
|
|
202
|
+
params: {
|
|
203
|
+
...notification.params,
|
|
204
|
+
_meta: {
|
|
205
|
+
...notification.params?._meta,
|
|
206
|
+
[_modelcontextprotocol_core_internal.SUBSCRIPTION_ID_META_KEY]: subscriptionId
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Read the requested filter off a `subscriptions/listen` request body.
|
|
213
|
+
* Returns the validated filter, or `undefined` when `params.notifications`
|
|
214
|
+
* is absent or fails the schema (the caller answers `-32602` — the spec
|
|
215
|
+
* marks `notifications` REQUIRED on the listen request).
|
|
216
|
+
*/
|
|
217
|
+
function parseListenFilter(message) {
|
|
218
|
+
const outcome = require_src.codecForVersion(require_src.MODERN_WIRE_REVISION).validateRequest("subscriptions/listen", message);
|
|
219
|
+
return outcome.ok ? outcome.value.params?.notifications : void 0;
|
|
220
|
+
}
|
|
221
|
+
function createListenRouter(options) {
|
|
222
|
+
const { bus, onerror } = options;
|
|
223
|
+
const maxSubscriptions = options.maxSubscriptions ?? DEFAULT_MAX_SUBSCRIPTIONS;
|
|
224
|
+
const keepAliveMs = options.keepAliveMs ?? DEFAULT_SSE_KEEP_ALIVE_MS;
|
|
225
|
+
const open = /* @__PURE__ */ new Set();
|
|
226
|
+
function serve(message, signal, capabilities, serverInfo) {
|
|
227
|
+
if (open.size >= maxSubscriptions) {
|
|
228
|
+
onerror?.(/* @__PURE__ */ new Error(`subscriptions/listen refused: subscription limit reached (${maxSubscriptions})`));
|
|
229
|
+
return jsonRpcError(message.id, -32603, "Subscription limit reached");
|
|
230
|
+
}
|
|
231
|
+
const filter = parseListenFilter(message);
|
|
232
|
+
if (filter === void 0) return jsonRpcError(message.id, -32602, "Invalid params: 'notifications' is required and must be a valid SubscriptionFilter");
|
|
233
|
+
const honored = honoredSubset(filter, capabilities);
|
|
234
|
+
const subscriptionId = message.id;
|
|
235
|
+
const encoder = new TextEncoder();
|
|
236
|
+
let controller;
|
|
237
|
+
let closed = false;
|
|
238
|
+
let unsubscribe;
|
|
239
|
+
let keepAliveTimer;
|
|
240
|
+
let abortCleanup;
|
|
241
|
+
const writeFrame = (frame) => {
|
|
242
|
+
if (closed) return;
|
|
243
|
+
try {
|
|
244
|
+
controller.enqueue(encoder.encode(frame));
|
|
245
|
+
} catch (error) {
|
|
246
|
+
onerror?.(error instanceof Error ? error : new Error(String(error)));
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const writeNotification = (method, params) => {
|
|
250
|
+
writeFrame(`event: message\ndata: ${JSON.stringify({
|
|
251
|
+
jsonrpc: "2.0",
|
|
252
|
+
method,
|
|
253
|
+
params
|
|
254
|
+
})}\n\n`);
|
|
255
|
+
};
|
|
256
|
+
const teardown = (graceful) => {
|
|
257
|
+
if (closed) return;
|
|
258
|
+
if (graceful) writeFrame(`event: message\ndata: ${JSON.stringify({
|
|
259
|
+
jsonrpc: "2.0",
|
|
260
|
+
id: subscriptionId,
|
|
261
|
+
result: {
|
|
262
|
+
resultType: "complete",
|
|
263
|
+
_meta: {
|
|
264
|
+
[_modelcontextprotocol_core_internal.SUBSCRIPTION_ID_META_KEY]: subscriptionId,
|
|
265
|
+
[_modelcontextprotocol_core_internal.SERVER_INFO_META_KEY]: serverInfo
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
})}\n\n`);
|
|
269
|
+
closed = true;
|
|
270
|
+
try {
|
|
271
|
+
unsubscribe?.();
|
|
272
|
+
} catch (error) {
|
|
273
|
+
onerror?.(error instanceof Error ? error : new Error(String(error)));
|
|
274
|
+
}
|
|
275
|
+
if (keepAliveTimer !== void 0) clearInterval(keepAliveTimer);
|
|
276
|
+
abortCleanup?.();
|
|
277
|
+
open.delete(teardown);
|
|
278
|
+
try {
|
|
279
|
+
controller.close();
|
|
280
|
+
} catch {}
|
|
281
|
+
};
|
|
282
|
+
const readable = new ReadableStream({
|
|
283
|
+
start(streamController) {
|
|
284
|
+
controller = streamController;
|
|
285
|
+
const ack = stampSubscriptionId({
|
|
286
|
+
method: "notifications/subscriptions/acknowledged",
|
|
287
|
+
params: { notifications: honored }
|
|
288
|
+
}, subscriptionId);
|
|
289
|
+
writeNotification(ack.method, ack.params);
|
|
290
|
+
unsubscribe = bus.subscribe((event) => {
|
|
291
|
+
if (closed || !listenFilterAccepts(honored, event)) return;
|
|
292
|
+
const note = stampSubscriptionId(serverEventToNotification(event), subscriptionId);
|
|
293
|
+
writeNotification(note.method, note.params);
|
|
294
|
+
});
|
|
295
|
+
keepAliveTimer = armSseKeepAlive(keepAliveMs, () => writeFrame(": keepalive\n\n"));
|
|
296
|
+
open.add(teardown);
|
|
297
|
+
},
|
|
298
|
+
cancel() {
|
|
299
|
+
teardown(false);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
if (signal !== void 0) if (signal.aborted) teardown(false);
|
|
303
|
+
else {
|
|
304
|
+
const onAbort = () => teardown(false);
|
|
305
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
306
|
+
abortCleanup = () => signal.removeEventListener("abort", onAbort);
|
|
307
|
+
}
|
|
308
|
+
return new Response(readable, {
|
|
309
|
+
status: 200,
|
|
310
|
+
headers: {
|
|
311
|
+
"Content-Type": "text/event-stream",
|
|
312
|
+
"Cache-Control": "no-cache, no-transform",
|
|
313
|
+
Connection: "keep-alive",
|
|
314
|
+
"X-Accel-Buffering": "no"
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return {
|
|
319
|
+
serve,
|
|
320
|
+
closeAll() {
|
|
321
|
+
for (const teardown of open) teardown(true);
|
|
322
|
+
},
|
|
323
|
+
get openCount() {
|
|
324
|
+
return open.size;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
const CHANGE_NOTIFICATION_METHODS = new Set([
|
|
329
|
+
"notifications/tools/list_changed",
|
|
330
|
+
"notifications/prompts/list_changed",
|
|
331
|
+
"notifications/resources/list_changed",
|
|
332
|
+
"notifications/resources/updated"
|
|
333
|
+
]);
|
|
334
|
+
/**
|
|
335
|
+
* Per-connection listen state for the stdio entry. One instance is held by
|
|
336
|
+
* `serveStdio` for the connection lifetime; it routes inbound
|
|
337
|
+
* `subscriptions/listen` / `notifications/cancelled` and rewrites outbound
|
|
338
|
+
* change notifications onto the active subscriptions. No bus — the long-lived
|
|
339
|
+
* pinned instance's existing `send*ListChanged()` calls feed straight into
|
|
340
|
+
* `routeOutbound()`.
|
|
341
|
+
*/
|
|
342
|
+
var StdioListenRouter = class {
|
|
343
|
+
/** Active subscriptions, keyed by the listen request's JSON-RPC id verbatim. */
|
|
344
|
+
_subs = /* @__PURE__ */ new Map();
|
|
345
|
+
/**
|
|
346
|
+
* The serving instance's declared capabilities. Filled in by the entry
|
|
347
|
+
* once the modern instance is constructed (the router is created before
|
|
348
|
+
* the instance exists), so the acknowledged filter is narrowed against
|
|
349
|
+
* what the server can actually deliver.
|
|
350
|
+
*/
|
|
351
|
+
_serverCapabilities;
|
|
352
|
+
/**
|
|
353
|
+
* The serving instance's identity, stamped onto the graceful-close
|
|
354
|
+
* results' `_meta` (the spec's `SubscriptionsListenResultMeta` extends
|
|
355
|
+
* `ResultMetaObject`). Handed over together with the capabilities.
|
|
356
|
+
*/
|
|
357
|
+
_serverInfo;
|
|
358
|
+
constructor(_maxSubscriptions = DEFAULT_MAX_SUBSCRIPTIONS, serverCapabilities, serverInfo) {
|
|
359
|
+
this._maxSubscriptions = _maxSubscriptions;
|
|
360
|
+
this._serverCapabilities = serverCapabilities;
|
|
361
|
+
this._serverInfo = serverInfo;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Record the serving instance's declared capabilities and identity once
|
|
365
|
+
* it has been constructed. Called by `serveStdio`'s connect path;
|
|
366
|
+
* subsequent `serve()` calls narrow the honored filter against the
|
|
367
|
+
* capabilities, and `teardownAll()` stamps the identity.
|
|
368
|
+
*/
|
|
369
|
+
setServerCapabilities(capabilities, serverInfo) {
|
|
370
|
+
this._serverCapabilities = capabilities;
|
|
371
|
+
if (serverInfo !== void 0) this._serverInfo = serverInfo;
|
|
372
|
+
}
|
|
373
|
+
/** Whether `id` is an active listen subscription on this connection. */
|
|
374
|
+
has(id) {
|
|
375
|
+
return this._subs.has(id);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Serve one inbound `subscriptions/listen` request: registers the
|
|
379
|
+
* subscription and returns the stamped acknowledged notification (or, on
|
|
380
|
+
* capacity / params rejection, the in-band JSON-RPC error response).
|
|
381
|
+
*
|
|
382
|
+
* @throws when called before {@linkcode setServerCapabilities} (or the
|
|
383
|
+
* constructor) has supplied the serving instance's capabilities. Honoring a
|
|
384
|
+
* filter without knowing the server's advertised capabilities would fail
|
|
385
|
+
* open (deliver unadvertised types); the entry guarantees capabilities are
|
|
386
|
+
* set before any listen request is routed here.
|
|
387
|
+
*/
|
|
388
|
+
serve(message) {
|
|
389
|
+
if (this._serverCapabilities === void 0) throw new Error("StdioListenRouter.serve() called before setServerCapabilities(); refusing to honor a filter without capabilities");
|
|
390
|
+
if (this._subs.size >= this._maxSubscriptions) return {
|
|
391
|
+
jsonrpc: "2.0",
|
|
392
|
+
id: message.id,
|
|
393
|
+
error: {
|
|
394
|
+
code: -32603,
|
|
395
|
+
message: "Subscription limit reached"
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
const filter = parseListenFilter(message);
|
|
399
|
+
if (filter === void 0) return {
|
|
400
|
+
jsonrpc: "2.0",
|
|
401
|
+
id: message.id,
|
|
402
|
+
error: {
|
|
403
|
+
code: -32602,
|
|
404
|
+
message: "Invalid params: 'notifications' is required and must be a valid SubscriptionFilter"
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
const honored = honoredSubset(filter, this._serverCapabilities);
|
|
408
|
+
this._subs.set(message.id, honored);
|
|
409
|
+
return stampSubscriptionId({
|
|
410
|
+
method: "notifications/subscriptions/acknowledged",
|
|
411
|
+
params: { notifications: honored }
|
|
412
|
+
}, message.id);
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Tear down one subscription (inbound `notifications/cancelled`). Returns
|
|
416
|
+
* `true` when a subscription was removed. After this call NOTHING further
|
|
417
|
+
* is delivered for that subscription id (the post-cancel hardening).
|
|
418
|
+
*/
|
|
419
|
+
cancel(id) {
|
|
420
|
+
return this._subs.delete(id);
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Route an outbound notification through the active subscriptions.
|
|
424
|
+
*
|
|
425
|
+
* - For a subscription-gated change notification, returns one stamped copy
|
|
426
|
+
* per subscription that opted in to it (an empty array means it is
|
|
427
|
+
* dropped — the modern era never delivers an un-requested change type).
|
|
428
|
+
* - For any other outbound message, returns `'passthrough'` (the entry
|
|
429
|
+
* forwards it as-is).
|
|
430
|
+
*/
|
|
431
|
+
routeOutbound(message) {
|
|
432
|
+
if (!CHANGE_NOTIFICATION_METHODS.has(message.method)) return "passthrough";
|
|
433
|
+
const uriParam = message.params?.["uri"];
|
|
434
|
+
const uri = typeof uriParam === "string" ? uriParam : void 0;
|
|
435
|
+
const event = notificationToServerEvent(message.method, uri);
|
|
436
|
+
const out = [];
|
|
437
|
+
for (const [subscriptionId, filter] of this._subs) if (listenFilterAccepts(filter, event)) out.push(stampSubscriptionId({
|
|
438
|
+
method: message.method,
|
|
439
|
+
params: message.params ?? {}
|
|
440
|
+
}, subscriptionId));
|
|
441
|
+
return out;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Server-side graceful teardown of every active subscription: returns the
|
|
445
|
+
* empty `subscriptions/listen` JSON-RPC result for each subscription id —
|
|
446
|
+
* the spec's graceful-close signal, `_meta` carrying the subscription id
|
|
447
|
+
* and the serving instance's identity — for the entry to emit before
|
|
448
|
+
* closing the wire. Clears the set so nothing further is delivered.
|
|
449
|
+
*/
|
|
450
|
+
teardownAll() {
|
|
451
|
+
const out = [];
|
|
452
|
+
for (const id of this._subs.keys()) out.push({
|
|
453
|
+
jsonrpc: "2.0",
|
|
454
|
+
id,
|
|
455
|
+
result: {
|
|
456
|
+
resultType: "complete",
|
|
457
|
+
_meta: {
|
|
458
|
+
[_modelcontextprotocol_core_internal.SUBSCRIPTION_ID_META_KEY]: id,
|
|
459
|
+
...this._serverInfo !== void 0 && { [_modelcontextprotocol_core_internal.SERVER_INFO_META_KEY]: this._serverInfo }
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
this._subs.clear();
|
|
464
|
+
return out;
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
function notificationToServerEvent(method, uri) {
|
|
468
|
+
switch (method) {
|
|
469
|
+
case "notifications/tools/list_changed": return { kind: "tools_list_changed" };
|
|
470
|
+
case "notifications/prompts/list_changed": return { kind: "prompts_list_changed" };
|
|
471
|
+
case "notifications/resources/list_changed": return { kind: "resources_list_changed" };
|
|
472
|
+
default: return {
|
|
473
|
+
kind: "resource_updated",
|
|
474
|
+
uri: uri ?? ""
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/server/legacyInputRequiredShim.ts
|
|
481
|
+
/**
|
|
482
|
+
* Default handler re-entries per originating request — tighter than the
|
|
483
|
+
* client driver's 10 because the shim holds a live wire request open.
|
|
484
|
+
*/
|
|
485
|
+
const DEFAULT_LEGACY_SHIM_MAX_ROUNDS = 8;
|
|
486
|
+
/** Default per-leg timeout: legs are human-paced, so the 60s protocol default is wrong. */
|
|
487
|
+
const DEFAULT_LEGACY_SHIM_ROUND_TIMEOUT_MS = 6e5;
|
|
488
|
+
/** Resolves and validates `ServerOptions.inputRequired`, failing loudly at construction time. */
|
|
489
|
+
function resolveLegacyShimOptions(options) {
|
|
490
|
+
if (options?.maxRounds !== void 0 && (!Number.isInteger(options.maxRounds) || options.maxRounds < 1)) throw new RangeError(`inputRequired.maxRounds must be a positive integer (got ${options.maxRounds})`);
|
|
491
|
+
if (options?.roundTimeoutMs !== void 0 && (!Number.isFinite(options.roundTimeoutMs) || options.roundTimeoutMs <= 0)) throw new RangeError(`inputRequired.roundTimeoutMs must be a positive number (got ${options.roundTimeoutMs})`);
|
|
492
|
+
return {
|
|
493
|
+
maxRounds: options?.maxRounds ?? DEFAULT_LEGACY_SHIM_MAX_ROUNDS,
|
|
494
|
+
roundTimeoutMs: options?.roundTimeoutMs ?? DEFAULT_LEGACY_SHIM_ROUND_TIMEOUT_MS,
|
|
495
|
+
legacyShim: options?.legacyShim ?? true
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Validates one `inputRequests` entry: malformed or unknown kinds are server
|
|
500
|
+
* bugs and fail loudly on both eras. Shared by the modern seam's capability
|
|
501
|
+
* check and the shim's gate.
|
|
502
|
+
*/
|
|
503
|
+
function coerceEmbeddedInputRequest(method, key, entry) {
|
|
504
|
+
if (entry === null || typeof entry !== "object" || typeof entry.method !== "string") throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an invalid input request '${key}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);
|
|
505
|
+
const embedded = entry;
|
|
506
|
+
const required = require_src.requiredClientCapabilitiesForInputRequest(embedded);
|
|
507
|
+
if (required === void 0) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${key}' of kind '${embedded.method}', which is not an embedded request the 2026-07-28 revision defines`);
|
|
508
|
+
return {
|
|
509
|
+
embedded,
|
|
510
|
+
required
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* The 2025-11-25 URL-mode wire shape requires an `elicitationId`; the 2026
|
|
515
|
+
* in-band shape has none, so URL legs mint one (CSPRNG-backed, with a
|
|
516
|
+
* getRandomValues fallback for runtimes without `randomUUID`).
|
|
517
|
+
*/
|
|
518
|
+
function syntheticElicitationId() {
|
|
519
|
+
const webCrypto = globalThis.crypto;
|
|
520
|
+
if (webCrypto?.randomUUID !== void 0) return webCrypto.randomUUID();
|
|
521
|
+
const bytes = new Uint8Array(16);
|
|
522
|
+
webCrypto.getRandomValues(bytes);
|
|
523
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
524
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
525
|
+
const hex = [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
526
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
527
|
+
}
|
|
528
|
+
/** Per-family surfacing: tools/call → isError result (the 2025 idiom); prompts/resources → JSON-RPC error. */
|
|
529
|
+
function legacyShimFailure(method, message) {
|
|
530
|
+
if (method === "tools/call") return {
|
|
531
|
+
content: [{
|
|
532
|
+
type: "text",
|
|
533
|
+
text: message
|
|
534
|
+
}],
|
|
535
|
+
isError: true
|
|
536
|
+
};
|
|
537
|
+
throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, message);
|
|
538
|
+
}
|
|
539
|
+
/** The fulfilment loop — see the module doc for the contract. */
|
|
540
|
+
var LegacyInputRequiredShim = class {
|
|
541
|
+
constructor(_host) {
|
|
542
|
+
this._host = _host;
|
|
543
|
+
}
|
|
544
|
+
async fulfill(method, handler, request, ctx, firstResult) {
|
|
545
|
+
const { maxRounds, roundTimeoutMs } = this._host;
|
|
546
|
+
const outerSignal = ctx.mcpReq.signal;
|
|
547
|
+
let current = firstResult;
|
|
548
|
+
let round = 0;
|
|
549
|
+
while (true) {
|
|
550
|
+
round += 1;
|
|
551
|
+
if (round > maxRounds) return legacyShimFailure(method, require_src.inputRequiredRoundsExceededMessage(method, maxRounds));
|
|
552
|
+
const inputRequests = current.inputRequests;
|
|
553
|
+
const hasInputRequests = inputRequests != null && Object.keys(inputRequests).length > 0;
|
|
554
|
+
const requestState = typeof current.requestState === "string" ? current.requestState : void 0;
|
|
555
|
+
if (!hasInputRequests && requestState === void 0) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);
|
|
556
|
+
let responses;
|
|
557
|
+
if (hasInputRequests) {
|
|
558
|
+
const declared = this._host.resolvedClientCapabilities(ctx);
|
|
559
|
+
const coerced = [];
|
|
560
|
+
for (const [key, entry] of Object.entries(inputRequests)) {
|
|
561
|
+
const { embedded, required } = coerceEmbeddedInputRequest(method, key, entry);
|
|
562
|
+
if (embedded.method !== "roots/list" && embedded.params === void 0) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${key}' of kind '${embedded.method}' without params`);
|
|
563
|
+
if (require_src.missingClientCapabilities(required, declared) !== void 0) return legacyShimFailure(method, `Cannot request input '${key}' (${embedded.method}): the client on this 2025-era connection did not declare the required capability${declared === void 0 ? " (no client capabilities are available on this connection — per-request legacy serving cannot receive server-to-client requests)" : ""}`);
|
|
564
|
+
coerced.push([key, embedded]);
|
|
565
|
+
}
|
|
566
|
+
const roundAbort = require_src.linkedRoundAbort(outerSignal);
|
|
567
|
+
try {
|
|
568
|
+
const legOptions = {
|
|
569
|
+
relatedRequestId: ctx.mcpReq.id,
|
|
570
|
+
timeout: roundTimeoutMs,
|
|
571
|
+
resetTimeoutOnProgress: true,
|
|
572
|
+
onprogress: () => {},
|
|
573
|
+
signal: roundAbort.signal
|
|
574
|
+
};
|
|
575
|
+
const fulfilled = await Promise.all(coerced.map(async ([key, embedded]) => {
|
|
576
|
+
try {
|
|
577
|
+
return [key, await this._dispatchLeg(embedded, legOptions)];
|
|
578
|
+
} catch (error) {
|
|
579
|
+
roundAbort.abort(error);
|
|
580
|
+
throw error;
|
|
581
|
+
}
|
|
582
|
+
}));
|
|
583
|
+
responses = Object.fromEntries(fulfilled);
|
|
584
|
+
} catch (error) {
|
|
585
|
+
if (outerSignal.aborted) throw error;
|
|
586
|
+
return legacyShimFailure(method, `Fulfilling input required by '${method}' failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
587
|
+
} finally {
|
|
588
|
+
roundAbort.dispose();
|
|
589
|
+
}
|
|
590
|
+
} else await require_src.sleep(require_src.REQUEST_STATE_ONLY_LEG_PACING_MS, outerSignal);
|
|
591
|
+
let ctxNext = {
|
|
592
|
+
...ctx,
|
|
593
|
+
mcpReq: {
|
|
594
|
+
...ctx.mcpReq,
|
|
595
|
+
inputResponses: responses,
|
|
596
|
+
droppedInputResponseKeys: void 0,
|
|
597
|
+
requestState: require_src.requestStateAccessor(requestState)
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
if (requestState !== void 0) {
|
|
601
|
+
const decoded = await this._host.verifyRequestState(requestState, ctxNext, method);
|
|
602
|
+
if (decoded !== void 0) ctxNext = require_src.withRequestStateValue(ctxNext, decoded);
|
|
603
|
+
}
|
|
604
|
+
const next = await handler(request, ctxNext);
|
|
605
|
+
if (!require_src.isInputRequiredResult(next)) return next;
|
|
606
|
+
current = next;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
/** Routes one embedded request through the host's existing 2025-era senders (gate already ran). */
|
|
610
|
+
async _dispatchLeg(embedded, options) {
|
|
611
|
+
switch (embedded.method) {
|
|
612
|
+
case "elicitation/create": {
|
|
613
|
+
let params = embedded.params;
|
|
614
|
+
if (params.mode === "url" && params.elicitationId === void 0) params = {
|
|
615
|
+
...params,
|
|
616
|
+
elicitationId: syntheticElicitationId()
|
|
617
|
+
};
|
|
618
|
+
return await this._host.sendElicitation(params, options);
|
|
619
|
+
}
|
|
620
|
+
case "sampling/createMessage": return await this._host.sendSampling(embedded.params, options);
|
|
621
|
+
case "roots/list": return await this._host.listRoots(embedded.params, options);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
//#endregion
|
|
627
|
+
//#region src/server/server.ts
|
|
628
|
+
/**
|
|
629
|
+
* The request methods whose 2026-07-28 result vocabulary includes
|
|
630
|
+
* `input_required` (the multi round-trip methods). Returning an
|
|
631
|
+
* input-required result from any other handler is a server bug.
|
|
632
|
+
*/
|
|
633
|
+
const INPUT_REQUIRED_CAPABLE_METHODS = new Set([
|
|
634
|
+
"tools/call",
|
|
635
|
+
"prompts/get",
|
|
636
|
+
"resources/read"
|
|
637
|
+
]);
|
|
638
|
+
let writeClientIdentity;
|
|
639
|
+
let installDiscoverHandler;
|
|
640
|
+
let readServerIdentity;
|
|
641
|
+
/**
|
|
642
|
+
* Package-internal: backfills the connection-scoped client-identity fields of a
|
|
643
|
+
* per-request server instance from the request's validated `_meta` envelope, so the
|
|
644
|
+
* (deprecated) {@linkcode Server.getClientCapabilities} / {@linkcode Server.getClientVersion}
|
|
645
|
+
* accessors keep answering on instances that never see an `initialize` handshake.
|
|
646
|
+
* Not public API.
|
|
647
|
+
*/
|
|
648
|
+
function seedClientIdentityFromEnvelope(server, identity) {
|
|
649
|
+
writeClientIdentity(server, identity);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Package-internal: installs the modern-only `server/discover` handler on an instance
|
|
653
|
+
* the HTTP entry has marked as serving the 2026-07-28 era, and makes sure the modern
|
|
654
|
+
* revisions the entry serves appear in the instance's supported-versions list (so the
|
|
655
|
+
* discover advertisement and version-mismatch errors name them). Idempotent.
|
|
656
|
+
* Hand-constructed instances are unaffected: nothing else calls this, so they keep
|
|
657
|
+
* answering `-32601` unless their own supported-versions list opts into a modern
|
|
658
|
+
* revision. Not public API.
|
|
659
|
+
*/
|
|
660
|
+
function installModernOnlyHandlers(server, servedModernVersions) {
|
|
661
|
+
installDiscoverHandler(server, servedModernVersions);
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Package-internal: the instance's implementation identity, for the serving
|
|
665
|
+
* entries to stamp onto entry-built results (the `subscriptions/listen`
|
|
666
|
+
* graceful-close result — built outside the encode seam, but the spec's
|
|
667
|
+
* `SubscriptionsListenResultMeta` extends `ResultMetaObject`, so it carries
|
|
668
|
+
* the serverInfo SHOULD like every other result). Not public API.
|
|
669
|
+
*/
|
|
670
|
+
function serverIdentityOf(server) {
|
|
671
|
+
return readServerIdentity(server);
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* An MCP server on top of a pluggable transport.
|
|
675
|
+
*
|
|
676
|
+
* This server will automatically respond to the initialization flow as initiated from the client.
|
|
677
|
+
*
|
|
678
|
+
* @deprecated Use {@linkcode server/mcp.McpServer | McpServer} instead for the high-level API. Only use `Server` for advanced use cases.
|
|
679
|
+
*/
|
|
680
|
+
var Server = class extends require_src.Protocol {
|
|
681
|
+
_clientCapabilities;
|
|
682
|
+
_clientVersion;
|
|
683
|
+
static {
|
|
684
|
+
writeClientIdentity = (server, identity) => {
|
|
685
|
+
if (identity.clientCapabilities !== void 0) server._clientCapabilities = identity.clientCapabilities;
|
|
686
|
+
if (identity.clientInfo !== void 0) server._clientVersion = identity.clientInfo;
|
|
687
|
+
};
|
|
688
|
+
installDiscoverHandler = (server, servedModernVersions) => {
|
|
689
|
+
const missing = servedModernVersions.filter((version) => !server._supportedProtocolVersions.includes(version));
|
|
690
|
+
if (missing.length > 0) server._supportedProtocolVersions = [...server._supportedProtocolVersions, ...missing];
|
|
691
|
+
server.setRequestHandler("server/discover", () => server._ondiscover());
|
|
692
|
+
};
|
|
693
|
+
readServerIdentity = (server) => server._serverInfo;
|
|
694
|
+
}
|
|
695
|
+
_capabilities;
|
|
696
|
+
_instructions;
|
|
697
|
+
_jsonSchemaValidator;
|
|
698
|
+
_cacheHints;
|
|
699
|
+
_requestStateVerify;
|
|
700
|
+
_inputRequiredServing;
|
|
701
|
+
_legacyShim;
|
|
702
|
+
/** Lazily-built legacy shim; the loop lives in legacyInputRequiredShim.ts behind a narrow host contract. */
|
|
703
|
+
_legacyInputRequiredShim() {
|
|
704
|
+
return this._legacyShim ??= new LegacyInputRequiredShim({
|
|
705
|
+
maxRounds: this._inputRequiredServing.maxRounds,
|
|
706
|
+
roundTimeoutMs: this._inputRequiredServing.roundTimeoutMs,
|
|
707
|
+
resolvedClientCapabilities: (ctx) => this._inputRequestCapabilityView(ctx),
|
|
708
|
+
verifyRequestState: (state, ctx, method) => this._verifyRequestState(state, ctx, method),
|
|
709
|
+
sendElicitation: (params, options) => this._sendElicitationLeg(params, options, { validateAcceptedContent: false }),
|
|
710
|
+
sendSampling: (params, options) => this.createMessage(params, options),
|
|
711
|
+
listRoots: (params, options) => this.listRoots(params, options)
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Callback for when initialization has fully completed (i.e., the client has sent an `notifications/initialized` notification).
|
|
716
|
+
*/
|
|
717
|
+
oninitialized;
|
|
718
|
+
/**
|
|
719
|
+
* Initializes this server with the given name and version information.
|
|
720
|
+
*/
|
|
721
|
+
constructor(_serverInfo, options) {
|
|
722
|
+
super(options);
|
|
723
|
+
this._serverInfo = _serverInfo;
|
|
724
|
+
this._capabilities = options?.capabilities ? { ...options.capabilities } : {};
|
|
725
|
+
this._instructions = options?.instructions;
|
|
726
|
+
this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new _modelcontextprotocol_server__shims.DefaultJsonSchemaValidator();
|
|
727
|
+
this._requestStateVerify = options?.requestState?.verify;
|
|
728
|
+
this._inputRequiredServing = resolveLegacyShimOptions(options?.inputRequired);
|
|
729
|
+
if (options?.cacheHints !== void 0) {
|
|
730
|
+
for (const [operation, hint] of Object.entries(options.cacheHints)) if (hint !== void 0) require_src.assertValidCacheHint(hint, `cacheHints['${operation}']`);
|
|
731
|
+
this._cacheHints = options.cacheHints;
|
|
732
|
+
}
|
|
733
|
+
this.setRequestHandler("initialize", (request) => this._oninitialize(request));
|
|
734
|
+
this.setNotificationHandler("notifications/initialized", () => this.oninitialized?.());
|
|
735
|
+
if (require_src.modernProtocolVersions(this._supportedProtocolVersions).length > 0) this.setRequestHandler("server/discover", () => this._ondiscover());
|
|
736
|
+
if (this._capabilities.logging) this._registerLoggingHandler();
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Registers the built-in `logging/setLevel` request handler.
|
|
740
|
+
*
|
|
741
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
742
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
743
|
+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
|
|
744
|
+
*/
|
|
745
|
+
_registerLoggingHandler() {
|
|
746
|
+
this.setRequestHandler("logging/setLevel", async (request, ctx) => {
|
|
747
|
+
const transportSessionId = ctx.sessionId || ctx.http?.req?.headers.get("mcp-session-id") || void 0;
|
|
748
|
+
const { level } = request.params;
|
|
749
|
+
const parseResult = require_src.parseSchema(_modelcontextprotocol_core_internal.LoggingLevelSchema, level);
|
|
750
|
+
if (parseResult.success) this._loggingLevels.set(transportSessionId, parseResult.data);
|
|
751
|
+
return {};
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
buildContext(ctx, transportInfo) {
|
|
755
|
+
const hasHttpInfo = ctx.http || transportInfo?.request || transportInfo?.closeSSEStream || transportInfo?.closeStandaloneSSEStream;
|
|
756
|
+
return {
|
|
757
|
+
...ctx,
|
|
758
|
+
mcpReq: {
|
|
759
|
+
...ctx.mcpReq,
|
|
760
|
+
log: (level, data, logger) => {
|
|
761
|
+
if (!this._capabilities.logging) return Promise.resolve();
|
|
762
|
+
let threshold;
|
|
763
|
+
if (this._servedModernEra()) {
|
|
764
|
+
threshold = ctx.mcpReq.envelope?.[_modelcontextprotocol_core_internal.LOG_LEVEL_META_KEY];
|
|
765
|
+
if (threshold === void 0) return Promise.resolve();
|
|
766
|
+
} else threshold = this._loggingLevels.get(ctx.sessionId) ?? this._loggingLevels.get(void 0);
|
|
767
|
+
if (threshold !== void 0 && this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(threshold)) return Promise.resolve();
|
|
768
|
+
return ctx.mcpReq.notify({
|
|
769
|
+
method: "notifications/message",
|
|
770
|
+
params: {
|
|
771
|
+
level,
|
|
772
|
+
data,
|
|
773
|
+
logger
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
},
|
|
777
|
+
elicitInput: (params, options) => this.elicitInput(params, options),
|
|
778
|
+
requestSampling: (params, options) => this.createMessage(params, options)
|
|
779
|
+
},
|
|
780
|
+
http: hasHttpInfo ? {
|
|
781
|
+
...ctx.http,
|
|
782
|
+
req: transportInfo?.request,
|
|
783
|
+
closeSSE: transportInfo?.closeSSEStream,
|
|
784
|
+
closeStandaloneSSE: transportInfo?.closeStandaloneSSEStream
|
|
785
|
+
} : void 0
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
_loggingLevels = /* @__PURE__ */ new Map();
|
|
789
|
+
LOG_LEVEL_SEVERITY = new Map(_modelcontextprotocol_core_internal.LoggingLevelSchema.options.map((level, index) => [level, index]));
|
|
790
|
+
isMessageIgnored = (level, sessionId) => {
|
|
791
|
+
const currentLevel = this._loggingLevels.get(sessionId);
|
|
792
|
+
return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
|
|
793
|
+
};
|
|
794
|
+
/**
|
|
795
|
+
* Registers new capabilities. This can only be called before connecting to a transport.
|
|
796
|
+
*
|
|
797
|
+
* The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
|
|
798
|
+
*/
|
|
799
|
+
registerCapabilities(capabilities) {
|
|
800
|
+
if (this.transport) throw new require_src.SdkError(require_src.SdkErrorCode.AlreadyConnected, "Cannot register capabilities after connecting to transport");
|
|
801
|
+
const hadLogging = !!this._capabilities.logging;
|
|
802
|
+
this._capabilities = require_src.mergeCapabilities(this._capabilities, capabilities);
|
|
803
|
+
if (!hadLogging && this._capabilities.logging) this._registerLoggingHandler();
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Enforces server-side validation for `tools/call` results regardless of how the
|
|
807
|
+
* handler was registered, attaches the configured per-operation cache hint
|
|
808
|
+
* (when one exists) so the 2026-07-28 encode seam can fill `ttlMs`/`cacheScope`
|
|
809
|
+
* for results that do not provide their own, and owns the multi-round-trip
|
|
810
|
+
* seam: on the methods whose 2026-07-28 result vocabulary includes
|
|
811
|
+
* `input_required` (`tools/call`, `prompts/get`, `resources/read`) an
|
|
812
|
+
* input-required return skips result-schema validation and is checked
|
|
813
|
+
* against the served era, the at-least-one rule, and the request's own
|
|
814
|
+
* declared client capabilities; on every other method an input-required
|
|
815
|
+
* return is a server bug and fails loudly. The hint rides a symbol-keyed
|
|
816
|
+
* property that is never serialized, so 2025-era responses are unaffected.
|
|
817
|
+
*/
|
|
818
|
+
_wrapHandler(method, handler) {
|
|
819
|
+
if (method !== "tools/call") {
|
|
820
|
+
const cacheHint = this._cacheHints?.[method];
|
|
821
|
+
const isInputRequiredCapable = INPUT_REQUIRED_CAPABLE_METHODS.has(method);
|
|
822
|
+
if (cacheHint === void 0 && !isInputRequiredCapable) return async (request, ctx) => {
|
|
823
|
+
const result = await handler(request, ctx);
|
|
824
|
+
if (require_src.isInputRequiredResult(result)) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);
|
|
825
|
+
return result;
|
|
826
|
+
};
|
|
827
|
+
return async (request, ctx) => {
|
|
828
|
+
const result = isInputRequiredCapable ? await this._invokeInputRequiredCapableHandler(method, handler, request, ctx) : await handler(request, ctx);
|
|
829
|
+
if (require_src.isInputRequiredResult(result)) {
|
|
830
|
+
if (!isInputRequiredCapable) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);
|
|
831
|
+
return result;
|
|
832
|
+
}
|
|
833
|
+
return cacheHint === void 0 ? result : require_src.attachCacheHintFallback(result, cacheHint);
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
return async (request, ctx) => {
|
|
837
|
+
const codec = require_src.codecForVersion(this._negotiatedProtocolVersion);
|
|
838
|
+
const validatedRequest = codec.validateRequest("tools/call", request);
|
|
839
|
+
if (!validatedRequest.ok) throw new require_src.ProtocolError(validatedRequest.reason === "not-in-era" ? require_src.ProtocolErrorCode.InternalError : require_src.ProtocolErrorCode.InvalidParams, validatedRequest.reason === "not-in-era" ? "No wire schema for tools/call in the resolved era" : `Invalid tools/call request: ${validatedRequest.message}`);
|
|
840
|
+
const result = await this._invokeInputRequiredCapableHandler("tools/call", handler, request, ctx);
|
|
841
|
+
if (require_src.isInputRequiredResult(result)) return result;
|
|
842
|
+
const normalizedResult = require_src.normalizeContentlessToolResult(result);
|
|
843
|
+
const validationResult = codec.validateResult("tools/call", normalizedResult);
|
|
844
|
+
if (!validationResult.ok) throw new require_src.ProtocolError(validationResult.reason === "not-in-era" ? require_src.ProtocolErrorCode.InternalError : require_src.ProtocolErrorCode.InvalidParams, validationResult.reason === "not-in-era" ? "No wire schema for tools/call in the resolved era" : `Invalid tools/call result: ${validationResult.message}`);
|
|
845
|
+
return validationResult.value;
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Whether this instance is bound to a 2026-07-28-or-later protocol
|
|
850
|
+
* revision. Era is instance state — a serving entry (`createMcpHandler`,
|
|
851
|
+
* `serveStdio`) marks the instance modern at construction; a 2025-era
|
|
852
|
+
* `initialize` handshake binds it legacy. The multi-round-trip seam reads
|
|
853
|
+
* this directly: there is no per-request era consult.
|
|
854
|
+
*/
|
|
855
|
+
_servedModernEra() {
|
|
856
|
+
return this._negotiatedProtocolVersion !== void 0 && require_src.isModernProtocolVersion(this._negotiatedProtocolVersion);
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Invokes a handler for one of the multi-round-trip methods and applies
|
|
860
|
+
* the input-required seam:
|
|
861
|
+
*
|
|
862
|
+
* - a `UrlElicitationRequiredError` (or any 2025-style server→client
|
|
863
|
+
* request idiom) escaping the handler on a request served on the
|
|
864
|
+
* 2026-07-28 era fails LOUDLY with a clear steer to
|
|
865
|
+
* `inputRequired.elicitUrl(...)` — the `-32042` error never reaches the
|
|
866
|
+
* 2026-07-28 wire and the throw is not silently converted. Requests
|
|
867
|
+
* served on the 2025 era keep today's `-32042` behavior byte-exact (the
|
|
868
|
+
* error is rethrown unchanged).
|
|
869
|
+
* - an input-required RETURN toward a 2026-07-28 request must satisfy
|
|
870
|
+
* the at-least-one rule, and every embedded request must be covered by
|
|
871
|
+
* the capabilities declared on the request's envelope (violations
|
|
872
|
+
* answer the typed `-32021` error). Toward a 2025-era request the
|
|
873
|
+
* return is fulfilled by the default-on legacy shim, whose own gate
|
|
874
|
+
* consults the initialize-declared capabilities and surfaces
|
|
875
|
+
* violations per family; `inputRequired.legacyShim: false` restores
|
|
876
|
+
* the pre-shim loud failure.
|
|
877
|
+
*/
|
|
878
|
+
async _invokeInputRequiredCapableHandler(method, handler, request, ctx) {
|
|
879
|
+
const servedModern = this._servedModernEra();
|
|
880
|
+
const rawRequestState = ctx.mcpReq.requestState();
|
|
881
|
+
if (rawRequestState !== void 0 && typeof rawRequestState !== "string") throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, "Invalid or expired requestState", { reason: "invalid_request_state" });
|
|
882
|
+
let ctxForHandler = ctx;
|
|
883
|
+
if (typeof rawRequestState === "string") {
|
|
884
|
+
const decoded = await this._verifyRequestState(rawRequestState, ctx, method);
|
|
885
|
+
if (decoded !== void 0) ctxForHandler = require_src.withRequestStateValue(ctx, decoded);
|
|
886
|
+
}
|
|
887
|
+
let result;
|
|
888
|
+
try {
|
|
889
|
+
result = await handler(request, ctxForHandler);
|
|
890
|
+
} catch (error) {
|
|
891
|
+
if (error instanceof require_src.ProtocolError && error.code === require_src.ProtocolErrorCode.UrlElicitationRequired) {
|
|
892
|
+
if (!servedModern) throw error;
|
|
893
|
+
throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `URL elicitation cannot be signalled by throwing UrlElicitationRequiredError on protocol revision ${this._negotiatedProtocolVersion}: return inputRequired({ inputRequests: { …: inputRequired.elicitUrl(...) } }) from the handler instead. The urlElicitationRequired error (-32042) of earlier revisions is not available on this revision.`);
|
|
894
|
+
}
|
|
895
|
+
throw error;
|
|
896
|
+
}
|
|
897
|
+
if (!require_src.isInputRequiredResult(result)) return result;
|
|
898
|
+
if (!servedModern) {
|
|
899
|
+
if (!this._inputRequiredServing.legacyShim) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion ?? _modelcontextprotocol_core_internal.LATEST_PROTOCOL_VERSION}, which has no input_required vocabulary`);
|
|
900
|
+
return await this._legacyInputRequiredShim().fulfill(method, handler, request, ctxForHandler, result);
|
|
901
|
+
}
|
|
902
|
+
const inputRequests = result.inputRequests;
|
|
903
|
+
const hasInputRequests = inputRequests != null && Object.keys(inputRequests).length > 0;
|
|
904
|
+
const hasRequestState = typeof result.requestState === "string";
|
|
905
|
+
if (!hasInputRequests && !hasRequestState) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);
|
|
906
|
+
if (hasInputRequests) {
|
|
907
|
+
const declared = this._inputRequestCapabilityView(ctx);
|
|
908
|
+
for (const [key, entry] of Object.entries(inputRequests)) {
|
|
909
|
+
const { embedded, required } = coerceEmbeddedInputRequest(method, key, entry);
|
|
910
|
+
const missing = require_src.missingClientCapabilities(required, declared);
|
|
911
|
+
if (missing !== void 0) throw new require_src.MissingRequiredClientCapabilityError({ requiredCapabilities: missing }, `Cannot request input '${key}' (${embedded.method}): the request's client capabilities do not declare the required capability`);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
return result;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Runs the configured `requestState.verify` hook and returns its
|
|
918
|
+
* resolved value (`undefined` when unconfigured or the hook returns
|
|
919
|
+
* nothing). Deny-on-error: any hook failure answers the frozen `-32602`;
|
|
920
|
+
* the reason goes to `onerror` only.
|
|
921
|
+
*/
|
|
922
|
+
async _verifyRequestState(state, ctx, method) {
|
|
923
|
+
if (this._requestStateVerify === void 0) return;
|
|
924
|
+
try {
|
|
925
|
+
return await this._requestStateVerify(state, ctx);
|
|
926
|
+
} catch (error) {
|
|
927
|
+
this.onerror?.(/* @__PURE__ */ new Error(`requestState verification rejected ${method}: ${error instanceof Error ? error.message : String(error)}`));
|
|
928
|
+
throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, "Invalid or expired requestState", { reason: "invalid_request_state" });
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* The per-request resolved client-capabilities view: the request's own
|
|
933
|
+
* `_meta` envelope on the 2026 era; the `initialize`-declared state on a
|
|
934
|
+
* 2025-era connection. Per-request instances that never saw an
|
|
935
|
+
* initialize (stateless legacy) hold nothing, so gates refuse there.
|
|
936
|
+
*/
|
|
937
|
+
_inputRequestCapabilityView(ctx) {
|
|
938
|
+
return this._servedModernEra() ? ctx.mcpReq.envelope?.[_modelcontextprotocol_core_internal.CLIENT_CAPABILITIES_META_KEY] : this._clientCapabilities;
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Guard for the push-style server→client request APIs ({@linkcode createMessage},
|
|
942
|
+
* {@linkcode elicitInput}, {@linkcode listRoots}, {@linkcode ping}) on a
|
|
943
|
+
* modern-era instance: the 2026-07-28 revision has no server→client request
|
|
944
|
+
* channel, so the call fails before any wire traffic with a typed error
|
|
945
|
+
* whose message steers to `inputRequired(...)`. The base era gate would
|
|
946
|
+
* also reject it; this guard runs first to carry the steer.
|
|
947
|
+
*/
|
|
948
|
+
_assertPushApiInServedEra(method) {
|
|
949
|
+
if (this._servedModernEra()) throw new require_src.SdkError(require_src.SdkErrorCode.MethodNotSupportedByProtocolVersion, `Server-to-client requests are not available on protocol revision ${this._negotiatedProtocolVersion}: '${method}' cannot be sent while serving a request on that revision. Return inputRequired({ ... }) from the handler instead — the client fulfils the embedded requests and retries the original request (multi round-trip requests).`, {
|
|
950
|
+
method,
|
|
951
|
+
era: "2026-07-28"
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
assertCapabilityForMethod(method) {
|
|
955
|
+
switch (method) {
|
|
956
|
+
case "sampling/createMessage":
|
|
957
|
+
if (!this._clientCapabilities?.sampling) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Client does not support sampling (required for ${method})`);
|
|
958
|
+
break;
|
|
959
|
+
case "elicitation/create":
|
|
960
|
+
if (!this._clientCapabilities?.elicitation) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Client does not support elicitation (required for ${method})`);
|
|
961
|
+
break;
|
|
962
|
+
case "roots/list":
|
|
963
|
+
if (!this._clientCapabilities?.roots) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Client does not support listing roots (required for ${method})`);
|
|
964
|
+
break;
|
|
965
|
+
case "ping": break;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
assertNotificationCapability(method) {
|
|
969
|
+
switch (method) {
|
|
970
|
+
case "notifications/message":
|
|
971
|
+
if (!this._capabilities.logging) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support logging (required for ${method})`);
|
|
972
|
+
break;
|
|
973
|
+
case "notifications/resources/updated":
|
|
974
|
+
case "notifications/resources/list_changed":
|
|
975
|
+
if (!this._capabilities.resources) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support notifying about resources (required for ${method})`);
|
|
976
|
+
break;
|
|
977
|
+
case "notifications/tools/list_changed":
|
|
978
|
+
if (!this._capabilities.tools) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support notifying of tool list changes (required for ${method})`);
|
|
979
|
+
break;
|
|
980
|
+
case "notifications/prompts/list_changed":
|
|
981
|
+
if (!this._capabilities.prompts) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support notifying of prompt list changes (required for ${method})`);
|
|
982
|
+
break;
|
|
983
|
+
case "notifications/elicitation/complete":
|
|
984
|
+
if (!this._clientCapabilities?.elicitation?.url) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Client does not support URL elicitation (required for ${method})`);
|
|
985
|
+
break;
|
|
986
|
+
case "notifications/cancelled": break;
|
|
987
|
+
case "notifications/progress": break;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
assertRequestHandlerCapability(method) {
|
|
991
|
+
switch (method) {
|
|
992
|
+
case "completion/complete":
|
|
993
|
+
if (!this._capabilities.completions) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support completions (required for ${method})`);
|
|
994
|
+
break;
|
|
995
|
+
case "logging/setLevel":
|
|
996
|
+
if (!this._capabilities.logging) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support logging (required for ${method})`);
|
|
997
|
+
break;
|
|
998
|
+
case "prompts/get":
|
|
999
|
+
case "prompts/list":
|
|
1000
|
+
if (!this._capabilities.prompts) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support prompts (required for ${method})`);
|
|
1001
|
+
break;
|
|
1002
|
+
case "resources/list":
|
|
1003
|
+
case "resources/templates/list":
|
|
1004
|
+
case "resources/read":
|
|
1005
|
+
if (!this._capabilities.resources) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support resources (required for ${method})`);
|
|
1006
|
+
break;
|
|
1007
|
+
case "tools/call":
|
|
1008
|
+
case "tools/list":
|
|
1009
|
+
if (!this._capabilities.tools) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, `Server does not support tools (required for ${method})`);
|
|
1010
|
+
break;
|
|
1011
|
+
case "ping":
|
|
1012
|
+
case "initialize": break;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
async _oninitialize(request) {
|
|
1016
|
+
const requestedVersion = request.params.protocolVersion;
|
|
1017
|
+
this._clientCapabilities = request.params.capabilities;
|
|
1018
|
+
this._clientVersion = request.params.clientInfo;
|
|
1019
|
+
const legacyVersions = require_src.legacyProtocolVersions(this._supportedProtocolVersions);
|
|
1020
|
+
const protocolVersion = legacyVersions.includes(requestedVersion) ? requestedVersion : legacyVersions[0] ?? _modelcontextprotocol_core_internal.LATEST_PROTOCOL_VERSION;
|
|
1021
|
+
this._negotiatedProtocolVersion = protocolVersion;
|
|
1022
|
+
this.transport?.setProtocolVersion?.(protocolVersion);
|
|
1023
|
+
return {
|
|
1024
|
+
protocolVersion,
|
|
1025
|
+
capabilities: this.getCapabilities(),
|
|
1026
|
+
serverInfo: this._serverInfo,
|
|
1027
|
+
...this._instructions && { instructions: this._instructions }
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Answers `server/discover` (protocol revision 2026-07-28). `supportedVersions`
|
|
1032
|
+
* lists only modern revisions (2025-era versions are negotiated via `initialize`);
|
|
1033
|
+
* the capabilities are advertised as-is, listChanged/subscribe bits included
|
|
1034
|
+
* (see {@linkcode discoverAdvertisedCapabilities}).
|
|
1035
|
+
*/
|
|
1036
|
+
_ondiscover() {
|
|
1037
|
+
return {
|
|
1038
|
+
supportedVersions: require_src.modernProtocolVersions(this._supportedProtocolVersions),
|
|
1039
|
+
capabilities: discoverAdvertisedCapabilities(this.getCapabilities()),
|
|
1040
|
+
...this._instructions && { instructions: this._instructions }
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* The identity the 2026-era encode seam stamps into every outbound
|
|
1045
|
+
* result's `_meta` under `io.modelcontextprotocol/serverInfo` (spec PR
|
|
1046
|
+
* #3002: servers SHOULD identify themselves on every response).
|
|
1047
|
+
*/
|
|
1048
|
+
_outboundServerInfo() {
|
|
1049
|
+
return this._serverInfo;
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* After initialization has completed, this will be populated with the client's reported capabilities.
|
|
1053
|
+
*
|
|
1054
|
+
* @deprecated Read client identity from the per-request handler context instead: on
|
|
1055
|
+
* 2026-07-28 (per-request envelope) requests `ctx.mcpReq.envelope` carries the client's
|
|
1056
|
+
* declared capabilities, while on 2025-era connections this accessor keeps returning the
|
|
1057
|
+
* `initialize`-scoped value. The accessor remains functional — instances serving the
|
|
1058
|
+
* 2026-07-28 era are backfilled per request from the validated envelope.
|
|
1059
|
+
*/
|
|
1060
|
+
getClientCapabilities() {
|
|
1061
|
+
return this._clientCapabilities;
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* After initialization has completed, this will be populated with information about the client's name and version.
|
|
1065
|
+
*
|
|
1066
|
+
* @deprecated Read client identity from the per-request handler context instead: on
|
|
1067
|
+
* 2026-07-28 (per-request envelope) requests `ctx.mcpReq.envelope` carries the client's
|
|
1068
|
+
* name and version, while on 2025-era connections this accessor keeps returning the
|
|
1069
|
+
* `initialize`-scoped value. The accessor remains functional — instances serving the
|
|
1070
|
+
* 2026-07-28 era are backfilled per request from the validated envelope.
|
|
1071
|
+
*/
|
|
1072
|
+
getClientVersion() {
|
|
1073
|
+
return this._clientVersion;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* After initialization has completed, this will be populated with the protocol version negotiated
|
|
1077
|
+
* with the client (the version the server responded with during the initialize handshake), or
|
|
1078
|
+
* `undefined` before initialization.
|
|
1079
|
+
*
|
|
1080
|
+
* @deprecated Read the protocol revision from the per-request handler context instead: on
|
|
1081
|
+
* 2026-07-28 (per-request envelope) requests `ctx.mcpReq.envelope` names the revision the
|
|
1082
|
+
* request was sent for, while on 2025-era connections this accessor keeps returning the
|
|
1083
|
+
* `initialize`-negotiated version. The accessor remains functional — instances serving the
|
|
1084
|
+
* 2026-07-28 era report that revision.
|
|
1085
|
+
*/
|
|
1086
|
+
getNegotiatedProtocolVersion() {
|
|
1087
|
+
return this._negotiatedProtocolVersion;
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Project a `tools/call` result through this instance's negotiated wire
|
|
1091
|
+
* codec — the era-agnostic SEP-2106 §4.3 TextContent auto-append, plus on
|
|
1092
|
+
* the 2025 era the `{result:…}` wrap when `structuredContent` is a
|
|
1093
|
+
* non-object value or the advertised `outputSchema` had a non-object root.
|
|
1094
|
+
* Identity for object-shaped `structuredContent` on the 2026 era.
|
|
1095
|
+
*
|
|
1096
|
+
* `McpServer`'s built-in `tools/call` handler routes through this method.
|
|
1097
|
+
* Low-level `setRequestHandler('tools/call', …)` authors call it
|
|
1098
|
+
* themselves so the projection lives in one place (the codec) and the
|
|
1099
|
+
* server-side handler stays era-blind.
|
|
1100
|
+
*
|
|
1101
|
+
* This is the only codec function exposed on `Server` — the full
|
|
1102
|
+
* `WireCodec` is intentionally not part of the public surface.
|
|
1103
|
+
*/
|
|
1104
|
+
projectCallToolResult(result, advertisedOutputSchema) {
|
|
1105
|
+
return this._wireCodec().projectCallToolResult(result, advertisedOutputSchema);
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Returns the current server capabilities.
|
|
1109
|
+
*/
|
|
1110
|
+
getCapabilities() {
|
|
1111
|
+
return this._capabilities;
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Sends a `ping` request to the connected client.
|
|
1115
|
+
*
|
|
1116
|
+
* @deprecated The 2026-07-28 protocol removed ping; it throws on a 2026-07-28-era instance.
|
|
1117
|
+
* If your factory serves both eras, this only works on the legacy path.
|
|
1118
|
+
*/
|
|
1119
|
+
async ping() {
|
|
1120
|
+
this._assertPushApiInServedEra("ping");
|
|
1121
|
+
return this.request({ method: "ping" });
|
|
1122
|
+
}
|
|
1123
|
+
async createMessage(params, options) {
|
|
1124
|
+
this._assertPushApiInServedEra("sampling/createMessage");
|
|
1125
|
+
if ((params.tools || params.toolChoice) && !this._clientCapabilities?.sampling?.tools) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, "Client does not support sampling tools capability.");
|
|
1126
|
+
if (params.messages.length > 0) {
|
|
1127
|
+
const lastMessage = params.messages.at(-1);
|
|
1128
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
1129
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
1130
|
+
const previousMessage = params.messages.length > 1 ? params.messages.at(-2) : void 0;
|
|
1131
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
1132
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
1133
|
+
if (hasToolResults) {
|
|
1134
|
+
if (lastContent.some((c) => c.type !== "tool_result")) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, "The last message must contain only tool_result content if any is present");
|
|
1135
|
+
if (!hasPreviousToolUse) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, "tool_result blocks are not matching any tool_use from the previous message");
|
|
1136
|
+
}
|
|
1137
|
+
if (hasPreviousToolUse) {
|
|
1138
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
1139
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
1140
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, "ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
const hasTools = Boolean(params.tools || params.toolChoice);
|
|
1144
|
+
const wide = await this.request({
|
|
1145
|
+
method: "sampling/createMessage",
|
|
1146
|
+
params
|
|
1147
|
+
}, options);
|
|
1148
|
+
const outcome = this._wireCodec().samplingResultVariant(hasTools, wide);
|
|
1149
|
+
if (!outcome.ok) throw new require_src.SdkError(require_src.SdkErrorCode.InvalidResult, `Invalid sampling/createMessage result: ${outcome.reason === "invalid" ? outcome.message : outcome.reason}`);
|
|
1150
|
+
return outcome.value;
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Creates an elicitation request for the given parameters.
|
|
1154
|
+
* For backwards compatibility, `mode` may be omitted for form requests and will default to `"form"`.
|
|
1155
|
+
* @param params The parameters for the elicitation request.
|
|
1156
|
+
* @param options Optional request options.
|
|
1157
|
+
* @returns The result of the elicitation request.
|
|
1158
|
+
*
|
|
1159
|
+
* @deprecated Throws on a 2026-07-28-era request — use {@link index.inputRequired | inputRequired} (multi-round-trip)
|
|
1160
|
+
* instead. The 2025 push-style server-to-client request model is replaced by input_required
|
|
1161
|
+
* results in the 2026-07-28 protocol. If your factory serves both eras, this only works on the
|
|
1162
|
+
* legacy path.
|
|
1163
|
+
*/
|
|
1164
|
+
async elicitInput(params, options) {
|
|
1165
|
+
this._assertPushApiInServedEra("elicitation/create");
|
|
1166
|
+
switch (params.mode ?? "form") {
|
|
1167
|
+
case "url":
|
|
1168
|
+
if (!this._clientCapabilities?.elicitation?.url) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, "Client does not support url elicitation.");
|
|
1169
|
+
break;
|
|
1170
|
+
case "form":
|
|
1171
|
+
if (!this._clientCapabilities?.elicitation?.form) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, "Client does not support form elicitation.");
|
|
1172
|
+
break;
|
|
1173
|
+
}
|
|
1174
|
+
return this._sendElicitationLeg(params, options);
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* The capability-check-free core of {@linkcode elicitInput}. The shim
|
|
1178
|
+
* uses it because its gate differs from the public checks: a bare
|
|
1179
|
+
* `elicitation: {}` counts as form support (the pre-mode rule), and
|
|
1180
|
+
* accepted content passes through unvalidated for parity with the
|
|
1181
|
+
* modern client driver (handlers validate via the schema-aware
|
|
1182
|
+
* `acceptedContent` overload and can re-ask).
|
|
1183
|
+
*/
|
|
1184
|
+
async _sendElicitationLeg(params, options, behavior) {
|
|
1185
|
+
const mode = params.mode ?? "form";
|
|
1186
|
+
const validateAcceptedContent = behavior?.validateAcceptedContent ?? true;
|
|
1187
|
+
switch (mode) {
|
|
1188
|
+
case "url": {
|
|
1189
|
+
const urlParams = params;
|
|
1190
|
+
return this.request({
|
|
1191
|
+
method: "elicitation/create",
|
|
1192
|
+
params: urlParams
|
|
1193
|
+
}, options);
|
|
1194
|
+
}
|
|
1195
|
+
case "form": {
|
|
1196
|
+
const formParams = params.mode === "form" ? params : {
|
|
1197
|
+
...params,
|
|
1198
|
+
mode: "form"
|
|
1199
|
+
};
|
|
1200
|
+
const result = await this.request({
|
|
1201
|
+
method: "elicitation/create",
|
|
1202
|
+
params: formParams
|
|
1203
|
+
}, options);
|
|
1204
|
+
if (validateAcceptedContent && result.action === "accept" && result.content && formParams.requestedSchema) try {
|
|
1205
|
+
const validationResult = this._jsonSchemaValidator.getValidator(formParams.requestedSchema)(result.content);
|
|
1206
|
+
if (!validationResult.valid) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Elicitation response content does not match requested schema: ${validationResult.errorMessage}`);
|
|
1207
|
+
} catch (error) {
|
|
1208
|
+
if (error instanceof require_src.ProtocolError) throw error;
|
|
1209
|
+
throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InternalError, `Error validating elicitation response: ${error instanceof Error ? error.message : String(error)}`);
|
|
1210
|
+
}
|
|
1211
|
+
return result;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Creates a reusable callback that, when invoked, will send a `notifications/elicitation/complete`
|
|
1217
|
+
* notification for the specified elicitation ID.
|
|
1218
|
+
*
|
|
1219
|
+
* The notification (and the `elicitationId` it references) exists only on protocol revision
|
|
1220
|
+
* 2025-11-25 — the 2026-07-28 revision removed both. On a connection negotiated at 2026-07-28 the
|
|
1221
|
+
* returned callback rejects with a typed local error before anything reaches the transport
|
|
1222
|
+
* (the method is not part of that revision's wire registry).
|
|
1223
|
+
*
|
|
1224
|
+
* @param elicitationId The ID of the elicitation to mark as complete.
|
|
1225
|
+
* @param options Optional notification options. Useful when the completion notification should be related to a prior request.
|
|
1226
|
+
* @returns A function that emits the completion notification when awaited.
|
|
1227
|
+
*/
|
|
1228
|
+
createElicitationCompletionNotifier(elicitationId, options) {
|
|
1229
|
+
if (!this._clientCapabilities?.elicitation?.url) throw new require_src.SdkError(require_src.SdkErrorCode.CapabilityNotSupported, "Client does not support URL elicitation (required for notifications/elicitation/complete)");
|
|
1230
|
+
return () => this.notification({
|
|
1231
|
+
method: "notifications/elicitation/complete",
|
|
1232
|
+
params: { elicitationId }
|
|
1233
|
+
}, options);
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Requests the list of roots from the client.
|
|
1237
|
+
*
|
|
1238
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1239
|
+
* Throws on a 2026-07-28-era request — use {@link index.inputRequired | inputRequired} (multi-round-trip) instead,
|
|
1240
|
+
* or migrate to passing paths via tool parameters, resource URIs, or configuration. The 2025
|
|
1241
|
+
* push-style server-to-client request model is replaced by input_required results in the
|
|
1242
|
+
* 2026-07-28 protocol. If your factory serves both eras, this only works on the legacy path.
|
|
1243
|
+
*/
|
|
1244
|
+
async listRoots(params, options) {
|
|
1245
|
+
this._assertPushApiInServedEra("roots/list");
|
|
1246
|
+
return this.request({
|
|
1247
|
+
method: "roots/list",
|
|
1248
|
+
params
|
|
1249
|
+
}, options);
|
|
1250
|
+
}
|
|
1251
|
+
/**
|
|
1252
|
+
* Sends a logging message to the client, if connected.
|
|
1253
|
+
* Note: You only need to send the parameters object, not the entire JSON-RPC message.
|
|
1254
|
+
* @see {@linkcode LoggingMessageNotification}
|
|
1255
|
+
* @param params
|
|
1256
|
+
* @param sessionId Optional for stateless transports and backward compatibility.
|
|
1257
|
+
*
|
|
1258
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1259
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
1260
|
+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
|
|
1261
|
+
*/
|
|
1262
|
+
async sendLoggingMessage(params, sessionId) {
|
|
1263
|
+
if (this._capabilities.logging && !this.isMessageIgnored(params.level, sessionId)) return this.notification({
|
|
1264
|
+
method: "notifications/message",
|
|
1265
|
+
params
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
async sendResourceUpdated(params) {
|
|
1269
|
+
return this.notification({
|
|
1270
|
+
method: "notifications/resources/updated",
|
|
1271
|
+
params
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
async sendResourceListChanged() {
|
|
1275
|
+
return this.notification({ method: "notifications/resources/list_changed" });
|
|
1276
|
+
}
|
|
1277
|
+
async sendToolListChanged() {
|
|
1278
|
+
return this.notification({ method: "notifications/tools/list_changed" });
|
|
1279
|
+
}
|
|
1280
|
+
async sendPromptListChanged() {
|
|
1281
|
+
return this.notification({ method: "notifications/prompts/list_changed" });
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
/**
|
|
1285
|
+
* The capability set a server advertises on `server/discover`. Pure — never
|
|
1286
|
+
* mutates the input; the legacy `initialize` advertisement is untouched.
|
|
1287
|
+
*
|
|
1288
|
+
* The serving entries serve `subscriptions/listen` themselves, so the
|
|
1289
|
+
* `listChanged` and `resources.subscribe` capability bits are advertised
|
|
1290
|
+
* as-is: a modern-era client uses them to decide which notification types to
|
|
1291
|
+
* request on its listen filter.
|
|
1292
|
+
*/
|
|
1293
|
+
function discoverAdvertisedCapabilities(capabilities) {
|
|
1294
|
+
return { ...capabilities };
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
//#endregion
|
|
1298
|
+
//#region src/server/mcp.ts
|
|
1299
|
+
/**
|
|
1300
|
+
* High-level MCP server that provides a simpler API for working with resources, tools, and prompts.
|
|
1301
|
+
* For advanced usage (like sending notifications or setting custom request handlers), use the underlying
|
|
1302
|
+
* {@linkcode Server} instance available via the {@linkcode McpServer.server | server} property.
|
|
1303
|
+
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* ```ts source="./mcp.examples.ts#McpServer_basicUsage"
|
|
1306
|
+
* const server = new McpServer({
|
|
1307
|
+
* name: 'my-server',
|
|
1308
|
+
* version: '1.0.0'
|
|
1309
|
+
* });
|
|
1310
|
+
* ```
|
|
1311
|
+
*/
|
|
1312
|
+
var McpServer = class {
|
|
1313
|
+
/**
|
|
1314
|
+
* The underlying {@linkcode Server} instance, useful for advanced operations like sending notifications.
|
|
1315
|
+
*/
|
|
1316
|
+
server;
|
|
1317
|
+
_registeredResources = {};
|
|
1318
|
+
_registeredResourceTemplates = {};
|
|
1319
|
+
_registeredTools = {};
|
|
1320
|
+
_registeredPrompts = {};
|
|
1321
|
+
/**
|
|
1322
|
+
* Per-tool JSON-converted `inputSchema`, memoized so the SEP-2243
|
|
1323
|
+
* registration-time scan and the pre-dispatch validation step share one
|
|
1324
|
+
* conversion instead of paying it twice per request under the
|
|
1325
|
+
* per-request-factory `createMcpHandler` model.
|
|
1326
|
+
*/
|
|
1327
|
+
_toolInputSchemaJson = {};
|
|
1328
|
+
/**
|
|
1329
|
+
* The JSON-serialized `inputSchema` of a registered tool, or `undefined`
|
|
1330
|
+
* when no such tool is registered. Used by the HTTP entry's pre-dispatch
|
|
1331
|
+
* SEP-2243 `Mcp-Param-*` validation step (which needs the same JSON Schema
|
|
1332
|
+
* `tools/list` would emit, before dispatch reaches the handler).
|
|
1333
|
+
*
|
|
1334
|
+
* @internal
|
|
1335
|
+
*/
|
|
1336
|
+
toolInputSchemaJson(name) {
|
|
1337
|
+
const tool = this._registeredTools[name];
|
|
1338
|
+
if (tool === void 0 || !tool.enabled) return void 0;
|
|
1339
|
+
if (Object.hasOwn(this._toolInputSchemaJson, name)) return this._toolInputSchemaJson[name];
|
|
1340
|
+
if (tool.inputSchema === void 0) return EMPTY_OBJECT_JSON_SCHEMA;
|
|
1341
|
+
try {
|
|
1342
|
+
const json = require_src.standardSchemaToJsonSchema(tool.inputSchema, "input");
|
|
1343
|
+
this._toolInputSchemaJson[name] = json;
|
|
1344
|
+
return json;
|
|
1345
|
+
} catch {
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
constructor(serverInfo, options) {
|
|
1350
|
+
this.server = new Server(serverInfo, options);
|
|
1351
|
+
if (options?.capabilities?.tools) this.setToolRequestHandlers();
|
|
1352
|
+
if (options?.capabilities?.resources) this.setResourceRequestHandlers();
|
|
1353
|
+
if (options?.capabilities?.prompts) this.setPromptRequestHandlers();
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* Attaches to the given transport, starts it, and starts listening for messages.
|
|
1357
|
+
*
|
|
1358
|
+
* The `server` object assumes ownership of the {@linkcode Transport}, replacing any callbacks that have already been set, and expects that it is the only user of the {@linkcode Transport} instance going forward.
|
|
1359
|
+
*
|
|
1360
|
+
* @example
|
|
1361
|
+
* ```ts source="./mcp.examples.ts#McpServer_connect_stdio"
|
|
1362
|
+
* const server = new McpServer({ name: 'my-server', version: '1.0.0' });
|
|
1363
|
+
* const transport = new StdioServerTransport();
|
|
1364
|
+
* await server.connect(transport);
|
|
1365
|
+
* ```
|
|
1366
|
+
*/
|
|
1367
|
+
async connect(transport) {
|
|
1368
|
+
return await this.server.connect(transport);
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Closes the connection.
|
|
1372
|
+
*/
|
|
1373
|
+
async close() {
|
|
1374
|
+
await this.server.close();
|
|
1375
|
+
}
|
|
1376
|
+
_toolHandlersInitialized = false;
|
|
1377
|
+
setToolRequestHandlers() {
|
|
1378
|
+
if (this._toolHandlersInitialized) return;
|
|
1379
|
+
this.server.assertCanSetRequestHandler("tools/list");
|
|
1380
|
+
this.server.assertCanSetRequestHandler("tools/call");
|
|
1381
|
+
this.server.registerCapabilities({ tools: { listChanged: this.server.getCapabilities().tools?.listChanged ?? true } });
|
|
1382
|
+
this.server.setRequestHandler("tools/list", () => ({ tools: Object.entries(this._registeredTools).filter(([, tool]) => tool.enabled).map(([name, tool]) => {
|
|
1383
|
+
const toolDefinition = {
|
|
1384
|
+
name,
|
|
1385
|
+
title: tool.title,
|
|
1386
|
+
description: tool.description,
|
|
1387
|
+
inputSchema: tool.inputSchema ? require_src.standardSchemaToJsonSchema(tool.inputSchema, "input") : EMPTY_OBJECT_JSON_SCHEMA,
|
|
1388
|
+
annotations: tool.annotations,
|
|
1389
|
+
icons: tool.icons,
|
|
1390
|
+
execution: tool.execution,
|
|
1391
|
+
_meta: tool._meta
|
|
1392
|
+
};
|
|
1393
|
+
if (tool.outputSchema) toolDefinition.outputSchema = require_src.standardSchemaToJsonSchema(tool.outputSchema, "output");
|
|
1394
|
+
return toolDefinition;
|
|
1395
|
+
}) }));
|
|
1396
|
+
this.server.setRequestHandler("tools/call", async (request, ctx) => {
|
|
1397
|
+
const tool = this._registeredTools[request.params.name];
|
|
1398
|
+
if (!tool) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
|
|
1399
|
+
if (!tool.enabled) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
|
|
1400
|
+
try {
|
|
1401
|
+
const args = await this.validateToolInput(tool, request.params.arguments, request.params.name);
|
|
1402
|
+
const result = await this.executeToolHandler(tool, args, ctx);
|
|
1403
|
+
await this.validateToolOutput(tool, result, request.params.name);
|
|
1404
|
+
if (require_src.isInputRequiredResult(result)) return result;
|
|
1405
|
+
return this.server.projectCallToolResult(result, tool.outputSchemaJson);
|
|
1406
|
+
} catch (error) {
|
|
1407
|
+
if (error instanceof require_src.ProtocolError && error.code === require_src.ProtocolErrorCode.UrlElicitationRequired) throw error;
|
|
1408
|
+
return this.createToolError(error instanceof Error ? error.message : String(error));
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1411
|
+
this._toolHandlersInitialized = true;
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Creates a tool error result.
|
|
1415
|
+
*
|
|
1416
|
+
* @param errorMessage - The error message.
|
|
1417
|
+
* @returns The tool error result.
|
|
1418
|
+
*/
|
|
1419
|
+
createToolError(errorMessage) {
|
|
1420
|
+
return {
|
|
1421
|
+
content: [{
|
|
1422
|
+
type: "text",
|
|
1423
|
+
text: errorMessage
|
|
1424
|
+
}],
|
|
1425
|
+
isError: true
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Validates tool input arguments against the tool's input schema.
|
|
1430
|
+
*/
|
|
1431
|
+
async validateToolInput(tool, args, toolName) {
|
|
1432
|
+
if (!tool.inputSchema) return;
|
|
1433
|
+
const parseResult = await require_src.validateStandardSchema(tool.inputSchema, args ?? {});
|
|
1434
|
+
if (!parseResult.success) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${toolName}: ${parseResult.error}`);
|
|
1435
|
+
return parseResult.data;
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
* Validates tool output against the tool's output schema.
|
|
1439
|
+
*/
|
|
1440
|
+
async validateToolOutput(tool, result, toolName) {
|
|
1441
|
+
if (!tool.outputSchema) return;
|
|
1442
|
+
if (require_src.isInputRequiredResult(result)) return;
|
|
1443
|
+
if (result.isError) return;
|
|
1444
|
+
if (result.structuredContent === void 0) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`);
|
|
1445
|
+
const parseResult = await require_src.validateStandardSchema(tool.outputSchema, result.structuredContent);
|
|
1446
|
+
if (!parseResult.success) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${parseResult.error}`);
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Executes a tool handler.
|
|
1450
|
+
*/
|
|
1451
|
+
async executeToolHandler(tool, args, ctx) {
|
|
1452
|
+
return tool.executor(args, ctx);
|
|
1453
|
+
}
|
|
1454
|
+
_completionHandlerInitialized = false;
|
|
1455
|
+
setCompletionRequestHandler() {
|
|
1456
|
+
if (this._completionHandlerInitialized) return;
|
|
1457
|
+
this.server.assertCanSetRequestHandler("completion/complete");
|
|
1458
|
+
this.server.registerCapabilities({ completions: {} });
|
|
1459
|
+
this.server.setRequestHandler("completion/complete", async (request) => {
|
|
1460
|
+
switch (request.params.ref.type) {
|
|
1461
|
+
case "ref/prompt":
|
|
1462
|
+
require_src.assertCompleteRequestPrompt(request);
|
|
1463
|
+
return this.handlePromptCompletion(request, request.params.ref);
|
|
1464
|
+
case "ref/resource":
|
|
1465
|
+
require_src.assertCompleteRequestResourceTemplate(request);
|
|
1466
|
+
return this.handleResourceCompletion(request, request.params.ref);
|
|
1467
|
+
default: throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Invalid completion reference: ${request.params.ref}`);
|
|
1468
|
+
}
|
|
1469
|
+
});
|
|
1470
|
+
this._completionHandlerInitialized = true;
|
|
1471
|
+
}
|
|
1472
|
+
async handlePromptCompletion(request, ref) {
|
|
1473
|
+
const prompt = this._registeredPrompts[ref.name];
|
|
1474
|
+
if (!prompt) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Prompt ${ref.name} not found`);
|
|
1475
|
+
if (!prompt.enabled) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Prompt ${ref.name} disabled`);
|
|
1476
|
+
if (!prompt.argsSchema) return EMPTY_COMPLETION_RESULT;
|
|
1477
|
+
const field = unwrapOptionalSchema(getSchemaShape(prompt.argsSchema)?.[request.params.argument.name]);
|
|
1478
|
+
if (!isCompletable(field)) return EMPTY_COMPLETION_RESULT;
|
|
1479
|
+
const completer = getCompleter(field);
|
|
1480
|
+
if (!completer) return EMPTY_COMPLETION_RESULT;
|
|
1481
|
+
return createCompletionResult(await completer(request.params.argument.value, request.params.context));
|
|
1482
|
+
}
|
|
1483
|
+
async handleResourceCompletion(request, ref) {
|
|
1484
|
+
const template = Object.values(this._registeredResourceTemplates).find((t) => t.resourceTemplate.uriTemplate.toString() === ref.uri);
|
|
1485
|
+
if (!template) {
|
|
1486
|
+
if (this._registeredResources[ref.uri]) return EMPTY_COMPLETION_RESULT;
|
|
1487
|
+
throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Resource template ${request.params.ref.uri} not found`);
|
|
1488
|
+
}
|
|
1489
|
+
const completer = template.resourceTemplate.completeCallback(request.params.argument.name);
|
|
1490
|
+
if (!completer) return EMPTY_COMPLETION_RESULT;
|
|
1491
|
+
return createCompletionResult(await completer(request.params.argument.value, request.params.context));
|
|
1492
|
+
}
|
|
1493
|
+
_resourceHandlersInitialized = false;
|
|
1494
|
+
setResourceRequestHandlers() {
|
|
1495
|
+
if (this._resourceHandlersInitialized) return;
|
|
1496
|
+
this.server.assertCanSetRequestHandler("resources/list");
|
|
1497
|
+
this.server.assertCanSetRequestHandler("resources/templates/list");
|
|
1498
|
+
this.server.assertCanSetRequestHandler("resources/read");
|
|
1499
|
+
this.server.registerCapabilities({ resources: { listChanged: this.server.getCapabilities().resources?.listChanged ?? true } });
|
|
1500
|
+
this.server.setRequestHandler("resources/list", async (_request, ctx) => {
|
|
1501
|
+
const resources = Object.entries(this._registeredResources).filter(([_, resource]) => resource.enabled).map(([uri, resource]) => ({
|
|
1502
|
+
uri,
|
|
1503
|
+
name: resource.name,
|
|
1504
|
+
...resource.metadata
|
|
1505
|
+
}));
|
|
1506
|
+
const templateResources = [];
|
|
1507
|
+
for (const template of Object.values(this._registeredResourceTemplates)) {
|
|
1508
|
+
if (!template.resourceTemplate.listCallback) continue;
|
|
1509
|
+
const result = await template.resourceTemplate.listCallback(ctx);
|
|
1510
|
+
for (const resource of result.resources) templateResources.push({
|
|
1511
|
+
...template.metadata,
|
|
1512
|
+
...resource
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
return { resources: [...resources, ...templateResources] };
|
|
1516
|
+
});
|
|
1517
|
+
this.server.setRequestHandler("resources/templates/list", async () => {
|
|
1518
|
+
return { resourceTemplates: Object.entries(this._registeredResourceTemplates).map(([name, template]) => ({
|
|
1519
|
+
name,
|
|
1520
|
+
uriTemplate: template.resourceTemplate.uriTemplate.toString(),
|
|
1521
|
+
...template.metadata
|
|
1522
|
+
})) };
|
|
1523
|
+
});
|
|
1524
|
+
this.server.setRequestHandler("resources/read", async (request, ctx) => {
|
|
1525
|
+
let uri;
|
|
1526
|
+
try {
|
|
1527
|
+
uri = new URL(request.params.uri);
|
|
1528
|
+
} catch {
|
|
1529
|
+
throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Resource URI ${request.params.uri} is invalid`, {
|
|
1530
|
+
uri: request.params.uri,
|
|
1531
|
+
reason: "invalid_uri"
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
const resource = this._registeredResources[uri.toString()];
|
|
1535
|
+
if (resource) {
|
|
1536
|
+
if (!resource.enabled) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Resource ${uri} disabled`);
|
|
1537
|
+
return require_src.attachCacheHintFallback(await resource.readCallback(uri, ctx), resource.cacheHint);
|
|
1538
|
+
}
|
|
1539
|
+
for (const template of Object.values(this._registeredResourceTemplates)) {
|
|
1540
|
+
const variables = template.resourceTemplate.uriTemplate.match(uri.toString());
|
|
1541
|
+
if (variables) return require_src.attachCacheHintFallback(await template.readCallback(uri, variables, ctx), template.cacheHint);
|
|
1542
|
+
}
|
|
1543
|
+
throw new require_src.ResourceNotFoundError(request.params.uri);
|
|
1544
|
+
});
|
|
1545
|
+
this._resourceHandlersInitialized = true;
|
|
1546
|
+
}
|
|
1547
|
+
_promptHandlersInitialized = false;
|
|
1548
|
+
setPromptRequestHandlers() {
|
|
1549
|
+
if (this._promptHandlersInitialized) return;
|
|
1550
|
+
this.server.assertCanSetRequestHandler("prompts/list");
|
|
1551
|
+
this.server.assertCanSetRequestHandler("prompts/get");
|
|
1552
|
+
this.server.registerCapabilities({ prompts: { listChanged: this.server.getCapabilities().prompts?.listChanged ?? true } });
|
|
1553
|
+
this.server.setRequestHandler("prompts/list", () => ({ prompts: Object.entries(this._registeredPrompts).filter(([, prompt]) => prompt.enabled).map(([name, prompt]) => {
|
|
1554
|
+
return {
|
|
1555
|
+
name,
|
|
1556
|
+
title: prompt.title,
|
|
1557
|
+
description: prompt.description,
|
|
1558
|
+
arguments: prompt.argsSchema ? require_src.promptArgumentsFromStandardSchema(prompt.argsSchema) : void 0,
|
|
1559
|
+
icons: prompt.icons,
|
|
1560
|
+
_meta: prompt._meta
|
|
1561
|
+
};
|
|
1562
|
+
}) }));
|
|
1563
|
+
this.server.setRequestHandler("prompts/get", async (request, ctx) => {
|
|
1564
|
+
const prompt = this._registeredPrompts[request.params.name];
|
|
1565
|
+
if (!prompt) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Prompt ${request.params.name} not found`);
|
|
1566
|
+
if (!prompt.enabled) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Prompt ${request.params.name} disabled`);
|
|
1567
|
+
return prompt.handler(request.params.arguments, ctx);
|
|
1568
|
+
});
|
|
1569
|
+
this._promptHandlersInitialized = true;
|
|
1570
|
+
}
|
|
1571
|
+
registerResource(name, uriOrTemplate, config, readCallback) {
|
|
1572
|
+
const cacheHint = config.cacheHint;
|
|
1573
|
+
let metadata = config;
|
|
1574
|
+
if (cacheHint !== void 0) {
|
|
1575
|
+
require_src.assertValidCacheHint(cacheHint, `resource ${name}`);
|
|
1576
|
+
const rest = { ...config };
|
|
1577
|
+
delete rest.cacheHint;
|
|
1578
|
+
metadata = rest;
|
|
1579
|
+
}
|
|
1580
|
+
if (typeof uriOrTemplate === "string") {
|
|
1581
|
+
if (this._registeredResources[uriOrTemplate]) throw new Error(`Resource ${uriOrTemplate} is already registered`);
|
|
1582
|
+
const registeredResource = this._createRegisteredResource(name, config.title, uriOrTemplate, metadata, readCallback);
|
|
1583
|
+
if (cacheHint !== void 0) registeredResource.cacheHint = cacheHint;
|
|
1584
|
+
this.setResourceRequestHandlers();
|
|
1585
|
+
this.sendResourceListChanged();
|
|
1586
|
+
return registeredResource;
|
|
1587
|
+
} else {
|
|
1588
|
+
if (this._registeredResourceTemplates[name]) throw new Error(`Resource template ${name} is already registered`);
|
|
1589
|
+
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config.title, uriOrTemplate, metadata, readCallback);
|
|
1590
|
+
if (cacheHint !== void 0) registeredResourceTemplate.cacheHint = cacheHint;
|
|
1591
|
+
this.setResourceRequestHandlers();
|
|
1592
|
+
this.sendResourceListChanged();
|
|
1593
|
+
return registeredResourceTemplate;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
_createRegisteredResource(name, title, uri, metadata, readCallback) {
|
|
1597
|
+
const registeredResource = {
|
|
1598
|
+
name,
|
|
1599
|
+
title,
|
|
1600
|
+
metadata,
|
|
1601
|
+
readCallback,
|
|
1602
|
+
enabled: true,
|
|
1603
|
+
disable: () => registeredResource.update({ enabled: false }),
|
|
1604
|
+
enable: () => registeredResource.update({ enabled: true }),
|
|
1605
|
+
remove: () => registeredResource.update({ uri: null }),
|
|
1606
|
+
update: (updates) => {
|
|
1607
|
+
if (updates.uri !== void 0 && updates.uri !== uri) {
|
|
1608
|
+
delete this._registeredResources[uri];
|
|
1609
|
+
if (updates.uri) this._registeredResources[updates.uri] = registeredResource;
|
|
1610
|
+
}
|
|
1611
|
+
if (updates.name !== void 0) registeredResource.name = updates.name;
|
|
1612
|
+
if (updates.title !== void 0) registeredResource.title = updates.title;
|
|
1613
|
+
if (updates.metadata !== void 0) registeredResource.metadata = updates.metadata;
|
|
1614
|
+
if (updates.callback !== void 0) registeredResource.readCallback = updates.callback;
|
|
1615
|
+
if (updates.enabled !== void 0) registeredResource.enabled = updates.enabled;
|
|
1616
|
+
this.sendResourceListChanged();
|
|
1617
|
+
}
|
|
1618
|
+
};
|
|
1619
|
+
this._registeredResources[uri] = registeredResource;
|
|
1620
|
+
return registeredResource;
|
|
1621
|
+
}
|
|
1622
|
+
_createRegisteredResourceTemplate(name, title, template, metadata, readCallback) {
|
|
1623
|
+
const registeredResourceTemplate = {
|
|
1624
|
+
resourceTemplate: template,
|
|
1625
|
+
title,
|
|
1626
|
+
metadata,
|
|
1627
|
+
readCallback,
|
|
1628
|
+
enabled: true,
|
|
1629
|
+
disable: () => registeredResourceTemplate.update({ enabled: false }),
|
|
1630
|
+
enable: () => registeredResourceTemplate.update({ enabled: true }),
|
|
1631
|
+
remove: () => registeredResourceTemplate.update({ name: null }),
|
|
1632
|
+
update: (updates) => {
|
|
1633
|
+
if (updates.name !== void 0 && updates.name !== name) {
|
|
1634
|
+
delete this._registeredResourceTemplates[name];
|
|
1635
|
+
if (updates.name) this._registeredResourceTemplates[updates.name] = registeredResourceTemplate;
|
|
1636
|
+
}
|
|
1637
|
+
if (updates.title !== void 0) registeredResourceTemplate.title = updates.title;
|
|
1638
|
+
if (updates.template !== void 0) registeredResourceTemplate.resourceTemplate = updates.template;
|
|
1639
|
+
if (updates.metadata !== void 0) registeredResourceTemplate.metadata = updates.metadata;
|
|
1640
|
+
if (updates.callback !== void 0) registeredResourceTemplate.readCallback = updates.callback;
|
|
1641
|
+
if (updates.enabled !== void 0) registeredResourceTemplate.enabled = updates.enabled;
|
|
1642
|
+
this.sendResourceListChanged();
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
this._registeredResourceTemplates[name] = registeredResourceTemplate;
|
|
1646
|
+
const variableNames = template.uriTemplate.variableNames;
|
|
1647
|
+
if (Array.isArray(variableNames) && variableNames.some((v) => !!template.completeCallback(v))) this.setCompletionRequestHandler();
|
|
1648
|
+
return registeredResourceTemplate;
|
|
1649
|
+
}
|
|
1650
|
+
_createRegisteredPrompt(name, title, description, argsSchema, callback, icons, _meta) {
|
|
1651
|
+
let currentArgsSchema = argsSchema;
|
|
1652
|
+
let currentCallback = callback;
|
|
1653
|
+
const registeredPrompt = {
|
|
1654
|
+
title,
|
|
1655
|
+
description,
|
|
1656
|
+
argsSchema,
|
|
1657
|
+
icons,
|
|
1658
|
+
_meta,
|
|
1659
|
+
handler: createPromptHandler(name, argsSchema, callback),
|
|
1660
|
+
enabled: true,
|
|
1661
|
+
disable: () => registeredPrompt.update({ enabled: false }),
|
|
1662
|
+
enable: () => registeredPrompt.update({ enabled: true }),
|
|
1663
|
+
remove: () => registeredPrompt.update({ name: null }),
|
|
1664
|
+
update: (updates) => {
|
|
1665
|
+
if (updates.name !== void 0 && updates.name !== name) {
|
|
1666
|
+
delete this._registeredPrompts[name];
|
|
1667
|
+
if (updates.name) this._registeredPrompts[updates.name] = registeredPrompt;
|
|
1668
|
+
}
|
|
1669
|
+
if (updates.title !== void 0) registeredPrompt.title = updates.title;
|
|
1670
|
+
if (updates.description !== void 0) registeredPrompt.description = updates.description;
|
|
1671
|
+
if (updates.icons !== void 0) registeredPrompt.icons = updates.icons;
|
|
1672
|
+
if (updates._meta !== void 0) registeredPrompt._meta = updates._meta;
|
|
1673
|
+
let needsHandlerRegen = false;
|
|
1674
|
+
if (updates.argsSchema !== void 0) {
|
|
1675
|
+
registeredPrompt.argsSchema = updates.argsSchema;
|
|
1676
|
+
currentArgsSchema = updates.argsSchema;
|
|
1677
|
+
needsHandlerRegen = true;
|
|
1678
|
+
}
|
|
1679
|
+
if (updates.callback !== void 0) {
|
|
1680
|
+
currentCallback = updates.callback;
|
|
1681
|
+
needsHandlerRegen = true;
|
|
1682
|
+
}
|
|
1683
|
+
if (needsHandlerRegen) registeredPrompt.handler = createPromptHandler(name, currentArgsSchema, currentCallback);
|
|
1684
|
+
if (updates.enabled !== void 0) registeredPrompt.enabled = updates.enabled;
|
|
1685
|
+
this.sendPromptListChanged();
|
|
1686
|
+
}
|
|
1687
|
+
};
|
|
1688
|
+
this._registeredPrompts[name] = registeredPrompt;
|
|
1689
|
+
if (argsSchema) {
|
|
1690
|
+
const shape = getSchemaShape(argsSchema);
|
|
1691
|
+
if (shape) {
|
|
1692
|
+
if (Object.values(shape).some((field) => {
|
|
1693
|
+
return isCompletable(unwrapOptionalSchema(field));
|
|
1694
|
+
})) this.setCompletionRequestHandler();
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
return registeredPrompt;
|
|
1698
|
+
}
|
|
1699
|
+
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, _meta, handler) {
|
|
1700
|
+
require_src.validateAndWarnToolName(name);
|
|
1701
|
+
if (inputSchema !== void 0) try {
|
|
1702
|
+
const json = require_src.standardSchemaToJsonSchema(inputSchema, "input");
|
|
1703
|
+
this._toolInputSchemaJson[name] = json;
|
|
1704
|
+
const scan = require_src.scanXMcpHeaderDeclarations(json);
|
|
1705
|
+
if (!scan.valid) console.warn(`[mcp-sdk] tool '${name}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${scan.reason}`);
|
|
1706
|
+
} catch {}
|
|
1707
|
+
let currentHandler = handler;
|
|
1708
|
+
const registeredTool = {
|
|
1709
|
+
title,
|
|
1710
|
+
description,
|
|
1711
|
+
inputSchema,
|
|
1712
|
+
outputSchema,
|
|
1713
|
+
outputSchemaJson: convertOutputSchemaJson(outputSchema),
|
|
1714
|
+
annotations,
|
|
1715
|
+
icons,
|
|
1716
|
+
execution,
|
|
1717
|
+
_meta,
|
|
1718
|
+
handler,
|
|
1719
|
+
executor: createToolExecutor(inputSchema, handler),
|
|
1720
|
+
enabled: true,
|
|
1721
|
+
disable: () => registeredTool.update({ enabled: false }),
|
|
1722
|
+
enable: () => registeredTool.update({ enabled: true }),
|
|
1723
|
+
remove: () => registeredTool.update({ name: null }),
|
|
1724
|
+
update: (updates) => {
|
|
1725
|
+
if (updates.name !== void 0 && updates.name !== name) {
|
|
1726
|
+
if (typeof updates.name === "string") require_src.validateAndWarnToolName(updates.name);
|
|
1727
|
+
delete this._registeredTools[name];
|
|
1728
|
+
delete this._toolInputSchemaJson[name];
|
|
1729
|
+
if (updates.name) {
|
|
1730
|
+
delete this._toolInputSchemaJson[updates.name];
|
|
1731
|
+
this._registeredTools[updates.name] = registeredTool;
|
|
1732
|
+
name = updates.name;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
if (updates.title !== void 0) registeredTool.title = updates.title;
|
|
1736
|
+
if (updates.description !== void 0) registeredTool.description = updates.description;
|
|
1737
|
+
let needsExecutorRegen = false;
|
|
1738
|
+
if (updates.paramsSchema !== void 0) {
|
|
1739
|
+
registeredTool.inputSchema = updates.paramsSchema;
|
|
1740
|
+
delete this._toolInputSchemaJson[name];
|
|
1741
|
+
needsExecutorRegen = true;
|
|
1742
|
+
}
|
|
1743
|
+
if (updates.callback !== void 0) {
|
|
1744
|
+
registeredTool.handler = updates.callback;
|
|
1745
|
+
currentHandler = updates.callback;
|
|
1746
|
+
needsExecutorRegen = true;
|
|
1747
|
+
}
|
|
1748
|
+
if (needsExecutorRegen) registeredTool.executor = createToolExecutor(registeredTool.inputSchema, currentHandler);
|
|
1749
|
+
if (updates.outputSchema !== void 0) {
|
|
1750
|
+
registeredTool.outputSchema = updates.outputSchema;
|
|
1751
|
+
registeredTool.outputSchemaJson = convertOutputSchemaJson(updates.outputSchema);
|
|
1752
|
+
}
|
|
1753
|
+
if (updates.annotations !== void 0) registeredTool.annotations = updates.annotations;
|
|
1754
|
+
if (updates.icons !== void 0) registeredTool.icons = updates.icons;
|
|
1755
|
+
if (updates._meta !== void 0) registeredTool._meta = updates._meta;
|
|
1756
|
+
if (updates.enabled !== void 0) registeredTool.enabled = updates.enabled;
|
|
1757
|
+
this.sendToolListChanged();
|
|
1758
|
+
}
|
|
1759
|
+
};
|
|
1760
|
+
this._registeredTools[name] = registeredTool;
|
|
1761
|
+
this.setToolRequestHandlers();
|
|
1762
|
+
this.sendToolListChanged();
|
|
1763
|
+
return registeredTool;
|
|
1764
|
+
}
|
|
1765
|
+
registerTool(name, config, cb) {
|
|
1766
|
+
if (this._registeredTools[name]) throw new Error(`Tool ${name} is already registered`);
|
|
1767
|
+
const { title, description, inputSchema, outputSchema, annotations, icons, _meta } = config;
|
|
1768
|
+
return this._createRegisteredTool(name, title, description, require_src.normalizeRawShapeSchema(inputSchema), require_src.normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, _meta, cb);
|
|
1769
|
+
}
|
|
1770
|
+
registerPrompt(name, config, cb) {
|
|
1771
|
+
if (this._registeredPrompts[name]) throw new Error(`Prompt ${name} is already registered`);
|
|
1772
|
+
const { title, description, argsSchema, icons, _meta } = config;
|
|
1773
|
+
const registeredPrompt = this._createRegisteredPrompt(name, title, description, require_src.normalizeRawShapeSchema(argsSchema), cb, icons, _meta);
|
|
1774
|
+
this.setPromptRequestHandlers();
|
|
1775
|
+
this.sendPromptListChanged();
|
|
1776
|
+
return registeredPrompt;
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Checks if the server is connected to a transport.
|
|
1780
|
+
* @returns `true` if the server is connected
|
|
1781
|
+
*/
|
|
1782
|
+
isConnected() {
|
|
1783
|
+
return this.server.transport !== void 0;
|
|
1784
|
+
}
|
|
1785
|
+
/**
|
|
1786
|
+
* Sends a logging message to the client, if connected.
|
|
1787
|
+
* Note: You only need to send the parameters object, not the entire JSON-RPC message.
|
|
1788
|
+
* @see {@linkcode LoggingMessageNotification}
|
|
1789
|
+
* @param params
|
|
1790
|
+
* @param sessionId Optional for stateless transports and backward compatibility.
|
|
1791
|
+
*
|
|
1792
|
+
* @example
|
|
1793
|
+
* ```ts source="./mcp.examples.ts#McpServer_sendLoggingMessage_basic"
|
|
1794
|
+
* await server.sendLoggingMessage({
|
|
1795
|
+
* level: 'info',
|
|
1796
|
+
* data: 'Processing complete'
|
|
1797
|
+
* });
|
|
1798
|
+
* ```
|
|
1799
|
+
*
|
|
1800
|
+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
|
|
1801
|
+
* Remains functional during the deprecation window (at least twelve months).
|
|
1802
|
+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
|
|
1803
|
+
*/
|
|
1804
|
+
async sendLoggingMessage(params, sessionId) {
|
|
1805
|
+
return this.server.sendLoggingMessage(params, sessionId);
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* Sends a resource list changed event to the client, if connected.
|
|
1809
|
+
*/
|
|
1810
|
+
sendResourceListChanged() {
|
|
1811
|
+
if (this.isConnected()) this.server.sendResourceListChanged();
|
|
1812
|
+
}
|
|
1813
|
+
/**
|
|
1814
|
+
* Sends a tool list changed event to the client, if connected.
|
|
1815
|
+
*/
|
|
1816
|
+
sendToolListChanged() {
|
|
1817
|
+
if (this.isConnected()) this.server.sendToolListChanged();
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Sends a prompt list changed event to the client, if connected.
|
|
1821
|
+
*/
|
|
1822
|
+
sendPromptListChanged() {
|
|
1823
|
+
if (this.isConnected()) this.server.sendPromptListChanged();
|
|
1824
|
+
}
|
|
1825
|
+
};
|
|
1826
|
+
/**
|
|
1827
|
+
* A resource template combines a URI pattern with optional functionality to enumerate
|
|
1828
|
+
* all resources matching that pattern.
|
|
1829
|
+
*/
|
|
1830
|
+
var ResourceTemplate = class {
|
|
1831
|
+
_uriTemplate;
|
|
1832
|
+
constructor(uriTemplate, _callbacks) {
|
|
1833
|
+
this._callbacks = _callbacks;
|
|
1834
|
+
this._uriTemplate = typeof uriTemplate === "string" ? new require_src.UriTemplate(uriTemplate) : uriTemplate;
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* Gets the URI template pattern.
|
|
1838
|
+
*/
|
|
1839
|
+
get uriTemplate() {
|
|
1840
|
+
return this._uriTemplate;
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* Gets the list callback, if one was provided.
|
|
1844
|
+
*/
|
|
1845
|
+
get listCallback() {
|
|
1846
|
+
return this._callbacks.list;
|
|
1847
|
+
}
|
|
1848
|
+
/**
|
|
1849
|
+
* Gets the callback for completing a specific URI template variable, if one was provided.
|
|
1850
|
+
*/
|
|
1851
|
+
completeCallback(variable) {
|
|
1852
|
+
return this._callbacks.complete?.[variable];
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1855
|
+
/**
|
|
1856
|
+
* Creates an executor that invokes the handler with the appropriate arguments.
|
|
1857
|
+
* When `inputSchema` is defined, the handler is called with `(args, ctx)`.
|
|
1858
|
+
* When `inputSchema` is undefined, the handler is called with just `(ctx)`.
|
|
1859
|
+
*/
|
|
1860
|
+
function createToolExecutor(inputSchema, handler) {
|
|
1861
|
+
if (inputSchema) {
|
|
1862
|
+
const callback$1 = handler;
|
|
1863
|
+
return async (args, ctx) => callback$1(args, ctx);
|
|
1864
|
+
}
|
|
1865
|
+
const callback = handler;
|
|
1866
|
+
return async (_args, ctx) => callback(ctx);
|
|
1867
|
+
}
|
|
1868
|
+
const EMPTY_OBJECT_JSON_SCHEMA = {
|
|
1869
|
+
type: "object",
|
|
1870
|
+
properties: {}
|
|
1871
|
+
};
|
|
1872
|
+
/**
|
|
1873
|
+
* Convert a registered `outputSchema` to JSON Schema, memoised on {@link RegisteredTool.outputSchemaJson}
|
|
1874
|
+
* so `tools/call` passes the SAME advertised schema to the wire codec's `projectCallToolResult` that
|
|
1875
|
+
* `tools/list` emits (and that the 2025 codec's `encodeResult('tools/list', …)` may wrap). A conversion
|
|
1876
|
+
* failure yields `undefined` so the failure surfaces where it always has (`tools/list`).
|
|
1877
|
+
*/
|
|
1878
|
+
function convertOutputSchemaJson(outputSchema) {
|
|
1879
|
+
if (outputSchema === void 0) return void 0;
|
|
1880
|
+
try {
|
|
1881
|
+
return require_src.standardSchemaToJsonSchema(outputSchema, "output");
|
|
1882
|
+
} catch {
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
/**
|
|
1887
|
+
* Creates a type-safe prompt handler that captures the schema and callback in a closure.
|
|
1888
|
+
* This eliminates the need for type assertions at the call site.
|
|
1889
|
+
*/
|
|
1890
|
+
function createPromptHandler(name, argsSchema, callback) {
|
|
1891
|
+
if (argsSchema) {
|
|
1892
|
+
const typedCallback = callback;
|
|
1893
|
+
return async (args, ctx) => {
|
|
1894
|
+
const parseResult = await require_src.validateStandardSchema(argsSchema, args);
|
|
1895
|
+
if (!parseResult.success) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Invalid arguments for prompt ${name}: ${parseResult.error}`);
|
|
1896
|
+
return typedCallback(parseResult.data, ctx);
|
|
1897
|
+
};
|
|
1898
|
+
} else {
|
|
1899
|
+
const typedCallback = callback;
|
|
1900
|
+
return async (_args, ctx) => {
|
|
1901
|
+
return typedCallback(ctx);
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
function createCompletionResult(suggestions) {
|
|
1906
|
+
return { completion: {
|
|
1907
|
+
values: suggestions.map(String).slice(0, 100),
|
|
1908
|
+
total: suggestions.length,
|
|
1909
|
+
hasMore: suggestions.length > 100
|
|
1910
|
+
} };
|
|
1911
|
+
}
|
|
1912
|
+
const EMPTY_COMPLETION_RESULT = { completion: {
|
|
1913
|
+
values: [],
|
|
1914
|
+
hasMore: false
|
|
1915
|
+
} };
|
|
1916
|
+
/** @internal Gets the shape of a Zod object schema */
|
|
1917
|
+
function getSchemaShape(schema) {
|
|
1918
|
+
const candidate = schema;
|
|
1919
|
+
if (candidate.shape && typeof candidate.shape === "object") return candidate.shape;
|
|
1920
|
+
}
|
|
1921
|
+
/** @internal Checks if a Zod schema is optional */
|
|
1922
|
+
function isOptionalSchema(schema) {
|
|
1923
|
+
return schema?.type === "optional";
|
|
1924
|
+
}
|
|
1925
|
+
/** @internal Unwraps an optional Zod schema */
|
|
1926
|
+
function unwrapOptionalSchema(schema) {
|
|
1927
|
+
if (!isOptionalSchema(schema)) return schema;
|
|
1928
|
+
return schema.def?.innerType ?? schema;
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
//#endregion
|
|
1932
|
+
Object.defineProperty(exports, 'DEFAULT_MAX_SUBSCRIPTIONS', {
|
|
1933
|
+
enumerable: true,
|
|
1934
|
+
get: function () {
|
|
1935
|
+
return DEFAULT_MAX_SUBSCRIPTIONS;
|
|
1936
|
+
}
|
|
1937
|
+
});
|
|
1938
|
+
Object.defineProperty(exports, 'DEFAULT_SSE_KEEP_ALIVE_MS', {
|
|
1939
|
+
enumerable: true,
|
|
1940
|
+
get: function () {
|
|
1941
|
+
return DEFAULT_SSE_KEEP_ALIVE_MS;
|
|
1942
|
+
}
|
|
1943
|
+
});
|
|
1944
|
+
Object.defineProperty(exports, 'InMemoryServerEventBus', {
|
|
1945
|
+
enumerable: true,
|
|
1946
|
+
get: function () {
|
|
1947
|
+
return InMemoryServerEventBus;
|
|
1948
|
+
}
|
|
1949
|
+
});
|
|
1950
|
+
Object.defineProperty(exports, 'McpServer', {
|
|
1951
|
+
enumerable: true,
|
|
1952
|
+
get: function () {
|
|
1953
|
+
return McpServer;
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
Object.defineProperty(exports, 'ResourceTemplate', {
|
|
1957
|
+
enumerable: true,
|
|
1958
|
+
get: function () {
|
|
1959
|
+
return ResourceTemplate;
|
|
1960
|
+
}
|
|
1961
|
+
});
|
|
1962
|
+
Object.defineProperty(exports, 'Server', {
|
|
1963
|
+
enumerable: true,
|
|
1964
|
+
get: function () {
|
|
1965
|
+
return Server;
|
|
1966
|
+
}
|
|
1967
|
+
});
|
|
1968
|
+
Object.defineProperty(exports, 'StdioListenRouter', {
|
|
1969
|
+
enumerable: true,
|
|
1970
|
+
get: function () {
|
|
1971
|
+
return StdioListenRouter;
|
|
1972
|
+
}
|
|
1973
|
+
});
|
|
1974
|
+
Object.defineProperty(exports, 'armSseKeepAlive', {
|
|
1975
|
+
enumerable: true,
|
|
1976
|
+
get: function () {
|
|
1977
|
+
return armSseKeepAlive;
|
|
1978
|
+
}
|
|
1979
|
+
});
|
|
1980
|
+
Object.defineProperty(exports, 'completable', {
|
|
1981
|
+
enumerable: true,
|
|
1982
|
+
get: function () {
|
|
1983
|
+
return completable;
|
|
1984
|
+
}
|
|
1985
|
+
});
|
|
1986
|
+
Object.defineProperty(exports, 'createListenRouter', {
|
|
1987
|
+
enumerable: true,
|
|
1988
|
+
get: function () {
|
|
1989
|
+
return createListenRouter;
|
|
1990
|
+
}
|
|
1991
|
+
});
|
|
1992
|
+
Object.defineProperty(exports, 'createServerNotifier', {
|
|
1993
|
+
enumerable: true,
|
|
1994
|
+
get: function () {
|
|
1995
|
+
return createServerNotifier;
|
|
1996
|
+
}
|
|
1997
|
+
});
|
|
1998
|
+
Object.defineProperty(exports, 'installModernOnlyHandlers', {
|
|
1999
|
+
enumerable: true,
|
|
2000
|
+
get: function () {
|
|
2001
|
+
return installModernOnlyHandlers;
|
|
2002
|
+
}
|
|
2003
|
+
});
|
|
2004
|
+
Object.defineProperty(exports, 'isCompletable', {
|
|
2005
|
+
enumerable: true,
|
|
2006
|
+
get: function () {
|
|
2007
|
+
return isCompletable;
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
2010
|
+
Object.defineProperty(exports, 'seedClientIdentityFromEnvelope', {
|
|
2011
|
+
enumerable: true,
|
|
2012
|
+
get: function () {
|
|
2013
|
+
return seedClientIdentityFromEnvelope;
|
|
2014
|
+
}
|
|
2015
|
+
});
|
|
2016
|
+
Object.defineProperty(exports, 'serverIdentityOf', {
|
|
2017
|
+
enumerable: true,
|
|
2018
|
+
get: function () {
|
|
2019
|
+
return serverIdentityOf;
|
|
2020
|
+
}
|
|
2021
|
+
});
|
|
2022
|
+
//# sourceMappingURL=mcp-D7GmuPnv.cjs.map
|