mcp-use 2.0.0-beta.8 → 2.0.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/bin.js +1 -179
- package/dist/branding.d.ts +81 -0
- package/dist/buffered-response.d.ts +27 -0
- package/dist/chunk-273ZVKJJ.js +2 -0
- package/dist/{chunk-FCGJJVL2.js → chunk-GX6PGIEO.js} +33 -142
- package/dist/chunk-IS7FKXFR.js +1 -0
- package/dist/chunk-KGTOBJW2.js +1 -0
- package/dist/chunk-MIZQEWZS.js +1 -0
- package/dist/chunk-OJF6B5EU.js +1 -0
- package/dist/chunk-PSKSL567.js +1 -0
- package/dist/chunk-XYHHP43G.js +1 -0
- package/dist/chunk-Y26DNVWA.js +3 -0
- package/dist/chunk-ZMU5USAZ.js +1 -0
- package/dist/completable.d.ts +0 -1
- package/dist/config.d.ts +88 -80
- package/dist/context.d.ts +154 -60
- package/dist/fetch-app.d.ts +3 -28
- package/dist/index-node.js +781 -0
- package/dist/index.d.ts +34 -14
- package/dist/index.js +41 -2229
- package/dist/internal/node-http-unavailable.js +1 -0
- package/dist/internal/node-http.js +1 -0
- package/dist/internal/resource-completion.js +1 -7
- package/dist/internal/usage.js +1 -0
- package/dist/landing-handler-TG6LVQBI.js +1 -0
- package/dist/landing-handler.d.ts +3 -2
- package/dist/landing.d.ts +19 -5
- package/dist/landing.js +1 -7
- package/dist/listen-address.d.ts +8 -0
- package/dist/logging.d.ts +0 -1
- package/dist/mcp-proxy-NETCUGUD.js +2 -0
- package/dist/mcp-proxy.d.ts +158 -0
- package/dist/middleware/cors.d.ts +0 -1
- package/dist/middleware/mcp-middleware.d.ts +178 -104
- package/dist/mount-mcp.d.ts +0 -1
- package/dist/next/config.d.ts +67 -0
- package/dist/next/handler.d.ts +32 -0
- package/dist/next/index.d.ts +9 -0
- package/dist/next/index.js +1 -0
- package/dist/node-bridge.d.ts +33 -4
- package/dist/node-bridge.js +1 -151
- package/dist/node-http-unavailable.d.ts +9 -0
- package/dist/node-http.d.ts +2 -0
- package/dist/oauth/adapters.d.ts +0 -1
- package/dist/oauth/auth0.d.ts +24 -1
- package/dist/oauth/auth0.js +1 -61
- package/dist/oauth/better-auth.d.ts +23 -1
- package/dist/oauth/better-auth.js +1 -76
- package/dist/oauth/clerk.d.ts +30 -3
- package/dist/oauth/clerk.js +1 -70
- package/dist/oauth/errors.d.ts +3 -0
- package/dist/oauth/guards.d.ts +0 -1
- package/dist/oauth/index.d.ts +0 -1
- package/dist/oauth/index.js +1 -28
- package/dist/oauth/internal.d.ts +0 -1
- package/dist/oauth/jwt.d.ts +10 -4
- package/dist/oauth/keycloak.d.ts +28 -1
- package/dist/oauth/keycloak.js +1 -94
- package/dist/oauth/provider.d.ts +17 -2
- package/dist/oauth/supabase.d.ts +38 -2
- package/dist/oauth/supabase.js +1 -101
- package/dist/oauth/workos.d.ts +27 -1
- package/dist/oauth/workos.js +1 -77
- package/dist/openapi/index.d.ts +0 -1
- package/dist/openapi/index.js +1 -7
- package/dist/openapi/types.d.ts +0 -1
- package/dist/prompts.d.ts +7 -4
- package/dist/public-route-DAQJGS6K.js +1 -0
- package/dist/react/components/error-boundary.d.ts +3 -1
- package/dist/react/components/image.d.ts +0 -1
- package/dist/react/components/model-context.d.ts +8 -57
- package/dist/react/components/theme-provider.d.ts +7 -4
- package/dist/react/components/view-controls.d.ts +0 -1
- package/dist/react/hooks/use-call-tool.d.ts +29 -12
- package/dist/react/hooks/use-display-mode.d.ts +0 -1
- package/dist/react/hooks/use-files.d.ts +0 -1
- package/dist/react/hooks/use-host-context.d.ts +5 -1
- package/dist/react/hooks/use-open-external.d.ts +0 -1
- package/dist/react/hooks/use-send-follow-up.d.ts +0 -1
- package/dist/react/hooks/use-send-size-changed.d.ts +0 -1
- package/dist/react/hooks/use-tool-context.d.ts +0 -1
- package/dist/react/hooks/use-view-state.d.ts +23 -0
- package/dist/react/hooks/use-view-theme.d.ts +0 -1
- package/dist/react/hooks/use-view-tool.d.ts +3 -4
- package/dist/react/index.d.ts +9 -9
- package/dist/react/index.js +286 -131
- package/dist/react/public-assets.d.ts +21 -6
- package/dist/react/runtime/bootstrap-view.d.ts +3 -4
- package/dist/react/runtime/model-context-store.d.ts +34 -69
- package/dist/react/runtime/view-config.d.ts +0 -1
- package/dist/react/runtime/view-runtime-context.d.ts +0 -1
- package/dist/react/runtime/view-runtime.d.ts +4 -6
- package/dist/react/types/file-types.d.ts +2 -1
- package/dist/react/types/host-types.d.ts +2 -1
- package/dist/react/types/register.d.ts +11 -4
- package/dist/react/types/result-types.d.ts +0 -1
- package/dist/resource-completion.d.ts +0 -1
- package/dist/resources.d.ts +14 -6
- package/dist/response-conversion.d.ts +25 -0
- package/dist/response-helpers.d.ts +231 -0
- package/dist/server.d.ts +134 -50
- package/dist/tools.d.ts +14 -14
- package/dist/usage.d.ts +14 -0
- package/dist/views/capabilities.d.ts +0 -1
- package/dist/views/constants.d.ts +1 -2
- package/dist/views/csp-env.d.ts +0 -1
- package/dist/views/document.d.ts +9 -11
- package/dist/views/index.d.ts +0 -1
- package/dist/views/origin.d.ts +0 -1
- package/dist/views/public-route.d.ts +5 -4
- package/dist/views/register.d.ts +1 -2
- package/dist/views/routes.d.ts +4 -3
- package/dist/views/types.d.ts +21 -17
- package/dist/views/wire.d.ts +7 -7
- package/dist/vite-client.d.ts +1 -0
- package/package.json +41 -21
- package/dist/.tsbuildinfo +0 -1
- package/dist/bin/args.d.ts +0 -61
- package/dist/bin/args.d.ts.map +0 -1
- package/dist/bin/main.d.ts +0 -32
- package/dist/bin/main.d.ts.map +0 -1
- package/dist/bin/start.d.ts +0 -40
- package/dist/bin/start.d.ts.map +0 -1
- package/dist/bin.d.ts +0 -3
- package/dist/bin.d.ts.map +0 -1
- package/dist/bin.js.map +0 -1
- package/dist/chunk-AATFAERC.js +0 -384
- package/dist/chunk-AATFAERC.js.map +0 -1
- package/dist/chunk-DPL7OEXC.js +0 -518
- package/dist/chunk-DPL7OEXC.js.map +0 -1
- package/dist/chunk-DQ7LE4ZA.js +0 -237
- package/dist/chunk-DQ7LE4ZA.js.map +0 -1
- package/dist/chunk-FC2Z2VFO.js +0 -99
- package/dist/chunk-FC2Z2VFO.js.map +0 -1
- package/dist/chunk-FCGJJVL2.js.map +0 -1
- package/dist/chunk-IG2BCCMU.js +0 -98
- package/dist/chunk-IG2BCCMU.js.map +0 -1
- package/dist/chunk-KIZ72TIK.js +0 -38
- package/dist/chunk-KIZ72TIK.js.map +0 -1
- package/dist/chunk-QUUANIE4.js +0 -125
- package/dist/chunk-QUUANIE4.js.map +0 -1
- package/dist/chunk-RQRT27Q3.js +0 -454
- package/dist/chunk-RQRT27Q3.js.map +0 -1
- package/dist/chunk-STCR3P5O.js +0 -95
- package/dist/chunk-STCR3P5O.js.map +0 -1
- package/dist/chunk-XUD22N3Y.js +0 -156
- package/dist/chunk-XUD22N3Y.js.map +0 -1
- package/dist/chunk-Z326HADF.js +0 -82
- package/dist/chunk-Z326HADF.js.map +0 -1
- package/dist/chunk-ZMIKQPSO.js +0 -151
- package/dist/chunk-ZMIKQPSO.js.map +0 -1
- package/dist/cli/build.d.ts +0 -61
- package/dist/cli/build.d.ts.map +0 -1
- package/dist/cli/dev-api.d.ts +0 -49
- package/dist/cli/dev-api.d.ts.map +0 -1
- package/dist/cli/dev.d.ts +0 -101
- package/dist/cli/dev.d.ts.map +0 -1
- package/dist/cli/entry.d.ts +0 -31
- package/dist/cli/entry.d.ts.map +0 -1
- package/dist/cli/index.d.ts +0 -17
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/port.d.ts +0 -30
- package/dist/cli/port.d.ts.map +0 -1
- package/dist/cli/tools-declaration.d.ts +0 -22
- package/dist/cli/tools-declaration.d.ts.map +0 -1
- package/dist/cli/tunnel.d.ts +0 -46
- package/dist/cli/tunnel.d.ts.map +0 -1
- package/dist/cli/views-bindings.d.ts +0 -30
- package/dist/cli/views-bindings.d.ts.map +0 -1
- package/dist/cli/views-plugin.d.ts +0 -47
- package/dist/cli/views-plugin.d.ts.map +0 -1
- package/dist/cli/views.d.ts +0 -75
- package/dist/cli/views.d.ts.map +0 -1
- package/dist/cli/vite-config.d.ts +0 -21
- package/dist/cli/vite-config.d.ts.map +0 -1
- package/dist/cli/workspace.d.ts +0 -107
- package/dist/cli/workspace.d.ts.map +0 -1
- package/dist/commands/build.d.ts +0 -8
- package/dist/commands/build.d.ts.map +0 -1
- package/dist/commands/build.js +0 -370
- package/dist/commands/build.js.map +0 -1
- package/dist/commands/client.d.ts +0 -22
- package/dist/commands/client.d.ts.map +0 -1
- package/dist/commands/client.js +0 -14
- package/dist/commands/client.js.map +0 -1
- package/dist/commands/cloud-api.d.ts +0 -70
- package/dist/commands/cloud-api.d.ts.map +0 -1
- package/dist/commands/deploy.d.ts +0 -3
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js +0 -242
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/deployments.d.ts +0 -3
- package/dist/commands/deployments.d.ts.map +0 -1
- package/dist/commands/deployments.js +0 -213
- package/dist/commands/deployments.js.map +0 -1
- package/dist/commands/dev.d.ts +0 -8
- package/dist/commands/dev.d.ts.map +0 -1
- package/dist/commands/dev.js +0 -656
- package/dist/commands/dev.js.map +0 -1
- package/dist/commands/identity.d.ts +0 -3
- package/dist/commands/identity.d.ts.map +0 -1
- package/dist/commands/identity.js +0 -192
- package/dist/commands/identity.js.map +0 -1
- package/dist/commands/load-client.d.ts +0 -11
- package/dist/commands/load-client.d.ts.map +0 -1
- package/dist/commands/organizations.d.ts +0 -3
- package/dist/commands/organizations.d.ts.map +0 -1
- package/dist/commands/organizations.js +0 -97
- package/dist/commands/organizations.js.map +0 -1
- package/dist/commands/screenshot.d.ts +0 -3
- package/dist/commands/screenshot.d.ts.map +0 -1
- package/dist/commands/screenshot.js +0 -463
- package/dist/commands/screenshot.js.map +0 -1
- package/dist/commands/servers.d.ts +0 -3
- package/dist/commands/servers.d.ts.map +0 -1
- package/dist/commands/servers.js +0 -278
- package/dist/commands/servers.js.map +0 -1
- package/dist/commands/shared.d.ts +0 -44
- package/dist/commands/shared.d.ts.map +0 -1
- package/dist/commands/skills.d.ts +0 -3
- package/dist/commands/skills.d.ts.map +0 -1
- package/dist/commands/skills.js +0 -84
- package/dist/commands/skills.js.map +0 -1
- package/dist/commands/start.d.ts +0 -8
- package/dist/commands/start.d.ts.map +0 -1
- package/dist/commands/start.js +0 -72
- package/dist/commands/start.js.map +0 -1
- package/dist/completable.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/context.d.ts.map +0 -1
- package/dist/fetch-app.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inspector-shell.d.ts +0 -87
- package/dist/inspector-shell.d.ts.map +0 -1
- package/dist/internal/resource-completion.js.map +0 -1
- package/dist/landing-handler-VQRYCQOV.js +0 -31
- package/dist/landing-handler-VQRYCQOV.js.map +0 -1
- package/dist/landing-handler.d.ts.map +0 -1
- package/dist/landing.d.ts.map +0 -1
- package/dist/landing.js.map +0 -1
- package/dist/logging.d.ts.map +0 -1
- package/dist/middleware/cors.d.ts.map +0 -1
- package/dist/middleware/mcp-middleware.d.ts.map +0 -1
- package/dist/mount-mcp.d.ts.map +0 -1
- package/dist/node-bridge.d.ts.map +0 -1
- package/dist/node-bridge.js.map +0 -1
- package/dist/oauth/adapters.d.ts.map +0 -1
- package/dist/oauth/auth0.d.ts.map +0 -1
- package/dist/oauth/auth0.js.map +0 -1
- package/dist/oauth/better-auth.d.ts.map +0 -1
- package/dist/oauth/better-auth.js.map +0 -1
- package/dist/oauth/clerk.d.ts.map +0 -1
- package/dist/oauth/clerk.js.map +0 -1
- package/dist/oauth/guards.d.ts.map +0 -1
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/internal.d.ts.map +0 -1
- package/dist/oauth/jwt.d.ts.map +0 -1
- package/dist/oauth/keycloak.d.ts.map +0 -1
- package/dist/oauth/keycloak.js.map +0 -1
- package/dist/oauth/provider.d.ts.map +0 -1
- package/dist/oauth/supabase.d.ts.map +0 -1
- package/dist/oauth/supabase.js.map +0 -1
- package/dist/oauth/workos.d.ts.map +0 -1
- package/dist/oauth/workos.js.map +0 -1
- package/dist/openapi/index.d.ts.map +0 -1
- package/dist/openapi/index.js.map +0 -1
- package/dist/openapi/types.d.ts.map +0 -1
- package/dist/prompts.d.ts.map +0 -1
- package/dist/public-route-26FUVRO5.js +0 -62
- package/dist/public-route-26FUVRO5.js.map +0 -1
- package/dist/react/components/error-boundary.d.ts.map +0 -1
- package/dist/react/components/image.d.ts.map +0 -1
- package/dist/react/components/model-context.d.ts.map +0 -1
- package/dist/react/components/theme-provider.d.ts.map +0 -1
- package/dist/react/components/view-controls.d.ts.map +0 -1
- package/dist/react/hooks/use-call-tool.d.ts.map +0 -1
- package/dist/react/hooks/use-display-mode.d.ts.map +0 -1
- package/dist/react/hooks/use-files.d.ts.map +0 -1
- package/dist/react/hooks/use-host-context.d.ts.map +0 -1
- package/dist/react/hooks/use-open-external.d.ts.map +0 -1
- package/dist/react/hooks/use-send-follow-up.d.ts.map +0 -1
- package/dist/react/hooks/use-send-size-changed.d.ts.map +0 -1
- package/dist/react/hooks/use-tool-context.d.ts.map +0 -1
- package/dist/react/hooks/use-view-theme.d.ts.map +0 -1
- package/dist/react/hooks/use-view-tool.d.ts.map +0 -1
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js.map +0 -1
- package/dist/react/public-assets.d.ts.map +0 -1
- package/dist/react/runtime/bootstrap-view.d.ts.map +0 -1
- package/dist/react/runtime/model-context-store.d.ts.map +0 -1
- package/dist/react/runtime/view-config.d.ts.map +0 -1
- package/dist/react/runtime/view-runtime-context.d.ts.map +0 -1
- package/dist/react/runtime/view-runtime.d.ts.map +0 -1
- package/dist/react/types/file-types.d.ts.map +0 -1
- package/dist/react/types/host-types.d.ts.map +0 -1
- package/dist/react/types/register.d.ts.map +0 -1
- package/dist/react/types/result-types.d.ts.map +0 -1
- package/dist/resource-completion.d.ts.map +0 -1
- package/dist/resources.d.ts.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/tools.d.ts.map +0 -1
- package/dist/views/capabilities.d.ts.map +0 -1
- package/dist/views/constants.d.ts.map +0 -1
- package/dist/views/csp-env.d.ts.map +0 -1
- package/dist/views/document.d.ts.map +0 -1
- package/dist/views/index.d.ts.map +0 -1
- package/dist/views/origin.d.ts.map +0 -1
- package/dist/views/public-route.d.ts.map +0 -1
- package/dist/views/register.d.ts.map +0 -1
- package/dist/views/routes.d.ts.map +0 -1
- package/dist/views/types.d.ts.map +0 -1
- package/dist/views/wire.d.ts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/LICENSE +0 -216
- package/node_modules/@modelcontextprotocol/client/README.md +0 -26
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-Asx17_Co.mjs +0 -7069
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-Asx17_Co.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B7GnTXYx.d.mts +0 -1054
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B7GnTXYx.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B_4czhCS.d.cts +0 -1054
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-B_4czhCS.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-DNzBrkxq.cjs +0 -7086
- package/node_modules/@modelcontextprotocol/client/dist/ajvProvider-DNzBrkxq.cjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-D9GAttn8.d.cts +0 -59
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-D9GAttn8.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-DbU8BxXO.mjs +0 -970
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-DbU8BxXO.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Djgwc46-.cjs +0 -976
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Djgwc46-.cjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Xtj52JOa.d.mts +0 -59
- package/node_modules/@modelcontextprotocol/client/dist/cfWorkerProvider-Xtj52JOa.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/chunk-Bnu9O96Y.cjs +0 -60
- package/node_modules/@modelcontextprotocol/client/dist/chunk-Br0eD_fh.mjs +0 -42
- package/node_modules/@modelcontextprotocol/client/dist/index-ZagFkUbt.d.mts +0 -2675
- package/node_modules/@modelcontextprotocol/client/dist/index-ZagFkUbt.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index-gN3EXmil.d.cts +0 -2678
- package/node_modules/@modelcontextprotocol/client/dist/index-gN3EXmil.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs +0 -5427
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts +0 -3196
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts +0 -3196
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs +0 -5224
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.cjs +0 -14
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.cjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.cts +0 -13
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.mts +0 -13
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.mjs +0 -13
- package/node_modules/@modelcontextprotocol/client/dist/shimsBrowser.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.cjs +0 -14
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.cjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.cts +0 -13
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.mts +0 -13
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.mjs +0 -13
- package/node_modules/@modelcontextprotocol/client/dist/shimsNode.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +0 -21
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.cts +0 -13
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.mts +0 -13
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +0 -20
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/src-BzzZSQyL.cjs +0 -7331
- package/node_modules/@modelcontextprotocol/client/dist/src-BzzZSQyL.cjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/src-DGeA9On3.mjs +0 -6963
- package/node_modules/@modelcontextprotocol/client/dist/src-DGeA9On3.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +0 -181
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.cts +0 -87
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.mts +0 -87
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +0 -176
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/types-BDNQEPSs.d.mts +0 -1099
- package/node_modules/@modelcontextprotocol/client/dist/types-BDNQEPSs.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/types-DsbMXNFL.d.cts +0 -1099
- package/node_modules/@modelcontextprotocol/client/dist/types-DsbMXNFL.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.cjs +0 -5
- package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.d.cts +0 -2
- package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.d.mts +0 -2
- package/node_modules/@modelcontextprotocol/client/dist/validators/ajv.mjs +0 -3
- package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.cjs +0 -3
- package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.d.cts +0 -2
- package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.d.mts +0 -2
- package/node_modules/@modelcontextprotocol/client/dist/validators/cfWorker.mjs +0 -3
- package/node_modules/@modelcontextprotocol/client/package.json +0 -166
- package/node_modules/@modelcontextprotocol/core/LICENSE +0 -216
- package/node_modules/@modelcontextprotocol/core/README.md +0 -40
- package/node_modules/@modelcontextprotocol/core/dist/auth-BUWfrB3C.d.cts +0 -8198
- package/node_modules/@modelcontextprotocol/core/dist/auth-BUWfrB3C.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/core/dist/auth-CEFpHq32.cjs +0 -2862
- package/node_modules/@modelcontextprotocol/core/dist/auth-CEFpHq32.cjs.map +0 -1
- package/node_modules/@modelcontextprotocol/core/dist/auth-CNbu4K4a.d.mts +0 -8198
- package/node_modules/@modelcontextprotocol/core/dist/auth-CNbu4K4a.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/core/dist/auth-DFgbUATV.mjs +0 -1653
- package/node_modules/@modelcontextprotocol/core/dist/auth-DFgbUATV.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/core/dist/index.cjs +0 -174
- package/node_modules/@modelcontextprotocol/core/dist/index.d.cts +0 -2
- package/node_modules/@modelcontextprotocol/core/dist/index.d.mts +0 -2
- package/node_modules/@modelcontextprotocol/core/dist/index.mjs +0 -3
- package/node_modules/@modelcontextprotocol/core/dist/internal.cjs +0 -199
- package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts +0 -87
- package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts +0 -87
- package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/core/dist/internal.mjs +0 -3
- package/node_modules/@modelcontextprotocol/core/package.json +0 -85
- package/node_modules/jose/LICENSE.md +0 -21
- package/node_modules/jose/README.md +0 -153
- package/node_modules/jose/dist/types/index.d.ts +0 -55
- package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +0 -31
- package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +0 -65
- package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +0 -31
- package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +0 -83
- package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +0 -31
- package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +0 -74
- package/node_modules/jose/dist/types/jwk/embedded.d.ts +0 -17
- package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +0 -32
- package/node_modules/jose/dist/types/jwks/local.d.ts +0 -29
- package/node_modules/jose/dist/types/jwks/remote.d.ts +0 -237
- package/node_modules/jose/dist/types/jws/compact/sign.d.ts +0 -36
- package/node_modules/jose/dist/types/jws/compact/verify.d.ts +0 -33
- package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +0 -42
- package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +0 -33
- package/node_modules/jose/dist/types/jws/general/sign.d.ts +0 -53
- package/node_modules/jose/dist/types/jws/general/verify.d.ts +0 -33
- package/node_modules/jose/dist/types/jwt/decrypt.d.ts +0 -35
- package/node_modules/jose/dist/types/jwt/encrypt.d.ts +0 -91
- package/node_modules/jose/dist/types/jwt/sign.d.ts +0 -43
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +0 -43
- package/node_modules/jose/dist/types/jwt/verify.d.ts +0 -37
- package/node_modules/jose/dist/types/key/export.d.ts +0 -33
- package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +0 -47
- package/node_modules/jose/dist/types/key/generate_secret.d.ts +0 -35
- package/node_modules/jose/dist/types/key/import.d.ts +0 -83
- package/node_modules/jose/dist/types/types.d.ts +0 -841
- package/node_modules/jose/dist/types/util/base64url.d.ts +0 -9
- package/node_modules/jose/dist/types/util/decode_jwt.d.ts +0 -18
- package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +0 -17
- package/node_modules/jose/dist/types/util/errors.d.ts +0 -213
- package/node_modules/jose/dist/webapi/index.js +0 -32
- package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +0 -27
- package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +0 -27
- package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +0 -165
- package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +0 -169
- package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +0 -31
- package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +0 -187
- package/node_modules/jose/dist/webapi/jwk/embedded.js +0 -17
- package/node_modules/jose/dist/webapi/jwk/thumbprint.js +0 -68
- package/node_modules/jose/dist/webapi/jwks/local.js +0 -119
- package/node_modules/jose/dist/webapi/jwks/remote.js +0 -179
- package/node_modules/jose/dist/webapi/jws/compact/sign.js +0 -18
- package/node_modules/jose/dist/webapi/jws/compact/verify.js +0 -21
- package/node_modules/jose/dist/webapi/jws/flattened/sign.js +0 -92
- package/node_modules/jose/dist/webapi/jws/flattened/verify.js +0 -120
- package/node_modules/jose/dist/webapi/jws/general/sign.js +0 -73
- package/node_modules/jose/dist/webapi/jws/general/verify.js +0 -24
- package/node_modules/jose/dist/webapi/jwt/decrypt.js +0 -23
- package/node_modules/jose/dist/webapi/jwt/encrypt.js +0 -108
- package/node_modules/jose/dist/webapi/jwt/sign.js +0 -52
- package/node_modules/jose/dist/webapi/jwt/unsecured.js +0 -63
- package/node_modules/jose/dist/webapi/jwt/verify.js +0 -15
- package/node_modules/jose/dist/webapi/key/export.js +0 -11
- package/node_modules/jose/dist/webapi/key/generate_key_pair.js +0 -97
- package/node_modules/jose/dist/webapi/key/generate_secret.js +0 -40
- package/node_modules/jose/dist/webapi/key/import.js +0 -57
- package/node_modules/jose/dist/webapi/lib/aesgcmkw.js +0 -16
- package/node_modules/jose/dist/webapi/lib/aeskw.js +0 -25
- package/node_modules/jose/dist/webapi/lib/asn1.js +0 -243
- package/node_modules/jose/dist/webapi/lib/base64.js +0 -22
- package/node_modules/jose/dist/webapi/lib/buffer_utils.js +0 -43
- package/node_modules/jose/dist/webapi/lib/cek.js +0 -19
- package/node_modules/jose/dist/webapi/lib/check_cek_length.js +0 -7
- package/node_modules/jose/dist/webapi/lib/check_iv_length.js +0 -7
- package/node_modules/jose/dist/webapi/lib/check_key_length.js +0 -8
- package/node_modules/jose/dist/webapi/lib/check_key_type.js +0 -122
- package/node_modules/jose/dist/webapi/lib/crypto_key.js +0 -143
- package/node_modules/jose/dist/webapi/lib/decrypt.js +0 -106
- package/node_modules/jose/dist/webapi/lib/decrypt_key_management.js +0 -127
- package/node_modules/jose/dist/webapi/lib/digest.js +0 -4
- package/node_modules/jose/dist/webapi/lib/ecdhes.js +0 -52
- package/node_modules/jose/dist/webapi/lib/encrypt.js +0 -74
- package/node_modules/jose/dist/webapi/lib/encrypt_key_management.js +0 -92
- package/node_modules/jose/dist/webapi/lib/get_sign_verify_key.js +0 -12
- package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +0 -27
- package/node_modules/jose/dist/webapi/lib/is_disjoint.js +0 -21
- package/node_modules/jose/dist/webapi/lib/is_jwk.js +0 -6
- package/node_modules/jose/dist/webapi/lib/is_key_like.js +0 -17
- package/node_modules/jose/dist/webapi/lib/is_object.js +0 -14
- package/node_modules/jose/dist/webapi/lib/iv.js +0 -19
- package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +0 -109
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +0 -238
- package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +0 -31
- package/node_modules/jose/dist/webapi/lib/normalize_key.js +0 -176
- package/node_modules/jose/dist/webapi/lib/pbes2kw.js +0 -39
- package/node_modules/jose/dist/webapi/lib/private_symbols.js +0 -1
- package/node_modules/jose/dist/webapi/lib/rsaes.js +0 -24
- package/node_modules/jose/dist/webapi/lib/sign.js +0 -9
- package/node_modules/jose/dist/webapi/lib/subtle_dsa.js +0 -31
- package/node_modules/jose/dist/webapi/lib/validate_algorithms.js +0 -10
- package/node_modules/jose/dist/webapi/lib/validate_crit.js +0 -33
- package/node_modules/jose/dist/webapi/lib/verify.js +0 -14
- package/node_modules/jose/dist/webapi/util/base64url.js +0 -30
- package/node_modules/jose/dist/webapi/util/decode_jwt.js +0 -32
- package/node_modules/jose/dist/webapi/util/decode_protected_header.js +0 -34
- package/node_modules/jose/dist/webapi/util/errors.js +0 -99
- package/node_modules/jose/package.json +0 -200
- package/node_modules/zod/LICENSE +0 -21
- package/node_modules/zod/README.md +0 -191
- package/node_modules/zod/index.cjs +0 -33
- package/node_modules/zod/index.d.cts +0 -4
- package/node_modules/zod/index.d.ts +0 -4
- package/node_modules/zod/index.js +0 -4
- package/node_modules/zod/locales/index.cjs +0 -17
- package/node_modules/zod/locales/index.d.cts +0 -1
- package/node_modules/zod/locales/index.d.ts +0 -1
- package/node_modules/zod/locales/index.js +0 -1
- package/node_modules/zod/locales/package.json +0 -7
- package/node_modules/zod/mini/index.cjs +0 -32
- package/node_modules/zod/mini/index.d.cts +0 -3
- package/node_modules/zod/mini/index.d.ts +0 -3
- package/node_modules/zod/mini/index.js +0 -3
- package/node_modules/zod/mini/package.json +0 -7
- package/node_modules/zod/package.json +0 -135
- package/node_modules/zod/src/index.ts +0 -4
- package/node_modules/zod/src/locales/index.ts +0 -1
- package/node_modules/zod/src/mini/index.ts +0 -3
- package/node_modules/zod/src/v3/ZodError.ts +0 -330
- package/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
- package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
- package/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
- package/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
- package/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
- package/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
- package/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
- package/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
- package/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
- package/node_modules/zod/src/v3/errors.ts +0 -13
- package/node_modules/zod/src/v3/external.ts +0 -6
- package/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
- package/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
- package/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
- package/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
- package/node_modules/zod/src/v3/helpers/util.ts +0 -224
- package/node_modules/zod/src/v3/index.ts +0 -4
- package/node_modules/zod/src/v3/locales/en.ts +0 -124
- package/node_modules/zod/src/v3/standard-schema.ts +0 -113
- package/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
- package/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
- package/node_modules/zod/src/v3/tests/array.test.ts +0 -71
- package/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
- package/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
- package/node_modules/zod/src/v3/tests/base.test.ts +0 -29
- package/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
- package/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
- package/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
- package/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
- package/node_modules/zod/src/v3/tests/complex.test.ts +0 -70
- package/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
- package/node_modules/zod/src/v3/tests/date.test.ts +0 -32
- package/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
- package/node_modules/zod/src/v3/tests/default.test.ts +0 -112
- package/node_modules/zod/src/v3/tests/description.test.ts +0 -33
- package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
- package/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
- package/node_modules/zod/src/v3/tests/error.test.ts +0 -551
- package/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
- package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
- package/node_modules/zod/src/v3/tests/function.test.ts +0 -261
- package/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
- package/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
- package/node_modules/zod/src/v3/tests/intersection.test.ts +0 -110
- package/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
- package/node_modules/zod/src/v3/tests/language-server.test.ts +0 -207
- package/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
- package/node_modules/zod/src/v3/tests/map.test.ts +0 -110
- package/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
- package/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
- package/node_modules/zod/src/v3/tests/nan.test.ts +0 -24
- package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
- package/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
- package/node_modules/zod/src/v3/tests/number.test.ts +0 -176
- package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
- package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
- package/node_modules/zod/src/v3/tests/object.test.ts +0 -434
- package/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
- package/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
- package/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
- package/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
- package/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
- package/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
- package/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
- package/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
- package/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
- package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -194
- package/node_modules/zod/src/v3/tests/record.test.ts +0 -171
- package/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
- package/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
- package/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
- package/node_modules/zod/src/v3/tests/set.test.ts +0 -142
- package/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
- package/node_modules/zod/src/v3/tests/string.test.ts +0 -916
- package/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
- package/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
- package/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
- package/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
- package/node_modules/zod/src/v3/tests/void.test.ts +0 -15
- package/node_modules/zod/src/v3/types.ts +0 -5138
- package/node_modules/zod/src/v4/classic/checks.ts +0 -32
- package/node_modules/zod/src/v4/classic/coerce.ts +0 -27
- package/node_modules/zod/src/v4/classic/compat.ts +0 -70
- package/node_modules/zod/src/v4/classic/errors.ts +0 -82
- package/node_modules/zod/src/v4/classic/external.ts +0 -52
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +0 -659
- package/node_modules/zod/src/v4/classic/index.ts +0 -5
- package/node_modules/zod/src/v4/classic/iso.ts +0 -90
- package/node_modules/zod/src/v4/classic/parse.ts +0 -82
- package/node_modules/zod/src/v4/classic/schemas.ts +0 -2672
- package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +0 -59
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -264
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -216
- package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
- package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
- package/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -54
- package/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -106
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -326
- package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +0 -573
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +0 -703
- package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -374
- package/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -62
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -302
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -409
- package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +0 -27
- package/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +0 -197
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -694
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -285
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -807
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -711
- package/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -96
- package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -179
- package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +0 -26
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +0 -895
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -360
- package/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +0 -39
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +0 -68
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -939
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -60
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -198
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +0 -46
- package/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -109
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -227
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -117
- package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +0 -29
- package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +0 -24
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -330
- package/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
- package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
- package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -101
- package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -325
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -717
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -333
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -450
- package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -211
- package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -101
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -74
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +0 -26
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -351
- package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
- package/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
- package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -252
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -717
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -631
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -633
- package/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -243
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -181
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -134
- package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -125
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -1224
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -106
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -771
- package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +0 -438
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -3125
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -378
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -496
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -273
- package/node_modules/zod/src/v4/classic/tests/url.test.ts +0 -13
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
- package/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
- package/node_modules/zod/src/v4/core/api.ts +0 -1823
- package/node_modules/zod/src/v4/core/checks.ts +0 -1293
- package/node_modules/zod/src/v4/core/config.ts +0 -15
- package/node_modules/zod/src/v4/core/core.ts +0 -153
- package/node_modules/zod/src/v4/core/doc.ts +0 -44
- package/node_modules/zod/src/v4/core/errors.ts +0 -455
- package/node_modules/zod/src/v4/core/index.ts +0 -16
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +0 -126
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +0 -666
- package/node_modules/zod/src/v4/core/json-schema.ts +0 -147
- package/node_modules/zod/src/v4/core/parse.ts +0 -195
- package/node_modules/zod/src/v4/core/regexes.ts +0 -190
- package/node_modules/zod/src/v4/core/registries.ts +0 -105
- package/node_modules/zod/src/v4/core/schemas.ts +0 -4730
- package/node_modules/zod/src/v4/core/standard-schema.ts +0 -159
- package/node_modules/zod/src/v4/core/tests/extend.test.ts +0 -59
- package/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
- package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +0 -215
- package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +0 -181
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +0 -72
- package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +0 -379
- package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +0 -163
- package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +0 -46
- package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
- package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
- package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +0 -105
- package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +0 -125
- package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +0 -45
- package/node_modules/zod/src/v4/core/to-json-schema.ts +0 -622
- package/node_modules/zod/src/v4/core/util.ts +0 -983
- package/node_modules/zod/src/v4/core/versions.ts +0 -5
- package/node_modules/zod/src/v4/core/zsf.ts +0 -323
- package/node_modules/zod/src/v4/index.ts +0 -4
- package/node_modules/zod/src/v4/locales/ar.ts +0 -115
- package/node_modules/zod/src/v4/locales/az.ts +0 -111
- package/node_modules/zod/src/v4/locales/be.ts +0 -176
- package/node_modules/zod/src/v4/locales/bg.ts +0 -128
- package/node_modules/zod/src/v4/locales/ca.ts +0 -116
- package/node_modules/zod/src/v4/locales/cs.ts +0 -118
- package/node_modules/zod/src/v4/locales/da.ts +0 -123
- package/node_modules/zod/src/v4/locales/de.ts +0 -116
- package/node_modules/zod/src/v4/locales/el.ts +0 -121
- package/node_modules/zod/src/v4/locales/en.ts +0 -123
- package/node_modules/zod/src/v4/locales/eo.ts +0 -118
- package/node_modules/zod/src/v4/locales/es.ts +0 -141
- package/node_modules/zod/src/v4/locales/fa.ts +0 -126
- package/node_modules/zod/src/v4/locales/fi.ts +0 -121
- package/node_modules/zod/src/v4/locales/fr-CA.ts +0 -116
- package/node_modules/zod/src/v4/locales/fr.ts +0 -132
- package/node_modules/zod/src/v4/locales/he.ts +0 -246
- package/node_modules/zod/src/v4/locales/hr.ts +0 -131
- package/node_modules/zod/src/v4/locales/hu.ts +0 -117
- package/node_modules/zod/src/v4/locales/hy.ts +0 -164
- package/node_modules/zod/src/v4/locales/id.ts +0 -115
- package/node_modules/zod/src/v4/locales/index.ts +0 -52
- package/node_modules/zod/src/v4/locales/is.ts +0 -119
- package/node_modules/zod/src/v4/locales/it.ts +0 -116
- package/node_modules/zod/src/v4/locales/ja.ts +0 -114
- package/node_modules/zod/src/v4/locales/ka.ts +0 -123
- package/node_modules/zod/src/v4/locales/kh.ts +0 -7
- package/node_modules/zod/src/v4/locales/km.ts +0 -119
- package/node_modules/zod/src/v4/locales/ko.ts +0 -121
- package/node_modules/zod/src/v4/locales/lt.ts +0 -239
- package/node_modules/zod/src/v4/locales/mk.ts +0 -118
- package/node_modules/zod/src/v4/locales/ms.ts +0 -115
- package/node_modules/zod/src/v4/locales/nl.ts +0 -121
- package/node_modules/zod/src/v4/locales/no.ts +0 -116
- package/node_modules/zod/src/v4/locales/ota.ts +0 -117
- package/node_modules/zod/src/v4/locales/pl.ts +0 -118
- package/node_modules/zod/src/v4/locales/ps.ts +0 -126
- package/node_modules/zod/src/v4/locales/pt.ts +0 -116
- package/node_modules/zod/src/v4/locales/ro.ts +0 -129
- package/node_modules/zod/src/v4/locales/ru.ts +0 -176
- package/node_modules/zod/src/v4/locales/sl.ts +0 -118
- package/node_modules/zod/src/v4/locales/sv.ts +0 -119
- package/node_modules/zod/src/v4/locales/ta.ts +0 -118
- package/node_modules/zod/src/v4/locales/th.ts +0 -119
- package/node_modules/zod/src/v4/locales/tr.ts +0 -111
- package/node_modules/zod/src/v4/locales/ua.ts +0 -7
- package/node_modules/zod/src/v4/locales/uk.ts +0 -117
- package/node_modules/zod/src/v4/locales/ur.ts +0 -119
- package/node_modules/zod/src/v4/locales/uz.ts +0 -117
- package/node_modules/zod/src/v4/locales/vi.ts +0 -117
- package/node_modules/zod/src/v4/locales/yo.ts +0 -124
- package/node_modules/zod/src/v4/locales/zh-CN.ts +0 -116
- package/node_modules/zod/src/v4/locales/zh-TW.ts +0 -115
- package/node_modules/zod/src/v4/mini/checks.ts +0 -32
- package/node_modules/zod/src/v4/mini/coerce.ts +0 -27
- package/node_modules/zod/src/v4/mini/external.ts +0 -41
- package/node_modules/zod/src/v4/mini/index.ts +0 -3
- package/node_modules/zod/src/v4/mini/iso.ts +0 -66
- package/node_modules/zod/src/v4/mini/parse.ts +0 -14
- package/node_modules/zod/src/v4/mini/schemas.ts +0 -1947
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +0 -24
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -129
- package/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -94
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -144
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +0 -548
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -36
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -22
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -5
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -993
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -95
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -227
- package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -325
- package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +0 -50
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -352
- package/node_modules/zod/src/v4-mini/index.ts +0 -3
- package/node_modules/zod/v3/ZodError.cjs +0 -138
- package/node_modules/zod/v3/ZodError.d.cts +0 -164
- package/node_modules/zod/v3/ZodError.d.ts +0 -164
- package/node_modules/zod/v3/ZodError.js +0 -133
- package/node_modules/zod/v3/errors.cjs +0 -17
- package/node_modules/zod/v3/errors.d.cts +0 -5
- package/node_modules/zod/v3/errors.d.ts +0 -5
- package/node_modules/zod/v3/errors.js +0 -9
- package/node_modules/zod/v3/external.cjs +0 -22
- package/node_modules/zod/v3/external.d.cts +0 -6
- package/node_modules/zod/v3/external.d.ts +0 -6
- package/node_modules/zod/v3/external.js +0 -6
- package/node_modules/zod/v3/helpers/enumUtil.cjs +0 -2
- package/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
- package/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
- package/node_modules/zod/v3/helpers/enumUtil.js +0 -1
- package/node_modules/zod/v3/helpers/errorUtil.cjs +0 -9
- package/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
- package/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
- package/node_modules/zod/v3/helpers/errorUtil.js +0 -6
- package/node_modules/zod/v3/helpers/parseUtil.cjs +0 -124
- package/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
- package/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
- package/node_modules/zod/v3/helpers/parseUtil.js +0 -109
- package/node_modules/zod/v3/helpers/partialUtil.cjs +0 -2
- package/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
- package/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
- package/node_modules/zod/v3/helpers/partialUtil.js +0 -1
- package/node_modules/zod/v3/helpers/typeAliases.cjs +0 -2
- package/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
- package/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
- package/node_modules/zod/v3/helpers/typeAliases.js +0 -1
- package/node_modules/zod/v3/helpers/util.cjs +0 -137
- package/node_modules/zod/v3/helpers/util.d.cts +0 -85
- package/node_modules/zod/v3/helpers/util.d.ts +0 -85
- package/node_modules/zod/v3/helpers/util.js +0 -133
- package/node_modules/zod/v3/index.cjs +0 -33
- package/node_modules/zod/v3/index.d.cts +0 -4
- package/node_modules/zod/v3/index.d.ts +0 -4
- package/node_modules/zod/v3/index.js +0 -4
- package/node_modules/zod/v3/locales/en.cjs +0 -112
- package/node_modules/zod/v3/locales/en.d.cts +0 -3
- package/node_modules/zod/v3/locales/en.d.ts +0 -3
- package/node_modules/zod/v3/locales/en.js +0 -109
- package/node_modules/zod/v3/package.json +0 -7
- package/node_modules/zod/v3/standard-schema.cjs +0 -2
- package/node_modules/zod/v3/standard-schema.d.cts +0 -102
- package/node_modules/zod/v3/standard-schema.d.ts +0 -102
- package/node_modules/zod/v3/standard-schema.js +0 -1
- package/node_modules/zod/v3/types.cjs +0 -3777
- package/node_modules/zod/v3/types.d.cts +0 -1034
- package/node_modules/zod/v3/types.d.ts +0 -1034
- package/node_modules/zod/v3/types.js +0 -3695
- package/node_modules/zod/v4/classic/checks.cjs +0 -33
- package/node_modules/zod/v4/classic/checks.d.cts +0 -1
- package/node_modules/zod/v4/classic/checks.d.ts +0 -1
- package/node_modules/zod/v4/classic/checks.js +0 -1
- package/node_modules/zod/v4/classic/coerce.cjs +0 -47
- package/node_modules/zod/v4/classic/coerce.d.cts +0 -17
- package/node_modules/zod/v4/classic/coerce.d.ts +0 -17
- package/node_modules/zod/v4/classic/coerce.js +0 -17
- package/node_modules/zod/v4/classic/compat.cjs +0 -61
- package/node_modules/zod/v4/classic/compat.d.cts +0 -50
- package/node_modules/zod/v4/classic/compat.d.ts +0 -50
- package/node_modules/zod/v4/classic/compat.js +0 -31
- package/node_modules/zod/v4/classic/errors.cjs +0 -74
- package/node_modules/zod/v4/classic/errors.d.cts +0 -30
- package/node_modules/zod/v4/classic/errors.d.ts +0 -30
- package/node_modules/zod/v4/classic/errors.js +0 -48
- package/node_modules/zod/v4/classic/external.cjs +0 -73
- package/node_modules/zod/v4/classic/external.d.cts +0 -16
- package/node_modules/zod/v4/classic/external.d.ts +0 -16
- package/node_modules/zod/v4/classic/external.js +0 -20
- package/node_modules/zod/v4/classic/from-json-schema.cjs +0 -625
- package/node_modules/zod/v4/classic/from-json-schema.d.cts +0 -12
- package/node_modules/zod/v4/classic/from-json-schema.d.ts +0 -12
- package/node_modules/zod/v4/classic/from-json-schema.js +0 -599
- package/node_modules/zod/v4/classic/index.cjs +0 -33
- package/node_modules/zod/v4/classic/index.d.cts +0 -4
- package/node_modules/zod/v4/classic/index.d.ts +0 -4
- package/node_modules/zod/v4/classic/index.js +0 -4
- package/node_modules/zod/v4/classic/iso.cjs +0 -60
- package/node_modules/zod/v4/classic/iso.d.cts +0 -22
- package/node_modules/zod/v4/classic/iso.d.ts +0 -22
- package/node_modules/zod/v4/classic/iso.js +0 -30
- package/node_modules/zod/v4/classic/package.json +0 -7
- package/node_modules/zod/v4/classic/parse.cjs +0 -41
- package/node_modules/zod/v4/classic/parse.d.cts +0 -31
- package/node_modules/zod/v4/classic/parse.d.ts +0 -31
- package/node_modules/zod/v4/classic/parse.js +0 -15
- package/node_modules/zod/v4/classic/schemas.cjs +0 -1511
- package/node_modules/zod/v4/classic/schemas.d.cts +0 -767
- package/node_modules/zod/v4/classic/schemas.d.ts +0 -767
- package/node_modules/zod/v4/classic/schemas.js +0 -1395
- package/node_modules/zod/v4/core/api.cjs +0 -1227
- package/node_modules/zod/v4/core/api.d.cts +0 -325
- package/node_modules/zod/v4/core/api.d.ts +0 -325
- package/node_modules/zod/v4/core/api.js +0 -1087
- package/node_modules/zod/v4/core/checks.cjs +0 -601
- package/node_modules/zod/v4/core/checks.d.cts +0 -278
- package/node_modules/zod/v4/core/checks.d.ts +0 -278
- package/node_modules/zod/v4/core/checks.js +0 -575
- package/node_modules/zod/v4/core/core.cjs +0 -85
- package/node_modules/zod/v4/core/core.d.cts +0 -70
- package/node_modules/zod/v4/core/core.d.ts +0 -70
- package/node_modules/zod/v4/core/core.js +0 -78
- package/node_modules/zod/v4/core/doc.cjs +0 -39
- package/node_modules/zod/v4/core/doc.d.cts +0 -14
- package/node_modules/zod/v4/core/doc.d.ts +0 -14
- package/node_modules/zod/v4/core/doc.js +0 -35
- package/node_modules/zod/v4/core/errors.cjs +0 -216
- package/node_modules/zod/v4/core/errors.d.cts +0 -221
- package/node_modules/zod/v4/core/errors.d.ts +0 -221
- package/node_modules/zod/v4/core/errors.js +0 -185
- package/node_modules/zod/v4/core/index.cjs +0 -47
- package/node_modules/zod/v4/core/index.d.cts +0 -16
- package/node_modules/zod/v4/core/index.d.ts +0 -16
- package/node_modules/zod/v4/core/index.js +0 -16
- package/node_modules/zod/v4/core/json-schema-generator.cjs +0 -99
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +0 -65
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +0 -65
- package/node_modules/zod/v4/core/json-schema-generator.js +0 -95
- package/node_modules/zod/v4/core/json-schema-processors.cjs +0 -644
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +0 -49
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +0 -49
- package/node_modules/zod/v4/core/json-schema-processors.js +0 -601
- package/node_modules/zod/v4/core/json-schema.cjs +0 -2
- package/node_modules/zod/v4/core/json-schema.d.cts +0 -88
- package/node_modules/zod/v4/core/json-schema.d.ts +0 -88
- package/node_modules/zod/v4/core/json-schema.js +0 -1
- package/node_modules/zod/v4/core/package.json +0 -7
- package/node_modules/zod/v4/core/parse.cjs +0 -131
- package/node_modules/zod/v4/core/parse.d.cts +0 -49
- package/node_modules/zod/v4/core/parse.d.ts +0 -49
- package/node_modules/zod/v4/core/parse.js +0 -93
- package/node_modules/zod/v4/core/regexes.cjs +0 -172
- package/node_modules/zod/v4/core/regexes.d.cts +0 -85
- package/node_modules/zod/v4/core/regexes.d.ts +0 -85
- package/node_modules/zod/v4/core/regexes.js +0 -139
- package/node_modules/zod/v4/core/registries.cjs +0 -56
- package/node_modules/zod/v4/core/registries.d.cts +0 -35
- package/node_modules/zod/v4/core/registries.d.ts +0 -35
- package/node_modules/zod/v4/core/registries.js +0 -51
- package/node_modules/zod/v4/core/schemas.cjs +0 -2270
- package/node_modules/zod/v4/core/schemas.d.cts +0 -1184
- package/node_modules/zod/v4/core/schemas.d.ts +0 -1184
- package/node_modules/zod/v4/core/schemas.js +0 -2239
- package/node_modules/zod/v4/core/standard-schema.cjs +0 -2
- package/node_modules/zod/v4/core/standard-schema.d.cts +0 -126
- package/node_modules/zod/v4/core/standard-schema.d.ts +0 -126
- package/node_modules/zod/v4/core/standard-schema.js +0 -1
- package/node_modules/zod/v4/core/to-json-schema.cjs +0 -457
- package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -114
- package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -114
- package/node_modules/zod/v4/core/to-json-schema.js +0 -448
- package/node_modules/zod/v4/core/util.cjs +0 -734
- package/node_modules/zod/v4/core/util.d.cts +0 -200
- package/node_modules/zod/v4/core/util.d.ts +0 -200
- package/node_modules/zod/v4/core/util.js +0 -674
- package/node_modules/zod/v4/core/versions.cjs +0 -8
- package/node_modules/zod/v4/core/versions.d.cts +0 -5
- package/node_modules/zod/v4/core/versions.d.ts +0 -5
- package/node_modules/zod/v4/core/versions.js +0 -5
- package/node_modules/zod/v4/index.cjs +0 -22
- package/node_modules/zod/v4/index.d.cts +0 -3
- package/node_modules/zod/v4/index.d.ts +0 -3
- package/node_modules/zod/v4/index.js +0 -3
- package/node_modules/zod/v4/locales/ar.cjs +0 -133
- package/node_modules/zod/v4/locales/ar.d.cts +0 -5
- package/node_modules/zod/v4/locales/ar.d.ts +0 -4
- package/node_modules/zod/v4/locales/ar.js +0 -106
- package/node_modules/zod/v4/locales/az.cjs +0 -132
- package/node_modules/zod/v4/locales/az.d.cts +0 -5
- package/node_modules/zod/v4/locales/az.d.ts +0 -4
- package/node_modules/zod/v4/locales/az.js +0 -105
- package/node_modules/zod/v4/locales/be.cjs +0 -183
- package/node_modules/zod/v4/locales/be.d.cts +0 -5
- package/node_modules/zod/v4/locales/be.d.ts +0 -4
- package/node_modules/zod/v4/locales/be.js +0 -156
- package/node_modules/zod/v4/locales/bg.cjs +0 -147
- package/node_modules/zod/v4/locales/bg.d.cts +0 -5
- package/node_modules/zod/v4/locales/bg.d.ts +0 -4
- package/node_modules/zod/v4/locales/bg.js +0 -120
- package/node_modules/zod/v4/locales/ca.cjs +0 -134
- package/node_modules/zod/v4/locales/ca.d.cts +0 -5
- package/node_modules/zod/v4/locales/ca.d.ts +0 -4
- package/node_modules/zod/v4/locales/ca.js +0 -107
- package/node_modules/zod/v4/locales/cs.cjs +0 -138
- package/node_modules/zod/v4/locales/cs.d.cts +0 -5
- package/node_modules/zod/v4/locales/cs.d.ts +0 -4
- package/node_modules/zod/v4/locales/cs.js +0 -111
- package/node_modules/zod/v4/locales/da.cjs +0 -142
- package/node_modules/zod/v4/locales/da.d.cts +0 -5
- package/node_modules/zod/v4/locales/da.d.ts +0 -4
- package/node_modules/zod/v4/locales/da.js +0 -115
- package/node_modules/zod/v4/locales/de.cjs +0 -135
- package/node_modules/zod/v4/locales/de.d.cts +0 -5
- package/node_modules/zod/v4/locales/de.d.ts +0 -4
- package/node_modules/zod/v4/locales/de.js +0 -108
- package/node_modules/zod/v4/locales/el.cjs +0 -136
- package/node_modules/zod/v4/locales/el.d.cts +0 -5
- package/node_modules/zod/v4/locales/el.d.ts +0 -4
- package/node_modules/zod/v4/locales/el.js +0 -109
- package/node_modules/zod/v4/locales/en.cjs +0 -140
- package/node_modules/zod/v4/locales/en.d.cts +0 -5
- package/node_modules/zod/v4/locales/en.d.ts +0 -4
- package/node_modules/zod/v4/locales/en.js +0 -113
- package/node_modules/zod/v4/locales/eo.cjs +0 -136
- package/node_modules/zod/v4/locales/eo.d.cts +0 -5
- package/node_modules/zod/v4/locales/eo.d.ts +0 -4
- package/node_modules/zod/v4/locales/eo.js +0 -109
- package/node_modules/zod/v4/locales/es.cjs +0 -159
- package/node_modules/zod/v4/locales/es.d.cts +0 -5
- package/node_modules/zod/v4/locales/es.d.ts +0 -4
- package/node_modules/zod/v4/locales/es.js +0 -132
- package/node_modules/zod/v4/locales/fa.cjs +0 -141
- package/node_modules/zod/v4/locales/fa.d.cts +0 -5
- package/node_modules/zod/v4/locales/fa.d.ts +0 -4
- package/node_modules/zod/v4/locales/fa.js +0 -114
- package/node_modules/zod/v4/locales/fi.cjs +0 -139
- package/node_modules/zod/v4/locales/fi.d.cts +0 -5
- package/node_modules/zod/v4/locales/fi.d.ts +0 -4
- package/node_modules/zod/v4/locales/fi.js +0 -112
- package/node_modules/zod/v4/locales/fr-CA.cjs +0 -134
- package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -5
- package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
- package/node_modules/zod/v4/locales/fr-CA.js +0 -107
- package/node_modules/zod/v4/locales/fr.cjs +0 -152
- package/node_modules/zod/v4/locales/fr.d.cts +0 -5
- package/node_modules/zod/v4/locales/fr.d.ts +0 -4
- package/node_modules/zod/v4/locales/fr.js +0 -125
- package/node_modules/zod/v4/locales/he.cjs +0 -241
- package/node_modules/zod/v4/locales/he.d.cts +0 -5
- package/node_modules/zod/v4/locales/he.d.ts +0 -4
- package/node_modules/zod/v4/locales/he.js +0 -214
- package/node_modules/zod/v4/locales/hr.cjs +0 -149
- package/node_modules/zod/v4/locales/hr.d.cts +0 -5
- package/node_modules/zod/v4/locales/hr.d.ts +0 -4
- package/node_modules/zod/v4/locales/hr.js +0 -122
- package/node_modules/zod/v4/locales/hu.cjs +0 -135
- package/node_modules/zod/v4/locales/hu.d.cts +0 -5
- package/node_modules/zod/v4/locales/hu.d.ts +0 -4
- package/node_modules/zod/v4/locales/hu.js +0 -108
- package/node_modules/zod/v4/locales/hy.cjs +0 -174
- package/node_modules/zod/v4/locales/hy.d.cts +0 -5
- package/node_modules/zod/v4/locales/hy.d.ts +0 -4
- package/node_modules/zod/v4/locales/hy.js +0 -147
- package/node_modules/zod/v4/locales/id.cjs +0 -133
- package/node_modules/zod/v4/locales/id.d.cts +0 -5
- package/node_modules/zod/v4/locales/id.d.ts +0 -4
- package/node_modules/zod/v4/locales/id.js +0 -106
- package/node_modules/zod/v4/locales/index.cjs +0 -111
- package/node_modules/zod/v4/locales/index.d.cts +0 -52
- package/node_modules/zod/v4/locales/index.d.ts +0 -52
- package/node_modules/zod/v4/locales/index.js +0 -52
- package/node_modules/zod/v4/locales/is.cjs +0 -136
- package/node_modules/zod/v4/locales/is.d.cts +0 -5
- package/node_modules/zod/v4/locales/is.d.ts +0 -4
- package/node_modules/zod/v4/locales/is.js +0 -109
- package/node_modules/zod/v4/locales/it.cjs +0 -135
- package/node_modules/zod/v4/locales/it.d.cts +0 -5
- package/node_modules/zod/v4/locales/it.d.ts +0 -4
- package/node_modules/zod/v4/locales/it.js +0 -108
- package/node_modules/zod/v4/locales/ja.cjs +0 -134
- package/node_modules/zod/v4/locales/ja.d.cts +0 -5
- package/node_modules/zod/v4/locales/ja.d.ts +0 -4
- package/node_modules/zod/v4/locales/ja.js +0 -107
- package/node_modules/zod/v4/locales/ka.cjs +0 -139
- package/node_modules/zod/v4/locales/ka.d.cts +0 -5
- package/node_modules/zod/v4/locales/ka.d.ts +0 -4
- package/node_modules/zod/v4/locales/ka.js +0 -112
- package/node_modules/zod/v4/locales/kh.cjs +0 -12
- package/node_modules/zod/v4/locales/kh.d.cts +0 -5
- package/node_modules/zod/v4/locales/kh.d.ts +0 -5
- package/node_modules/zod/v4/locales/kh.js +0 -5
- package/node_modules/zod/v4/locales/km.cjs +0 -137
- package/node_modules/zod/v4/locales/km.d.cts +0 -5
- package/node_modules/zod/v4/locales/km.d.ts +0 -4
- package/node_modules/zod/v4/locales/km.js +0 -110
- package/node_modules/zod/v4/locales/ko.cjs +0 -138
- package/node_modules/zod/v4/locales/ko.d.cts +0 -5
- package/node_modules/zod/v4/locales/ko.d.ts +0 -4
- package/node_modules/zod/v4/locales/ko.js +0 -111
- package/node_modules/zod/v4/locales/lt.cjs +0 -230
- package/node_modules/zod/v4/locales/lt.d.cts +0 -5
- package/node_modules/zod/v4/locales/lt.d.ts +0 -4
- package/node_modules/zod/v4/locales/lt.js +0 -203
- package/node_modules/zod/v4/locales/mk.cjs +0 -136
- package/node_modules/zod/v4/locales/mk.d.cts +0 -5
- package/node_modules/zod/v4/locales/mk.d.ts +0 -4
- package/node_modules/zod/v4/locales/mk.js +0 -109
- package/node_modules/zod/v4/locales/ms.cjs +0 -134
- package/node_modules/zod/v4/locales/ms.d.cts +0 -5
- package/node_modules/zod/v4/locales/ms.d.ts +0 -4
- package/node_modules/zod/v4/locales/ms.js +0 -107
- package/node_modules/zod/v4/locales/nl.cjs +0 -137
- package/node_modules/zod/v4/locales/nl.d.cts +0 -5
- package/node_modules/zod/v4/locales/nl.d.ts +0 -4
- package/node_modules/zod/v4/locales/nl.js +0 -110
- package/node_modules/zod/v4/locales/no.cjs +0 -135
- package/node_modules/zod/v4/locales/no.d.cts +0 -5
- package/node_modules/zod/v4/locales/no.d.ts +0 -4
- package/node_modules/zod/v4/locales/no.js +0 -108
- package/node_modules/zod/v4/locales/ota.cjs +0 -136
- package/node_modules/zod/v4/locales/ota.d.cts +0 -5
- package/node_modules/zod/v4/locales/ota.d.ts +0 -4
- package/node_modules/zod/v4/locales/ota.js +0 -109
- package/node_modules/zod/v4/locales/package.json +0 -7
- package/node_modules/zod/v4/locales/pl.cjs +0 -136
- package/node_modules/zod/v4/locales/pl.d.cts +0 -5
- package/node_modules/zod/v4/locales/pl.d.ts +0 -4
- package/node_modules/zod/v4/locales/pl.js +0 -109
- package/node_modules/zod/v4/locales/ps.cjs +0 -141
- package/node_modules/zod/v4/locales/ps.d.cts +0 -5
- package/node_modules/zod/v4/locales/ps.d.ts +0 -4
- package/node_modules/zod/v4/locales/ps.js +0 -114
- package/node_modules/zod/v4/locales/pt.cjs +0 -135
- package/node_modules/zod/v4/locales/pt.d.cts +0 -5
- package/node_modules/zod/v4/locales/pt.d.ts +0 -4
- package/node_modules/zod/v4/locales/pt.js +0 -108
- package/node_modules/zod/v4/locales/ro.cjs +0 -146
- package/node_modules/zod/v4/locales/ro.d.cts +0 -5
- package/node_modules/zod/v4/locales/ro.d.ts +0 -4
- package/node_modules/zod/v4/locales/ro.js +0 -119
- package/node_modules/zod/v4/locales/ru.cjs +0 -183
- package/node_modules/zod/v4/locales/ru.d.cts +0 -5
- package/node_modules/zod/v4/locales/ru.d.ts +0 -4
- package/node_modules/zod/v4/locales/ru.js +0 -156
- package/node_modules/zod/v4/locales/sl.cjs +0 -136
- package/node_modules/zod/v4/locales/sl.d.cts +0 -5
- package/node_modules/zod/v4/locales/sl.d.ts +0 -4
- package/node_modules/zod/v4/locales/sl.js +0 -109
- package/node_modules/zod/v4/locales/sv.cjs +0 -137
- package/node_modules/zod/v4/locales/sv.d.cts +0 -5
- package/node_modules/zod/v4/locales/sv.d.ts +0 -4
- package/node_modules/zod/v4/locales/sv.js +0 -110
- package/node_modules/zod/v4/locales/ta.cjs +0 -137
- package/node_modules/zod/v4/locales/ta.d.cts +0 -5
- package/node_modules/zod/v4/locales/ta.d.ts +0 -4
- package/node_modules/zod/v4/locales/ta.js +0 -110
- package/node_modules/zod/v4/locales/th.cjs +0 -137
- package/node_modules/zod/v4/locales/th.d.cts +0 -5
- package/node_modules/zod/v4/locales/th.d.ts +0 -4
- package/node_modules/zod/v4/locales/th.js +0 -110
- package/node_modules/zod/v4/locales/tr.cjs +0 -132
- package/node_modules/zod/v4/locales/tr.d.cts +0 -5
- package/node_modules/zod/v4/locales/tr.d.ts +0 -4
- package/node_modules/zod/v4/locales/tr.js +0 -105
- package/node_modules/zod/v4/locales/ua.cjs +0 -12
- package/node_modules/zod/v4/locales/ua.d.cts +0 -5
- package/node_modules/zod/v4/locales/ua.d.ts +0 -5
- package/node_modules/zod/v4/locales/ua.js +0 -5
- package/node_modules/zod/v4/locales/uk.cjs +0 -135
- package/node_modules/zod/v4/locales/uk.d.cts +0 -5
- package/node_modules/zod/v4/locales/uk.d.ts +0 -4
- package/node_modules/zod/v4/locales/uk.js +0 -108
- package/node_modules/zod/v4/locales/ur.cjs +0 -137
- package/node_modules/zod/v4/locales/ur.d.cts +0 -5
- package/node_modules/zod/v4/locales/ur.d.ts +0 -4
- package/node_modules/zod/v4/locales/ur.js +0 -110
- package/node_modules/zod/v4/locales/uz.cjs +0 -137
- package/node_modules/zod/v4/locales/uz.d.cts +0 -5
- package/node_modules/zod/v4/locales/uz.d.ts +0 -4
- package/node_modules/zod/v4/locales/uz.js +0 -110
- package/node_modules/zod/v4/locales/vi.cjs +0 -135
- package/node_modules/zod/v4/locales/vi.d.cts +0 -5
- package/node_modules/zod/v4/locales/vi.d.ts +0 -4
- package/node_modules/zod/v4/locales/vi.js +0 -108
- package/node_modules/zod/v4/locales/yo.cjs +0 -134
- package/node_modules/zod/v4/locales/yo.d.cts +0 -5
- package/node_modules/zod/v4/locales/yo.d.ts +0 -4
- package/node_modules/zod/v4/locales/yo.js +0 -107
- package/node_modules/zod/v4/locales/zh-CN.cjs +0 -136
- package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -5
- package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
- package/node_modules/zod/v4/locales/zh-CN.js +0 -109
- package/node_modules/zod/v4/locales/zh-TW.cjs +0 -134
- package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -5
- package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
- package/node_modules/zod/v4/locales/zh-TW.js +0 -107
- package/node_modules/zod/v4/mini/checks.cjs +0 -34
- package/node_modules/zod/v4/mini/checks.d.cts +0 -1
- package/node_modules/zod/v4/mini/checks.d.ts +0 -1
- package/node_modules/zod/v4/mini/checks.js +0 -1
- package/node_modules/zod/v4/mini/coerce.cjs +0 -52
- package/node_modules/zod/v4/mini/coerce.d.cts +0 -7
- package/node_modules/zod/v4/mini/coerce.d.ts +0 -7
- package/node_modules/zod/v4/mini/coerce.js +0 -22
- package/node_modules/zod/v4/mini/external.cjs +0 -63
- package/node_modules/zod/v4/mini/external.d.cts +0 -13
- package/node_modules/zod/v4/mini/external.d.ts +0 -13
- package/node_modules/zod/v4/mini/external.js +0 -14
- package/node_modules/zod/v4/mini/index.cjs +0 -32
- package/node_modules/zod/v4/mini/index.d.cts +0 -3
- package/node_modules/zod/v4/mini/index.d.ts +0 -3
- package/node_modules/zod/v4/mini/index.js +0 -3
- package/node_modules/zod/v4/mini/iso.cjs +0 -64
- package/node_modules/zod/v4/mini/iso.d.cts +0 -22
- package/node_modules/zod/v4/mini/iso.d.ts +0 -22
- package/node_modules/zod/v4/mini/iso.js +0 -34
- package/node_modules/zod/v4/mini/package.json +0 -7
- package/node_modules/zod/v4/mini/parse.cjs +0 -16
- package/node_modules/zod/v4/mini/parse.d.cts +0 -1
- package/node_modules/zod/v4/mini/parse.d.ts +0 -1
- package/node_modules/zod/v4/mini/parse.js +0 -1
- package/node_modules/zod/v4/mini/schemas.cjs +0 -1083
- package/node_modules/zod/v4/mini/schemas.d.cts +0 -445
- package/node_modules/zod/v4/mini/schemas.d.ts +0 -445
- package/node_modules/zod/v4/mini/schemas.js +0 -961
- package/node_modules/zod/v4/package.json +0 -7
- package/node_modules/zod/v4-mini/index.cjs +0 -32
- package/node_modules/zod/v4-mini/index.d.cts +0 -3
- package/node_modules/zod/v4-mini/index.d.ts +0 -3
- package/node_modules/zod/v4-mini/index.js +0 -3
- package/node_modules/zod/v4-mini/package.json +0 -7
package/dist/index.js
CHANGED
|
@@ -1,2229 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
wrapOAuthTokenVerifier
|
|
42
|
-
} from "./chunk-DPL7OEXC.js";
|
|
43
|
-
|
|
44
|
-
// src/server.ts
|
|
45
|
-
import {
|
|
46
|
-
localhostAllowedHostnames,
|
|
47
|
-
localhostAllowedOrigins,
|
|
48
|
-
McpServer as SdkMcpServer,
|
|
49
|
-
ResourceTemplate,
|
|
50
|
-
isInputRequiredResult
|
|
51
|
-
} from "@modelcontextprotocol/server";
|
|
52
|
-
|
|
53
|
-
// src/config.ts
|
|
54
|
-
function assertServerConfig(config) {
|
|
55
|
-
if (config.basePath !== void 0) {
|
|
56
|
-
if (typeof config.basePath !== "string") {
|
|
57
|
-
throw new TypeError(
|
|
58
|
-
"basePath must be an absolute URL pathname without empty segments, trailing slash, query, fragment, or whitespace"
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
const { basePath } = config;
|
|
62
|
-
if (!basePath.startsWith("/") || basePath.includes("?") || basePath.includes("#") || /\s/.test(basePath) || basePath.includes("//") || basePath.length > 1 && basePath.endsWith("/")) {
|
|
63
|
-
throw new TypeError(
|
|
64
|
-
"basePath must be an absolute URL pathname without empty segments, trailing slash, query, fragment, or whitespace"
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// src/context.ts
|
|
71
|
-
import {
|
|
72
|
-
CLIENT_CAPABILITIES_META_KEY as CLIENT_CAPABILITIES_META_KEY2,
|
|
73
|
-
inputRequired,
|
|
74
|
-
inputResponse
|
|
75
|
-
} from "@modelcontextprotocol/server";
|
|
76
|
-
|
|
77
|
-
// src/views/capabilities.ts
|
|
78
|
-
import {
|
|
79
|
-
CLIENT_CAPABILITIES_META_KEY
|
|
80
|
-
} from "@modelcontextprotocol/server";
|
|
81
|
-
|
|
82
|
-
// src/views/constants.ts
|
|
83
|
-
var UI_EXTENSION_ID = "io.modelcontextprotocol/ui";
|
|
84
|
-
var UI_MIME_TYPE = "text/html;profile=mcp-app";
|
|
85
|
-
var UI_RESOURCE_URI_PREFIX = "ui://views/";
|
|
86
|
-
var UI_META_KEY = "ui";
|
|
87
|
-
var UI_RESOURCE_URI_META_KEY = "ui/resourceUri";
|
|
88
|
-
function viewResourceUri(viewName) {
|
|
89
|
-
return `${UI_RESOURCE_URI_PREFIX}${viewName}.html`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// src/views/capabilities.ts
|
|
93
|
-
var clientCapabilitiesByRequest = /* @__PURE__ */ new WeakMap();
|
|
94
|
-
function stashClientCapabilities(request, capabilities) {
|
|
95
|
-
clientCapabilitiesByRequest.set(request, capabilities);
|
|
96
|
-
}
|
|
97
|
-
function extractClientCapabilitiesFromBody(body) {
|
|
98
|
-
if (typeof body !== "object" || body === null) {
|
|
99
|
-
return void 0;
|
|
100
|
-
}
|
|
101
|
-
const params = body["params"];
|
|
102
|
-
if (typeof params !== "object" || params === null) {
|
|
103
|
-
return void 0;
|
|
104
|
-
}
|
|
105
|
-
const meta = params["_meta"];
|
|
106
|
-
if (typeof meta !== "object" || meta === null) {
|
|
107
|
-
return void 0;
|
|
108
|
-
}
|
|
109
|
-
const capabilities = meta[CLIENT_CAPABILITIES_META_KEY];
|
|
110
|
-
if (typeof capabilities !== "object" || capabilities === null) {
|
|
111
|
-
return void 0;
|
|
112
|
-
}
|
|
113
|
-
return capabilities;
|
|
114
|
-
}
|
|
115
|
-
function supportsViews(capabilities) {
|
|
116
|
-
const extensions = capabilities?.extensions;
|
|
117
|
-
if (extensions === void 0) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
const uiExtension = extensions[UI_EXTENSION_ID];
|
|
121
|
-
if (typeof uiExtension !== "object" || uiExtension === null) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
const mimeTypes = uiExtension["mimeTypes"];
|
|
125
|
-
if (!Array.isArray(mimeTypes)) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
return mimeTypes.includes(UI_MIME_TYPE);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// src/context.ts
|
|
132
|
-
function requireOAuthAuthInfo(authInfo) {
|
|
133
|
-
if (authInfo === void 0 || authInfo.extra === void 0 || authInfo.expiresAt === void 0) {
|
|
134
|
-
throw new Error("OAuth callback did not receive mapped AuthInfo.extra");
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
function toClientContext(ctx) {
|
|
138
|
-
const envelopeCaps = ctx.mcpReq.envelope?.[CLIENT_CAPABILITIES_META_KEY2];
|
|
139
|
-
return {
|
|
140
|
-
supportsViews() {
|
|
141
|
-
return supportsViews(envelopeCaps);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function createElicit(inputResponses) {
|
|
146
|
-
return async function elicit(key, message, schemaOrUrl) {
|
|
147
|
-
let request;
|
|
148
|
-
let formSchema;
|
|
149
|
-
if (typeof schemaOrUrl === "string") {
|
|
150
|
-
request = inputRequired.elicitUrl({
|
|
151
|
-
message,
|
|
152
|
-
url: schemaOrUrl
|
|
153
|
-
});
|
|
154
|
-
} else if (schemaOrUrl !== void 0) {
|
|
155
|
-
formSchema = schemaOrUrl;
|
|
156
|
-
request = inputRequired.elicit({
|
|
157
|
-
message,
|
|
158
|
-
requestedSchema: schemaOrUrl
|
|
159
|
-
});
|
|
160
|
-
} else {
|
|
161
|
-
throw new TypeError(
|
|
162
|
-
"ctx.elicit(key, message, value) requires a form schema or URL string"
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
const response = inputResponse(inputResponses, key);
|
|
166
|
-
if (response.kind === "elicit") {
|
|
167
|
-
if (response.action !== "accept") {
|
|
168
|
-
return { status: response.action };
|
|
169
|
-
}
|
|
170
|
-
if (formSchema === void 0) {
|
|
171
|
-
return { status: "accept" };
|
|
172
|
-
}
|
|
173
|
-
if (response.content !== void 0) {
|
|
174
|
-
const outcome = await formSchema["~standard"].validate(
|
|
175
|
-
response.content
|
|
176
|
-
);
|
|
177
|
-
if (outcome.issues === void 0) {
|
|
178
|
-
return { status: "accept", data: outcome.value };
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
status: "required",
|
|
184
|
-
result: inputRequired({ inputRequests: { [key]: request } })
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function toRequestContext(ctx) {
|
|
189
|
-
const request = ctx.http?.req;
|
|
190
|
-
return {
|
|
191
|
-
signal: ctx.mcpReq.signal,
|
|
192
|
-
...request !== void 0 && { request },
|
|
193
|
-
...ctx.mcpReq.inputResponses !== void 0 && {
|
|
194
|
-
inputResponses: ctx.mcpReq.inputResponses
|
|
195
|
-
},
|
|
196
|
-
client: toClientContext(ctx),
|
|
197
|
-
elicit: createElicit(ctx.mcpReq.inputResponses),
|
|
198
|
-
requestState: () => ctx.mcpReq.requestState(),
|
|
199
|
-
async reportProgress(progress, total, message) {
|
|
200
|
-
const progressToken = ctx.mcpReq._meta?.progressToken;
|
|
201
|
-
if (progressToken === void 0) return false;
|
|
202
|
-
await ctx.mcpReq.notify({
|
|
203
|
-
method: "notifications/progress",
|
|
204
|
-
params: {
|
|
205
|
-
progressToken,
|
|
206
|
-
progress,
|
|
207
|
-
...total !== void 0 && { total },
|
|
208
|
-
...message !== void 0 && { message }
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
return true;
|
|
212
|
-
},
|
|
213
|
-
async sendLog(level, data, logger) {
|
|
214
|
-
await ctx.mcpReq.notify({
|
|
215
|
-
method: "notifications/message",
|
|
216
|
-
params: {
|
|
217
|
-
level,
|
|
218
|
-
data,
|
|
219
|
-
...logger !== void 0 && { logger }
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function toAuthenticatedRequestContext(ctx) {
|
|
226
|
-
const authInfo = ctx.http?.authInfo;
|
|
227
|
-
requireOAuthAuthInfo(authInfo);
|
|
228
|
-
return {
|
|
229
|
-
...toRequestContext(ctx),
|
|
230
|
-
auth: {
|
|
231
|
-
user: authInfo.extra.user,
|
|
232
|
-
payload: authInfo.extra.payload,
|
|
233
|
-
accessToken: authInfo.token,
|
|
234
|
-
scopes: [...authInfo.scopes],
|
|
235
|
-
permissions: [...authInfo.extra.permissions],
|
|
236
|
-
...authInfo.clientId.length > 0 && { clientId: authInfo.clientId },
|
|
237
|
-
expiresAt: authInfo.expiresAt,
|
|
238
|
-
...authInfo.resource !== void 0 && { resource: authInfo.resource }
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// src/middleware/cors.ts
|
|
244
|
-
var DEFAULT_METHODS = ["GET", "HEAD", "POST", "OPTIONS"];
|
|
245
|
-
var DEFAULT_ALLOWED_HEADERS = [
|
|
246
|
-
"Content-Type",
|
|
247
|
-
"Authorization",
|
|
248
|
-
"mcp-protocol-version",
|
|
249
|
-
"mcp-method",
|
|
250
|
-
"mcp-name"
|
|
251
|
-
];
|
|
252
|
-
function resolveAllowedOrigin(origin, requestOrigin) {
|
|
253
|
-
if (origin === void 0) {
|
|
254
|
-
return requestOrigin;
|
|
255
|
-
}
|
|
256
|
-
if (typeof origin === "function") {
|
|
257
|
-
return origin(requestOrigin);
|
|
258
|
-
}
|
|
259
|
-
if (origin === "*") {
|
|
260
|
-
return "*";
|
|
261
|
-
}
|
|
262
|
-
if (Array.isArray(origin)) {
|
|
263
|
-
if (requestOrigin !== null && origin.includes(requestOrigin)) {
|
|
264
|
-
return requestOrigin;
|
|
265
|
-
}
|
|
266
|
-
return null;
|
|
267
|
-
}
|
|
268
|
-
return origin;
|
|
269
|
-
}
|
|
270
|
-
function corsHeaders(options, request) {
|
|
271
|
-
if (request.headers.has("Access-Control-Allow-Origin")) {
|
|
272
|
-
return void 0;
|
|
273
|
-
}
|
|
274
|
-
const requestOrigin = request.headers.get("Origin");
|
|
275
|
-
const allowedOrigin = resolveAllowedOrigin(options.origin, requestOrigin);
|
|
276
|
-
if (allowedOrigin === null) {
|
|
277
|
-
return void 0;
|
|
278
|
-
}
|
|
279
|
-
const headers = {
|
|
280
|
-
"Access-Control-Allow-Origin": allowedOrigin,
|
|
281
|
-
"Access-Control-Allow-Methods": options.methods.join(", "),
|
|
282
|
-
"Access-Control-Allow-Headers": options.allowedHeaders.join(", ")
|
|
283
|
-
};
|
|
284
|
-
if (options.credentials) {
|
|
285
|
-
headers["Access-Control-Allow-Credentials"] = "true";
|
|
286
|
-
}
|
|
287
|
-
if (allowedOrigin !== "*") {
|
|
288
|
-
headers.Vary = "Origin";
|
|
289
|
-
}
|
|
290
|
-
return headers;
|
|
291
|
-
}
|
|
292
|
-
function mergeCorsHeaders(response, headers) {
|
|
293
|
-
if (response.headers.has("Access-Control-Allow-Origin")) {
|
|
294
|
-
return response;
|
|
295
|
-
}
|
|
296
|
-
const merged = new Headers(response.headers);
|
|
297
|
-
const corsHeaders2 = new Headers(headers);
|
|
298
|
-
corsHeaders2.forEach((value, key) => {
|
|
299
|
-
merged.set(key, value);
|
|
300
|
-
});
|
|
301
|
-
return new Response(response.body, {
|
|
302
|
-
status: response.status,
|
|
303
|
-
statusText: response.statusText,
|
|
304
|
-
headers: merged
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
function corsFetchMiddleware(options) {
|
|
308
|
-
const enabled = options.enabled !== false;
|
|
309
|
-
if (!enabled) {
|
|
310
|
-
return async (_request, next) => next();
|
|
311
|
-
}
|
|
312
|
-
const resolved = {
|
|
313
|
-
...options.origin !== void 0 && { origin: options.origin },
|
|
314
|
-
methods: options.methods ?? DEFAULT_METHODS,
|
|
315
|
-
allowedHeaders: options.allowedHeaders ?? DEFAULT_ALLOWED_HEADERS,
|
|
316
|
-
credentials: options.credentials ?? false
|
|
317
|
-
};
|
|
318
|
-
return async (request, next) => {
|
|
319
|
-
const headers = corsHeaders(resolved, request);
|
|
320
|
-
if (headers === void 0) {
|
|
321
|
-
return next();
|
|
322
|
-
}
|
|
323
|
-
if (request.method === "OPTIONS") {
|
|
324
|
-
return new Response(null, { status: 204, headers });
|
|
325
|
-
}
|
|
326
|
-
const response = await next();
|
|
327
|
-
return mergeCorsHeaders(response, headers);
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
function isGlobalCorsEnabled(cors) {
|
|
331
|
-
return cors !== void 0 && cors.enabled !== false;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// src/middleware/mcp-middleware.ts
|
|
335
|
-
function matchesPattern(pattern, method) {
|
|
336
|
-
if (pattern === "*") return true;
|
|
337
|
-
if (pattern.endsWith("/*")) {
|
|
338
|
-
const prefix = pattern.slice(0, -1);
|
|
339
|
-
return method.startsWith(prefix);
|
|
340
|
-
}
|
|
341
|
-
return pattern === method;
|
|
342
|
-
}
|
|
343
|
-
function composeMiddleware(entries, method, innerFn) {
|
|
344
|
-
const matching = entries.filter((e) => matchesPattern(e.pattern, method));
|
|
345
|
-
if (matching.length === 0) {
|
|
346
|
-
return (_ctx) => innerFn();
|
|
347
|
-
}
|
|
348
|
-
return (ctx) => {
|
|
349
|
-
let index = -1;
|
|
350
|
-
const dispatch = (i) => {
|
|
351
|
-
if (i <= index) {
|
|
352
|
-
return Promise.reject(new Error("next() called multiple times"));
|
|
353
|
-
}
|
|
354
|
-
index = i;
|
|
355
|
-
if (i === matching.length) {
|
|
356
|
-
return innerFn();
|
|
357
|
-
}
|
|
358
|
-
const entry = matching[i];
|
|
359
|
-
return entry.handler(ctx, () => dispatch(i + 1));
|
|
360
|
-
};
|
|
361
|
-
return dispatch(0);
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
function freezeMiddlewareContext(ctx) {
|
|
365
|
-
return Object.freeze({
|
|
366
|
-
method: ctx.method,
|
|
367
|
-
params: Object.freeze({ ...ctx.params }),
|
|
368
|
-
...ctx.auth !== void 0 && { auth: ctx.auth },
|
|
369
|
-
state: ctx.state
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
async function runMcpOperation(middlewares, events, method, ctx, innerFn) {
|
|
373
|
-
dispatchMcpEvents(events, method, "before", ctx);
|
|
374
|
-
const chained = composeMiddleware(middlewares, method, innerFn);
|
|
375
|
-
const result = await chained(ctx);
|
|
376
|
-
dispatchMcpEvents(events, method, "complete", ctx, result);
|
|
377
|
-
return result;
|
|
378
|
-
}
|
|
379
|
-
function dispatchMcpEvents(events, method, phase, ctx, result) {
|
|
380
|
-
const frozen = freezeMiddlewareContext(ctx);
|
|
381
|
-
for (const entry of events) {
|
|
382
|
-
if (entry.phase !== phase || !matchesPattern(entry.pattern, method)) {
|
|
383
|
-
continue;
|
|
384
|
-
}
|
|
385
|
-
try {
|
|
386
|
-
if (phase === "before") {
|
|
387
|
-
entry.handler(frozen);
|
|
388
|
-
} else {
|
|
389
|
-
entry.handler(frozen, result);
|
|
390
|
-
}
|
|
391
|
-
} catch (error) {
|
|
392
|
-
console.error(
|
|
393
|
-
`[mcp-use] MCP event listener for "${entry.pattern}" (${phase}) threw:`,
|
|
394
|
-
error
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
function parseMcpPattern(raw) {
|
|
400
|
-
const pattern = raw.startsWith("mcp:") ? raw.slice(4) : raw;
|
|
401
|
-
if (pattern.endsWith(":complete")) {
|
|
402
|
-
return {
|
|
403
|
-
pattern: pattern.slice(0, -":complete".length),
|
|
404
|
-
phase: "complete"
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
return { pattern, phase: "before" };
|
|
408
|
-
}
|
|
409
|
-
function normalizeMcpMiddlewarePattern(raw) {
|
|
410
|
-
return raw.startsWith("mcp:") ? raw.slice(4) : raw;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// src/inspector-shell.ts
|
|
414
|
-
var INSPECTOR_TAG = "beta";
|
|
415
|
-
var DEFAULT_INSPECTOR_ASSETS_URL = `https://cdn.jsdelivr.net/npm/@mcp-use/inspector@${INSPECTOR_TAG}/dist/cdn/inspector.js`;
|
|
416
|
-
function inspectorStylesUrl(assetsUrl) {
|
|
417
|
-
return assetsUrl.replace(/\.js(?=$|[?#])/, ".css");
|
|
418
|
-
}
|
|
419
|
-
function isDefaultJsdelivrInspectorUrl(url) {
|
|
420
|
-
return url.startsWith("https://cdn.jsdelivr.net/npm/@mcp-use/inspector@");
|
|
421
|
-
}
|
|
422
|
-
function withInspectorCacheBust(assetsUrl) {
|
|
423
|
-
if (!isDefaultJsdelivrInspectorUrl(assetsUrl)) return assetsUrl;
|
|
424
|
-
const sep = assetsUrl.includes("?") ? "&" : "?";
|
|
425
|
-
return `${assetsUrl}${sep}cb=${crypto.randomUUID()}`;
|
|
426
|
-
}
|
|
427
|
-
function matchesInspectorShellPath(pathname, basePath) {
|
|
428
|
-
const prefix = pathUnderBase(basePath, "inspector");
|
|
429
|
-
if (pathname !== prefix && !pathname.startsWith(`${prefix}/`)) {
|
|
430
|
-
return false;
|
|
431
|
-
}
|
|
432
|
-
const suffix = pathname.slice(prefix.length);
|
|
433
|
-
return suffix !== "/api" && !suffix.startsWith("/api/");
|
|
434
|
-
}
|
|
435
|
-
function escapeHtml(value) {
|
|
436
|
-
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
437
|
-
}
|
|
438
|
-
function serializeForInlineScript(value) {
|
|
439
|
-
return JSON.stringify(value).replaceAll("<", "\\u003c");
|
|
440
|
-
}
|
|
441
|
-
function renderInspectorShell(options) {
|
|
442
|
-
const { serverName, basePath, assetsUrl, manufactChatUrl } = options;
|
|
443
|
-
const serializedBasePath = serializeForInlineScript(basePath);
|
|
444
|
-
const serializedManufactChatUrl = manufactChatUrl ? serializeForInlineScript(manufactChatUrl) : null;
|
|
445
|
-
const rawUrl = assetsUrl ?? DEFAULT_INSPECTOR_ASSETS_URL;
|
|
446
|
-
const bundleUrl = withInspectorCacheBust(rawUrl);
|
|
447
|
-
const scriptSrc = escapeHtml(bundleUrl);
|
|
448
|
-
const stylesHref = escapeHtml(inspectorStylesUrl(bundleUrl));
|
|
449
|
-
return `<!doctype html>
|
|
450
|
-
<html lang="en">
|
|
451
|
-
<head>
|
|
452
|
-
<meta charset="utf-8" />
|
|
453
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
454
|
-
<title>${escapeHtml(serverName)} \u2014 MCP Inspector</title>
|
|
455
|
-
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
456
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
457
|
-
<link
|
|
458
|
-
href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;500;700&display=swap"
|
|
459
|
-
rel="stylesheet"
|
|
460
|
-
/>
|
|
461
|
-
<link rel="stylesheet" href="${stylesHref}" />
|
|
462
|
-
<style>
|
|
463
|
-
:root { color-scheme: light dark; }
|
|
464
|
-
html, body { height: 100%; margin: 0; background-color: #f3f3f3; }
|
|
465
|
-
</style>
|
|
466
|
-
</head>
|
|
467
|
-
<body>
|
|
468
|
-
<div id="root"></div>
|
|
469
|
-
<script>
|
|
470
|
-
(function () {
|
|
471
|
-
var basePath = ${serializedBasePath};
|
|
472
|
-
// The connect URL is derived from the page's own origin: the server
|
|
473
|
-
// never guesses the hostname a browser reached it by.
|
|
474
|
-
window.__MCP_USE_INSPECTOR__ = {
|
|
475
|
-
autoConnectUrl: window.location.origin + basePath,
|
|
476
|
-
basePath: basePath,
|
|
477
|
-
};
|
|
478
|
-
// Read by the current inspector bundle to derive its own URLs.
|
|
479
|
-
window.__MCP_BASE_PATH__ = basePath;
|
|
480
|
-
${serializedManufactChatUrl ? `window.__MANUFACT_CHAT_URL__ = ${serializedManufactChatUrl};` : ""}
|
|
481
|
-
// The bundle carries Node-flavored dependencies that touch \`process\`
|
|
482
|
-
// at module scope; give them the same browser polyfill the v1
|
|
483
|
-
// inspector shell provides, or the bundle throws on load.
|
|
484
|
-
if (typeof window.process === "undefined") {
|
|
485
|
-
window.process = {
|
|
486
|
-
env: {},
|
|
487
|
-
platform: "browser",
|
|
488
|
-
browser: true,
|
|
489
|
-
version: "v18.0.0",
|
|
490
|
-
versions: { node: "18.0.0" },
|
|
491
|
-
cwd: function () { return "/"; },
|
|
492
|
-
nextTick: function (fn) {
|
|
493
|
-
var args = Array.prototype.slice.call(arguments, 1);
|
|
494
|
-
queueMicrotask(function () { fn.apply(null, args); });
|
|
495
|
-
},
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
})();
|
|
499
|
-
</script>
|
|
500
|
-
<script type="module" src="${scriptSrc}"></script>
|
|
501
|
-
</body>
|
|
502
|
-
</html>
|
|
503
|
-
`;
|
|
504
|
-
}
|
|
505
|
-
function createInspectorHandler(inspector, options) {
|
|
506
|
-
if (inspector?.enabled === false) {
|
|
507
|
-
return void 0;
|
|
508
|
-
}
|
|
509
|
-
const { assetsUrl: configAssetsUrl, manufactChatUrl: configManufactChatUrl } = inspector ?? {};
|
|
510
|
-
const assetsUrl = configAssetsUrl ?? process.env["MCP_USE_INSPECTOR_ASSETS_URL"] ?? void 0;
|
|
511
|
-
const manufactChatUrl = configManufactChatUrl ?? process.env["MANUFACT_CHAT_URL"] ?? void 0;
|
|
512
|
-
const shellOptions = {
|
|
513
|
-
serverName: options.serverName,
|
|
514
|
-
basePath: options.basePath,
|
|
515
|
-
assetsUrl,
|
|
516
|
-
manufactChatUrl
|
|
517
|
-
};
|
|
518
|
-
return async (request) => {
|
|
519
|
-
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
520
|
-
return new Response("Method Not Allowed", { status: 405 });
|
|
521
|
-
}
|
|
522
|
-
const pathname = new URL(request.url).pathname;
|
|
523
|
-
if (!matchesInspectorShellPath(pathname, options.basePath)) {
|
|
524
|
-
return new Response("Not Found", { status: 404 });
|
|
525
|
-
}
|
|
526
|
-
const html = renderInspectorShell(shellOptions);
|
|
527
|
-
return new Response(request.method === "HEAD" ? null : html, {
|
|
528
|
-
status: 200,
|
|
529
|
-
headers: { "content-type": "text/html; charset=utf-8" }
|
|
530
|
-
});
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
// src/logging.ts
|
|
535
|
-
import {
|
|
536
|
-
CLIENT_INFO_META_KEY,
|
|
537
|
-
isJSONRPCRequest
|
|
538
|
-
} from "@modelcontextprotocol/server";
|
|
539
|
-
function colorsEnabled() {
|
|
540
|
-
if (typeof process === "undefined") return false;
|
|
541
|
-
if (process.env?.["NO_COLOR"] !== void 0) return false;
|
|
542
|
-
return process.stdout?.isTTY === true;
|
|
543
|
-
}
|
|
544
|
-
function ansi(open, close) {
|
|
545
|
-
return (text) => colorsEnabled() ? `\x1B[${open}m${text}\x1B[${close}m` : text;
|
|
546
|
-
}
|
|
547
|
-
var bold = ansi(1, 22);
|
|
548
|
-
var dim = ansi(2, 22);
|
|
549
|
-
var red = ansi(31, 39);
|
|
550
|
-
var green = ansi(32, 39);
|
|
551
|
-
var yellow = ansi(33, 39);
|
|
552
|
-
var blue = ansi(34, 39);
|
|
553
|
-
var magenta = ansi(35, 39);
|
|
554
|
-
var cyan = ansi(36, 39);
|
|
555
|
-
var gray = ansi(90, 39);
|
|
556
|
-
function resolveLogLevel(configured) {
|
|
557
|
-
const raw = typeof process === "undefined" ? void 0 : process.env?.["MCP_USE_LOG_LEVEL"]?.toLowerCase();
|
|
558
|
-
if (raw === "info" || raw === "debug" || raw === "trace") return raw;
|
|
559
|
-
return configured ?? "info";
|
|
560
|
-
}
|
|
561
|
-
function formatClientInfo(info) {
|
|
562
|
-
if (info === void 0) return void 0;
|
|
563
|
-
return typeof info.version === "string" && info.version !== "" ? `${info.name}/${info.version}` : info.name;
|
|
564
|
-
}
|
|
565
|
-
var detailFormatters = {
|
|
566
|
-
initialize: (p) => ({ subject: formatClientInfo(p.clientInfo) }),
|
|
567
|
-
ping: () => ({}),
|
|
568
|
-
"server/discover": () => ({}),
|
|
569
|
-
"completion/complete": (p) => ({
|
|
570
|
-
subject: p.ref.type === "ref/prompt" ? p.ref.name : p.ref.uri,
|
|
571
|
-
input: p.argument
|
|
572
|
-
}),
|
|
573
|
-
"logging/setLevel": (p) => ({ subject: p.level }),
|
|
574
|
-
"prompts/get": (p) => ({ subject: p.name, input: p.arguments }),
|
|
575
|
-
"prompts/list": () => ({}),
|
|
576
|
-
"resources/list": () => ({}),
|
|
577
|
-
"resources/templates/list": () => ({}),
|
|
578
|
-
"resources/read": (p) => ({ subject: p.uri }),
|
|
579
|
-
"resources/subscribe": (p) => ({ subject: p.uri }),
|
|
580
|
-
"resources/unsubscribe": (p) => ({ subject: p.uri }),
|
|
581
|
-
"subscriptions/listen": () => ({}),
|
|
582
|
-
"tools/call": (p) => ({ subject: p.name, input: p.arguments }),
|
|
583
|
-
"tools/list": () => ({}),
|
|
584
|
-
"sampling/createMessage": () => ({}),
|
|
585
|
-
"elicitation/create": () => ({}),
|
|
586
|
-
"roots/list": () => ({})
|
|
587
|
-
};
|
|
588
|
-
function isKnownMethod(method) {
|
|
589
|
-
return Object.prototype.hasOwnProperty.call(detailFormatters, method);
|
|
590
|
-
}
|
|
591
|
-
function formatDetail(message) {
|
|
592
|
-
if (!isKnownMethod(message.method)) return {};
|
|
593
|
-
try {
|
|
594
|
-
const formatter = detailFormatters[message.method];
|
|
595
|
-
const detail = formatter(message.params);
|
|
596
|
-
return typeof detail.subject === "string" || detail.subject === void 0 ? detail : {};
|
|
597
|
-
} catch {
|
|
598
|
-
return {};
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
var INLINE_JSON_MAX_LENGTH = 80;
|
|
602
|
-
function inlineJson(value) {
|
|
603
|
-
let text;
|
|
604
|
-
try {
|
|
605
|
-
text = JSON.stringify(value) ?? String(value);
|
|
606
|
-
} catch {
|
|
607
|
-
text = String(value);
|
|
608
|
-
}
|
|
609
|
-
return text.length > INLINE_JSON_MAX_LENGTH ? `${text.slice(0, INLINE_JSON_MAX_LENGTH)}...` : text;
|
|
610
|
-
}
|
|
611
|
-
function formatClientIdentity(message) {
|
|
612
|
-
const meta = message.params?._meta;
|
|
613
|
-
if (meta === void 0) return void 0;
|
|
614
|
-
const info = meta[CLIENT_INFO_META_KEY];
|
|
615
|
-
if (typeof info !== "object" || info === null || typeof info.name !== "string") {
|
|
616
|
-
return void 0;
|
|
617
|
-
}
|
|
618
|
-
return formatClientInfo(info);
|
|
619
|
-
}
|
|
620
|
-
function sanitize(text) {
|
|
621
|
-
return text.replace(/[\u0000-\u001F\u007F-\u009F]+/g, " ");
|
|
622
|
-
}
|
|
623
|
-
function methodStyle(method) {
|
|
624
|
-
if (method.startsWith("tools/")) return cyan;
|
|
625
|
-
if (method.startsWith("resources/")) return green;
|
|
626
|
-
if (method.startsWith("prompts/")) return magenta;
|
|
627
|
-
if (method === "initialize" || method === "ping") return gray;
|
|
628
|
-
return blue;
|
|
629
|
-
}
|
|
630
|
-
var REDACTED_HEADERS = /* @__PURE__ */ new Set([
|
|
631
|
-
"authorization",
|
|
632
|
-
"proxy-authorization",
|
|
633
|
-
"cookie",
|
|
634
|
-
"set-cookie",
|
|
635
|
-
"x-api-key"
|
|
636
|
-
]);
|
|
637
|
-
function redactHeaders(headers) {
|
|
638
|
-
return Object.fromEntries(
|
|
639
|
-
Object.entries(headers).map(([name, value]) => [
|
|
640
|
-
name,
|
|
641
|
-
REDACTED_HEADERS.has(name.toLowerCase()) ? "[REDACTED]" : value
|
|
642
|
-
])
|
|
643
|
-
);
|
|
644
|
-
}
|
|
645
|
-
async function extractResponseOutcome(res) {
|
|
646
|
-
if (!res.body) return { errorMessage: null };
|
|
647
|
-
let text;
|
|
648
|
-
try {
|
|
649
|
-
text = await res.clone().text();
|
|
650
|
-
} catch {
|
|
651
|
-
return { errorMessage: null };
|
|
652
|
-
}
|
|
653
|
-
if (!text) return { errorMessage: null };
|
|
654
|
-
const isSse = (res.headers.get("content-type") ?? "").includes(
|
|
655
|
-
"text/event-stream"
|
|
656
|
-
);
|
|
657
|
-
const payloads = [];
|
|
658
|
-
const tryParse = (raw) => {
|
|
659
|
-
try {
|
|
660
|
-
payloads.push(JSON.parse(raw));
|
|
661
|
-
} catch {
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
if (isSse) {
|
|
665
|
-
for (const line of text.split(/\r?\n/)) {
|
|
666
|
-
if (line.startsWith("data:")) {
|
|
667
|
-
const data = line.slice(5).trim();
|
|
668
|
-
if (data) tryParse(data);
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
} else {
|
|
672
|
-
tryParse(text);
|
|
673
|
-
}
|
|
674
|
-
let result;
|
|
675
|
-
for (const payload of payloads) {
|
|
676
|
-
if (payload === null || typeof payload !== "object") continue;
|
|
677
|
-
const message = payload;
|
|
678
|
-
if (typeof message.error?.message === "string") {
|
|
679
|
-
return { errorMessage: message.error.message };
|
|
680
|
-
}
|
|
681
|
-
if (message.result?.isError === true) {
|
|
682
|
-
const blocks = Array.isArray(message.result.content) ? message.result.content : [];
|
|
683
|
-
const textBlock = blocks.find(
|
|
684
|
-
(b) => b?.type === "text" && typeof b.text === "string"
|
|
685
|
-
);
|
|
686
|
-
return {
|
|
687
|
-
errorMessage: textBlock ? String(textBlock.text) : "tool error"
|
|
688
|
-
};
|
|
689
|
-
}
|
|
690
|
-
if ("result" in message) result = message.result;
|
|
691
|
-
}
|
|
692
|
-
return { errorMessage: null, result };
|
|
693
|
-
}
|
|
694
|
-
function compactToolResult(result) {
|
|
695
|
-
if (result === null || typeof result !== "object") return result;
|
|
696
|
-
const { structuredContent, content } = result;
|
|
697
|
-
if (structuredContent !== void 0) return structuredContent;
|
|
698
|
-
if (Array.isArray(content)) {
|
|
699
|
-
const [block] = content;
|
|
700
|
-
if (content.length === 1 && block?.type === "text") return block.text;
|
|
701
|
-
}
|
|
702
|
-
return content;
|
|
703
|
-
}
|
|
704
|
-
function formatForDump(value) {
|
|
705
|
-
function truncate(val) {
|
|
706
|
-
if (typeof val === "string" && val.length > 100) {
|
|
707
|
-
return `${val.slice(0, 100)}...`;
|
|
708
|
-
}
|
|
709
|
-
if (Array.isArray(val)) return val.map(truncate);
|
|
710
|
-
if (val !== null && typeof val === "object") {
|
|
711
|
-
return Object.fromEntries(
|
|
712
|
-
Object.entries(val).map(([k, v]) => [
|
|
713
|
-
k,
|
|
714
|
-
truncate(v)
|
|
715
|
-
])
|
|
716
|
-
);
|
|
717
|
-
}
|
|
718
|
-
return val;
|
|
719
|
-
}
|
|
720
|
-
try {
|
|
721
|
-
return JSON.stringify(truncate(value), null, 2);
|
|
722
|
-
} catch {
|
|
723
|
-
return String(value);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
var DUMP_BODY_MAX_LENGTH = 1e4;
|
|
727
|
-
async function printTraceDump(response, requestHeaders, requestBody, readResponseBody) {
|
|
728
|
-
console.log(`
|
|
729
|
-
${cyan("=".repeat(80))}`);
|
|
730
|
-
console.log(bold(cyan("[TRACE] Request Details")));
|
|
731
|
-
console.log(cyan("-".repeat(80)));
|
|
732
|
-
if (Object.keys(requestHeaders).length > 0) {
|
|
733
|
-
console.log(yellow("Request Headers:"));
|
|
734
|
-
console.log(formatForDump(redactHeaders(requestHeaders)));
|
|
735
|
-
}
|
|
736
|
-
if (requestBody !== void 0) {
|
|
737
|
-
console.log(yellow("Request Body:"));
|
|
738
|
-
console.log(
|
|
739
|
-
typeof requestBody === "string" ? requestBody : formatForDump(requestBody)
|
|
740
|
-
);
|
|
741
|
-
}
|
|
742
|
-
const responseHeaders = {};
|
|
743
|
-
response.headers.forEach((value, key) => {
|
|
744
|
-
responseHeaders[key] = value;
|
|
745
|
-
});
|
|
746
|
-
if (Object.keys(responseHeaders).length > 0) {
|
|
747
|
-
console.log(yellow("Response Headers:"));
|
|
748
|
-
console.log(formatForDump(redactHeaders(responseHeaders)));
|
|
749
|
-
}
|
|
750
|
-
if (!readResponseBody) {
|
|
751
|
-
console.log(`${yellow("Response Body:")} (streaming \u2014 not dumped)`);
|
|
752
|
-
} else if (response.body === null) {
|
|
753
|
-
console.log(`${yellow("Response Body:")} (no body)`);
|
|
754
|
-
} else {
|
|
755
|
-
try {
|
|
756
|
-
const text = await response.clone().text();
|
|
757
|
-
if (text.length === 0) {
|
|
758
|
-
console.log(`${yellow("Response Body:")} (empty)`);
|
|
759
|
-
} else {
|
|
760
|
-
console.log(yellow("Response Body:"));
|
|
761
|
-
try {
|
|
762
|
-
console.log(formatForDump(JSON.parse(text)));
|
|
763
|
-
} catch {
|
|
764
|
-
console.log(
|
|
765
|
-
text.length > DUMP_BODY_MAX_LENGTH ? `${text.slice(0, DUMP_BODY_MAX_LENGTH)}
|
|
766
|
-
... (truncated, ${text.length - DUMP_BODY_MAX_LENGTH} more characters)` : text
|
|
767
|
-
);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
} catch {
|
|
771
|
-
console.log(`${yellow("Response Body:")} (unable to read)`);
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
console.log(`${cyan("=".repeat(80))}
|
|
775
|
-
`);
|
|
776
|
-
}
|
|
777
|
-
function styleStatus(status) {
|
|
778
|
-
const text = String(status);
|
|
779
|
-
if (status >= 500) return magenta(text);
|
|
780
|
-
if (status >= 400) return red(text);
|
|
781
|
-
if (status >= 300) return yellow(text);
|
|
782
|
-
return green(text);
|
|
783
|
-
}
|
|
784
|
-
function isNoisyRequest(httpMethod, pathname) {
|
|
785
|
-
if (httpMethod !== "GET" && httpMethod !== "HEAD") return false;
|
|
786
|
-
return pathname.includes("/inspector") || pathname.endsWith("/favicon.ico");
|
|
787
|
-
}
|
|
788
|
-
function requestLogger(options = {}) {
|
|
789
|
-
if (options.enabled === false) {
|
|
790
|
-
return (_request, next) => next();
|
|
791
|
-
}
|
|
792
|
-
return async (request, next) => {
|
|
793
|
-
const level = resolveLogLevel(options.level);
|
|
794
|
-
const startedAt = Date.now();
|
|
795
|
-
const httpMethod = request.method;
|
|
796
|
-
const pathname = new URL(request.url).pathname;
|
|
797
|
-
if (isNoisyRequest(httpMethod, pathname)) {
|
|
798
|
-
return next();
|
|
799
|
-
}
|
|
800
|
-
const requestHeaders = {};
|
|
801
|
-
if (level === "trace") {
|
|
802
|
-
request.headers.forEach((value, key) => {
|
|
803
|
-
requestHeaders[key] = value;
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
let requestBody;
|
|
807
|
-
if (httpMethod !== "GET" && httpMethod !== "HEAD") {
|
|
808
|
-
const parsedBody = getRequestBag(request).parsedBody;
|
|
809
|
-
if (parsedBody !== void 0) {
|
|
810
|
-
requestBody = parsedBody;
|
|
811
|
-
} else {
|
|
812
|
-
try {
|
|
813
|
-
requestBody = await request.clone().json();
|
|
814
|
-
} catch {
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
const response = await next();
|
|
819
|
-
const durationMs = Date.now() - startedAt;
|
|
820
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString().substring(11, 19);
|
|
821
|
-
const mcpRequest = isJSONRPCRequest(requestBody) ? requestBody : void 0;
|
|
822
|
-
const isStreamingMethod = mcpRequest?.method === "subscriptions/listen";
|
|
823
|
-
const lines = [
|
|
824
|
-
[
|
|
825
|
-
dim(timestamp),
|
|
826
|
-
bold(httpMethod),
|
|
827
|
-
pathname,
|
|
828
|
-
styleStatus(response.status),
|
|
829
|
-
dim(`in ${durationMs}ms`)
|
|
830
|
-
].join(" ")
|
|
831
|
-
];
|
|
832
|
-
if (mcpRequest !== void 0) {
|
|
833
|
-
const method = sanitize(mcpRequest.method);
|
|
834
|
-
const parts = [` ${methodStyle(method)(method)}`];
|
|
835
|
-
const detail = formatDetail(mcpRequest);
|
|
836
|
-
if (detail.subject !== void 0) {
|
|
837
|
-
parts.push(bold(sanitize(detail.subject)));
|
|
838
|
-
}
|
|
839
|
-
const echoPayloads = level !== "info";
|
|
840
|
-
if (echoPayloads && detail.input !== void 0) {
|
|
841
|
-
parts.push(inlineJson(detail.input));
|
|
842
|
-
}
|
|
843
|
-
const outcome = isStreamingMethod ? { errorMessage: null } : await extractResponseOutcome(response);
|
|
844
|
-
if (echoPayloads && mcpRequest.method === "tools/call" && outcome.errorMessage === null && outcome.result !== void 0) {
|
|
845
|
-
parts.push(dim("->"), inlineJson(compactToolResult(outcome.result)));
|
|
846
|
-
}
|
|
847
|
-
if (mcpRequest.method !== "initialize") {
|
|
848
|
-
const client = formatClientIdentity(mcpRequest);
|
|
849
|
-
if (client !== void 0) parts.push(dim(sanitize(client)));
|
|
850
|
-
}
|
|
851
|
-
if (outcome.errorMessage !== null) {
|
|
852
|
-
parts.push(red(`ERROR ${sanitize(outcome.errorMessage)}`));
|
|
853
|
-
} else if (response.status >= 400) {
|
|
854
|
-
parts.push(red(`ERROR (HTTP ${response.status})`));
|
|
855
|
-
}
|
|
856
|
-
lines.push(parts.join(" "));
|
|
857
|
-
}
|
|
858
|
-
console.log(lines.join("\n"));
|
|
859
|
-
if (level === "trace") {
|
|
860
|
-
await printTraceDump(
|
|
861
|
-
response,
|
|
862
|
-
requestHeaders,
|
|
863
|
-
requestBody,
|
|
864
|
-
!isStreamingMethod
|
|
865
|
-
);
|
|
866
|
-
}
|
|
867
|
-
return response;
|
|
868
|
-
};
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
// src/mount-mcp.ts
|
|
872
|
-
import {
|
|
873
|
-
createMcpHandler
|
|
874
|
-
} from "@modelcontextprotocol/server";
|
|
875
|
-
function createMcpMount(factory, options = {}) {
|
|
876
|
-
const {
|
|
877
|
-
path = "/mcp",
|
|
878
|
-
handler: handlerOptions,
|
|
879
|
-
authInfo: getAuthInfo
|
|
880
|
-
} = options;
|
|
881
|
-
const legacyMode = handlerOptions?.legacy ?? "stateless";
|
|
882
|
-
const handler = createMcpHandler(factory, {
|
|
883
|
-
legacy: "stateless",
|
|
884
|
-
...handlerOptions
|
|
885
|
-
});
|
|
886
|
-
const fetch = async (request) => {
|
|
887
|
-
if (!matchesPath(request, path)) {
|
|
888
|
-
return new Response("Not Found", { status: 404 });
|
|
889
|
-
}
|
|
890
|
-
if (legacyMode === "stateless") {
|
|
891
|
-
const method = request.method.toUpperCase();
|
|
892
|
-
if (method === "GET" || method === "DELETE" || method === "HEAD") {
|
|
893
|
-
return new Response(null, { status: 204 });
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
const bag = getRequestBag(request);
|
|
897
|
-
let parsedBody = bag.parsedBody;
|
|
898
|
-
if (parsedBody === void 0) {
|
|
899
|
-
try {
|
|
900
|
-
parsedBody = await request.clone().json();
|
|
901
|
-
} catch {
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
const capabilities = extractClientCapabilitiesFromBody(parsedBody);
|
|
905
|
-
if (capabilities !== void 0) {
|
|
906
|
-
stashClientCapabilities(request, capabilities);
|
|
907
|
-
}
|
|
908
|
-
const authInfo = getAuthInfo?.(request) ?? bag.authInfo;
|
|
909
|
-
return handler.fetch(request, {
|
|
910
|
-
...parsedBody !== void 0 && { parsedBody },
|
|
911
|
-
...authInfo !== void 0 && { authInfo }
|
|
912
|
-
});
|
|
913
|
-
};
|
|
914
|
-
return { handler, fetch };
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
// src/tools.ts
|
|
918
|
-
function resolveToolInputSchema(definition) {
|
|
919
|
-
return definition.inputSchema ?? definition.schema;
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
// src/views/register.ts
|
|
923
|
-
var registerViews = /* @__PURE__ */ Symbol("mcp-use/registerViews");
|
|
924
|
-
|
|
925
|
-
// src/views/csp-env.ts
|
|
926
|
-
var CATEGORY_ENV = {
|
|
927
|
-
connectDomains: "CSP_CONNECT_DOMAINS",
|
|
928
|
-
resourceDomains: "CSP_RESOURCE_DOMAINS",
|
|
929
|
-
frameDomains: "CSP_FRAME_DOMAINS",
|
|
930
|
-
baseUriDomains: "CSP_BASE_URI_DOMAINS"
|
|
931
|
-
};
|
|
932
|
-
function parseDomainList(raw) {
|
|
933
|
-
if (raw === void 0 || raw.trim() === "") {
|
|
934
|
-
return [];
|
|
935
|
-
}
|
|
936
|
-
return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
937
|
-
}
|
|
938
|
-
function readEnvDomains(name) {
|
|
939
|
-
if (typeof process === "undefined") {
|
|
940
|
-
return void 0;
|
|
941
|
-
}
|
|
942
|
-
const raw = process.env[name];
|
|
943
|
-
if (raw === void 0 || raw.trim() === "") {
|
|
944
|
-
return void 0;
|
|
945
|
-
}
|
|
946
|
-
return parseDomainList(raw);
|
|
947
|
-
}
|
|
948
|
-
function readCspUrlsShortcut() {
|
|
949
|
-
return readEnvDomains("CSP_URLS") ?? [];
|
|
950
|
-
}
|
|
951
|
-
function readEnvDomainsForCategory(category) {
|
|
952
|
-
const perCategory = readEnvDomains(CATEGORY_ENV[category]);
|
|
953
|
-
if (perCategory !== void 0) {
|
|
954
|
-
return perCategory;
|
|
955
|
-
}
|
|
956
|
-
return readCspUrlsShortcut();
|
|
957
|
-
}
|
|
958
|
-
function mergeDomainLists(...segments) {
|
|
959
|
-
const seen = /* @__PURE__ */ new Set();
|
|
960
|
-
const out = [];
|
|
961
|
-
for (const segment of segments) {
|
|
962
|
-
for (const domain of segment) {
|
|
963
|
-
if (!seen.has(domain)) {
|
|
964
|
-
seen.add(domain);
|
|
965
|
-
out.push(domain);
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
return out;
|
|
970
|
-
}
|
|
971
|
-
function toWebSocketOrigin(serverOrigin) {
|
|
972
|
-
if (serverOrigin.startsWith("https://")) {
|
|
973
|
-
return `wss://${serverOrigin.slice("https://".length)}`;
|
|
974
|
-
}
|
|
975
|
-
if (serverOrigin.startsWith("http://")) {
|
|
976
|
-
return `ws://${serverOrigin.slice("http://".length)}`;
|
|
977
|
-
}
|
|
978
|
-
return serverOrigin;
|
|
979
|
-
}
|
|
980
|
-
function buildMergedResourceCsp(authorFacts, options) {
|
|
981
|
-
const author = authorFacts?.csp;
|
|
982
|
-
const mcpConnectAuto = [];
|
|
983
|
-
if (options.serverOrigin !== "") {
|
|
984
|
-
mcpConnectAuto.push(options.serverOrigin);
|
|
985
|
-
if (options.hmrWs === true) {
|
|
986
|
-
mcpConnectAuto.push(toWebSocketOrigin(options.serverOrigin));
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
const mcpResourceAuto = [];
|
|
990
|
-
const resourceOrigin = options.explicitAssetsBase ? options.assetsOrigin : options.serverOrigin;
|
|
991
|
-
if (resourceOrigin !== "") {
|
|
992
|
-
mcpResourceAuto.push(resourceOrigin);
|
|
993
|
-
}
|
|
994
|
-
const connectDomains = mergeDomainLists(
|
|
995
|
-
author?.connectDomains ?? [],
|
|
996
|
-
readEnvDomainsForCategory("connectDomains"),
|
|
997
|
-
mcpConnectAuto
|
|
998
|
-
);
|
|
999
|
-
const resourceDomains = mergeDomainLists(
|
|
1000
|
-
author?.resourceDomains ?? [],
|
|
1001
|
-
readEnvDomainsForCategory("resourceDomains"),
|
|
1002
|
-
mcpResourceAuto
|
|
1003
|
-
);
|
|
1004
|
-
const frameDomains = mergeDomainLists(
|
|
1005
|
-
author?.frameDomains ?? [],
|
|
1006
|
-
readEnvDomainsForCategory("frameDomains")
|
|
1007
|
-
);
|
|
1008
|
-
const baseUriDomains = mergeDomainLists(
|
|
1009
|
-
author?.baseUriDomains ?? [],
|
|
1010
|
-
readEnvDomainsForCategory("baseUriDomains")
|
|
1011
|
-
);
|
|
1012
|
-
return {
|
|
1013
|
-
...author,
|
|
1014
|
-
connectDomains,
|
|
1015
|
-
resourceDomains,
|
|
1016
|
-
frameDomains,
|
|
1017
|
-
baseUriDomains
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
// src/views/routes.ts
|
|
1022
|
-
var PUBLIC_BUILD_DIR = ".mcp-use/build/views/public";
|
|
1023
|
-
var PUBLIC_DEV_DIR = "public";
|
|
1024
|
-
var VIEW_ASSETS_BUILD_ROOT = ".mcp-use/build/views";
|
|
1025
|
-
function createViewAssetsHandler(basePath, views, options) {
|
|
1026
|
-
if (views.size === 0) {
|
|
1027
|
-
return void 0;
|
|
1028
|
-
}
|
|
1029
|
-
const assetsPrefix = pathUnderBase(basePath, "_mcp-use/views");
|
|
1030
|
-
const projectRoot = options?.projectRoot ?? process.cwd();
|
|
1031
|
-
return async (request) => {
|
|
1032
|
-
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
1033
|
-
return new Response("Method Not Allowed", { status: 405 });
|
|
1034
|
-
}
|
|
1035
|
-
if (!matchesPathPrefix(request, assetsPrefix)) {
|
|
1036
|
-
return new Response("Not Found", { status: 404 });
|
|
1037
|
-
}
|
|
1038
|
-
const pathname = pathnameOf(request);
|
|
1039
|
-
const remainder = pathname.slice(assetsPrefix.length + 1);
|
|
1040
|
-
const slash = remainder.indexOf("/");
|
|
1041
|
-
if (slash <= 0 || slash === remainder.length - 1) {
|
|
1042
|
-
return new Response("Not Found", { status: 404 });
|
|
1043
|
-
}
|
|
1044
|
-
const viewName = remainder.slice(0, slash);
|
|
1045
|
-
const subpath = remainder.slice(slash + 1);
|
|
1046
|
-
const entry = views.get(viewName);
|
|
1047
|
-
if (entry === void 0 || entry.kind !== "external") {
|
|
1048
|
-
return new Response("Not Found", { status: 404 });
|
|
1049
|
-
}
|
|
1050
|
-
const [{ join }, { resolvePublicFilePath, servePublicFile }] = await Promise.all([import("path"), import("./public-route-26FUVRO5.js")]);
|
|
1051
|
-
const viewRoot = join(projectRoot, VIEW_ASSETS_BUILD_ROOT, viewName);
|
|
1052
|
-
const diskPath = await resolvePublicFilePath(viewRoot, subpath);
|
|
1053
|
-
if (diskPath === null) {
|
|
1054
|
-
return new Response("Not Found", { status: 404 });
|
|
1055
|
-
}
|
|
1056
|
-
return await servePublicFile(
|
|
1057
|
-
diskPath,
|
|
1058
|
-
options?.deferCors === true ? { deferCors: true } : {}
|
|
1059
|
-
);
|
|
1060
|
-
};
|
|
1061
|
-
}
|
|
1062
|
-
function createViewPublicHandler(basePath, views, options) {
|
|
1063
|
-
if (views.size === 0) {
|
|
1064
|
-
return void 0;
|
|
1065
|
-
}
|
|
1066
|
-
const publicPrefix = pathUnderBase(basePath, "_mcp-use/public");
|
|
1067
|
-
const subdir = options?.dev === true ? PUBLIC_DEV_DIR : PUBLIC_BUILD_DIR;
|
|
1068
|
-
const projectRoot = options?.projectRoot ?? process.cwd();
|
|
1069
|
-
return async (request) => {
|
|
1070
|
-
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
1071
|
-
return new Response("Method Not Allowed", { status: 405 });
|
|
1072
|
-
}
|
|
1073
|
-
if (!matchesPathPrefix(request, publicPrefix)) {
|
|
1074
|
-
return new Response("Not Found", { status: 404 });
|
|
1075
|
-
}
|
|
1076
|
-
const pathname = pathnameOf(request);
|
|
1077
|
-
const subpath = pathname.slice(publicPrefix.length + 1);
|
|
1078
|
-
if (subpath.length === 0) {
|
|
1079
|
-
return new Response("Not Found", { status: 404 });
|
|
1080
|
-
}
|
|
1081
|
-
const [{ join }, { resolvePublicFilePath, servePublicFile }] = await Promise.all([import("path"), import("./public-route-26FUVRO5.js")]);
|
|
1082
|
-
const publicRoot = join(projectRoot, subdir);
|
|
1083
|
-
const diskPath = await resolvePublicFilePath(publicRoot, subpath);
|
|
1084
|
-
if (diskPath === null) {
|
|
1085
|
-
return new Response("Not Found", { status: 404 });
|
|
1086
|
-
}
|
|
1087
|
-
return await servePublicFile(
|
|
1088
|
-
diskPath,
|
|
1089
|
-
options?.deferCors === true ? { deferCors: true } : {}
|
|
1090
|
-
);
|
|
1091
|
-
};
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
// src/views/wire.ts
|
|
1095
|
-
function buildToolUiMeta(viewName, visibility, existingMetadata) {
|
|
1096
|
-
if (viewName === void 0 && visibility === void 0 && existingMetadata === void 0) {
|
|
1097
|
-
return void 0;
|
|
1098
|
-
}
|
|
1099
|
-
const meta = { ...existingMetadata };
|
|
1100
|
-
const existingUi = existingMetadata?.[UI_META_KEY];
|
|
1101
|
-
const existingUiIsObject = typeof existingUi === "object" && existingUi !== null && !Array.isArray(existingUi);
|
|
1102
|
-
const ui = existingUiIsObject ? { ...existingUi } : {};
|
|
1103
|
-
if (viewName !== void 0) {
|
|
1104
|
-
const resourceUri = viewResourceUri(viewName);
|
|
1105
|
-
ui["resourceUri"] = resourceUri;
|
|
1106
|
-
meta[UI_RESOURCE_URI_META_KEY] = resourceUri;
|
|
1107
|
-
} else {
|
|
1108
|
-
delete ui["resourceUri"];
|
|
1109
|
-
delete meta[UI_RESOURCE_URI_META_KEY];
|
|
1110
|
-
}
|
|
1111
|
-
if (visibility !== void 0) {
|
|
1112
|
-
ui["visibility"] = [visibility];
|
|
1113
|
-
} else {
|
|
1114
|
-
delete ui["visibility"];
|
|
1115
|
-
}
|
|
1116
|
-
if (viewName !== void 0 || visibility !== void 0 || existingUiIsObject) {
|
|
1117
|
-
meta[UI_META_KEY] = ui;
|
|
1118
|
-
}
|
|
1119
|
-
return meta;
|
|
1120
|
-
}
|
|
1121
|
-
function buildToolResultUiMeta(viewName) {
|
|
1122
|
-
const resourceUri = viewResourceUri(viewName);
|
|
1123
|
-
return {
|
|
1124
|
-
[UI_META_KEY]: { resourceUri },
|
|
1125
|
-
[UI_RESOURCE_URI_META_KEY]: resourceUri
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
function resolveCspOptions(options) {
|
|
1129
|
-
const request = options?.request;
|
|
1130
|
-
const serverOrigin = options?.serverOrigin ?? (request !== void 0 ? resolveServerOrigin(request) : "");
|
|
1131
|
-
const assetsBase = options?.assetsBase ?? (request !== void 0 ? resolveAssetsBase(request) : serverOrigin);
|
|
1132
|
-
return {
|
|
1133
|
-
serverOrigin,
|
|
1134
|
-
assetsOrigin: originFromAssetsBase(assetsBase),
|
|
1135
|
-
explicitAssetsBase: hasExplicitAssetsBase(),
|
|
1136
|
-
...options?.hmrWs === true ? { hmrWs: true } : {}
|
|
1137
|
-
};
|
|
1138
|
-
}
|
|
1139
|
-
function buildResourceUiMeta(authorFacts, options) {
|
|
1140
|
-
const csp = buildMergedResourceCsp(authorFacts, resolveCspOptions(options));
|
|
1141
|
-
const ui = { csp };
|
|
1142
|
-
if (authorFacts?.permissions !== void 0) {
|
|
1143
|
-
ui["permissions"] = authorFacts.permissions;
|
|
1144
|
-
}
|
|
1145
|
-
if (authorFacts?.domain !== void 0) {
|
|
1146
|
-
ui["domain"] = authorFacts.domain;
|
|
1147
|
-
}
|
|
1148
|
-
if (authorFacts?.prefersBorder !== void 0) {
|
|
1149
|
-
ui["prefersBorder"] = authorFacts.prefersBorder;
|
|
1150
|
-
}
|
|
1151
|
-
return { [UI_META_KEY]: ui };
|
|
1152
|
-
}
|
|
1153
|
-
function viewResourceConfig(_viewName, _entry, authorFacts, options) {
|
|
1154
|
-
return {
|
|
1155
|
-
mimeType: UI_MIME_TYPE,
|
|
1156
|
-
...authorFacts?.description !== void 0 && {
|
|
1157
|
-
description: authorFacts.description
|
|
1158
|
-
},
|
|
1159
|
-
_meta: buildResourceUiMeta(authorFacts, options)
|
|
1160
|
-
};
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
// src/server.ts
|
|
1164
|
-
var MCPServer = class _MCPServer {
|
|
1165
|
-
#config;
|
|
1166
|
-
#tools = /* @__PURE__ */ new Map();
|
|
1167
|
-
#resources = /* @__PURE__ */ new Map();
|
|
1168
|
-
#resourceTemplates = /* @__PURE__ */ new Map();
|
|
1169
|
-
#prompts = /* @__PURE__ */ new Map();
|
|
1170
|
-
#views = /* @__PURE__ */ new Map();
|
|
1171
|
-
/**
|
|
1172
|
-
* One-to-one tool→view bindings. Each view name maps to the single tool
|
|
1173
|
-
* that bound it; that tool's `view:` config is the sole source of
|
|
1174
|
-
* resource facts for the primed view resource.
|
|
1175
|
-
*/
|
|
1176
|
-
#viewBindings = /* @__PURE__ */ new Map();
|
|
1177
|
-
#viewsPrimed = false;
|
|
1178
|
-
/** When true, resource CSP emission includes the HMR websocket origin. */
|
|
1179
|
-
#viewsDevMode = false;
|
|
1180
|
-
/** Project root for filesystem-backed view routes (dev `public/`). */
|
|
1181
|
-
#viewsProjectRoot = process.cwd();
|
|
1182
|
-
#fetchHandler;
|
|
1183
|
-
#handler;
|
|
1184
|
-
#httpServer;
|
|
1185
|
-
#oauthResource;
|
|
1186
|
-
#oauthResourceResolved = false;
|
|
1187
|
-
#oauthResourceConfigurationAbsent = false;
|
|
1188
|
-
/** Whether the mounted app validates Host headers (fixed at first mount). */
|
|
1189
|
-
#hostValidated = false;
|
|
1190
|
-
#mcpMiddlewares = [];
|
|
1191
|
-
#mcpEventListeners = [];
|
|
1192
|
-
/**
|
|
1193
|
-
* Create an MCP server from a parsed, bundled OpenAPI document.
|
|
1194
|
-
*
|
|
1195
|
-
* Each included OpenAPI operation becomes a tool that validates its input,
|
|
1196
|
-
* calls the matching upstream HTTP endpoint, and returns the response using
|
|
1197
|
-
* the SDK's raw tool-result shape. External `$ref` values are not fetched;
|
|
1198
|
-
* bundle the document before passing it in.
|
|
1199
|
-
*
|
|
1200
|
-
* @param options - OpenAPI document, operation filters, upstream URL, and
|
|
1201
|
-
* request authentication options.
|
|
1202
|
-
* @returns An unauthenticated MCP server populated with generated tools.
|
|
1203
|
-
*
|
|
1204
|
-
* @example
|
|
1205
|
-
* ```ts
|
|
1206
|
-
* const spec = await fetch("https://api.example.com/openapi.json")
|
|
1207
|
-
* .then((response) => response.json());
|
|
1208
|
-
* const server = MCPServer.fromOpenAPI({ spec });
|
|
1209
|
-
* await server.listen(3000);
|
|
1210
|
-
* ```
|
|
1211
|
-
*/
|
|
1212
|
-
static fromOpenAPI(options) {
|
|
1213
|
-
const server = new _MCPServer({
|
|
1214
|
-
name: options.name ?? options.spec.info.title,
|
|
1215
|
-
version: options.version ?? options.spec.info.version ?? "1.0.0"
|
|
1216
|
-
});
|
|
1217
|
-
registerOpenAPITools(server, options);
|
|
1218
|
-
return server;
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* Create a server. `config.name` and `config.version` identify the server
|
|
1222
|
-
* to clients during initialization. `config.basePath` (default `"/mcp"`)
|
|
1223
|
-
* is both the MCP route and the path of the OAuth protected-resource
|
|
1224
|
-
* identity, so any explicit OAuth resource URL must use that exact path.
|
|
1225
|
-
* Nothing binds or listens until {@link MCPServer.listen} or
|
|
1226
|
-
* {@link MCPServer.getHandler} is called.
|
|
1227
|
-
*/
|
|
1228
|
-
constructor(config) {
|
|
1229
|
-
assertServerConfig(config);
|
|
1230
|
-
this.#config = config;
|
|
1231
|
-
if (config.oauth !== void 0) {
|
|
1232
|
-
const mcpUrl = typeof process === "undefined" ? void 0 : process.env["MCP_URL"];
|
|
1233
|
-
const resource = resolveConfiguredOAuthResource({
|
|
1234
|
-
provider: config.oauth,
|
|
1235
|
-
basePath: this.#basePath(),
|
|
1236
|
-
...mcpUrl !== void 0 && { mcpUrl }
|
|
1237
|
-
});
|
|
1238
|
-
this.#oauthResource = resource;
|
|
1239
|
-
this.#oauthResourceResolved = resource !== void 0;
|
|
1240
|
-
this.#oauthResourceConfigurationAbsent = resource === void 0;
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
/**
|
|
1244
|
-
* The URL path prefix the MCP endpoint is mounted at.
|
|
1245
|
-
*
|
|
1246
|
-
* Reflects `config.basePath` (default `"/mcp"`). Exposed so tooling that
|
|
1247
|
-
* imports the entry module — `mcp-use dev`'s startup log, for example —
|
|
1248
|
-
* can build the endpoint and inspector URLs without assuming the default.
|
|
1249
|
-
*/
|
|
1250
|
-
get basePath() {
|
|
1251
|
-
return this.#basePath();
|
|
1252
|
-
}
|
|
1253
|
-
/**
|
|
1254
|
-
* Register a tool. Input is validated against `inputSchema` before the callback
|
|
1255
|
-
* runs; results carrying `structuredContent` are type-checked against
|
|
1256
|
-
* `outputSchema` at the callback's return position.
|
|
1257
|
-
*
|
|
1258
|
-
* @returns A {@link ToolRef} carrying the tool name and phantom types for
|
|
1259
|
-
* inference-based view typing.
|
|
1260
|
-
*/
|
|
1261
|
-
tool(definition, callback) {
|
|
1262
|
-
this.#assertNotStarted("tool", definition.name);
|
|
1263
|
-
this.#validateToolViewBinding(definition);
|
|
1264
|
-
this.#tools.set(definition.name, {
|
|
1265
|
-
definition,
|
|
1266
|
-
callback
|
|
1267
|
-
});
|
|
1268
|
-
return Object.freeze({
|
|
1269
|
-
name: definition.name
|
|
1270
|
-
});
|
|
1271
|
-
}
|
|
1272
|
-
/**
|
|
1273
|
-
* Prime the views registry from a build/dev manifest.
|
|
1274
|
-
*
|
|
1275
|
-
* @param views - Manifest map keyed by view directory name.
|
|
1276
|
-
* @param options - Priming options. When `dev` is true, resource CSP
|
|
1277
|
-
* emission appends the serving origin's websocket variant to
|
|
1278
|
-
* `connectDomains` so Vite HMR passes host-enforced CSP. Pass
|
|
1279
|
-
* `projectRoot` in dev so the `public/` route resolves against the user's
|
|
1280
|
-
* project directory rather than the CLI process cwd.
|
|
1281
|
-
* @throws If views are already primed, or after the server has started.
|
|
1282
|
-
*
|
|
1283
|
-
* @internal
|
|
1284
|
-
*/
|
|
1285
|
-
[registerViews](views, options) {
|
|
1286
|
-
if (this.#viewsPrimed) {
|
|
1287
|
-
throw new Error(
|
|
1288
|
-
"Cannot prime views: the views registry is already primed on this server instance."
|
|
1289
|
-
);
|
|
1290
|
-
}
|
|
1291
|
-
this.#assertNotStarted("views", "manifest");
|
|
1292
|
-
this.#viewsDevMode = options?.dev === true;
|
|
1293
|
-
if (options?.projectRoot !== void 0) {
|
|
1294
|
-
this.#viewsProjectRoot = options.projectRoot;
|
|
1295
|
-
}
|
|
1296
|
-
for (const [name, entry] of Object.entries(views)) {
|
|
1297
|
-
this.#views.set(name, entry);
|
|
1298
|
-
}
|
|
1299
|
-
this.#viewsPrimed = true;
|
|
1300
|
-
}
|
|
1301
|
-
/**
|
|
1302
|
-
* Prime the views registry — string-keyed alias for {@link registerViews}
|
|
1303
|
-
* used by the CLI when the symbol export cannot be shared across duplicate
|
|
1304
|
-
* module copies (dev module runner with an externalized package).
|
|
1305
|
-
*
|
|
1306
|
-
* @param views - Manifest map keyed by view directory name.
|
|
1307
|
-
* @param options - Priming options forwarded to {@link registerViews}.
|
|
1308
|
-
* @throws If views are already primed, or after the server has started.
|
|
1309
|
-
*
|
|
1310
|
-
* @internal
|
|
1311
|
-
*/
|
|
1312
|
-
__primeViews(views, options) {
|
|
1313
|
-
this[registerViews](views, options);
|
|
1314
|
-
}
|
|
1315
|
-
/** Register a static resource readable at `definition.uri`. */
|
|
1316
|
-
resource(definition, callback) {
|
|
1317
|
-
this.#assertNotStarted("resource", definition.name);
|
|
1318
|
-
this.#resources.set(definition.name, { definition, callback });
|
|
1319
|
-
return this;
|
|
1320
|
-
}
|
|
1321
|
-
/**
|
|
1322
|
-
* Register a parameterized resource. Reads matching `uriTemplate` invoke
|
|
1323
|
-
* the callback with the extracted variables.
|
|
1324
|
-
*
|
|
1325
|
-
* The `const` type parameter keeps `uriTemplate` a string literal during
|
|
1326
|
-
* inference (plain generic inference widens object-literal properties to
|
|
1327
|
-
* `string`), which is what lets `InferTemplateParams` type the callback's
|
|
1328
|
-
* `params` from the template's variables.
|
|
1329
|
-
*/
|
|
1330
|
-
resourceTemplate(definition, callback) {
|
|
1331
|
-
this.#assertNotStarted("resourceTemplate", definition.name);
|
|
1332
|
-
const complete = definition.complete === void 0 ? void 0 : normalizeCompletions(definition.complete);
|
|
1333
|
-
this.#resourceTemplates.set(definition.name, {
|
|
1334
|
-
definition,
|
|
1335
|
-
...complete !== void 0 && { complete },
|
|
1336
|
-
callback
|
|
1337
|
-
});
|
|
1338
|
-
return this;
|
|
1339
|
-
}
|
|
1340
|
-
/**
|
|
1341
|
-
* Register a prompt template. Schema fields wrapped with `completable()`
|
|
1342
|
-
* gain autocomplete via `completion/complete`.
|
|
1343
|
-
*/
|
|
1344
|
-
prompt(definition, callback) {
|
|
1345
|
-
this.#assertNotStarted("prompt", definition.name);
|
|
1346
|
-
this.#prompts.set(definition.name, {
|
|
1347
|
-
definition,
|
|
1348
|
-
callback
|
|
1349
|
-
});
|
|
1350
|
-
return this;
|
|
1351
|
-
}
|
|
1352
|
-
/**
|
|
1353
|
-
* Web-standard request handler for the whole app (MCP endpoint included) —
|
|
1354
|
-
* usable directly on serverless/edge runtimes or in tests.
|
|
1355
|
-
*
|
|
1356
|
-
* The handler never binds a socket, so no Host/Origin validation applies
|
|
1357
|
-
* by default: DNS rebinding targets locally bound servers, and platform
|
|
1358
|
-
* edges (Vercel, Cloudflare, …) only route hostnames assigned to the
|
|
1359
|
-
* deployment. Set `allowedHosts`/`allowedOrigins` to opt into validation
|
|
1360
|
-
* (additive — localhost-class values stay allowed).
|
|
1361
|
-
*
|
|
1362
|
-
* Pass the same `bus` to multiple server instances when their handlers
|
|
1363
|
-
* replace one another while existing `subscriptions/listen` streams remain
|
|
1364
|
-
* open. The bus is fixed when this instance first mounts.
|
|
1365
|
-
*
|
|
1366
|
-
* @param options - Optional handler wiring.
|
|
1367
|
-
*
|
|
1368
|
-
* @example
|
|
1369
|
-
* ```ts
|
|
1370
|
-
* const handler = server.getHandler();
|
|
1371
|
-
* export default { fetch: handler };
|
|
1372
|
-
* ```
|
|
1373
|
-
*/
|
|
1374
|
-
getHandler(options = {}) {
|
|
1375
|
-
const { fetch } = this.#ensureMounted("handler", void 0, options.bus);
|
|
1376
|
-
return toFrameworkHandler(fetch);
|
|
1377
|
-
}
|
|
1378
|
-
/**
|
|
1379
|
-
* Node `(req, res) => void` handler for composing with an existing
|
|
1380
|
-
* `http.Server`. Uses the same internal `toNodeHandler` bridge as
|
|
1381
|
-
* {@link MCPServer.listen}; MCPServer users do not need to import
|
|
1382
|
-
* `mcp-use/node`.
|
|
1383
|
-
*
|
|
1384
|
-
* @example
|
|
1385
|
-
* ```ts
|
|
1386
|
-
* import { createServer } from "node:http";
|
|
1387
|
-
* const httpServer = createServer(await server.getNodeHandler());
|
|
1388
|
-
* httpServer.listen(3000);
|
|
1389
|
-
* ```
|
|
1390
|
-
*/
|
|
1391
|
-
async getNodeHandler() {
|
|
1392
|
-
const { fetch } = this.#ensureMounted("handler");
|
|
1393
|
-
const { toNodeHandler } = await import("./node-bridge.js");
|
|
1394
|
-
return toNodeHandler({ fetch });
|
|
1395
|
-
}
|
|
1396
|
-
/**
|
|
1397
|
-
* Register MCP operation middleware that intercepts JSON-RPC dispatch.
|
|
1398
|
-
*
|
|
1399
|
-
* Patterns use an `mcp:` prefix (for example `mcp:tools/call`, `mcp:*`).
|
|
1400
|
-
* Middleware runs in registration order; call `next()` to continue the chain.
|
|
1401
|
-
*
|
|
1402
|
-
* @example
|
|
1403
|
-
* ```ts
|
|
1404
|
-
* server.use("mcp:tools/call", async (ctx, next) => {
|
|
1405
|
-
* console.log(`Calling tool: ${ctx.params.name}`);
|
|
1406
|
-
* return next();
|
|
1407
|
-
* });
|
|
1408
|
-
* ```
|
|
1409
|
-
*/
|
|
1410
|
-
use(pattern, handler) {
|
|
1411
|
-
this.#assertNotStarted("middleware", pattern);
|
|
1412
|
-
this.#mcpMiddlewares.push({
|
|
1413
|
-
pattern: normalizeMcpMiddlewarePattern(pattern),
|
|
1414
|
-
handler
|
|
1415
|
-
});
|
|
1416
|
-
return this;
|
|
1417
|
-
}
|
|
1418
|
-
/**
|
|
1419
|
-
* Register a read-only MCP observer. Unlike {@link MCPServer.use}, listeners
|
|
1420
|
-
* cannot block, override, or mutate params. Throwing is logged and does not
|
|
1421
|
-
* fail the request.
|
|
1422
|
-
*
|
|
1423
|
-
* Append `:complete` to run after the handler (for example
|
|
1424
|
-
* `mcp:tools/call:complete`).
|
|
1425
|
-
*
|
|
1426
|
-
* @example
|
|
1427
|
-
* ```ts
|
|
1428
|
-
* server.on("mcp:tools/call", (ctx) => {
|
|
1429
|
-
* metrics.increment("tools.call", { tool: ctx.params.name });
|
|
1430
|
-
* });
|
|
1431
|
-
* ```
|
|
1432
|
-
*/
|
|
1433
|
-
on(pattern, handler) {
|
|
1434
|
-
this.#assertNotStarted("event listener", pattern);
|
|
1435
|
-
const { pattern: stripped, phase } = parseMcpPattern(pattern);
|
|
1436
|
-
this.#mcpEventListeners.push({
|
|
1437
|
-
pattern: stripped,
|
|
1438
|
-
phase,
|
|
1439
|
-
handler
|
|
1440
|
-
});
|
|
1441
|
-
return this;
|
|
1442
|
-
}
|
|
1443
|
-
/**
|
|
1444
|
-
* Publish a tools-list change to v2 clients with active subscriptions.
|
|
1445
|
-
*
|
|
1446
|
-
* @example
|
|
1447
|
-
* ```ts
|
|
1448
|
-
* await server.notifyToolsChanged();
|
|
1449
|
-
* ```
|
|
1450
|
-
*/
|
|
1451
|
-
async notifyToolsChanged() {
|
|
1452
|
-
await this.#ensureMounted("handler").handler.notify.toolsChanged();
|
|
1453
|
-
}
|
|
1454
|
-
/**
|
|
1455
|
-
* Publish a prompts-list change to v2 clients with active subscriptions.
|
|
1456
|
-
*
|
|
1457
|
-
* @example
|
|
1458
|
-
* ```ts
|
|
1459
|
-
* await server.notifyPromptsChanged();
|
|
1460
|
-
* ```
|
|
1461
|
-
*/
|
|
1462
|
-
async notifyPromptsChanged() {
|
|
1463
|
-
await this.#ensureMounted("handler").handler.notify.promptsChanged();
|
|
1464
|
-
}
|
|
1465
|
-
/**
|
|
1466
|
-
* Publish a resources-list change to v2 clients with active subscriptions.
|
|
1467
|
-
*
|
|
1468
|
-
* @example
|
|
1469
|
-
* ```ts
|
|
1470
|
-
* await server.notifyResourcesChanged();
|
|
1471
|
-
* ```
|
|
1472
|
-
*/
|
|
1473
|
-
async notifyResourcesChanged() {
|
|
1474
|
-
await this.#ensureMounted("handler").handler.notify.resourcesChanged();
|
|
1475
|
-
}
|
|
1476
|
-
/**
|
|
1477
|
-
* Publish a resource update to subscribed v2 clients.
|
|
1478
|
-
*
|
|
1479
|
-
* @param uri - Resource URI whose representation changed.
|
|
1480
|
-
*
|
|
1481
|
-
* @example
|
|
1482
|
-
* ```ts
|
|
1483
|
-
* await server.notifyResourceUpdated("config://settings");
|
|
1484
|
-
* ```
|
|
1485
|
-
*/
|
|
1486
|
-
async notifyResourceUpdated(uri) {
|
|
1487
|
-
await this.#ensureMounted("handler").handler.notify.resourceUpdated(uri);
|
|
1488
|
-
}
|
|
1489
|
-
/**
|
|
1490
|
-
* Serve over HTTP on Node. Pass port `0` for an ephemeral port.
|
|
1491
|
-
*
|
|
1492
|
-
* Binds `config.host` (default `127.0.0.1`). Localhost-class binds get
|
|
1493
|
-
* DNS-rebinding protection automatically: `Host` on every request,
|
|
1494
|
-
* `Origin` only on non-GET/HEAD (sandboxed view iframes send
|
|
1495
|
-
* `Origin: null` on asset GETs). To serve publicly set `host: "0.0.0.0"`;
|
|
1496
|
-
* behind a platform edge that is all that's needed, and `allowedHosts`
|
|
1497
|
-
* restricts direct exposure (additive — localhost-class values stay allowed).
|
|
1498
|
-
*
|
|
1499
|
-
* With OAuth and no explicit resource or `MCP_URL`, a localhost listener
|
|
1500
|
-
* derives its protected-resource URL from the actual bound port. Mounting
|
|
1501
|
-
* therefore waits for the listener callback (especially for port `0`), and
|
|
1502
|
-
* requests accepted before then are queued. Public/wildcard listeners must
|
|
1503
|
-
* configure the resource before calling this method.
|
|
1504
|
-
*
|
|
1505
|
-
* @throws If called on a localhost-class bind after {@link MCPServer.getHandler}
|
|
1506
|
-
* already mounted the app without Host validation.
|
|
1507
|
-
*/
|
|
1508
|
-
async listen(port = 3e3) {
|
|
1509
|
-
this.#assertListenOAuthConfiguration();
|
|
1510
|
-
const { createServer } = await import("http");
|
|
1511
|
-
const { toNodeHandler } = await import("./node-bridge.js");
|
|
1512
|
-
const host = this.#config.host ?? "127.0.0.1";
|
|
1513
|
-
return new Promise((resolve, reject) => {
|
|
1514
|
-
let resolveFetch;
|
|
1515
|
-
let rejectFetch;
|
|
1516
|
-
const fetchReady = new Promise(
|
|
1517
|
-
(resolveFetchPromise, rejectFetchPromise) => {
|
|
1518
|
-
resolveFetch = resolveFetchPromise;
|
|
1519
|
-
rejectFetch = rejectFetchPromise;
|
|
1520
|
-
}
|
|
1521
|
-
);
|
|
1522
|
-
void fetchReady.catch(() => void 0);
|
|
1523
|
-
let settled = false;
|
|
1524
|
-
const rejectAndClose = (error) => {
|
|
1525
|
-
if (!settled) {
|
|
1526
|
-
settled = true;
|
|
1527
|
-
reject(error);
|
|
1528
|
-
}
|
|
1529
|
-
rejectFetch?.(error);
|
|
1530
|
-
void new Promise(
|
|
1531
|
-
(closeResolve) => server.close(() => closeResolve())
|
|
1532
|
-
).catch(() => void 0).finally(() => {
|
|
1533
|
-
if (this.#httpServer === server) {
|
|
1534
|
-
this.#httpServer = void 0;
|
|
1535
|
-
}
|
|
1536
|
-
});
|
|
1537
|
-
};
|
|
1538
|
-
const nodeHandler = toNodeHandler({
|
|
1539
|
-
fetch: async (request) => (await fetchReady)(request)
|
|
1540
|
-
});
|
|
1541
|
-
const server = createServer((req, res) => {
|
|
1542
|
-
void nodeHandler(req, res);
|
|
1543
|
-
});
|
|
1544
|
-
server.once("error", rejectAndClose);
|
|
1545
|
-
server.listen(port, host, () => {
|
|
1546
|
-
try {
|
|
1547
|
-
const address = server.address();
|
|
1548
|
-
const boundPort = typeof address === "object" && address !== null ? address.port : port;
|
|
1549
|
-
const { fetch } = this.#ensureMounted("listen", boundPort);
|
|
1550
|
-
resolveFetch?.(fetch);
|
|
1551
|
-
if (!settled) {
|
|
1552
|
-
settled = true;
|
|
1553
|
-
resolve({
|
|
1554
|
-
port: boundPort,
|
|
1555
|
-
url: `http://localhost:${boundPort}${this.#basePath()}`
|
|
1556
|
-
});
|
|
1557
|
-
}
|
|
1558
|
-
} catch (error) {
|
|
1559
|
-
rejectAndClose(error);
|
|
1560
|
-
}
|
|
1561
|
-
});
|
|
1562
|
-
this.#httpServer = server;
|
|
1563
|
-
});
|
|
1564
|
-
}
|
|
1565
|
-
/**
|
|
1566
|
-
* Abort in-flight MCP exchanges and stop the HTTP listener.
|
|
1567
|
-
*
|
|
1568
|
-
* A closed server is done for good — the underlying MCP handler stays
|
|
1569
|
-
* closed, so `listen()`/`getHandler()` cannot revive it. Create a new
|
|
1570
|
-
* instance to serve again.
|
|
1571
|
-
*/
|
|
1572
|
-
async close() {
|
|
1573
|
-
await this.#handler?.close();
|
|
1574
|
-
const httpServer = this.#httpServer;
|
|
1575
|
-
if (httpServer !== void 0) {
|
|
1576
|
-
await new Promise((resolve, reject) => {
|
|
1577
|
-
httpServer.close((err) => err ? reject(err) : resolve());
|
|
1578
|
-
});
|
|
1579
|
-
this.#httpServer = void 0;
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
#basePath() {
|
|
1583
|
-
return this.#config.basePath ?? "/mcp";
|
|
1584
|
-
}
|
|
1585
|
-
#resolveOAuthResource(mode, listenPort) {
|
|
1586
|
-
if (this.#config.oauth === void 0) {
|
|
1587
|
-
return void 0;
|
|
1588
|
-
}
|
|
1589
|
-
if (this.#oauthResourceResolved) {
|
|
1590
|
-
return this.#oauthResource;
|
|
1591
|
-
}
|
|
1592
|
-
const host = this.#config.host ?? "127.0.0.1";
|
|
1593
|
-
const localListen = mode === "listen" && listenPort !== void 0 && ["127.0.0.1", "localhost", "::1"].includes(host);
|
|
1594
|
-
if (this.#oauthResourceConfigurationAbsent && localListen) {
|
|
1595
|
-
this.#oauthResource = resolveLocalOAuthResource(
|
|
1596
|
-
`http://localhost:${listenPort}`,
|
|
1597
|
-
this.#basePath()
|
|
1598
|
-
);
|
|
1599
|
-
this.#oauthResourceResolved = true;
|
|
1600
|
-
return this.#oauthResource;
|
|
1601
|
-
}
|
|
1602
|
-
throw new Error(
|
|
1603
|
-
"OAuth requires an explicit resource or MCP_URL when using getHandler() or listening on a non-local host"
|
|
1604
|
-
);
|
|
1605
|
-
}
|
|
1606
|
-
#assertListenOAuthConfiguration() {
|
|
1607
|
-
if (this.#config.oauth === void 0) {
|
|
1608
|
-
return;
|
|
1609
|
-
}
|
|
1610
|
-
const host = this.#config.host ?? "127.0.0.1";
|
|
1611
|
-
if (["127.0.0.1", "localhost", "::1"].includes(host)) {
|
|
1612
|
-
return;
|
|
1613
|
-
}
|
|
1614
|
-
if (!this.#oauthResourceResolved) {
|
|
1615
|
-
throw new Error(
|
|
1616
|
-
"OAuth listen() on a public or wildcard host requires an explicit provider resource or valid MCP_URL."
|
|
1617
|
-
);
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
#assertNotStarted(kind, name) {
|
|
1621
|
-
if (this.#handler !== void 0) {
|
|
1622
|
-
throw new Error(
|
|
1623
|
-
`Cannot register ${kind} "${name}" after the server has started: registrations are replayed per request from the registry, so register everything before listen()/getHandler().`
|
|
1624
|
-
);
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
/**
|
|
1628
|
-
* Effective Host/Origin allowlists for a mount mode; `undefined` means the
|
|
1629
|
-
* corresponding validation is off.
|
|
1630
|
-
*
|
|
1631
|
-
* Configured lists are additive to the localhost-class allowlists, so local
|
|
1632
|
-
* runs keep working when a deployment hostname is added. With nothing
|
|
1633
|
-
* configured, `listen()` on a localhost-class bind validates against the
|
|
1634
|
-
* localhost lists (the DNS-rebinding threat model), while `getHandler()` —
|
|
1635
|
-
* which never binds — applies no validation. `allowedOrigins` defaults to
|
|
1636
|
-
* mirroring the effective Host allowlist. Origin validation runs only on
|
|
1637
|
-
* non-GET/HEAD requests.
|
|
1638
|
-
*/
|
|
1639
|
-
#validationPolicy(mode) {
|
|
1640
|
-
const { host = "127.0.0.1", allowedHosts, allowedOrigins } = this.#config;
|
|
1641
|
-
const localhostBind = ["127.0.0.1", "localhost", "::1"].includes(host);
|
|
1642
|
-
const hosts = allowedHosts !== void 0 ? [.../* @__PURE__ */ new Set([...localhostAllowedHostnames(), ...allowedHosts])] : mode === "listen" && localhostBind ? localhostAllowedHostnames() : void 0;
|
|
1643
|
-
const origins = allowedOrigins !== void 0 ? [.../* @__PURE__ */ new Set([...localhostAllowedOrigins(), ...allowedOrigins])] : hosts;
|
|
1644
|
-
return { hosts, origins };
|
|
1645
|
-
}
|
|
1646
|
-
#ensureMounted(mode, listenPort, bus) {
|
|
1647
|
-
if (this.#fetchHandler === void 0 || this.#handler === void 0) {
|
|
1648
|
-
const { hosts, origins } = this.#validationPolicy(mode);
|
|
1649
|
-
const basePath = this.#basePath();
|
|
1650
|
-
const nestedBasePath = basePath === "/" ? "" : basePath;
|
|
1651
|
-
const middlewares = [
|
|
1652
|
-
jsonBodyMiddleware(),
|
|
1653
|
-
requestLogger(this.#config.logging)
|
|
1654
|
-
];
|
|
1655
|
-
const corsConfig = this.#config.cors;
|
|
1656
|
-
if (corsConfig !== void 0) {
|
|
1657
|
-
middlewares.unshift(corsFetchMiddleware(corsConfig));
|
|
1658
|
-
}
|
|
1659
|
-
const deferViewCors = isGlobalCorsEnabled(corsConfig);
|
|
1660
|
-
if (hosts !== void 0) {
|
|
1661
|
-
middlewares.unshift(hostValidationMiddleware(hosts));
|
|
1662
|
-
middlewares.push(originValidationMiddleware(origins ?? hosts));
|
|
1663
|
-
} else {
|
|
1664
|
-
if (origins !== void 0) {
|
|
1665
|
-
middlewares.push(originValidationMiddleware(origins));
|
|
1666
|
-
}
|
|
1667
|
-
if (mode === "listen") {
|
|
1668
|
-
console.warn(
|
|
1669
|
-
`[mcp-use] listen() is serving on ${this.#config.host} without Host validation. Behind a platform edge that only routes your own domains this is expected; if this process is reachable directly, set allowedHosts to restrict it.`
|
|
1670
|
-
);
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
this.#validateViewBindingsAtMount();
|
|
1674
|
-
const resource = this.#resolveOAuthResource(mode, listenPort);
|
|
1675
|
-
if (resource !== void 0) {
|
|
1676
|
-
const provider = this.#config.oauth;
|
|
1677
|
-
middlewares.push(oauthMetadata(provider, resource));
|
|
1678
|
-
}
|
|
1679
|
-
const { handler, fetch: mcpFetch } = createMcpMount(
|
|
1680
|
-
(ctx) => this.#buildSdkServer(ctx),
|
|
1681
|
-
{
|
|
1682
|
-
path: basePath,
|
|
1683
|
-
...(this.#config.legacy !== void 0 || bus !== void 0) && {
|
|
1684
|
-
handler: {
|
|
1685
|
-
...this.#config.legacy !== void 0 && {
|
|
1686
|
-
legacy: this.#config.legacy
|
|
1687
|
-
},
|
|
1688
|
-
...bus !== void 0 && { bus }
|
|
1689
|
-
}
|
|
1690
|
-
},
|
|
1691
|
-
...resource !== void 0 && {
|
|
1692
|
-
authInfo: (request) => authInfoFromRequest(request)
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
);
|
|
1696
|
-
let protectWithBearer = async (_request, next) => next();
|
|
1697
|
-
if (resource !== void 0) {
|
|
1698
|
-
const provider = this.#config.oauth;
|
|
1699
|
-
const providerOptions = getOAuthProviderOptions(provider);
|
|
1700
|
-
const gate = requireBearerAuth({
|
|
1701
|
-
verifier: wrapOAuthTokenVerifier(provider, resource),
|
|
1702
|
-
resourceMetadataUrl: getOAuthProtectedResourceMetadataUrl(resource),
|
|
1703
|
-
...providerOptions.requiredScopes !== void 0 && {
|
|
1704
|
-
requiredScopes: providerOptions.requiredScopes
|
|
1705
|
-
}
|
|
1706
|
-
});
|
|
1707
|
-
protectWithBearer = async (request, next) => {
|
|
1708
|
-
const result = await gate(request);
|
|
1709
|
-
if (result instanceof Response) {
|
|
1710
|
-
return result;
|
|
1711
|
-
}
|
|
1712
|
-
const bag = getRequestBag(request);
|
|
1713
|
-
bag.authInfo = result;
|
|
1714
|
-
return next();
|
|
1715
|
-
};
|
|
1716
|
-
}
|
|
1717
|
-
const mcpRouteHandler = (request) => protectWithBearer(request, () => mcpFetch(request));
|
|
1718
|
-
const endpointHandler = async (request) => {
|
|
1719
|
-
if (!isHtmlNavigationRequest(request)) {
|
|
1720
|
-
return mcpRouteHandler(request);
|
|
1721
|
-
}
|
|
1722
|
-
const respond = async () => {
|
|
1723
|
-
const { createLandingPageResponse } = await import("./landing-handler-VQRYCQOV.js");
|
|
1724
|
-
return createLandingPageResponse(
|
|
1725
|
-
request,
|
|
1726
|
-
basePath,
|
|
1727
|
-
this.#config,
|
|
1728
|
-
this.#tools.values(),
|
|
1729
|
-
this.#prompts.values(),
|
|
1730
|
-
this.#resources.values()
|
|
1731
|
-
);
|
|
1732
|
-
};
|
|
1733
|
-
if (resource !== void 0 && this.#config.publicLandingPage !== true) {
|
|
1734
|
-
return protectWithBearer(request, respond);
|
|
1735
|
-
}
|
|
1736
|
-
return respond();
|
|
1737
|
-
};
|
|
1738
|
-
const routes = [];
|
|
1739
|
-
const viewHandler = createViewPublicHandler(basePath, this.#views, {
|
|
1740
|
-
dev: this.#viewsDevMode,
|
|
1741
|
-
projectRoot: this.#viewsProjectRoot,
|
|
1742
|
-
deferCors: deferViewCors
|
|
1743
|
-
});
|
|
1744
|
-
if (viewHandler !== void 0) {
|
|
1745
|
-
routes.push({
|
|
1746
|
-
match: (request) => request.method === "GET" || request.method === "HEAD" ? new URL(request.url).pathname.startsWith(
|
|
1747
|
-
`${nestedBasePath}/_mcp-use/public/`
|
|
1748
|
-
) : false,
|
|
1749
|
-
handler: viewHandler
|
|
1750
|
-
});
|
|
1751
|
-
}
|
|
1752
|
-
if (!this.#viewsDevMode) {
|
|
1753
|
-
const viewAssetsHandler = createViewAssetsHandler(
|
|
1754
|
-
basePath,
|
|
1755
|
-
this.#views,
|
|
1756
|
-
{ projectRoot: this.#viewsProjectRoot, deferCors: deferViewCors }
|
|
1757
|
-
);
|
|
1758
|
-
if (viewAssetsHandler !== void 0) {
|
|
1759
|
-
routes.push({
|
|
1760
|
-
match: (request) => request.method === "GET" || request.method === "HEAD" ? new URL(request.url).pathname.startsWith(
|
|
1761
|
-
`${nestedBasePath}/_mcp-use/views/`
|
|
1762
|
-
) : false,
|
|
1763
|
-
handler: viewAssetsHandler
|
|
1764
|
-
});
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
const inspectorHandler = createInspectorHandler(this.#config.inspector, {
|
|
1768
|
-
serverName: this.#config.name,
|
|
1769
|
-
basePath
|
|
1770
|
-
});
|
|
1771
|
-
if (inspectorHandler !== void 0) {
|
|
1772
|
-
routes.push({
|
|
1773
|
-
match: (request) => {
|
|
1774
|
-
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
1775
|
-
return false;
|
|
1776
|
-
}
|
|
1777
|
-
const pathname = new URL(request.url).pathname;
|
|
1778
|
-
return matchesInspectorShellPath(pathname, basePath);
|
|
1779
|
-
},
|
|
1780
|
-
handler: inspectorHandler
|
|
1781
|
-
});
|
|
1782
|
-
}
|
|
1783
|
-
routes.push({
|
|
1784
|
-
match: (request) => matchesPath(request, basePath),
|
|
1785
|
-
handler: endpointHandler
|
|
1786
|
-
});
|
|
1787
|
-
const terminal = routeFetch(routes);
|
|
1788
|
-
this.#fetchHandler = composeFetch(terminal, ...middlewares);
|
|
1789
|
-
this.#handler = handler;
|
|
1790
|
-
this.#hostValidated = hosts !== void 0;
|
|
1791
|
-
} else if (bus !== void 0 && this.#handler.bus !== bus) {
|
|
1792
|
-
throw new Error(
|
|
1793
|
-
"Cannot change the MCP event bus after the server has started."
|
|
1794
|
-
);
|
|
1795
|
-
} else if (mode === "listen" && !this.#hostValidated && this.#validationPolicy("listen").hosts !== void 0) {
|
|
1796
|
-
throw new Error(
|
|
1797
|
-
"Cannot listen() on a localhost bind after getHandler(): the app is already mounted without Host validation (getHandler() expects a platform edge in front). Call listen() first, or set allowedHosts."
|
|
1798
|
-
);
|
|
1799
|
-
}
|
|
1800
|
-
return { fetch: this.#fetchHandler, handler: this.#handler };
|
|
1801
|
-
}
|
|
1802
|
-
#validateToolViewBinding(definition) {
|
|
1803
|
-
const view = definition.view;
|
|
1804
|
-
if (view === void 0) {
|
|
1805
|
-
return;
|
|
1806
|
-
}
|
|
1807
|
-
if (definition.outputSchema === void 0) {
|
|
1808
|
-
throw new Error(
|
|
1809
|
-
`Tool "${definition.name}" declares view "${view.name}" but has no outputSchema. View-bound tools require an outputSchema \u2014 the view reads structuredContent typed from it. Use outputSchema: z.object({}) for a view that takes no structured output.`
|
|
1810
|
-
);
|
|
1811
|
-
}
|
|
1812
|
-
const existing = this.#viewBindings.get(view.name);
|
|
1813
|
-
if (existing !== void 0) {
|
|
1814
|
-
throw new Error(
|
|
1815
|
-
`View "${view.name}" is already bound to tool "${existing.toolName}"; tool "${definition.name}" cannot bind the same view. Each view may be bound to one tool.`
|
|
1816
|
-
);
|
|
1817
|
-
}
|
|
1818
|
-
this.#viewBindings.set(view.name, {
|
|
1819
|
-
toolName: definition.name,
|
|
1820
|
-
config: view
|
|
1821
|
-
});
|
|
1822
|
-
}
|
|
1823
|
-
#validateViewBindingsAtMount() {
|
|
1824
|
-
if (this.#viewBindings.size > 0 && !this.#viewsPrimed) {
|
|
1825
|
-
const first = [...this.#tools.values()].find(
|
|
1826
|
-
(entry) => entry.definition.view !== void 0
|
|
1827
|
-
);
|
|
1828
|
-
const viewName = first?.definition.view?.name ?? "unknown";
|
|
1829
|
-
throw new Error(
|
|
1830
|
-
`Tool "${first?.definition.name ?? "unknown"}" is bound to view "${viewName}" but no views were primed. Run \`mcp-use build\` and deploy the built entry, or in dev let the CLI prime views automatically.`
|
|
1831
|
-
);
|
|
1832
|
-
}
|
|
1833
|
-
for (const entry of this.#tools.values()) {
|
|
1834
|
-
const viewName = entry.definition.view?.name;
|
|
1835
|
-
if (viewName !== void 0 && !this.#views.has(viewName)) {
|
|
1836
|
-
throw new Error(
|
|
1837
|
-
`Tool "${entry.definition.name}" is bound to view "${viewName}" which is not in the primed views registry. Run \`mcp-use build\` and deploy the built entry, or in dev let the CLI prime views automatically.`
|
|
1838
|
-
);
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
for (const viewName of this.#views.keys()) {
|
|
1842
|
-
if (!this.#viewBindings.has(viewName)) {
|
|
1843
|
-
console.warn(
|
|
1844
|
-
`[mcp-use] View "${viewName}" is registered but no tool binds it.`
|
|
1845
|
-
);
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
/** Build a fresh SDK server from the registry (runs once per request). */
|
|
1850
|
-
#buildSdkServer(ctx) {
|
|
1851
|
-
const { name, version, title, description, instructions } = this.#config;
|
|
1852
|
-
const authInfo = ctx.authInfo;
|
|
1853
|
-
const server = new SdkMcpServer(
|
|
1854
|
-
{
|
|
1855
|
-
name,
|
|
1856
|
-
version,
|
|
1857
|
-
...title !== void 0 && { title },
|
|
1858
|
-
...description !== void 0 && { description }
|
|
1859
|
-
},
|
|
1860
|
-
{
|
|
1861
|
-
capabilities: {
|
|
1862
|
-
tools: { listChanged: true },
|
|
1863
|
-
prompts: { listChanged: true },
|
|
1864
|
-
resources: { listChanged: true, subscribe: true }
|
|
1865
|
-
},
|
|
1866
|
-
...instructions !== void 0 && { instructions },
|
|
1867
|
-
...authInfo !== void 0 && { authInfo },
|
|
1868
|
-
...this.#config.requestState !== void 0 && {
|
|
1869
|
-
requestState: this.#config.requestState
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
);
|
|
1873
|
-
const request = ctx.requestInfo;
|
|
1874
|
-
const viewMetaOptions = request !== void 0 ? { request, hmrWs: this.#viewsDevMode } : { hmrWs: this.#viewsDevMode };
|
|
1875
|
-
const basePath = this.#basePath();
|
|
1876
|
-
for (const entry of this.#tools.values()) {
|
|
1877
|
-
this.#registerTool(server, entry);
|
|
1878
|
-
}
|
|
1879
|
-
for (const entry of this.#resources.values()) {
|
|
1880
|
-
this.#registerResource(server, entry);
|
|
1881
|
-
}
|
|
1882
|
-
for (const entry of this.#resourceTemplates.values()) {
|
|
1883
|
-
this.#registerResourceTemplate(server, entry);
|
|
1884
|
-
}
|
|
1885
|
-
for (const entry of this.#prompts.values()) {
|
|
1886
|
-
this.#registerPrompt(server, entry);
|
|
1887
|
-
}
|
|
1888
|
-
for (const [viewName, viewEntry] of this.#views.entries()) {
|
|
1889
|
-
this.#registerViewResource(
|
|
1890
|
-
server,
|
|
1891
|
-
viewName,
|
|
1892
|
-
viewEntry,
|
|
1893
|
-
viewMetaOptions,
|
|
1894
|
-
basePath
|
|
1895
|
-
);
|
|
1896
|
-
}
|
|
1897
|
-
this.#wrapListHandlers(server);
|
|
1898
|
-
return server;
|
|
1899
|
-
}
|
|
1900
|
-
#createMiddlewareContext(method, params, ctx) {
|
|
1901
|
-
return {
|
|
1902
|
-
method,
|
|
1903
|
-
params,
|
|
1904
|
-
...ctx.http?.authInfo !== void 0 && { auth: ctx.http.authInfo },
|
|
1905
|
-
state: /* @__PURE__ */ new Map()
|
|
1906
|
-
};
|
|
1907
|
-
}
|
|
1908
|
-
#runMcpHook(method, ctx, innerFn) {
|
|
1909
|
-
return runMcpOperation(
|
|
1910
|
-
this.#mcpMiddlewares,
|
|
1911
|
-
this.#mcpEventListeners,
|
|
1912
|
-
method,
|
|
1913
|
-
ctx,
|
|
1914
|
-
innerFn
|
|
1915
|
-
);
|
|
1916
|
-
}
|
|
1917
|
-
/**
|
|
1918
|
-
* Wrap native SDK list handlers with the MCP middleware chain.
|
|
1919
|
-
*
|
|
1920
|
-
* ponytail: uses SDK-private `_requestHandlers`; pin compile-time test.
|
|
1921
|
-
*
|
|
1922
|
-
* @internal
|
|
1923
|
-
*/
|
|
1924
|
-
#wrapListHandlers(server) {
|
|
1925
|
-
const handlers = server.server._requestHandlers;
|
|
1926
|
-
if (handlers === void 0) {
|
|
1927
|
-
return;
|
|
1928
|
-
}
|
|
1929
|
-
const wrapListMethod = (method, resultKey) => {
|
|
1930
|
-
const original = handlers.get(method);
|
|
1931
|
-
if (original === void 0) {
|
|
1932
|
-
return;
|
|
1933
|
-
}
|
|
1934
|
-
if (original.__mcpListWrapped) {
|
|
1935
|
-
return;
|
|
1936
|
-
}
|
|
1937
|
-
const wrapped = async (request, extra) => {
|
|
1938
|
-
const authInfo = extra?.http?.authInfo;
|
|
1939
|
-
const mwCtx = {
|
|
1940
|
-
method,
|
|
1941
|
-
params: {},
|
|
1942
|
-
...authInfo !== void 0 && { auth: authInfo },
|
|
1943
|
-
state: /* @__PURE__ */ new Map()
|
|
1944
|
-
};
|
|
1945
|
-
const innerFn = async () => {
|
|
1946
|
-
const result = await original(request, extra);
|
|
1947
|
-
return result[resultKey] ?? result;
|
|
1948
|
-
};
|
|
1949
|
-
const filtered = await this.#runMcpHook(method, mwCtx, innerFn);
|
|
1950
|
-
if (Array.isArray(filtered)) {
|
|
1951
|
-
return { [resultKey]: filtered };
|
|
1952
|
-
}
|
|
1953
|
-
return filtered;
|
|
1954
|
-
};
|
|
1955
|
-
wrapped.__mcpListWrapped = true;
|
|
1956
|
-
handlers.set(method, wrapped);
|
|
1957
|
-
};
|
|
1958
|
-
wrapListMethod("tools/list", "tools");
|
|
1959
|
-
wrapListMethod("resources/list", "resources");
|
|
1960
|
-
wrapListMethod("prompts/list", "prompts");
|
|
1961
|
-
}
|
|
1962
|
-
#registerTool(server, { definition, callback }) {
|
|
1963
|
-
const view = definition.view;
|
|
1964
|
-
const toolMeta = buildToolUiMeta(
|
|
1965
|
-
view?.name,
|
|
1966
|
-
definition.visibility,
|
|
1967
|
-
definition._meta
|
|
1968
|
-
);
|
|
1969
|
-
const config = {
|
|
1970
|
-
...definition.title !== void 0 && { title: definition.title },
|
|
1971
|
-
...definition.description !== void 0 && {
|
|
1972
|
-
description: definition.description
|
|
1973
|
-
},
|
|
1974
|
-
...definition.annotations !== void 0 && {
|
|
1975
|
-
annotations: definition.annotations
|
|
1976
|
-
},
|
|
1977
|
-
...definition.outputSchema !== void 0 && {
|
|
1978
|
-
outputSchema: definition.outputSchema
|
|
1979
|
-
},
|
|
1980
|
-
...toolMeta !== void 0 && { _meta: toolMeta }
|
|
1981
|
-
};
|
|
1982
|
-
const wireResultMeta = view !== void 0 ? buildToolResultUiMeta(view.name) : void 0;
|
|
1983
|
-
const inputSchema = resolveToolInputSchema(definition);
|
|
1984
|
-
const invokeTool = async (args, ctx) => {
|
|
1985
|
-
const mwCtx = this.#createMiddlewareContext(
|
|
1986
|
-
"tools/call",
|
|
1987
|
-
{ name: definition.name, arguments: args },
|
|
1988
|
-
ctx
|
|
1989
|
-
);
|
|
1990
|
-
const innerFn = async () => {
|
|
1991
|
-
const effectiveArgs = mwCtx.params.arguments ?? {};
|
|
1992
|
-
const result = await callback(
|
|
1993
|
-
effectiveArgs,
|
|
1994
|
-
this.#toRequestContext(ctx)
|
|
1995
|
-
);
|
|
1996
|
-
if (isInputRequiredResult(result) || wireResultMeta === void 0 || result.isError === true) {
|
|
1997
|
-
return result;
|
|
1998
|
-
}
|
|
1999
|
-
return {
|
|
2000
|
-
...result,
|
|
2001
|
-
_meta: { ...result._meta, ...wireResultMeta }
|
|
2002
|
-
};
|
|
2003
|
-
};
|
|
2004
|
-
return await this.#runMcpHook("tools/call", mwCtx, innerFn);
|
|
2005
|
-
};
|
|
2006
|
-
if (inputSchema !== void 0) {
|
|
2007
|
-
server.registerTool(
|
|
2008
|
-
definition.name,
|
|
2009
|
-
{ ...config, inputSchema },
|
|
2010
|
-
async (args, ctx) => invokeTool(args, ctx)
|
|
2011
|
-
);
|
|
2012
|
-
} else {
|
|
2013
|
-
server.registerTool(
|
|
2014
|
-
definition.name,
|
|
2015
|
-
config,
|
|
2016
|
-
async (ctx) => invokeTool({}, ctx)
|
|
2017
|
-
);
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2020
|
-
#registerViewResource(server, viewName, entry, metaOptions, basePath) {
|
|
2021
|
-
const uri = viewResourceUri(viewName);
|
|
2022
|
-
const authorFacts = this.#viewResourceFacts(
|
|
2023
|
-
this.#viewBindings.get(viewName)?.config
|
|
2024
|
-
);
|
|
2025
|
-
const resourceConfig = viewResourceConfig(
|
|
2026
|
-
viewName,
|
|
2027
|
-
entry,
|
|
2028
|
-
authorFacts,
|
|
2029
|
-
metaOptions
|
|
2030
|
-
);
|
|
2031
|
-
server.registerResource(
|
|
2032
|
-
viewName,
|
|
2033
|
-
uri,
|
|
2034
|
-
resourceConfig,
|
|
2035
|
-
async (readUri, ctx) => {
|
|
2036
|
-
const req = ctx.http?.req;
|
|
2037
|
-
const readOptions = req !== void 0 ? {
|
|
2038
|
-
request: req,
|
|
2039
|
-
...metaOptions.hmrWs === true ? { hmrWs: true } : {}
|
|
2040
|
-
} : metaOptions.hmrWs === true ? { hmrWs: true } : {};
|
|
2041
|
-
const assetsBase = req !== void 0 ? resolveAssetsBase(req) : metaOptions.request !== void 0 ? resolveAssetsBase(metaOptions.request) : "";
|
|
2042
|
-
const html = synthesizeViewDocument(
|
|
2043
|
-
entry,
|
|
2044
|
-
assetsBase,
|
|
2045
|
-
basePath,
|
|
2046
|
-
viewName
|
|
2047
|
-
);
|
|
2048
|
-
return {
|
|
2049
|
-
contents: [
|
|
2050
|
-
{
|
|
2051
|
-
uri: readUri.href,
|
|
2052
|
-
mimeType: resourceConfig.mimeType,
|
|
2053
|
-
text: html,
|
|
2054
|
-
_meta: buildResourceUiMeta(authorFacts, readOptions)
|
|
2055
|
-
}
|
|
2056
|
-
]
|
|
2057
|
-
};
|
|
2058
|
-
}
|
|
2059
|
-
);
|
|
2060
|
-
}
|
|
2061
|
-
#registerResource(server, { definition, callback }) {
|
|
2062
|
-
server.registerResource(
|
|
2063
|
-
definition.name,
|
|
2064
|
-
definition.uri,
|
|
2065
|
-
{
|
|
2066
|
-
...definition.title !== void 0 && { title: definition.title },
|
|
2067
|
-
...definition.description !== void 0 && {
|
|
2068
|
-
description: definition.description
|
|
2069
|
-
},
|
|
2070
|
-
...definition.mimeType !== void 0 && {
|
|
2071
|
-
mimeType: definition.mimeType
|
|
2072
|
-
},
|
|
2073
|
-
...definition.annotations !== void 0 && {
|
|
2074
|
-
annotations: definition.annotations
|
|
2075
|
-
},
|
|
2076
|
-
...definition._meta !== void 0 && {
|
|
2077
|
-
_meta: { ...definition._meta }
|
|
2078
|
-
}
|
|
2079
|
-
},
|
|
2080
|
-
async (uri, ctx) => {
|
|
2081
|
-
const mwCtx = this.#createMiddlewareContext(
|
|
2082
|
-
"resources/read",
|
|
2083
|
-
{ uri: uri.href },
|
|
2084
|
-
ctx
|
|
2085
|
-
);
|
|
2086
|
-
const innerFn = async () => callback(uri, this.#toRequestContext(ctx));
|
|
2087
|
-
return await this.#runMcpHook(
|
|
2088
|
-
"resources/read",
|
|
2089
|
-
mwCtx,
|
|
2090
|
-
innerFn
|
|
2091
|
-
);
|
|
2092
|
-
}
|
|
2093
|
-
);
|
|
2094
|
-
}
|
|
2095
|
-
#registerResourceTemplate(server, { definition, callback, complete }) {
|
|
2096
|
-
const template = new ResourceTemplate(definition.uriTemplate, {
|
|
2097
|
-
list: void 0,
|
|
2098
|
-
...complete !== void 0 && { complete }
|
|
2099
|
-
});
|
|
2100
|
-
server.registerResource(
|
|
2101
|
-
definition.name,
|
|
2102
|
-
template,
|
|
2103
|
-
{
|
|
2104
|
-
...definition.title !== void 0 && { title: definition.title },
|
|
2105
|
-
...definition.description !== void 0 && {
|
|
2106
|
-
description: definition.description
|
|
2107
|
-
},
|
|
2108
|
-
...definition.mimeType !== void 0 && {
|
|
2109
|
-
mimeType: definition.mimeType
|
|
2110
|
-
},
|
|
2111
|
-
...definition.annotations !== void 0 && {
|
|
2112
|
-
annotations: definition.annotations
|
|
2113
|
-
},
|
|
2114
|
-
...definition._meta !== void 0 && {
|
|
2115
|
-
_meta: { ...definition._meta }
|
|
2116
|
-
}
|
|
2117
|
-
},
|
|
2118
|
-
async (uri, variables, ctx) => {
|
|
2119
|
-
const mwCtx = this.#createMiddlewareContext(
|
|
2120
|
-
"resources/read",
|
|
2121
|
-
{ uri: uri.href },
|
|
2122
|
-
ctx
|
|
2123
|
-
);
|
|
2124
|
-
const innerFn = async () => callback(
|
|
2125
|
-
uri,
|
|
2126
|
-
variables,
|
|
2127
|
-
this.#toRequestContext(ctx)
|
|
2128
|
-
);
|
|
2129
|
-
return await this.#runMcpHook(
|
|
2130
|
-
"resources/read",
|
|
2131
|
-
mwCtx,
|
|
2132
|
-
innerFn
|
|
2133
|
-
);
|
|
2134
|
-
}
|
|
2135
|
-
);
|
|
2136
|
-
}
|
|
2137
|
-
#viewResourceFacts(viewConfig) {
|
|
2138
|
-
if (viewConfig === void 0) {
|
|
2139
|
-
return void 0;
|
|
2140
|
-
}
|
|
2141
|
-
return {
|
|
2142
|
-
...viewConfig.description !== void 0 && {
|
|
2143
|
-
description: viewConfig.description
|
|
2144
|
-
},
|
|
2145
|
-
...viewConfig.csp !== void 0 && { csp: viewConfig.csp },
|
|
2146
|
-
...viewConfig.permissions !== void 0 && {
|
|
2147
|
-
permissions: viewConfig.permissions
|
|
2148
|
-
},
|
|
2149
|
-
...viewConfig.domain !== void 0 && { domain: viewConfig.domain },
|
|
2150
|
-
...viewConfig.prefersBorder !== void 0 && {
|
|
2151
|
-
prefersBorder: viewConfig.prefersBorder
|
|
2152
|
-
}
|
|
2153
|
-
};
|
|
2154
|
-
}
|
|
2155
|
-
#registerPrompt(server, { definition, callback }) {
|
|
2156
|
-
const config = {
|
|
2157
|
-
...definition.title !== void 0 && { title: definition.title },
|
|
2158
|
-
...definition.description !== void 0 && {
|
|
2159
|
-
description: definition.description
|
|
2160
|
-
}
|
|
2161
|
-
};
|
|
2162
|
-
const invokePrompt = async (args, ctx) => {
|
|
2163
|
-
const mwCtx = this.#createMiddlewareContext(
|
|
2164
|
-
"prompts/get",
|
|
2165
|
-
{ name: definition.name, arguments: args },
|
|
2166
|
-
ctx
|
|
2167
|
-
);
|
|
2168
|
-
const innerFn = async () => {
|
|
2169
|
-
const effectiveArgs = mwCtx.params.arguments ?? {};
|
|
2170
|
-
return callback(effectiveArgs, this.#toRequestContext(ctx));
|
|
2171
|
-
};
|
|
2172
|
-
return await this.#runMcpHook("prompts/get", mwCtx, innerFn);
|
|
2173
|
-
};
|
|
2174
|
-
if (definition.schema !== void 0) {
|
|
2175
|
-
server.registerPrompt(
|
|
2176
|
-
definition.name,
|
|
2177
|
-
{ ...config, argsSchema: definition.schema },
|
|
2178
|
-
async (args, ctx) => invokePrompt(args, ctx)
|
|
2179
|
-
);
|
|
2180
|
-
} else {
|
|
2181
|
-
const handler = async (ctx) => invokePrompt({}, ctx);
|
|
2182
|
-
server.registerPrompt(
|
|
2183
|
-
definition.name,
|
|
2184
|
-
config,
|
|
2185
|
-
handler
|
|
2186
|
-
);
|
|
2187
|
-
}
|
|
2188
|
-
}
|
|
2189
|
-
#toRequestContext(ctx) {
|
|
2190
|
-
if (this.#config.oauth === void 0) {
|
|
2191
|
-
return toRequestContext(ctx);
|
|
2192
|
-
}
|
|
2193
|
-
return toAuthenticatedRequestContext(ctx);
|
|
2194
|
-
}
|
|
2195
|
-
};
|
|
2196
|
-
|
|
2197
|
-
// src/index.ts
|
|
2198
|
-
import {
|
|
2199
|
-
acceptedContent,
|
|
2200
|
-
createRequestStateCodec,
|
|
2201
|
-
inputRequired as inputRequired2,
|
|
2202
|
-
inputResponse as inputResponse2,
|
|
2203
|
-
isInputRequiredResult as isInputRequiredResult2
|
|
2204
|
-
} from "@modelcontextprotocol/server";
|
|
2205
|
-
export {
|
|
2206
|
-
MCPServer,
|
|
2207
|
-
acceptedContent,
|
|
2208
|
-
completable,
|
|
2209
|
-
composeFetch,
|
|
2210
|
-
composeMiddleware,
|
|
2211
|
-
createMcpMount,
|
|
2212
|
-
createRequestStateCodec,
|
|
2213
|
-
getRequestBag,
|
|
2214
|
-
hostValidationMiddleware,
|
|
2215
|
-
inputRequired2 as inputRequired,
|
|
2216
|
-
inputResponse2 as inputResponse,
|
|
2217
|
-
isInputRequiredResult2 as isInputRequiredResult,
|
|
2218
|
-
jsonBodyMiddleware,
|
|
2219
|
-
matchesPath,
|
|
2220
|
-
matchesPathPrefix,
|
|
2221
|
-
matchesPattern,
|
|
2222
|
-
originValidationMiddleware,
|
|
2223
|
-
pathnameOf,
|
|
2224
|
-
registerViews,
|
|
2225
|
-
requestLogger,
|
|
2226
|
-
routeFetch,
|
|
2227
|
-
toFrameworkHandler
|
|
2228
|
-
};
|
|
2229
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{resolvePublicFilePath,servePublicFile}from"./chunk-ZMU5USAZ.js";import{hasExplicitAssetsBase,originFromAssetsBase,resolveAssetsBase,resolveServerOrigin}from"./chunk-PSKSL567.js";import{registerOpenAPITools}from"./chunk-Y26DNVWA.js";import{completable,normalizeCompletions}from"./chunk-OJF6B5EU.js";import{isUsageDisabled,recordUsage}from"./chunk-273ZVKJJ.js";import{inheritBufferedResponse,toNodeHandler,trackBufferedResponse}from"./chunk-XYHHP43G.js";import{authInfoFromRequest,composeFetch,getOAuthProtectedResourceMetadataUrl,getRequestBag,hostValidationMiddleware,isHtmlNavigationRequest,jsonBodyMiddleware,matchesPath,matchesPathPrefix,oauthMetadata,originValidationMiddleware,pathUnderBase,pathnameOf,requireBearerAuth}from"./chunk-MIZQEWZS.js";import{getOAuthProviderOptions,resolveConfiguredOAuthResource,resolveLocalOAuthResource,wrapOAuthTokenVerifier}from"./chunk-IS7FKXFR.js";import{localhostAllowedHostnames,localhostAllowedOrigins,McpServer as SdkMcpServer,ResourceTemplate,CLIENT_CAPABILITIES_META_KEY as CLIENT_CAPABILITIES_META_KEY3,CLIENT_INFO_META_KEY as CLIENT_INFO_META_KEY3,PROTOCOL_VERSION_META_KEY,isJSONRPCRequest as isJSONRPCRequest2,isInputRequiredResult as isInputRequiredResult2}from"@modelcontextprotocol/server";import{createServer as createNodeHttpServer}from"#mcp-use-node-http";import{Hono}from"hono";var FAVICON_CACHE_CONTROL="public, max-age=31536000, immutable",FAVICON_REDIRECT_CACHE_CONTROL="public, max-age=300";function protocolOf(value){return/^([a-z][a-z\d+.-]*):/i.exec(value)?.[1]?.toLowerCase()}function publicAssetPath(basePath,source){return`${basePath==="/"?"":basePath}/_mcp-use/public/${source.split("/").map(segment=>encodeURIComponent(segment)).join("/")}`}function isLocalPublicSource(source){return protocolOf(source)===void 0}function selectFaviconFromIcons(icons){return icons[0]}function assertLocalPublicSource(source,field){if(source.startsWith("/")||source.includes("\\")||source.includes("?")||source.includes("#")||source.split("/").some(segment=>segment===""||segment===".."))throw new TypeError(`${field} must be an http(s) URL, image data URL, or safe path relative to public/`)}function parseDataImage(source,field){let comma=source.indexOf(",");if(comma<0)throw new TypeError(`${field} must be a valid image data URL`);let metadata=source.slice(5,comma),payload=source.slice(comma+1),parts=metadata.split(";"),mimeType=parts[0]?.toLowerCase()??"";if(!mimeType.startsWith("image/"))throw new TypeError(`${field} data URL must use an image MIME type`);try{if(parts.includes("base64")){let binary2=atob(payload);return{mimeType,bytes:Uint8Array.from(binary2,character=>character.charCodeAt(0))}}return{mimeType,bytes:new TextEncoder().encode(decodeURIComponent(payload))}}catch{throw new TypeError(`${field} must be a valid image data URL`)}}function assertBrandingSource(source,field){if(typeof source!="string"||source.length===0)throw new TypeError(`${field} must be a non-empty string`);let protocol=protocolOf(source);if(protocol===void 0)return assertLocalPublicSource(source,field),source;if(protocol==="data")return parseDataImage(source,field),source;if(protocol!=="http"&&protocol!=="https")throw new TypeError(`${field} must be an http(s) URL, image data URL, or safe path relative to public/`);try{new URL(source)}catch{throw new TypeError(`${field} must be a valid absolute http(s) URL`)}return source}function normalizeServerBranding(config){let websiteUrl;if(config.websiteUrl!==void 0){if(typeof config.websiteUrl!="string"||config.websiteUrl.length===0)throw new TypeError("websiteUrl must be a non-empty absolute http(s) URL");let parsed;try{parsed=new URL(config.websiteUrl)}catch{throw new TypeError("websiteUrl must be a non-empty absolute http(s) URL")}if(parsed.protocol!=="http:"&&parsed.protocol!=="https:")throw new TypeError("websiteUrl must be a non-empty absolute http(s) URL");websiteUrl=config.websiteUrl}let icons;if(config.icons!==void 0){if(!Array.isArray(config.icons))throw new TypeError("icons must be an array of MCP Icon objects");icons=Object.freeze(config.icons.map((value,index)=>{if(typeof value!="object"||value===null)throw new TypeError(`icons[${index}] must be an MCP Icon object`);let icon=value,src=assertBrandingSource(icon.src,`icons[${index}].src`),mimeType=icon.mimeType;if(mimeType!==void 0&&(typeof mimeType!="string"||!mimeType.toLowerCase().startsWith("image/")))throw new TypeError(`icons[${index}].mimeType must be an image MIME type when provided`);let sizes=icon.sizes;if(sizes!==void 0&&(!Array.isArray(sizes)||sizes.some(size=>typeof size!="string"||size.length===0)))throw new TypeError(`icons[${index}].sizes must be an array of non-empty strings when provided`);let normalizedSizes=sizes===void 0?void 0:sizes.map(size=>size),theme=icon.theme;if(theme!==void 0&&theme!=="light"&&theme!=="dark")throw new TypeError(`icons[${index}].theme must be "light" or "dark" when provided`);return Object.freeze({src,...mimeType!==void 0&&{mimeType},...normalizedSizes!==void 0&&{sizes:Object.freeze(normalizedSizes)},...theme!==void 0&&{theme}})}))}let explicitFavicon=config.favicon===void 0?void 0:assertBrandingSource(config.favicon,"favicon"),inferred=explicitFavicon===void 0?selectFaviconFromIcons(icons??[]):void 0,favicon=explicitFavicon??inferred?.src,faviconMimeType=inferred?.mimeType??icons?.find(icon=>icon.src===explicitFavicon)?.mimeType;return Object.freeze({...favicon!==void 0&&{favicon},...faviconMimeType!==void 0&&{faviconMimeType},...icons!==void 0&&{icons},...websiteUrl!==void 0&&{websiteUrl}})}function resolveImplementationIcons(icons,request,basePath){if(icons!==void 0)return icons.map(icon=>({...icon,src:request!==void 0&&isLocalPublicSource(icon.src)?`${resolveAssetsBase(request)}${publicAssetPath(basePath,icon.src)}`:icon.src,...icon.sizes!==void 0&&{sizes:[...icon.sizes]}}))}function hasLocalBrandingAsset(branding){return branding.favicon!==void 0&&isLocalPublicSource(branding.favicon)||branding.icons?.some(icon=>isLocalPublicSource(icon.src))===!0}function createFaviconHandler(branding,options){let source=branding.favicon;if(source!==void 0)return async request=>{if(request.method!=="GET"&&request.method!=="HEAD")return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});if(new URL(request.url).pathname!=="/favicon.ico")return new Response("Not Found",{status:404});let protocol=protocolOf(source);if(protocol==="http"||protocol==="https")return new Response(null,{status:307,headers:{Location:source,"Cache-Control":FAVICON_REDIRECT_CACHE_CONTROL}});if(protocol==="data"){let data=parseDataImage(source,"favicon");return new Response(request.method==="HEAD"?null:data.bytes.buffer,{status:200,headers:{"Content-Type":branding.faviconMimeType??data.mimeType,"Cache-Control":FAVICON_CACHE_CONTROL,"X-Content-Type-Options":"nosniff"}})}let{join}=await import("path"),publicRoot=options.dev?join(options.projectRoot,"public"):join(options.projectRoot,".mcp-use/build/views/public"),diskPath=await resolvePublicFilePath(publicRoot,source);if(diskPath===null)return new Response("Not Found",{status:404,headers:{"Cache-Control":"no-store"}});let response=await servePublicFile(diskPath,{...options.deferCors===!0&&{deferCors:!0},...request.method==="HEAD"&&{head:!0}});return response.headers.set("Cache-Control",FAVICON_CACHE_CONTROL),response.headers.set("X-Content-Type-Options","nosniff"),branding.faviconMimeType!==void 0&&response.headers.set("Content-Type",branding.faviconMimeType),response}}function assertServerConfig(config){if(config.basePath!==void 0){if(typeof config.basePath!="string")throw new TypeError("basePath must be an absolute URL pathname without empty segments, trailing slash, query, fragment, or whitespace");let{basePath}=config;if(!basePath.startsWith("/")||basePath.includes("?")||basePath.includes("#")||/\s/.test(basePath)||basePath.includes("//")||basePath.length>1&&basePath.endsWith("/"))throw new TypeError("basePath must be an absolute URL pathname without empty segments, trailing slash, query, fragment, or whitespace")}if(config.port!==void 0&&(typeof config.port!="number"||!Number.isInteger(config.port)||config.port<0||config.port>65535))throw new TypeError("port must be an integer between 0 and 65535")}var DEFAULT_LISTEN_HOST="127.0.0.1";function resolveListenHost(explicitHost,configuredHost,env=process.env){if(explicitHost!==void 0)return explicitHost;let envHost=env.HOST?.trim();return envHost!==void 0&&envHost!==""?envHost:configuredHost??DEFAULT_LISTEN_HOST}function resolveListenPort(explicitPort,configuredPort,env=process.env){if(explicitPort!==void 0)return explicitPort;let envPort=parsePort(env.PORT);return envPort!==void 0?envPort:configuredPort??3e3}function parsePort(value){if(value===void 0||value.trim()==="")return;let port=Number(value);return Number.isInteger(port)&&port>=0&&port<=65535?port:void 0}import{CLIENT_CAPABILITIES_META_KEY as CLIENT_CAPABILITIES_META_KEY2,CLIENT_INFO_META_KEY}from"@modelcontextprotocol/server";import{HonoRequest}from"hono/request";import{CLIENT_CAPABILITIES_META_KEY}from"@modelcontextprotocol/server";var UI_EXTENSION_ID="io.modelcontextprotocol/ui",UI_MIME_TYPE="text/html;profile=mcp-app",UI_RESOURCE_URI_PREFIX="ui://views/";var UI_RESOURCE_URI_META_KEY="ui/resourceUri";function viewResourceUri(viewName){return`${UI_RESOURCE_URI_PREFIX}${viewName}.html`}var clientCapabilitiesByRequest=new WeakMap;function stashClientCapabilities(request,capabilities){clientCapabilitiesByRequest.set(request,capabilities)}function extractClientCapabilitiesFromBody(body){if(typeof body!="object"||body===null)return;let params=body.params;if(typeof params!="object"||params===null)return;let meta=params._meta;if(typeof meta!="object"||meta===null)return;let capabilities=meta[CLIENT_CAPABILITIES_META_KEY];if(!(typeof capabilities!="object"||capabilities===null))return capabilities}function supportsViews(capabilities){let extensions=capabilities?.extensions;if(extensions===void 0)return!1;let uiExtension=extensions[UI_EXTENSION_ID];if(typeof uiExtension!="object"||uiExtension===null)return!1;let mimeTypes=uiExtension.mimeTypes;return Array.isArray(mimeTypes)?mimeTypes.includes(UI_MIME_TYPE):!1}function requireOAuthAuthInfo(authInfo){if(authInfo===void 0||authInfo.extra===void 0||authInfo.expiresAt===void 0)throw new Error("OAuth callback did not receive mapped AuthInfo.extra")}function stringValue(value){return typeof value=="string"?value:void 0}function coordinateValue(value){return typeof value=="string"||typeof value=="number"&&Number.isFinite(value)?value:void 0}function normalizeUserContext(meta){if(meta===void 0)return;let locale=stringValue(meta["openai/locale"])??stringValue(meta["webplus/i18n"]),userAgent=stringValue(meta["openai/userAgent"]),subject=stringValue(meta["openai/subject"]),conversationId=stringValue(meta["openai/session"]),organizationId=stringValue(meta["openai/organization"]),rawLocation=meta["openai/userLocation"],location;if(typeof rawLocation=="object"&&rawLocation!==null&&!Array.isArray(rawLocation)){let values=rawLocation,normalized={city:stringValue(values.city),region:stringValue(values.region),country:stringValue(values.country),timezone:stringValue(values.timezone),latitude:coordinateValue(values.latitude),longitude:coordinateValue(values.longitude)},entries=Object.entries(normalized).filter(entry=>entry[1]!==void 0);entries.length>0&&(location=Object.fromEntries(entries))}if(!(locale===void 0&&userAgent===void 0&&location===void 0&&subject===void 0&&conversationId===void 0&&organizationId===void 0))return{...locale!==void 0&&{locale},...userAgent!==void 0&&{userAgent},...location!==void 0&&{location},...subject!==void 0&&{subject},...conversationId!==void 0&&{conversationId},...organizationId!==void 0&&{organizationId}}}function toClientContext(ctx){let envelope=ctx.mcpReq.envelope,capabilities={...envelope?.[CLIENT_CAPABILITIES_META_KEY2]??{}},info={...envelope?.[CLIENT_INFO_META_KEY]??{}},user=normalizeUserContext(ctx.mcpReq._meta);return{can(capability){return Object.hasOwn(capabilities,capability)},capabilities(){return{...capabilities}},extension(id){let settings=capabilities.extensions?.[id];return settings===void 0?void 0:{...settings}},info(){return{...info}},user(){return user===void 0?void 0:{...user,...user.location!==void 0&&{location:{...user.location}}}},supportsViews(){return supportsViews(capabilities)}}}function toRequestContext(ctx){let rawRequest=ctx.http?.req,http=rawRequest===void 0?void 0:getRequestBag(rawRequest).honoContext,request=http?.req??(rawRequest===void 0?void 0:new HonoRequest(rawRequest)),additions={signal:ctx.mcpReq.signal,...request!==void 0&&{request},...ctx.mcpReq.inputResponses!==void 0&&{inputResponses:ctx.mcpReq.inputResponses},client:toClientContext(ctx),requestState:()=>ctx.mcpReq.requestState(),async sendNotification(method,params){await ctx.mcpReq.notify({method,...params!==void 0&&{params}})},async reportProgress(progress,total,message){let progressToken=ctx.mcpReq._meta?.progressToken;return progressToken===void 0?!1:(await ctx.mcpReq.notify({method:"notifications/progress",params:{progressToken,progress,...total!==void 0&&{total},...message!==void 0&&{message}}}),!0)},async sendLog(level,data,logger){await ctx.mcpReq.notify({method:"notifications/message",params:{level,data,...logger!==void 0&&{logger}}})}};return http!==void 0?Object.assign(http,additions):{...additions,...request!==void 0&&{req:request}}}function toAuthenticatedRequestContext(ctx){let authInfo=ctx.http?.authInfo;return requireOAuthAuthInfo(authInfo),Object.assign(toRequestContext(ctx),{auth:{user:authInfo.extra.user,payload:authInfo.extra.payload,accessToken:authInfo.token,scopes:[...authInfo.scopes],permissions:[...authInfo.extra.permissions],...authInfo.clientId.length>0&&{clientId:authInfo.clientId},expiresAt:authInfo.expiresAt,...authInfo.resource!==void 0&&{resource:authInfo.resource}}})}function isReadResourceResult(result){return"contents"in result&&Array.isArray(result.contents)}function isGetPromptResult(result){return"messages"in result&&Array.isArray(result.messages)}function toResourceResult(result,uri){if(isReadResourceResult(result))return result;let mime=result._meta&&typeof result._meta=="object"&&typeof result._meta.mimeType=="string"?result._meta.mimeType:void 0,contents=[];for(let block of result.content??[]){let mapped=contentBlockToResourceContents(block,uri,mime);mapped!==void 0&&contents.push(mapped)}return contents.length===0&&result.structuredContent!==void 0&&contents.push({uri,mimeType:"application/json",text:JSON.stringify(result.structuredContent)}),contents.length===0&&contents.push({uri,mimeType:"text/plain",text:""}),{contents}}function contentBlockToResourceContents(block,uri,mimeHint){if(block.type==="text")return{uri,mimeType:mimeHint??"text/plain",text:block.text};if(block.type==="image"||block.type==="audio")return{uri,mimeType:block.mimeType,blob:block.data};if(block.type==="resource")return{...block.resource}}function toPromptResult(result){if(isGetPromptResult(result))return result;let messages=(result.content??[]).map(content=>({role:"user",content}));return messages.length===0&&result.structuredContent!==void 0&&messages.push({role:"user",content:{type:"text",text:JSON.stringify(result.structuredContent)}}),messages.length===0&&messages.push({role:"user",content:{type:"text",text:""}}),{messages}}var DEFAULT_METHODS=["GET","HEAD","POST","OPTIONS"],DEFAULT_ALLOWED_HEADERS=["Content-Type","Authorization","mcp-protocol-version","mcp-method","mcp-name"];function resolveAllowedOrigin(origin,requestOrigin){return origin===void 0?requestOrigin:typeof origin=="function"?origin(requestOrigin):origin==="*"?"*":Array.isArray(origin)?requestOrigin!==null&&origin.includes(requestOrigin)?requestOrigin:null:origin}function corsHeaders(options,request){if(request.headers.has("Access-Control-Allow-Origin"))return;let requestOrigin=request.headers.get("Origin"),allowedOrigin=resolveAllowedOrigin(options.origin,requestOrigin);if(allowedOrigin===null)return;let headers={"Access-Control-Allow-Origin":allowedOrigin,"Access-Control-Allow-Methods":options.methods.join(", "),"Access-Control-Allow-Headers":options.allowedHeaders.join(", ")};return options.credentials&&(headers["Access-Control-Allow-Credentials"]="true"),allowedOrigin!=="*"&&(headers.Vary="Origin"),headers}function mergeCorsHeaders(response,headers){if(response.headers.has("Access-Control-Allow-Origin"))return response;let merged=new Headers(response.headers);return new Headers(headers).forEach((value,key)=>{merged.set(key,value)}),inheritBufferedResponse(response,new Response(response.body,{status:response.status,statusText:response.statusText,headers:merged}))}function corsFetchMiddleware(options){if(!(options.enabled!==!1))return async(_request,next)=>next();let resolved={...options.origin!==void 0&&{origin:options.origin},methods:options.methods??DEFAULT_METHODS,allowedHeaders:options.allowedHeaders??DEFAULT_ALLOWED_HEADERS,credentials:options.credentials??!1};return async(request,next)=>{let headers=corsHeaders(resolved,request);if(headers===void 0)return next();if(request.method==="OPTIONS")return new Response(null,{status:204,headers});let response=await next();return mergeCorsHeaders(response,headers)}}function isGlobalCorsEnabled(cors){return cors!==void 0&&cors.enabled!==!1}import{CallToolResultSchema,GetPromptResultSchema,ListPromptsResultSchema,ListResourcesResultSchema,ListToolsResultSchema,ReadResourceResultSchema}from"@modelcontextprotocol/core";import{isInputRequiredResult}from"@modelcontextprotocol/server";var MCP_MIDDLEWARE_METHODS=["tools/call","tools/list","resources/read","resources/list","prompts/get","prompts/list"];function withMcpMiddlewareParams(request,params){if(typeof request!="object"||request===null||Array.isArray(request))throw new TypeError("[mcp-use] MCP middleware received an invalid downstream request");return{...request,params}}function createMcpMiddlewareEntry(pattern,handler){let normalizedPattern=normalizeMcpMiddlewarePattern(pattern),invoke=handler;if(normalizedPattern!=="*"&&!isMcpMiddlewareMethod(normalizedPattern))throw new TypeError(`Unsupported MCP middleware pattern "${pattern}". Use an exact MCP method or "mcp:*".`);return normalizedPattern==="*"?{pattern:normalizedPattern,handler:async(ctx,next)=>{let downstreamCalled=!1,downstreamResult;if(await invoke(ctx,async()=>{downstreamResult=await next(),downstreamCalled=!0}),!downstreamCalled)throw new Error(`Wildcard MCP middleware "${normalizedPattern}" must call next()`);return downstreamResult}}:{pattern:normalizedPattern,handler:(ctx,next)=>invoke(ctx,next)}}function createMcpEventListenerEntry(pattern,handler){let{pattern:normalizedPattern,phase}=parseMcpPattern(pattern),invoke=handler;return{pattern:normalizedPattern,phase,handler:(ctx,result)=>invoke(ctx,result)}}function matchesPattern(pattern,method){if(pattern==="*")return!0;if(pattern.endsWith("/*")){let prefix=pattern.slice(0,-1);return method.startsWith(prefix)}return pattern===method}function isMcpMiddlewareMethod(value){return MCP_MIDDLEWARE_METHODS.some(method=>method===value)}function composeMiddleware(entries,method,innerFn){let matching=entries.filter(entry=>matchesPattern(entry.pattern,method));return matching.length===0?_ctx=>innerFn():ctx=>{let index=-1,dispatch=i=>i<=index?Promise.reject(new Error("next() called multiple times")):(index=i,i===matching.length?innerFn():matching[i].handler(ctx,()=>dispatch(i+1)));return dispatch(0)}}function freezeMiddlewareContext(ctx){return Object.freeze({method:ctx.method,params:Object.freeze({...ctx.params}),...ctx.request!==void 0&&{request:ctx.request},...ctx.req!==void 0&&{req:ctx.req},...ctx.session!==void 0&&{session:Object.freeze({...ctx.session})},...ctx.auth!==void 0&&{auth:ctx.auth},state:new Map(ctx.state)})}async function runMcpOperation(middlewares,events,method,ctx,innerFn){dispatchMcpEvents(events,method,"before",ctx);let result=await composeMiddleware(middlewares,method,innerFn)(ctx);return assertValidMiddlewareResult(method,result),dispatchMcpEvents(events,method,"complete",ctx,result),result}function assertValidMiddlewareResult(method,result){if((method==="tools/call"||method==="resources/read"||method==="prompts/get")&&isInputRequiredResult(result))return;let validation=(()=>{switch(method){case"tools/call":return assertArrayProperty(method,result,"content"),CallToolResultSchema.safeParse(result);case"tools/list":return assertArrayResult(method,result),ListToolsResultSchema.safeParse({tools:result});case"resources/read":return assertArrayProperty(method,result,"contents"),ReadResourceResultSchema.safeParse(result);case"resources/list":return assertArrayResult(method,result),ListResourcesResultSchema.safeParse({resources:result});case"prompts/get":return assertArrayProperty(method,result,"messages"),GetPromptResultSchema.safeParse(result);case"prompts/list":return assertArrayResult(method,result),ListPromptsResultSchema.safeParse({prompts:result});default:throw new TypeError(`Unsupported MCP middleware method "${method}"`)}})();if(!validation.success)throw new TypeError(`[mcp-use] ${method} middleware returned an invalid result: ${validation.error.message}`)}function assertArrayResult(method,result){if(!Array.isArray(result))throw new TypeError(`[mcp-use] ${method} middleware returned an invalid result: expected an array`)}function assertArrayProperty(method,result,property){if(typeof result!="object"||result===null||!Array.isArray(result[property]))throw new TypeError(`[mcp-use] ${method} middleware returned an invalid result: expected a ${property} array`)}function dispatchMcpEvents(events,method,phase,ctx,result){let frozen=freezeMiddlewareContext(ctx);for(let entry of events)if(!(entry.phase!==phase||!matchesPattern(entry.pattern,method)))try{entry.handler(frozen,result)}catch(error2){console.error(`[mcp-use] MCP event listener for "${entry.pattern}" (${phase}) threw:`,error2)}}function parseMcpPattern(raw){let pattern=raw.startsWith("mcp:")?raw.slice(4):raw;return pattern.endsWith(":complete")?{pattern:pattern.slice(0,-9),phase:"complete"}:{pattern,phase:"before"}}function normalizeMcpMiddlewarePattern(raw){return raw.startsWith("mcp:")?raw.slice(4):raw}import{CLIENT_INFO_META_KEY as CLIENT_INFO_META_KEY2,isJSONRPCRequest}from"@modelcontextprotocol/server";function colorsEnabled(){return typeof process>"u"||process.env?.NO_COLOR!==void 0?!1:process.stdout?.isTTY===!0}function ansi(open,close){return text2=>colorsEnabled()?`\x1B[${open}m${text2}\x1B[${close}m`:text2}var bold=ansi(1,22),dim=ansi(2,22),red=ansi(31,39),green=ansi(32,39),yellow=ansi(33,39),blue=ansi(34,39),magenta=ansi(35,39),cyan=ansi(36,39),gray=ansi(90,39);function resolveLogLevel(configured){let raw=typeof process>"u"?void 0:process.env?.MCP_USE_LOG_LEVEL?.toLowerCase();return raw==="info"||raw==="debug"||raw==="trace"?raw:configured??"info"}function formatClientInfo(info){if(info!==void 0)return typeof info.version=="string"&&info.version!==""?`${info.name}/${info.version}`:info.name}var detailFormatters={initialize:p=>({subject:formatClientInfo(p.clientInfo)}),ping:()=>({}),"server/discover":()=>({}),"completion/complete":p=>({subject:p.ref.type==="ref/prompt"?p.ref.name:p.ref.uri,input:p.argument}),"logging/setLevel":p=>({subject:p.level}),"prompts/get":p=>({subject:p.name,input:p.arguments}),"prompts/list":()=>({}),"resources/list":()=>({}),"resources/templates/list":()=>({}),"resources/read":p=>({subject:p.uri}),"resources/subscribe":p=>({subject:p.uri}),"resources/unsubscribe":p=>({subject:p.uri}),"subscriptions/listen":()=>({}),"tools/call":p=>({subject:p.name,input:p.arguments}),"tools/list":()=>({}),"sampling/createMessage":()=>({}),"elicitation/create":()=>({}),"roots/list":()=>({})};function isKnownMethod(method){return Object.prototype.hasOwnProperty.call(detailFormatters,method)}function formatDetail(message){if(!isKnownMethod(message.method))return{};try{let formatter=detailFormatters[message.method],detail=formatter(message.params);return typeof detail.subject=="string"||detail.subject===void 0?detail:{}}catch{return{}}}var INLINE_JSON_MAX_LENGTH=80;function inlineJson(value){let text2;try{text2=JSON.stringify(value)??String(value)}catch{text2=String(value)}return text2.length>INLINE_JSON_MAX_LENGTH?`${text2.slice(0,INLINE_JSON_MAX_LENGTH)}...`:text2}function formatClientIdentity(message){let meta=message.params?._meta;if(meta===void 0)return;let info=meta[CLIENT_INFO_META_KEY2];if(!(typeof info!="object"||info===null||typeof info.name!="string"))return formatClientInfo(info)}function sanitize(text2){return text2.replace(/[\u0000-\u001F\u007F-\u009F]+/g," ")}function methodStyle(method){return method.startsWith("tools/")?cyan:method.startsWith("resources/")?green:method.startsWith("prompts/")?magenta:method==="initialize"||method==="ping"?gray:blue}var REDACTED_HEADERS=new Set(["authorization","proxy-authorization","cookie","set-cookie","x-api-key"]);function redactHeaders(headers){return Object.fromEntries(Object.entries(headers).map(([name,value])=>[name,REDACTED_HEADERS.has(name.toLowerCase())?"[REDACTED]":value]))}async function extractResponseOutcome(res){if(!res.body)return{errorMessage:null};let text2;try{text2=await res.clone().text()}catch{return{errorMessage:null}}if(!text2)return{errorMessage:null};let isSse=(res.headers.get("content-type")??"").includes("text/event-stream"),payloads=[],tryParse=raw=>{try{payloads.push(JSON.parse(raw))}catch{}};if(isSse){for(let line of text2.split(/\r?\n/))if(line.startsWith("data:")){let data=line.slice(5).trim();data&&tryParse(data)}}else tryParse(text2);let result;for(let payload of payloads){if(payload===null||typeof payload!="object")continue;let message=payload;if(typeof message.error?.message=="string")return{errorMessage:message.error.message};if(message.result?.isError===!0){let textBlock=(Array.isArray(message.result.content)?message.result.content:[]).find(b=>b?.type==="text"&&typeof b.text=="string");return{errorMessage:textBlock?String(textBlock.text):"tool error"}}"result"in message&&(result=message.result)}return{errorMessage:null,result}}function compactToolResult(result){if(result===null||typeof result!="object")return result;let{structuredContent,content}=result;if(structuredContent!==void 0)return structuredContent;if(Array.isArray(content)){let[block]=content;if(content.length===1&&block?.type==="text")return block.text}return content}function formatForDump(value){function truncate(val){return typeof val=="string"&&val.length>100?`${val.slice(0,100)}...`:Array.isArray(val)?val.map(truncate):val!==null&&typeof val=="object"?Object.fromEntries(Object.entries(val).map(([k,v])=>[k,truncate(v)])):val}try{return JSON.stringify(truncate(value),null,2)}catch{return String(value)}}var DUMP_BODY_MAX_LENGTH=1e4;async function printTraceDump(response,requestHeaders,requestBody,readResponseBody){console.log(`
|
|
2
|
+
${cyan("=".repeat(80))}`),console.log(bold(cyan("[TRACE] Request Details"))),console.log(cyan("-".repeat(80))),Object.keys(requestHeaders).length>0&&(console.log(yellow("Request Headers:")),console.log(formatForDump(redactHeaders(requestHeaders)))),requestBody!==void 0&&(console.log(yellow("Request Body:")),console.log(typeof requestBody=="string"?requestBody:formatForDump(requestBody)));let responseHeaders={};if(response.headers.forEach((value,key)=>{responseHeaders[key]=value}),Object.keys(responseHeaders).length>0&&(console.log(yellow("Response Headers:")),console.log(formatForDump(redactHeaders(responseHeaders)))),!readResponseBody)console.log(`${yellow("Response Body:")} (streaming \u2014 not dumped)`);else if(response.body===null)console.log(`${yellow("Response Body:")} (no body)`);else try{let text2=await response.clone().text();if(text2.length===0)console.log(`${yellow("Response Body:")} (empty)`);else{console.log(yellow("Response Body:"));try{console.log(formatForDump(JSON.parse(text2)))}catch{console.log(text2.length>DUMP_BODY_MAX_LENGTH?`${text2.slice(0,DUMP_BODY_MAX_LENGTH)}
|
|
3
|
+
... (truncated, ${text2.length-DUMP_BODY_MAX_LENGTH} more characters)`:text2)}}}catch{console.log(`${yellow("Response Body:")} (unable to read)`)}console.log(`${cyan("=".repeat(80))}
|
|
4
|
+
`)}function styleStatus(status){let text2=String(status);return status>=500?magenta(text2):status>=400?red(text2):status>=300?yellow(text2):green(text2)}function isNoisyRequest(httpMethod,pathname){return httpMethod!=="GET"&&httpMethod!=="HEAD"?!1:pathname.endsWith("/favicon.ico")}function requestLogger(options={}){return options.enabled===!1?(_request,next)=>next():async(request,next)=>{let level=resolveLogLevel(options.level),startedAt=Date.now(),httpMethod=request.method,pathname=new URL(request.url).pathname;if(isNoisyRequest(httpMethod,pathname))return next();let requestHeaders={};level==="trace"&&request.headers.forEach((value,key)=>{requestHeaders[key]=value});let requestBody;if(httpMethod!=="GET"&&httpMethod!=="HEAD"){let parsedBody=getRequestBag(request).parsedBody;if(parsedBody!==void 0)requestBody=parsedBody;else try{requestBody=await request.clone().json()}catch{}}let response=await next(),durationMs=Date.now()-startedAt,timestamp=new Date().toISOString().substring(11,19),mcpRequest=isJSONRPCRequest(requestBody)?requestBody:void 0,isStreamingMethod=mcpRequest?.method==="subscriptions/listen",lines=[[dim(timestamp),bold(httpMethod),pathname,styleStatus(response.status),dim(`in ${durationMs}ms`)].join(" ")];if(mcpRequest!==void 0){let method=sanitize(mcpRequest.method),parts=[` ${methodStyle(method)(method)}`],detail=formatDetail(mcpRequest);detail.subject!==void 0&&parts.push(bold(sanitize(detail.subject)));let echoPayloads=level!=="info";echoPayloads&&detail.input!==void 0&&parts.push(inlineJson(detail.input));let outcome=isStreamingMethod?{errorMessage:null}:await extractResponseOutcome(response);if(echoPayloads&&mcpRequest.method==="tools/call"&&outcome.errorMessage===null&&outcome.result!==void 0&&parts.push(dim("->"),inlineJson(compactToolResult(outcome.result))),mcpRequest.method!=="initialize"){let client=formatClientIdentity(mcpRequest);client!==void 0&&parts.push(dim(sanitize(client)))}outcome.errorMessage!==null?parts.push(red(`ERROR ${sanitize(outcome.errorMessage)}`)):response.status>=400&&parts.push(red(`ERROR (HTTP ${response.status})`)),lines.push(parts.join(" "))}return console.log(lines.join(`
|
|
5
|
+
`)),level==="trace"&&await printTraceDump(response,requestHeaders,requestBody,!isStreamingMethod),response}}import{createMcpHandler}from"@modelcontextprotocol/server";function createMcpMount(factory,options={}){let{path="/mcp",handler:handlerOptions,authInfo:getAuthInfo}=options,legacyMode=handlerOptions?.legacy??"stateless",handler=createMcpHandler(factory,{legacy:"stateless",...handlerOptions});return{handler,fetch:async request=>{if(!matchesPath(request,path))return new Response("Not Found",{status:404});if(legacyMode==="stateless"){let method=request.method.toUpperCase();if(method==="GET"||method==="DELETE"||method==="HEAD")return new Response(null,{status:204})}let bag=getRequestBag(request),parsedBody=bag.parsedBody;if(parsedBody===void 0)try{parsedBody=await request.clone().json()}catch{}let capabilities=extractClientCapabilitiesFromBody(parsedBody);capabilities!==void 0&&stashClientCapabilities(request,capabilities);let authInfo=getAuthInfo?.(request)??bag.authInfo,response=await handler.fetch(request,{...parsedBody!==void 0&&{parsedBody},...authInfo!==void 0&&{authInfo}});return response.headers.get("content-type")?.toLowerCase().includes("application/json")?"Bun"in globalThis&&response.body!==null?new Response(await response.arrayBuffer(),{status:response.status,statusText:response.statusText,headers:response.headers}):trackBufferedResponse(request,response):response}}}function resolveToolInputSchema(definition){return definition.inputSchema??definition.schema}var registerViews=Symbol("mcp-use/registerViews");function resolveAssetUrl(assetPath,origin){if(!assetPath.startsWith("/"))throw new Error(`View manifest asset path must be origin-absolute (start with "/"); got ${JSON.stringify(assetPath)}`);return`${origin}${assetPath}`}function viewAssetsBasePath(basePath,viewName){return`${pathUnderBase(basePath,`_mcp-use/views/${viewName}`)}/`}function resolveExternalAssetUrl(assetPath,assetsBase,basePath,viewName){return assetPath.startsWith("http://")||assetPath.startsWith("https://")||assetPath.startsWith("data:")?assetPath:assetPath.startsWith("/")?resolveAssetUrl(assetPath,assetsBase):`${assetsBase}${viewAssetsBasePath(basePath,viewName)}${assetPath.replace(/^\/+/,"")}`}function resolvePublicBase(assetsBase,basePath){return`${assetsBase}${pathUnderBase(basePath,"_mcp-use/public")}/`}function escapeInlineScript(code){return code.replaceAll(/<\/script/gi,"<\\/script").replaceAll("<!--","\\x3C!--")}function escapeInlineStyle(css2){return css2.replaceAll(/<\/style/gi,"<\\/style")}function escapeHtml(value){return value.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">")}var VIEW_BOOTSTRAP_STYLE=`<style>
|
|
6
|
+
html,body,#root{background:transparent}
|
|
7
|
+
html,body{margin:0}
|
|
8
|
+
#root[data-mcp-use-loading]{display:flex;min-height:100vh;align-items:center;justify-content:center;flex-direction:column;gap:10px;color:rgba(127,127,127,.9)}
|
|
9
|
+
#root[data-mcp-use-loading]::before{width:20px;height:20px;box-sizing:border-box;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;content:"";animation:mcp-use-view-spin .7s linear infinite}
|
|
10
|
+
#root[data-mcp-use-loading]::after{color:rgba(127,127,127,.9);content:"Compiling...";font:500 13px/1.2 ui-sans-serif,system-ui,sans-serif}
|
|
11
|
+
@keyframes mcp-use-view-spin{to{transform:rotate(360deg)}}
|
|
12
|
+
@media (prefers-reduced-motion:reduce){#root[data-mcp-use-loading]::before{animation-duration:1.4s}}
|
|
13
|
+
</style>`;function synthesizeViewDocument(entry,assetsBase,basePath,viewName){let viewConfig={publicBase:resolvePublicBase(assetsBase,basePath)},configScript=`<script>globalThis.__mcpUseViewConfig=${JSON.stringify(viewConfig)};</script>`;if(entry.kind==="inline"){let styleTag=entry.css.length>0?`<style>${escapeInlineStyle(entry.css)}</style>`:"",moduleScript=`<script type="module">${escapeInlineScript(entry.js)}</script>`;return`<!doctype html>
|
|
14
|
+
<html>
|
|
15
|
+
<head>
|
|
16
|
+
<meta charset="utf-8">
|
|
17
|
+
${configScript}
|
|
18
|
+
${VIEW_BOOTSTRAP_STYLE}
|
|
19
|
+
${styleTag}
|
|
20
|
+
</head>
|
|
21
|
+
<body>
|
|
22
|
+
<div id="root" data-mcp-use-loading></div>
|
|
23
|
+
${moduleScript}
|
|
24
|
+
</body>
|
|
25
|
+
</html>`}if(viewName===void 0)throw new Error("viewName is required when synthesizing an external view document.");let cssLinks=entry.css.map(path=>`<link rel="stylesheet" href="${escapeHtml(resolveExternalAssetUrl(path,assetsBase,basePath,viewName))}">`).join(`
|
|
26
|
+
`),scriptTags=(entry.scripts??[]).map(path=>`<script type="module" src="${escapeHtml(resolveExternalAssetUrl(path,assetsBase,basePath,viewName))}"></script>`).join(`
|
|
27
|
+
`),devImportMap=entry.entry.startsWith("/")&&(entry.scripts??[]).includes("/@vite/client")?`<script type="importmap">${escapeInlineScript(JSON.stringify({imports:{"/":`${assetsBase.replace(/\/+$/,"")}/`}}))}</script>`:"",entryUrl=resolveExternalAssetUrl(entry.entry,assetsBase,basePath,viewName);return`<!doctype html>
|
|
28
|
+
<html>
|
|
29
|
+
<head>
|
|
30
|
+
<meta charset="utf-8">
|
|
31
|
+
${configScript}
|
|
32
|
+
${devImportMap}
|
|
33
|
+
${VIEW_BOOTSTRAP_STYLE}
|
|
34
|
+
${cssLinks}
|
|
35
|
+
</head>
|
|
36
|
+
<body>
|
|
37
|
+
<div id="root" data-mcp-use-loading></div>
|
|
38
|
+
${scriptTags}
|
|
39
|
+
<script type="module" src="${escapeHtml(entryUrl)}"></script>
|
|
40
|
+
</body>
|
|
41
|
+
</html>`}var CATEGORY_ENV={connectDomains:"CSP_CONNECT_DOMAINS",resourceDomains:"CSP_RESOURCE_DOMAINS",frameDomains:"CSP_FRAME_DOMAINS",baseUriDomains:"CSP_BASE_URI_DOMAINS"};function parseDomainList(raw){return raw===void 0||raw.trim()===""?[]:raw.split(",").map(s=>s.trim()).filter(s=>s.length>0)}function readEnvDomains(name){if(typeof process>"u")return;let raw=process.env[name];if(!(raw===void 0||raw.trim()===""))return parseDomainList(raw)}function readCspUrlsShortcut(){return readEnvDomains("CSP_URLS")??[]}function readEnvDomainsForCategory(category){let perCategory=readEnvDomains(CATEGORY_ENV[category]);return perCategory!==void 0?perCategory:readCspUrlsShortcut()}function mergeDomainLists(...segments){let seen=new Set,out=[];for(let segment of segments)for(let domain of segment)seen.has(domain)||(seen.add(domain),out.push(domain));return out}function toWebSocketOrigin(serverOrigin){return serverOrigin.startsWith("https://")?`wss://${serverOrigin.slice(8)}`:serverOrigin.startsWith("http://")?`ws://${serverOrigin.slice(7)}`:serverOrigin}function buildMergedResourceCsp(authorFacts,options){let author=authorFacts?.csp,mcpConnectAuto=[];options.serverOrigin!==""&&(mcpConnectAuto.push(options.serverOrigin),options.hmrWs===!0&&mcpConnectAuto.push(toWebSocketOrigin(options.serverOrigin)));let mcpResourceAuto=[],resourceOrigin=options.explicitAssetsBase?options.assetsOrigin:options.serverOrigin;resourceOrigin!==""&&mcpResourceAuto.push(resourceOrigin);let connectDomains=mergeDomainLists(author?.connectDomains??[],readEnvDomainsForCategory("connectDomains"),mcpConnectAuto),resourceDomains=mergeDomainLists(author?.resourceDomains??[],readEnvDomainsForCategory("resourceDomains"),mcpResourceAuto),frameDomains=mergeDomainLists(author?.frameDomains??[],readEnvDomainsForCategory("frameDomains")),baseUriDomains=mergeDomainLists(author?.baseUriDomains??[],readEnvDomainsForCategory("baseUriDomains"));return{...author,connectDomains,resourceDomains,frameDomains,baseUriDomains}}var PUBLIC_BUILD_DIR=".mcp-use/build/views/public",PUBLIC_DEV_DIR="public",VIEW_ASSETS_BUILD_ROOT=".mcp-use/build/views";function createViewAssetsHandler(basePath,views,options){if(views.size===0)return;let assetsPrefix=pathUnderBase(basePath,"_mcp-use/views"),projectRoot=options?.projectRoot??process.cwd();return async request=>{if(request.method!=="GET"&&request.method!=="HEAD")return new Response("Method Not Allowed",{status:405});if(!matchesPathPrefix(request,assetsPrefix))return new Response("Not Found",{status:404});let remainder=pathnameOf(request).slice(assetsPrefix.length+1),slash=remainder.indexOf("/");if(slash<=0||slash===remainder.length-1)return new Response("Not Found",{status:404});let viewName=remainder.slice(0,slash),subpath=remainder.slice(slash+1),entry=views.get(viewName);if(entry===void 0||entry.kind!=="external")return new Response("Not Found",{status:404});let[{join},{resolvePublicFilePath:resolvePublicFilePath2,servePublicFile:servePublicFile2}]=await Promise.all([import("path"),import("./public-route-DAQJGS6K.js")]),viewRoot=join(projectRoot,VIEW_ASSETS_BUILD_ROOT,viewName),diskPath=await resolvePublicFilePath2(viewRoot,subpath);return diskPath===null?new Response("Not Found",{status:404}):await servePublicFile2(diskPath,{...options?.deferCors===!0&&{deferCors:!0},...request.method==="HEAD"&&{head:!0}})}}function createViewPublicHandler(basePath,views,options){if(views.size===0&&options?.enabled!==!0)return;let publicPrefix=pathUnderBase(basePath,"_mcp-use/public"),subdir=options?.dev===!0?PUBLIC_DEV_DIR:PUBLIC_BUILD_DIR,projectRoot=options?.projectRoot??process.cwd();return async request=>{if(request.method!=="GET"&&request.method!=="HEAD")return new Response("Method Not Allowed",{status:405});if(!matchesPathPrefix(request,publicPrefix))return new Response("Not Found",{status:404});let encodedSubpath=pathnameOf(request).slice(publicPrefix.length+1),subpath;try{subpath=decodeURIComponent(encodedSubpath)}catch{return new Response("Not Found",{status:404})}if(subpath.length===0)return new Response("Not Found",{status:404});let[{join},{resolvePublicFilePath:resolvePublicFilePath2,servePublicFile:servePublicFile2}]=await Promise.all([import("path"),import("./public-route-DAQJGS6K.js")]),publicRoot=join(projectRoot,subdir),diskPath=await resolvePublicFilePath2(publicRoot,subpath);return diskPath===null?new Response("Not Found",{status:404}):await servePublicFile2(diskPath,{...options?.deferCors===!0&&{deferCors:!0},...request.method==="HEAD"&&{head:!0}})}}function buildToolUiMeta(viewName,visibility,existingMetadata){if(viewName===void 0&&visibility===void 0&&existingMetadata===void 0)return;let meta={...existingMetadata},existingUi=existingMetadata?.["ui"],existingUiIsObject=typeof existingUi=="object"&&existingUi!==null&&!Array.isArray(existingUi),ui=existingUiIsObject?{...existingUi}:{};if(viewName!==void 0){let resourceUri=viewResourceUri(viewName);ui.resourceUri=resourceUri,meta[UI_RESOURCE_URI_META_KEY]=resourceUri}else delete ui.resourceUri,delete meta[UI_RESOURCE_URI_META_KEY];return visibility!==void 0?ui.visibility=[visibility]:delete ui.visibility,(viewName!==void 0||visibility!==void 0||existingUiIsObject)&&(meta["ui"]=ui),meta}function buildToolResultUiMeta(viewName){let resourceUri=viewResourceUri(viewName);return{ui:{resourceUri},[UI_RESOURCE_URI_META_KEY]:resourceUri}}function resolveCspOptions(options){let request=options?.request,serverOrigin=options?.serverOrigin??(request!==void 0?resolveServerOrigin(request):""),assetsBase=options?.assetsBase??(request!==void 0?resolveAssetsBase(request):serverOrigin);return{serverOrigin,assetsOrigin:originFromAssetsBase(assetsBase),explicitAssetsBase:hasExplicitAssetsBase(),...options?.hmrWs===!0?{hmrWs:!0}:{}}}function buildResourceUiMeta(authorFacts,options){let ui={csp:buildMergedResourceCsp(authorFacts,resolveCspOptions(options))};return authorFacts?.permissions!==void 0&&(ui.permissions=authorFacts.permissions),authorFacts?.domain!==void 0&&(ui.domain=authorFacts.domain),authorFacts?.prefersBorder!==void 0&&(ui.prefersBorder=authorFacts.prefersBorder),{ui}}function viewResourceConfig(_viewName,_entry,authorFacts,options){return{mimeType:UI_MIME_TYPE,...authorFacts?.description!==void 0&&{description:authorFacts.description},_meta:buildResourceUiMeta(authorFacts,options)}}function record(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)?value:void 0}function productId(value,fallback){if(typeof value!="string")return fallback;let normalized=value.trim();return normalized.length>0&&normalized.length<=64&&![...normalized].some(character=>{let code=character.charCodeAt(0);return code<32||code===127})?normalized:fallback}function clientUsageFromBody(body){if(!isJSONRPCRequest2(body))return;let params=record(body.params);if(body.method==="initialize"){let info2=record(params?.clientInfo),capabilities2=record(params?.capabilities)??{};return clientUsage(info2,capabilities2,params?.protocolVersion,"legacy")}let meta=record(params?._meta),info=record(meta?.[CLIENT_INFO_META_KEY3]),capabilities=record(meta?.[CLIENT_CAPABILITIES_META_KEY3]);if(!(info===void 0||capabilities===void 0))return clientUsage(info,capabilities,meta?.[PROTOCOL_VERSION_META_KEY],"modern")}function clientUsage(info,capabilities,protocolVersion,era){let typedCapabilities=capabilities;return{client_name:productId(info?.name,"other"),client_version:productId(info?.version,"unknown"),protocol_era:era,protocol_version:productId(protocolVersion,"unknown"),connection_mode:era==="modern"?"stateless_request":"legacy_session",sampling_capability:Object.hasOwn(capabilities,"sampling"),elicitation_capability:Object.hasOwn(capabilities,"elicitation"),roots_capability:Object.hasOwn(capabilities,"roots"),extensions_capability:Object.hasOwn(capabilities,"extensions"),views_capability:supportsViews(typedCapabilities),capability_count:Object.keys(capabilities).length}}function omitRootSchemaDialect(schema){if(typeof schema!="object"||schema===null||Array.isArray(schema)||!("$schema"in schema))return schema;let emittedSchema={...schema};return delete emittedSchema.$schema,emittedSchema}function omitToolSchemaDialects(tools){return tools.map(tool=>({...tool,inputSchema:omitRootSchemaDialect(tool.inputSchema),...tool.outputSchema===void 0?{}:{outputSchema:omitRootSchemaDialect(tool.outputSchema)}}))}function registerFetchMiddleware(app,middleware){app.use("*",async(context,next)=>{let response=await middleware(context.req.raw,async()=>(await next(),context.res));return context.res=response,response})}var MCPServer=class _MCPServer{#config;#branding;#tools=new Map;#resources=new Map;#resourceTemplates=new Map;#prompts=new Map;#views=new Map;#viewBindings=new Map;#viewsPrimed=!1;#viewsDevMode=!1;#viewsProjectRoot=process.cwd();#fetchHandler;#httpApp;#handler;#eventBus;#httpServer;#oauthResource;#oauthResourceResolved=!1;#oauthResourceConfigurationAbsent=!1;#hostValidated=!1;#mcpMiddlewares=[];#mcpEventListeners=[];#usageScope;#openApiTools=new Set;#proxiedTools=new Set;#proxiedResources=new Set;#proxiedPrompts=new Set;#httpMiddlewareCount=0;#proxyServersConfigured=0;#proxyServersConnected=0;#proxyToolsDiscovered=0;#proxyResourcesDiscovered=0;#proxyPromptsDiscovered=0;#proxyOwners=[];#proxyOperations=new Set;#closed=!1;app;get;post;put;patch;delete;all;fetch;static fromOpenAPI(options){let server=new _MCPServer({name:options.name??options.spec.info.title,version:options.version??options.spec.info.version??"1.0.0"});registerOpenAPITools(server,options);for(let name of server.#tools.keys())server.#openApiTools.add(name);return server}constructor(config){if(assertServerConfig(config),this.#config=config,this.#branding=normalizeServerBranding(config),this.app=new Hono,this.app.use("*",async(context,next)=>{getRequestBag(context.req.raw).honoContext=context,await next()}),this.get=this.app.get.bind(this.app),this.post=this.app.post.bind(this.app),this.put=this.app.put.bind(this.app),this.patch=this.app.patch.bind(this.app),this.delete=this.app.delete.bind(this.app),this.all=this.app.all.bind(this.app),this.fetch=async(request,env,executionCtx)=>(this.#ensureMounted("handler"),this.#httpApp.fetch(request,env,executionCtx)),config.oauth!==void 0){let mcpUrl=typeof process>"u"?void 0:process.env.MCP_URL,resource2=resolveConfiguredOAuthResource({provider:config.oauth,basePath:this.#basePath(),...mcpUrl!==void 0&&{mcpUrl}});this.#oauthResource=resource2,this.#oauthResourceResolved=resource2!==void 0,this.#oauthResourceConfigurationAbsent=resource2===void 0}}get basePath(){return this.#basePath()}get host(){return this.#config.host}get port(){return this.#config.port}get branding(){return this.#branding}getHandler(){return this.fetch}tool(definition,callback){return this.#assertNotStarted("tool",definition.name),this.#validateToolViewBinding(definition),this.#openApiTools.delete(definition.name),this.#proxiedTools.delete(definition.name),this.#tools.set(definition.name,{definition,callback}),Object.freeze({name:definition.name})}[registerViews](views,options){if(this.#viewsPrimed)throw new Error("Cannot prime views: the views registry is already primed on this server instance.");this.#assertNotStarted("views","manifest"),this.#viewsDevMode=options?.dev===!0,options?.projectRoot!==void 0&&(this.#viewsProjectRoot=options.projectRoot);for(let[name,entry]of Object.entries(views))this.#views.set(name,entry);this.#viewsPrimed=!0}__primeViews(views,options){this[registerViews](views,options)}resource(definition,callback){this.#assertNotStarted("resource",definition.name);let previous=this.#resources.get(definition.name);return previous!==void 0&&this.#proxiedResources.delete(previous.definition.uri),this.#resources.set(definition.name,{definition,callback}),this}resourceTemplate(definition,callback){this.#assertNotStarted("resourceTemplate",definition.name);let complete=definition.complete===void 0?void 0:normalizeCompletions(definition.complete);return this.#resourceTemplates.set(definition.name,{definition,...complete!==void 0&&{complete},callback}),this}prompt(definition,callback){return this.#assertNotStarted("prompt",definition.name),this.#proxiedPrompts.delete(definition.name),this.#prompts.set(definition.name,{definition,callback}),this}async proxy(input){this.#assertOpen("proxy()");let operation=(async()=>{let{isProxyConnection,mountProxyConnection,mountProxyServers}=await import("./mcp-proxy-NETCUGUD.js");if(isProxyConnection(input)){this.#proxyServersConfigured+=1,await mountProxyConnection(this.#proxyHost(),input);return}this.#proxyServersConfigured+=Object.keys(input).length,await mountProxyServers(this.#proxyHost(),input)})();this.#proxyOperations.add(operation);try{await operation}finally{this.#proxyOperations.delete(operation)}}use(patternOrHandler,...handlers){if(typeof patternOrHandler=="string"&&patternOrHandler.startsWith("mcp:")){this.#assertNotStarted("middleware",patternOrHandler);let handler=handlers[0];return this.#mcpMiddlewares.push(createMcpMiddlewareEntry(patternOrHandler,handler)),this}return this.app.use.call(this.app,patternOrHandler,...handlers),this.#httpMiddlewareCount+=typeof patternOrHandler=="function"?1:handlers.length,this}on(pattern,handler){return this.#assertNotStarted("event listener",pattern),this.#mcpEventListeners.push(createMcpEventListenerEntry(pattern,handler)),this}__setEventBus(bus){this.#assertNotStarted("event bus","shared"),this.#eventBus=bus}__mount(){this.#ensureMounted("handler")}async notifyToolsChanged(){await this.#ensureMounted("handler").handler.notify.toolsChanged()}async notifyPromptsChanged(){await this.#ensureMounted("handler").handler.notify.promptsChanged()}async notifyResourcesChanged(){await this.#ensureMounted("handler").handler.notify.resourcesChanged()}async notifyResourceUpdated(uri){await this.#ensureMounted("handler").handler.notify.resourceUpdated(uri)}async listen(port=void 0,options={}){this.#assertOpen("listen()");let host=resolveListenHost(options.host,this.#config.host),requestedPort=resolveListenPort(port,this.#config.port);return this.#assertListenOAuthConfiguration(host),new Promise((resolve,reject)=>{let resolveFetch,rejectFetch,fetchReady=new Promise((resolveFetchPromise,rejectFetchPromise)=>{resolveFetch=resolveFetchPromise,rejectFetch=rejectFetchPromise});fetchReady.catch(()=>{});let settled=!1,rejectAndClose=error2=>{settled||(settled=!0,reject(error2)),rejectFetch?.(error2),new Promise(closeResolve=>server.close(()=>closeResolve())).catch(()=>{}).finally(()=>{this.#httpServer===server&&(this.#httpServer=void 0)})},nodeHandler=toNodeHandler({fetch:async request=>(await fetchReady)(request)}),server=createNodeHttpServer((req,res)=>{nodeHandler(req,res)});server.once("error",rejectAndClose),server.listen(requestedPort,host,()=>{try{let address=server.address(),boundPort=typeof address=="object"&&address!==null?address.port:requestedPort,{fetch}=this.#ensureMounted("listen",boundPort,host);resolveFetch?.(fetch),settled||(settled=!0,resolve({port:boundPort,url:`http://localhost:${boundPort}${this.#basePath()}`}))}catch(error2){rejectAndClose(error2)}}),this.#httpServer=server})}async close(){this.#closed=!0,await Promise.allSettled([...this.#proxyOperations]);let errors=[],proxyOwners=this.#proxyOwners.splice(0),ownerResults=await Promise.allSettled(proxyOwners.map(owner=>owner.close()));for(let result of ownerResults)result.status==="rejected"&&errors.push(result.reason);try{await this.#handler?.close()}catch(error2){errors.push(error2)}let httpServer=this.#httpServer;if(httpServer!==void 0)try{await new Promise((resolve,reject)=>{httpServer.close(err=>err?reject(err):resolve())}),this.#httpServer=void 0}catch(error2){errors.push(error2)}if(errors.length>0)throw new AggregateError(errors,"Failed to close MCP server cleanly")}#assertOpen(operation){if(this.#closed)throw operation!==void 0?new Error(`Cannot call ${operation} after the server has closed.`):new Error("Cannot use the server after it has closed.")}#basePath(){return this.#config.basePath??"/mcp"}#resolveOAuthResource(mode,listenPort,listenHost){if(this.#config.oauth===void 0)return;if(this.#oauthResourceResolved)return this.#oauthResource;let host=listenHost??this.#config.host??"127.0.0.1",localListen=mode==="listen"&&listenPort!==void 0&&["127.0.0.1","localhost","::1"].includes(host);if(this.#oauthResourceConfigurationAbsent&&localListen)return this.#oauthResource=resolveLocalOAuthResource(`http://localhost:${listenPort}`,this.#basePath()),this.#oauthResourceResolved=!0,this.#oauthResource;throw new Error("OAuth requires an explicit resource or MCP_URL when using server.fetch or listening on a non-local host")}#assertListenOAuthConfiguration(host){if(this.#config.oauth!==void 0&&!["127.0.0.1","localhost","::1"].includes(host)&&!this.#oauthResourceResolved)throw new Error("OAuth listen() on a public or wildcard host requires an explicit provider resource or valid MCP_URL.")}#assertNotStarted(kind,name){if(this.#handler!==void 0)throw new Error(`Cannot register ${kind} "${name}" after the server has started: registrations are replayed per request from the registry, so register everything before listen()/server.fetch.`)}#trackConfigured(){recordUsage("server","configured",{tools_total:this.#tools.size,tools_local:this.#tools.size-this.#openApiTools.size-this.#proxiedTools.size,tools_openapi:this.#openApiTools.size,tools_proxied:this.#proxiedTools.size,resources:this.#resources.size,resource_templates:this.#resourceTemplates.size,prompts:this.#prompts.size,views:this.#views.size,proxy_servers_configured:this.#proxyServersConfigured,proxy_servers_connected:this.#proxyServersConnected,proxy_tools_discovered:this.#proxyToolsDiscovered,proxy_resources_discovered:this.#proxyResourcesDiscovered,proxy_prompts_discovered:this.#proxyPromptsDiscovered,proxy_tools_mounted:this.#proxiedTools.size,proxy_resources_mounted:this.#proxiedResources.size,proxy_prompts_mounted:this.#proxiedPrompts.size,http_middleware:this.#httpMiddlewareCount,mcp_middleware:this.#mcpMiddlewares.length,observers_before:this.#mcpEventListeners.filter(({phase})=>phase==="before").length,observers_complete:this.#mcpEventListeners.filter(({phase})=>phase==="complete").length,oauth_configured:this.#config.oauth!==void 0,cors_configured:this.#config.cors!==void 0,request_state_configured:this.#config.requestState!==void 0,legacy_policy:this.#config.legacy??"stateless"},{onceKey:`${this.#usageScopeId()}:server`,serverRoot:this.#viewsProjectRoot})}#trackClient(body){let client=clientUsageFromBody(body);client!==void 0&&recordUsage("client","observed",{...client},{onceKey:`${this.#usageScopeId()}:client:${JSON.stringify(client)}`,serverRoot:this.#viewsProjectRoot})}#usageScopeId(){return this.#usageScope??=crypto.randomUUID(),this.#usageScope}#proxyHost(){return{isStarted:()=>this.#handler!==void 0,hasTool:name=>this.#tools.has(name),hasResource:name=>this.#resources.has(name),hasPrompt:name=>this.#prompts.has(name),registerTool:(definition,callback)=>{this.#assertNotStarted("tool",definition.name),this.#proxiedTools.add(definition.name),this.#tools.set(definition.name,{definition,callback})},registerResource:(definition,callback)=>{this.#assertNotStarted("resource",definition.name),this.#proxiedResources.add(definition.uri),this.#resources.set(definition.name,{definition,callback})},registerPrompt:(definition,callback)=>{this.#assertNotStarted("prompt",definition.name),this.#proxiedPrompts.add(definition.name),this.#prompts.set(definition.name,{definition,callback})},trackOwner:owner=>{this.#proxyOwners.push(owner)},trackNamespace:({tools,resources,prompts})=>{this.#proxyServersConnected+=1,this.#proxyToolsDiscovered+=tools,this.#proxyResourcesDiscovered+=resources,this.#proxyPromptsDiscovered+=prompts}}}#validationPolicy(mode,listenHost){let{allowedHosts,allowedOrigins}=this.#config,host=listenHost??this.#config.host??"127.0.0.1",localhostBind=["127.0.0.1","localhost","::1"].includes(host),hosts=allowedHosts!==void 0?[...new Set([...localhostAllowedHostnames(),...allowedHosts])]:mode==="listen"&&localhostBind?localhostAllowedHostnames():void 0,origins=allowedOrigins!==void 0?[...new Set([...localhostAllowedOrigins(),...allowedOrigins])]:void 0;return{hosts,origins}}#ensureMounted(mode,listenPort,listenHost){if(this.#assertOpen(),this.#fetchHandler===void 0||this.#handler===void 0){let{hosts,origins}=this.#validationPolicy(mode,listenHost),basePath=this.#basePath(),nestedBasePath=basePath==="/"?"":basePath,httpApp=new Hono,middlewares=[jsonBodyMiddleware(),requestLogger(this.#config.logging)],corsConfig=this.#config.cors;corsConfig!==void 0&&middlewares.unshift(corsFetchMiddleware(corsConfig));let deferViewCors=isGlobalCorsEnabled(corsConfig);hosts!==void 0&&middlewares.unshift(hostValidationMiddleware(hosts)),origins!==void 0&&middlewares.push(originValidationMiddleware(origins)),hosts===void 0&&mode==="listen"&&console.warn(`[mcp-use] listen() is serving on ${listenHost} without Host validation. Behind a platform edge that only routes your own domains this is expected; if this process is reachable directly, set allowedHosts to restrict it.`),this.#validateViewBindingsAtMount();let resource2=this.#resolveOAuthResource(mode,listenPort,listenHost);if(resource2!==void 0){let provider=this.#config.oauth;middlewares.push(oauthMetadata(provider,resource2))}for(let middleware of middlewares)registerFetchMiddleware(httpApp,middleware);let{handler,fetch:mcpFetch}=createMcpMount(ctx=>this.#buildSdkServer(ctx),{path:basePath,...(this.#config.legacy!==void 0||this.#eventBus!==void 0)&&{handler:{...this.#config.legacy!==void 0&&{legacy:this.#config.legacy},...this.#eventBus!==void 0&&{bus:this.#eventBus}}},...resource2!==void 0&&{authInfo:request=>authInfoFromRequest(request)}}),protectWithBearer=async(_request,next)=>next();if(resource2!==void 0){let provider=this.#config.oauth,providerOptions=getOAuthProviderOptions(provider),gate=requireBearerAuth({verifier:wrapOAuthTokenVerifier(provider,resource2),resourceMetadataUrl:getOAuthProtectedResourceMetadataUrl(resource2),...providerOptions.requiredScopes!==void 0&&{requiredScopes:providerOptions.requiredScopes}});protectWithBearer=async(request,next)=>{let result=await gate(request);if(result instanceof Response)return result;let bag=getRequestBag(request);return bag.authInfo=result,next()},httpApp.use("*",async(context,next)=>{if(new URL(context.req.url).pathname!==basePath){await next();return}if(this.#config.publicLandingPage===!0&&isHtmlNavigationRequest(context.req.raw)){await next();return}let response=await protectWithBearer(context.req.raw,async()=>(await next(),context.res));return context.res=response,response})}let mcpRouteHandler=request=>{let body=getRequestBag(request).parsedBody;return isJSONRPCRequest2(body)&&(this.#trackConfigured(),this.#trackClient(body)),mcpFetch(request)},endpointHandler=async request=>isHtmlNavigationRequest(request)?(async()=>{let{createLandingPageResponse}=await import("./landing-handler-TG6LVQBI.js");return createLandingPageResponse(request,basePath,this.#config,this.#branding,this.#tools.values(),this.#prompts.values(),this.#resources.values())})():mcpRouteHandler(request),brandingDevMode=this.#viewsPrimed?this.#viewsDevMode:process.env.NODE_ENV!=="production",faviconHandler=createFaviconHandler(this.#branding,{dev:brandingDevMode,projectRoot:this.#viewsProjectRoot,deferCors:deferViewCors});faviconHandler!==void 0&&this.app.all("/favicon.ico",context=>faviconHandler(context.req.raw));let viewHandler=createViewPublicHandler(basePath,this.#views,{dev:this.#viewsPrimed?this.#viewsDevMode:brandingDevMode,projectRoot:this.#viewsProjectRoot,enabled:hasLocalBrandingAsset(this.#branding),deferCors:deferViewCors});if(viewHandler!==void 0&&this.app.on(["GET","HEAD"],`${nestedBasePath}/_mcp-use/public/*`,context=>viewHandler(context.req.raw)),!this.#viewsDevMode){let viewAssetsHandler=createViewAssetsHandler(basePath,this.#views,{projectRoot:this.#viewsProjectRoot,deferCors:deferViewCors});viewAssetsHandler!==void 0&&this.app.on(["GET","HEAD"],`${nestedBasePath}/_mcp-use/views/*`,context=>viewAssetsHandler(context.req.raw))}this.app.all(basePath,context=>endpointHandler(context.req.raw)),httpApp.route("/",this.app),this.#httpApp=httpApp,this.#fetchHandler=async request=>httpApp.fetch(request),this.#handler=handler,this.#hostValidated=hosts!==void 0}else if(mode==="listen"&&!this.#hostValidated&&this.#validationPolicy("listen",listenHost).hosts!==void 0)throw new Error("Cannot listen() on a localhost bind after server.fetch mounted the app without Host validation (server.fetch expects a platform edge in front). Call listen() first, or set allowedHosts.");return{fetch:this.#fetchHandler,handler:this.#handler}}#validateToolViewBinding(definition){let view=definition.view;if(view===void 0)return;if(definition.outputSchema===void 0)throw new Error(`Tool "${definition.name}" declares view "${view.name}" but has no outputSchema. View-bound tools require an outputSchema \u2014 the view reads structuredContent typed from it. Use outputSchema: z.object({}) for a view that takes no structured output.`);let existing=this.#viewBindings.get(view.name);if(existing!==void 0)throw new Error(`View "${view.name}" is already bound to tool "${existing.toolName}"; tool "${definition.name}" cannot bind the same view. Each view may be bound to one tool.`);this.#viewBindings.set(view.name,{toolName:definition.name,config:view})}#validateViewBindingsAtMount(){if(this.#viewBindings.size>0&&!this.#viewsPrimed){let first=[...this.#tools.values()].find(entry=>entry.definition.view!==void 0),viewName=first?.definition.view?.name??"unknown";throw new Error(`Tool "${first?.definition.name??"unknown"}" is bound to view "${viewName}" but no views were primed. Run \`mcp-use build\` and deploy the built entry, or in dev let the CLI prime views automatically.`)}for(let entry of this.#tools.values()){let viewName=entry.definition.view?.name;if(viewName!==void 0&&!this.#views.has(viewName))throw new Error(`Tool "${entry.definition.name}" is bound to view "${viewName}" which is not in the primed views registry. Run \`mcp-use build\` and deploy the built entry, or in dev let the CLI prime views automatically.`)}for(let viewName of this.#views.keys())this.#viewBindings.has(viewName)||console.warn(`[mcp-use] View "${viewName}" is registered but no tool binds it.`)}#buildSdkServer(ctx){let{name,version,title,description,instructions}=this.#config,authInfo=ctx.authInfo,server=new SdkMcpServer({name,version,...title!==void 0&&{title},...description!==void 0&&{description},...this.#branding.websiteUrl!==void 0&&{websiteUrl:this.#branding.websiteUrl},...this.#branding.icons!==void 0&&{icons:resolveImplementationIcons(this.#branding.icons,ctx.requestInfo,this.#basePath())}},{capabilities:{logging:{},tools:{listChanged:!0},prompts:{listChanged:!0},resources:{listChanged:!0,subscribe:!0}},...instructions!==void 0&&{instructions},...authInfo!==void 0&&{authInfo},...this.#config.requestState!==void 0&&{requestState:this.#config.requestState}}),request=ctx.requestInfo,viewMetaOptions=request!==void 0?{request,hmrWs:this.#viewsDevMode}:{hmrWs:this.#viewsDevMode},basePath=this.#basePath();for(let entry of this.#tools.values())this.#registerTool(server,entry);for(let entry of this.#resources.values())this.#registerResource(server,entry);for(let entry of this.#resourceTemplates.values())this.#registerResourceTemplate(server,entry);for(let entry of this.#prompts.values())this.#registerPrompt(server,entry);for(let[viewName,viewEntry]of this.#views.entries())this.#registerViewResource(server,viewName,viewEntry,viewMetaOptions,basePath);return this.#wrapListHandlers(server),server}#createMiddlewareContext(method,params,ctx){let requestContext=toRequestContext(ctx);return Object.assign(requestContext,{method,params,...ctx.sessionId!==void 0&&{session:{sessionId:ctx.sessionId}},...ctx.http?.authInfo!==void 0&&{auth:ctx.http.authInfo},state:new Map})}#runMcpHook(method,ctx,innerFn){let runOperation=method==="tools/call"&&this.#mcpMiddlewares.length===0&&this.#mcpEventListeners.length===0?innerFn:()=>runMcpOperation(this.#mcpMiddlewares,this.#mcpEventListeners,method,ctx,innerFn);if(isUsageDisabled())return runOperation();let startedAt=performance.now(),matchedMiddleware=this.#mcpMiddlewares.filter(entry=>matchesPattern(entry.pattern,method)).length,matchedObservers=phase=>this.#mcpEventListeners.filter(entry=>entry.phase===phase&&matchesPattern(entry.pattern,method)).length,request=ctx.request?.raw,client=request===void 0?void 0:clientUsageFromBody(getRequestBag(request).parsedBody),capture=(outcome,completedPhase)=>{recordUsage("operation","completed",{method,outcome,duration_ms:Math.max(0,Math.round(performance.now()-startedAt)),primitive_origin:this.#primitiveOrigin(method,ctx.params),matched_middleware:matchedMiddleware,observers_before:matchedObservers("before"),observers_complete:completedPhase?matchedObservers("complete"):0,...client?.protocol_era==="modern"?client:{client_name:"unknown",protocol_era:"legacy"}},{sampleRate:outcome==="success"?.1:1,serverRoot:this.#viewsProjectRoot})};return runOperation().then(result=>{let outcome=isInputRequiredResult2(result)?"input_required":method==="tools/call"&&typeof result=="object"&&result!==null&&"isError"in result&&result.isError===!0?"error":"success";return capture(outcome,!0),result},error2=>{throw capture("error",!1),error2})}#primitiveOrigin(method,params){if(method==="tools/call"){let name=String(params.name);return this.#proxiedTools.has(name)?"proxied":this.#openApiTools.has(name)?"openapi":"local"}return method==="resources/read"?this.#proxiedResources.has(String(params.uri))?"proxied":"local":method==="prompts/get"?this.#proxiedPrompts.has(String(params.name))?"proxied":"local":"mixed"}#wrapListHandlers(server){let handlers=server.server._requestHandlers;if(handlers===void 0)return;let wrapListMethod=(method,resultKey,transform)=>{let original=handlers.get(method);if(original===void 0||original.__mcpListWrapped)return;let wrapped=async(request,extra)=>{let serverContext=extra,params=request.params??{},mwCtx=this.#createMiddlewareContext(method,params,serverContext),originalEnvelope,innerFn=async()=>{let downstreamRequest=withMcpMiddlewareParams(request,mwCtx.params),result=await original(downstreamRequest,extra);if(typeof result!="object"||result===null)throw new TypeError(`[mcp-use] ${method} handler returned a non-object result`);originalEnvelope=result;let items=originalEnvelope[resultKey];if(!Array.isArray(items))throw new TypeError(`[mcp-use] ${method} handler result is missing a ${resultKey} array`);return items},filtered=await this.#runMcpHook(method,mwCtx,innerFn);if(!Array.isArray(filtered))throw new TypeError(`[mcp-use] ${method} middleware must return a ${resultKey} array`);let emitted=transform?.(filtered)??filtered;return{...originalEnvelope,[resultKey]:emitted}};wrapped.__mcpListWrapped=!0,handlers.set(method,wrapped)};wrapListMethod("tools/list","tools",omitToolSchemaDialects),wrapListMethod("resources/list","resources"),wrapListMethod("prompts/list","prompts")}#registerTool(server,{definition,callback}){let view=definition.view,toolMeta=buildToolUiMeta(view?.name,definition.visibility,definition._meta),config={...definition.title!==void 0&&{title:definition.title},...definition.description!==void 0&&{description:definition.description},...definition.annotations!==void 0&&{annotations:definition.annotations},...definition.outputSchema!==void 0&&{outputSchema:definition.outputSchema},...toolMeta!==void 0&&{_meta:toolMeta}},wireResultMeta=view!==void 0?buildToolResultUiMeta(view.name):void 0,inputSchema=resolveToolInputSchema(definition),invokeTool=async(args,ctx)=>{let mwCtx=this.#createMiddlewareContext("tools/call",{name:definition.name,arguments:args,...ctx.mcpReq._meta!==void 0&&{_meta:ctx.mcpReq._meta}},ctx),innerFn=async()=>{let effectiveArgs=mwCtx.params.arguments??{},result=await callback(effectiveArgs,this.#toRequestContext(ctx));return isInputRequiredResult2(result)||wireResultMeta===void 0||result.isError===!0?result:{...result,_meta:{...result._meta,...wireResultMeta}}};return await this.#runMcpHook("tools/call",mwCtx,innerFn)};inputSchema!==void 0?server.registerTool(definition.name,{...config,inputSchema},async(args,ctx)=>invokeTool(args,ctx)):server.registerTool(definition.name,config,async ctx=>invokeTool({},ctx))}#registerViewResource(server,viewName,entry,metaOptions,basePath){let uri=viewResourceUri(viewName),authorFacts=this.#viewResourceFacts(this.#viewBindings.get(viewName)?.config),resourceConfig=viewResourceConfig(viewName,entry,authorFacts,metaOptions);server.registerResource(viewName,uri,resourceConfig,async(readUri,ctx)=>{let req=ctx.http?.req,readOptions=req!==void 0?{request:req,...metaOptions.hmrWs===!0?{hmrWs:!0}:{}}:metaOptions.hmrWs===!0?{hmrWs:!0}:{},assetsBase=req!==void 0?resolveAssetsBase(req):metaOptions.request!==void 0?resolveAssetsBase(metaOptions.request):"",html2=synthesizeViewDocument(entry,assetsBase,basePath,viewName);return{contents:[{uri:readUri.href,mimeType:resourceConfig.mimeType,text:html2,_meta:buildResourceUiMeta(authorFacts,readOptions)}]}})}#registerResource(server,{definition,callback}){server.registerResource(definition.name,definition.uri,{...definition.title!==void 0&&{title:definition.title},...definition.description!==void 0&&{description:definition.description},...definition.mimeType!==void 0&&{mimeType:definition.mimeType},...definition.annotations!==void 0&&{annotations:definition.annotations},...definition._meta!==void 0&&{_meta:{...definition._meta}}},async(uri,ctx)=>{let mwCtx=this.#createMiddlewareContext("resources/read",{uri:uri.href,...ctx.mcpReq._meta!==void 0&&{_meta:ctx.mcpReq._meta}},ctx),innerFn=async()=>toResourceResult(await callback(uri,this.#toRequestContext(ctx)),uri.href);return await this.#runMcpHook("resources/read",mwCtx,innerFn)})}#registerResourceTemplate(server,{definition,callback,complete}){let template=new ResourceTemplate(definition.uriTemplate,{list:void 0,...complete!==void 0&&{complete}});server.registerResource(definition.name,template,{...definition.title!==void 0&&{title:definition.title},...definition.description!==void 0&&{description:definition.description},...definition.mimeType!==void 0&&{mimeType:definition.mimeType},...definition.annotations!==void 0&&{annotations:definition.annotations},...definition._meta!==void 0&&{_meta:{...definition._meta}}},async(uri,variables,ctx)=>{let mwCtx=this.#createMiddlewareContext("resources/read",{uri:uri.href,...ctx.mcpReq._meta!==void 0&&{_meta:ctx.mcpReq._meta}},ctx),innerFn=async()=>toResourceResult(await callback(uri,variables,this.#toRequestContext(ctx)),uri.href);return await this.#runMcpHook("resources/read",mwCtx,innerFn)})}#viewResourceFacts(viewConfig){if(viewConfig!==void 0)return{...viewConfig.description!==void 0&&{description:viewConfig.description},...viewConfig.csp!==void 0&&{csp:viewConfig.csp},...viewConfig.permissions!==void 0&&{permissions:viewConfig.permissions},...viewConfig.domain!==void 0&&{domain:viewConfig.domain},...viewConfig.prefersBorder!==void 0&&{prefersBorder:viewConfig.prefersBorder}}}#registerPrompt(server,{definition,callback}){let config={...definition.title!==void 0&&{title:definition.title},...definition.description!==void 0&&{description:definition.description}},invokePrompt=async(args,ctx)=>{let mwCtx=this.#createMiddlewareContext("prompts/get",{name:definition.name,arguments:args,...ctx.mcpReq._meta!==void 0&&{_meta:ctx.mcpReq._meta}},ctx),innerFn=async()=>{let effectiveArgs=mwCtx.params.arguments??{};return toPromptResult(await callback(effectiveArgs,this.#toRequestContext(ctx)))};return await this.#runMcpHook("prompts/get",mwCtx,innerFn)};if(definition.schema!==void 0)server.registerPrompt(definition.name,{...config,argsSchema:definition.schema},async(args,ctx)=>invokePrompt(args,ctx));else{let handler=async ctx=>invokePrompt({},ctx);server.registerPrompt(definition.name,config,handler)}}#toRequestContext(ctx){return this.#config.oauth===void 0?toRequestContext(ctx):toAuthenticatedRequestContext(ctx)}};import{acceptedContent,createRequestStateCodec,inputRequired,inputResponse,isInputRequiredResult as isInputRequiredResult3}from"@modelcontextprotocol/server";function text(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/plain"}}}function markdown(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/markdown"}}}function html(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/html"}}}function xml(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/xml"}}}function css(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/css"}}}function javascript(content){return{content:[{type:"text",text:content}],_meta:{mimeType:"text/javascript"}}}function image(data,mimeType="image/png"){return{content:[{type:"image",data,mimeType}],_meta:{mimeType,isImage:!0}}}function audio(data,mimeType="audio/wav"){return{content:[{type:"audio",data,mimeType}],_meta:{mimeType,isAudio:!0}}}function binary(base64Data,mimeType){return{content:[{type:"text",text:base64Data}],_meta:{mimeType,isBinary:!0}}}function resource(uri,mimeTypeOrContent,text2){if(typeof mimeTypeOrContent=="object"&&mimeTypeOrContent!==null&&"content"in mimeTypeOrContent){let contentResult=mimeTypeOrContent,extractedText,extractedMimeType;if(contentResult._meta&&typeof contentResult._meta=="object"){let meta=contentResult._meta;typeof meta.mimeType=="string"&&(extractedMimeType=meta.mimeType)}let first=contentResult.content?.[0];return first?.type==="text"&&"text"in first&&(extractedText=first.text),{content:[{type:"resource",resource:{uri,...extractedMimeType!==void 0&&{mimeType:extractedMimeType},text:extractedText??""}}]}}let mimeType=mimeTypeOrContent;return{content:[{type:"resource",resource:{uri,...mimeType!==void 0&&mimeType!==""&&{mimeType},text:text2??""}}]}}function error(message){return{isError:!0,content:[{type:"text",text:message}]}}function object(data){return Array.isArray(data)?array(data):{content:[{type:"text",text:JSON.stringify(data,null,2)}],structuredContent:data,_meta:{mimeType:"application/json"}}}function array(data){return{content:[{type:"text",text:JSON.stringify(data,null,2)}],structuredContent:data}}function widget(config){let props=config.props??config.data??{},{output,message,metadata}=config,result={content:message?[{type:"text",text:message}]:Array.isArray(output?.content)&&output.content.length>0?output.content:[{type:"text",text:""}]};return metadata!==void 0&&Object.keys(metadata).length>0&&(result._meta=metadata),output?.structuredContent!==void 0?result.structuredContent=output.structuredContent:Object.keys(props).length>0&&(result.structuredContent=props),result}function mix(...results){let withStructured=results.filter(result=>result.structuredContent!==void 0),structuredContent=withStructured.length>0?withStructured.map(result=>result.structuredContent).reduce((acc,value)=>({...acc,...typeof value=="object"&&value!==null?value:{}}),{}):void 0,withMeta=results.filter(result=>result._meta!==void 0),_meta=withMeta.length>0?withMeta.map(result=>result._meta).reduce((acc,value)=>({...acc,...value!==void 0?value:{}}),{}):void 0;return{content:results.flatMap(result=>result.content),...structuredContent!==void 0&&Object.keys(structuredContent).length>0&&{structuredContent},..._meta!==void 0&&Object.keys(_meta).length>0&&{_meta}}}export{MCPServer,acceptedContent,array,audio,binary,completable,composeFetch,composeMiddleware,createMcpEventListenerEntry,createMcpMiddlewareEntry,createMcpMount,createRequestStateCodec,css,error,getRequestBag,hostValidationMiddleware,html,image,inputRequired,inputResponse,isInputRequiredResult3 as isInputRequiredResult,javascript,jsonBodyMiddleware,markdown,matchesPath,matchesPathPrefix,matchesPattern,mix,object,originValidationMiddleware,pathnameOf,registerViews,requestLogger,resource,text,widget,xml};
|