@nimrobo/mcporter-remote 0.1.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/.claude/settings.local.json +7 -0
- package/.gitattributes +2 -0
- package/.github/workflows/ci.yml +26 -0
- package/AGENTS.md +109 -0
- package/CHANGELOG.md +361 -0
- package/LICENSE +21 -0
- package/README.md +449 -0
- package/bin/git +180 -0
- package/biome.json +43 -0
- package/config/mcporter.json +134 -0
- package/dist/cli/adhoc-server.d.ts +21 -0
- package/dist/cli/adhoc-server.d.ts.map +1 -0
- package/dist/cli/adhoc-server.js +228 -0
- package/dist/cli/adhoc-server.js.map +1 -0
- package/dist/cli/auth-command.d.ts +6 -0
- package/dist/cli/auth-command.d.ts.map +1 -0
- package/dist/cli/auth-command.js +257 -0
- package/dist/cli/auth-command.js.map +1 -0
- package/dist/cli/call-argument-expression.d.ts +5 -0
- package/dist/cli/call-argument-expression.d.ts.map +1 -0
- package/dist/cli/call-argument-expression.js +57 -0
- package/dist/cli/call-argument-expression.js.map +1 -0
- package/dist/cli/call-argument-values.d.ts +10 -0
- package/dist/cli/call-argument-values.d.ts.map +1 -0
- package/dist/cli/call-argument-values.js +83 -0
- package/dist/cli/call-argument-values.js.map +1 -0
- package/dist/cli/call-arguments.d.ts +17 -0
- package/dist/cli/call-arguments.d.ts.map +1 -0
- package/dist/cli/call-arguments.js +183 -0
- package/dist/cli/call-arguments.js.map +1 -0
- package/dist/cli/call-command.d.ts +5 -0
- package/dist/cli/call-command.d.ts.map +1 -0
- package/dist/cli/call-command.js +371 -0
- package/dist/cli/call-command.js.map +1 -0
- package/dist/cli/call-expression-parser.d.ts +9 -0
- package/dist/cli/call-expression-parser.d.ts.map +1 -0
- package/dist/cli/call-expression-parser.js +177 -0
- package/dist/cli/call-expression-parser.js.map +1 -0
- package/dist/cli/cli-factory.d.ts +16 -0
- package/dist/cli/cli-factory.d.ts.map +1 -0
- package/dist/cli/cli-factory.js +37 -0
- package/dist/cli/cli-factory.js.map +1 -0
- package/dist/cli/command-inference.d.ts +12 -0
- package/dist/cli/command-inference.d.ts.map +1 -0
- package/dist/cli/command-inference.js +75 -0
- package/dist/cli/command-inference.js.map +1 -0
- package/dist/cli/config/add.d.ts +23 -0
- package/dist/cli/config/add.d.ts.map +1 -0
- package/dist/cli/config/add.js +267 -0
- package/dist/cli/config/add.js.map +1 -0
- package/dist/cli/config/auth.d.ts +4 -0
- package/dist/cli/config/auth.d.ts.map +1 -0
- package/dist/cli/config/auth.js +21 -0
- package/dist/cli/config/auth.js.map +1 -0
- package/dist/cli/config/doctor.d.ts +3 -0
- package/dist/cli/config/doctor.d.ts.map +1 -0
- package/dist/cli/config/doctor.js +26 -0
- package/dist/cli/config/doctor.js.map +1 -0
- package/dist/cli/config/get.d.ts +3 -0
- package/dist/cli/config/get.d.ts.map +1 -0
- package/dist/cli/config/get.js +45 -0
- package/dist/cli/config/get.js.map +1 -0
- package/dist/cli/config/help.d.ts +18 -0
- package/dist/cli/config/help.d.ts.map +1 -0
- package/dist/cli/config/help.js +193 -0
- package/dist/cli/config/help.js.map +1 -0
- package/dist/cli/config/import.d.ts +9 -0
- package/dist/cli/config/import.d.ts.map +1 -0
- package/dist/cli/config/import.js +88 -0
- package/dist/cli/config/import.js.map +1 -0
- package/dist/cli/config/index.d.ts +2 -0
- package/dist/cli/config/index.d.ts.map +1 -0
- package/dist/cli/config/index.js +2 -0
- package/dist/cli/config/index.js.map +1 -0
- package/dist/cli/config/list.d.ts +7 -0
- package/dist/cli/config/list.d.ts.map +1 -0
- package/dist/cli/config/list.js +71 -0
- package/dist/cli/config/list.js.map +1 -0
- package/dist/cli/config/remove.d.ts +3 -0
- package/dist/cli/config/remove.d.ts.map +1 -0
- package/dist/cli/config/remove.js +19 -0
- package/dist/cli/config/remove.js.map +1 -0
- package/dist/cli/config/render.d.ts +26 -0
- package/dist/cli/config/render.d.ts.map +1 -0
- package/dist/cli/config/render.js +99 -0
- package/dist/cli/config/render.js.map +1 -0
- package/dist/cli/config/shared.d.ts +21 -0
- package/dist/cli/config/shared.d.ts.map +1 -0
- package/dist/cli/config/shared.js +130 -0
- package/dist/cli/config/shared.js.map +1 -0
- package/dist/cli/config/types.d.ts +7 -0
- package/dist/cli/config/types.d.ts.map +1 -0
- package/dist/cli/config/types.js +2 -0
- package/dist/cli/config/types.js.map +1 -0
- package/dist/cli/config-command.d.ts +7 -0
- package/dist/cli/config-command.d.ts.map +1 -0
- package/dist/cli/config-command.js +67 -0
- package/dist/cli/config-command.js.map +1 -0
- package/dist/cli/daemon-command.d.ts +8 -0
- package/dist/cli/daemon-command.d.ts.map +1 -0
- package/dist/cli/daemon-command.js +219 -0
- package/dist/cli/daemon-command.js.map +1 -0
- package/dist/cli/emit-ts-command.d.ts +31 -0
- package/dist/cli/emit-ts-command.d.ts.map +1 -0
- package/dist/cli/emit-ts-command.js +217 -0
- package/dist/cli/emit-ts-command.js.map +1 -0
- package/dist/cli/emit-ts-templates.d.ts +23 -0
- package/dist/cli/emit-ts-templates.d.ts.map +1 -0
- package/dist/cli/emit-ts-templates.js +130 -0
- package/dist/cli/emit-ts-templates.js.map +1 -0
- package/dist/cli/ephemeral-flags.d.ts +7 -0
- package/dist/cli/ephemeral-flags.d.ts.map +1 -0
- package/dist/cli/ephemeral-flags.js +108 -0
- package/dist/cli/ephemeral-flags.js.map +1 -0
- package/dist/cli/ephemeral-target.d.ts +16 -0
- package/dist/cli/ephemeral-target.d.ts.map +1 -0
- package/dist/cli/ephemeral-target.js +105 -0
- package/dist/cli/ephemeral-target.js.map +1 -0
- package/dist/cli/errors.d.ts +4 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/errors.js +7 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/flag-utils.d.ts +4 -0
- package/dist/cli/flag-utils.d.ts.map +1 -0
- package/dist/cli/flag-utils.js +27 -0
- package/dist/cli/flag-utils.js.map +1 -0
- package/dist/cli/generate/artifacts.d.ts +15 -0
- package/dist/cli/generate/artifacts.d.ts.map +1 -0
- package/dist/cli/generate/artifacts.js +247 -0
- package/dist/cli/generate/artifacts.js.map +1 -0
- package/dist/cli/generate/definition.d.ts +22 -0
- package/dist/cli/generate/definition.d.ts.map +1 -0
- package/dist/cli/generate/definition.js +265 -0
- package/dist/cli/generate/definition.js.map +1 -0
- package/dist/cli/generate/flag-parser.d.ts +11 -0
- package/dist/cli/generate/flag-parser.d.ts.map +1 -0
- package/dist/cli/generate/flag-parser.js +41 -0
- package/dist/cli/generate/flag-parser.js.map +1 -0
- package/dist/cli/generate/flags.d.ts +20 -0
- package/dist/cli/generate/flags.d.ts.map +1 -0
- package/dist/cli/generate/flags.js +220 -0
- package/dist/cli/generate/flags.js.map +1 -0
- package/dist/cli/generate/fs-helpers.d.ts +3 -0
- package/dist/cli/generate/fs-helpers.d.ts.map +1 -0
- package/dist/cli/generate/fs-helpers.js +34 -0
- package/dist/cli/generate/fs-helpers.js.map +1 -0
- package/dist/cli/generate/name-utils.d.ts +5 -0
- package/dist/cli/generate/name-utils.d.ts.map +1 -0
- package/dist/cli/generate/name-utils.js +170 -0
- package/dist/cli/generate/name-utils.js.map +1 -0
- package/dist/cli/generate/output.d.ts +5 -0
- package/dist/cli/generate/output.d.ts.map +1 -0
- package/dist/cli/generate/output.js +24 -0
- package/dist/cli/generate/output.js.map +1 -0
- package/dist/cli/generate/runtime.d.ts +3 -0
- package/dist/cli/generate/runtime.d.ts.map +1 -0
- package/dist/cli/generate/runtime.js +34 -0
- package/dist/cli/generate/runtime.js.map +1 -0
- package/dist/cli/generate/server-utils.d.ts +3 -0
- package/dist/cli/generate/server-utils.d.ts.map +1 -0
- package/dist/cli/generate/server-utils.js +33 -0
- package/dist/cli/generate/server-utils.js.map +1 -0
- package/dist/cli/generate/template-data.d.ts +25 -0
- package/dist/cli/generate/template-data.d.ts.map +1 -0
- package/dist/cli/generate/template-data.js +90 -0
- package/dist/cli/generate/template-data.js.map +1 -0
- package/dist/cli/generate/template-help.d.ts +2 -0
- package/dist/cli/generate/template-help.d.ts.map +1 -0
- package/dist/cli/generate/template-help.js +113 -0
- package/dist/cli/generate/template-help.js.map +1 -0
- package/dist/cli/generate/template.d.ts +30 -0
- package/dist/cli/generate/template.d.ts.map +1 -0
- package/dist/cli/generate/template.js +366 -0
- package/dist/cli/generate/template.js.map +1 -0
- package/dist/cli/generate/tools.d.ts +46 -0
- package/dist/cli/generate/tools.d.ts.map +1 -0
- package/dist/cli/generate/tools.js +304 -0
- package/dist/cli/generate/tools.js.map +1 -0
- package/dist/cli/generate/types.d.ts +5 -0
- package/dist/cli/generate/types.d.ts.map +1 -0
- package/dist/cli/generate/types.js +2 -0
- package/dist/cli/generate/types.js.map +1 -0
- package/dist/cli/generate-cli-runner.d.ts +3 -0
- package/dist/cli/generate-cli-runner.d.ts.map +1 -0
- package/dist/cli/generate-cli-runner.js +72 -0
- package/dist/cli/generate-cli-runner.js.map +1 -0
- package/dist/cli/help-output.d.ts +6 -0
- package/dist/cli/help-output.d.ts.map +1 -0
- package/dist/cli/help-output.js +186 -0
- package/dist/cli/help-output.js.map +1 -0
- package/dist/cli/http-utils.d.ts +9 -0
- package/dist/cli/http-utils.d.ts.map +1 -0
- package/dist/cli/http-utils.js +88 -0
- package/dist/cli/http-utils.js.map +1 -0
- package/dist/cli/identifier-helpers.d.ts +20 -0
- package/dist/cli/identifier-helpers.d.ts.map +1 -0
- package/dist/cli/identifier-helpers.js +84 -0
- package/dist/cli/identifier-helpers.js.map +1 -0
- package/dist/cli/image-output.d.ts +3 -0
- package/dist/cli/image-output.d.ts.map +1 -0
- package/dist/cli/image-output.js +57 -0
- package/dist/cli/image-output.js.map +1 -0
- package/dist/cli/inspect-cli-command.d.ts +11 -0
- package/dist/cli/inspect-cli-command.d.ts.map +1 -0
- package/dist/cli/inspect-cli-command.js +78 -0
- package/dist/cli/inspect-cli-command.js.map +1 -0
- package/dist/cli/json-output.d.ts +23 -0
- package/dist/cli/json-output.d.ts.map +1 -0
- package/dist/cli/json-output.js +38 -0
- package/dist/cli/json-output.js.map +1 -0
- package/dist/cli/list-command.d.ts +15 -0
- package/dist/cli/list-command.d.ts.map +1 -0
- package/dist/cli/list-command.js +372 -0
- package/dist/cli/list-command.js.map +1 -0
- package/dist/cli/list-detail-helpers.d.ts +41 -0
- package/dist/cli/list-detail-helpers.d.ts.map +1 -0
- package/dist/cli/list-detail-helpers.js +99 -0
- package/dist/cli/list-detail-helpers.js.map +1 -0
- package/dist/cli/list-doc-comments.d.ts +6 -0
- package/dist/cli/list-doc-comments.d.ts.map +1 -0
- package/dist/cli/list-doc-comments.js +114 -0
- package/dist/cli/list-doc-comments.js.map +1 -0
- package/dist/cli/list-format.d.ts +38 -0
- package/dist/cli/list-format.d.ts.map +1 -0
- package/dist/cli/list-format.js +98 -0
- package/dist/cli/list-format.js.map +1 -0
- package/dist/cli/list-output.d.ts +39 -0
- package/dist/cli/list-output.d.ts.map +1 -0
- package/dist/cli/list-output.js +159 -0
- package/dist/cli/list-output.js.map +1 -0
- package/dist/cli/list-signature.d.ts +26 -0
- package/dist/cli/list-signature.d.ts.map +1 -0
- package/dist/cli/list-signature.js +176 -0
- package/dist/cli/list-signature.js.map +1 -0
- package/dist/cli/logger-context.d.ts +9 -0
- package/dist/cli/logger-context.d.ts.map +1 -0
- package/dist/cli/logger-context.js +29 -0
- package/dist/cli/logger-context.js.map +1 -0
- package/dist/cli/output-format.d.ts +11 -0
- package/dist/cli/output-format.d.ts.map +1 -0
- package/dist/cli/output-format.js +51 -0
- package/dist/cli/output-format.js.map +1 -0
- package/dist/cli/output-utils.d.ts +5 -0
- package/dist/cli/output-utils.d.ts.map +1 -0
- package/dist/cli/output-utils.js +143 -0
- package/dist/cli/output-utils.js.map +1 -0
- package/dist/cli/path-utils.d.ts +2 -0
- package/dist/cli/path-utils.d.ts.map +1 -0
- package/dist/cli/path-utils.js +12 -0
- package/dist/cli/path-utils.js.map +1 -0
- package/dist/cli/runtime-debug.d.ts +4 -0
- package/dist/cli/runtime-debug.d.ts.map +1 -0
- package/dist/cli/runtime-debug.js +134 -0
- package/dist/cli/runtime-debug.js.map +1 -0
- package/dist/cli/server-lookup.d.ts +3 -0
- package/dist/cli/server-lookup.d.ts.map +1 -0
- package/dist/cli/server-lookup.js +21 -0
- package/dist/cli/server-lookup.js.map +1 -0
- package/dist/cli/terminal.d.ts +10 -0
- package/dist/cli/terminal.d.ts.map +1 -0
- package/dist/cli/terminal.js +33 -0
- package/dist/cli/terminal.js.map +1 -0
- package/dist/cli/timeouts.d.ts +9 -0
- package/dist/cli/timeouts.d.ts.map +1 -0
- package/dist/cli/timeouts.js +55 -0
- package/dist/cli/timeouts.js.map +1 -0
- package/dist/cli/tool-cache.d.ts +9 -0
- package/dist/cli/tool-cache.d.ts.map +1 -0
- package/dist/cli/tool-cache.js +31 -0
- package/dist/cli/tool-cache.js.map +1 -0
- package/dist/cli/transport-utils.d.ts +3 -0
- package/dist/cli/transport-utils.d.ts.map +1 -0
- package/dist/cli/transport-utils.js +9 -0
- package/dist/cli/transport-utils.js.map +1 -0
- package/dist/cli-metadata.d.ts +57 -0
- package/dist/cli-metadata.d.ts.map +1 -0
- package/dist/cli-metadata.js +92 -0
- package/dist/cli-metadata.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +217 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/imports/external.d.ts +8 -0
- package/dist/config/imports/external.d.ts.map +1 -0
- package/dist/config/imports/external.js +231 -0
- package/dist/config/imports/external.js.map +1 -0
- package/dist/config/imports/paths-utils.d.ts +3 -0
- package/dist/config/imports/paths-utils.d.ts.map +1 -0
- package/dist/config/imports/paths-utils.js +27 -0
- package/dist/config/imports/paths-utils.js.map +1 -0
- package/dist/config/imports/paths.d.ts +3 -0
- package/dist/config/imports/paths.d.ts.map +1 -0
- package/dist/config/imports/paths.js +135 -0
- package/dist/config/imports/paths.js.map +1 -0
- package/dist/config/imports/shared.d.ts +4 -0
- package/dist/config/imports/shared.d.ts.map +1 -0
- package/dist/config/imports/shared.js +25 -0
- package/dist/config/imports/shared.js.map +1 -0
- package/dist/config/path-discovery.d.ts +11 -0
- package/dist/config/path-discovery.d.ts.map +1 -0
- package/dist/config/path-discovery.js +65 -0
- package/dist/config/path-discovery.js.map +1 -0
- package/dist/config/read-config.d.ts +9 -0
- package/dist/config/read-config.d.ts.map +1 -0
- package/dist/config/read-config.js +74 -0
- package/dist/config/read-config.js.map +1 -0
- package/dist/config-imports.d.ts +7 -0
- package/dist/config-imports.d.ts.map +1 -0
- package/dist/config-imports.js +8 -0
- package/dist/config-imports.js.map +1 -0
- package/dist/config-normalize.d.ts +8 -0
- package/dist/config-normalize.d.ts.map +1 -0
- package/dist/config-normalize.js +184 -0
- package/dist/config-normalize.js.map +1 -0
- package/dist/config-schema.d.ts +164 -0
- package/dist/config-schema.d.ts.map +1 -0
- package/dist/config-schema.js +103 -0
- package/dist/config-schema.js.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +91 -0
- package/dist/config.js.map +1 -0
- package/dist/daemon/client.d.ts +34 -0
- package/dist/daemon/client.d.ts.map +1 -0
- package/dist/daemon/client.js +291 -0
- package/dist/daemon/client.js.map +1 -0
- package/dist/daemon/config-layers.d.ts +7 -0
- package/dist/daemon/config-layers.d.ts.map +1 -0
- package/dist/daemon/config-layers.js +20 -0
- package/dist/daemon/config-layers.js.map +1 -0
- package/dist/daemon/host.d.ts +32 -0
- package/dist/daemon/host.d.ts.map +1 -0
- package/dist/daemon/host.js +345 -0
- package/dist/daemon/host.js.map +1 -0
- package/dist/daemon/launch.d.ts +10 -0
- package/dist/daemon/launch.d.ts.map +1 -0
- package/dist/daemon/launch.js +35 -0
- package/dist/daemon/launch.js.map +1 -0
- package/dist/daemon/log-context.d.ts +18 -0
- package/dist/daemon/log-context.d.ts.map +1 -0
- package/dist/daemon/log-context.js +64 -0
- package/dist/daemon/log-context.js.map +1 -0
- package/dist/daemon/paths.d.ts +5 -0
- package/dist/daemon/paths.d.ts.map +1 -0
- package/dist/daemon/paths.js +30 -0
- package/dist/daemon/paths.js.map +1 -0
- package/dist/daemon/protocol.d.ts +51 -0
- package/dist/daemon/protocol.d.ts.map +1 -0
- package/dist/daemon/protocol.js +2 -0
- package/dist/daemon/protocol.js.map +1 -0
- package/dist/daemon/request-utils.d.ts +12 -0
- package/dist/daemon/request-utils.d.ts.map +1 -0
- package/dist/daemon/request-utils.js +52 -0
- package/dist/daemon/request-utils.js.map +1 -0
- package/dist/daemon/runtime-wrapper.d.ts +9 -0
- package/dist/daemon/runtime-wrapper.d.ts.map +1 -0
- package/dist/daemon/runtime-wrapper.js +110 -0
- package/dist/daemon/runtime-wrapper.js.map +1 -0
- package/dist/env.d.ts +5 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +93 -0
- package/dist/env.js.map +1 -0
- package/dist/error-classifier.d.ts +11 -0
- package/dist/error-classifier.d.ts.map +1 -0
- package/dist/error-classifier.js +141 -0
- package/dist/error-classifier.js.map +1 -0
- package/dist/fs-json.d.ts +3 -0
- package/dist/fs-json.d.ts.map +1 -0
- package/dist/fs-json.js +21 -0
- package/dist/fs-json.js.map +1 -0
- package/dist/generate-cli.d.ts +32 -0
- package/dist/generate-cli.d.ts.map +1 -0
- package/dist/generate-cli.js +155 -0
- package/dist/generate-cli.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +8 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +106 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/logging.d.ts +19 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +76 -0
- package/dist/logging.js.map +1 -0
- package/dist/oauth-manual.d.ts +9 -0
- package/dist/oauth-manual.d.ts.map +1 -0
- package/dist/oauth-manual.js +84 -0
- package/dist/oauth-manual.js.map +1 -0
- package/dist/oauth-persistence.d.ts +20 -0
- package/dist/oauth-persistence.d.ts.map +1 -0
- package/dist/oauth-persistence.js +254 -0
- package/dist/oauth-persistence.js.map +1 -0
- package/dist/oauth-vault.d.ts +19 -0
- package/dist/oauth-vault.d.ts.map +1 -0
- package/dist/oauth-vault.js +100 -0
- package/dist/oauth-vault.js.map +1 -0
- package/dist/oauth.d.ts +31 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +414 -0
- package/dist/oauth.js.map +1 -0
- package/dist/result-utils.d.ts +22 -0
- package/dist/result-utils.d.ts.map +1 -0
- package/dist/result-utils.js +229 -0
- package/dist/result-utils.js.map +1 -0
- package/dist/runtime/errors.d.ts +2 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +16 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/http-transport.d.ts +15 -0
- package/dist/runtime/http-transport.d.ts.map +1 -0
- package/dist/runtime/http-transport.js +91 -0
- package/dist/runtime/http-transport.js.map +1 -0
- package/dist/runtime/manual-oauth.d.ts +8 -0
- package/dist/runtime/manual-oauth.d.ts.map +1 -0
- package/dist/runtime/manual-oauth.js +81 -0
- package/dist/runtime/manual-oauth.js.map +1 -0
- package/dist/runtime/oauth.d.ts +22 -0
- package/dist/runtime/oauth.d.ts.map +1 -0
- package/dist/runtime/oauth.js +83 -0
- package/dist/runtime/oauth.js.map +1 -0
- package/dist/runtime/transport.d.ts +24 -0
- package/dist/runtime/transport.d.ts.map +1 -0
- package/dist/runtime/transport.js +165 -0
- package/dist/runtime/transport.js.map +1 -0
- package/dist/runtime/utils.d.ts +5 -0
- package/dist/runtime/utils.d.ts.map +1 -0
- package/dist/runtime/utils.js +47 -0
- package/dist/runtime/utils.js.map +1 -0
- package/dist/runtime-header-utils.d.ts +2 -0
- package/dist/runtime-header-utils.d.ts.map +1 -0
- package/dist/runtime-header-utils.js +19 -0
- package/dist/runtime-header-utils.js.map +1 -0
- package/dist/runtime-oauth-support.d.ts +5 -0
- package/dist/runtime-oauth-support.d.ts.map +1 -0
- package/dist/runtime-oauth-support.js +21 -0
- package/dist/runtime-oauth-support.js.map +1 -0
- package/dist/runtime-process-utils.d.ts +11 -0
- package/dist/runtime-process-utils.d.ts.map +1 -0
- package/dist/runtime-process-utils.js +299 -0
- package/dist/runtime-process-utils.js.map +1 -0
- package/dist/runtime.d.ts +55 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +245 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schema-cache.d.ts +10 -0
- package/dist/schema-cache.d.ts.map +1 -0
- package/dist/schema-cache.js +40 -0
- package/dist/schema-cache.js.map +1 -0
- package/dist/sdk-patches.d.ts +5 -0
- package/dist/sdk-patches.d.ts.map +1 -0
- package/dist/sdk-patches.js +399 -0
- package/dist/sdk-patches.js.map +1 -0
- package/dist/server-proxy.d.ts +17 -0
- package/dist/server-proxy.d.ts.map +1 -0
- package/dist/server-proxy.js +342 -0
- package/dist/server-proxy.js.map +1 -0
- package/docs/RELEASE.md +96 -0
- package/docs/adhoc.md +76 -0
- package/docs/call-heuristic.md +31 -0
- package/docs/call-syntax.md +75 -0
- package/docs/cli-generator.md +116 -0
- package/docs/cli-reference.md +76 -0
- package/docs/config.md +208 -0
- package/docs/daemon.md +95 -0
- package/docs/emit-ts.md +98 -0
- package/docs/hang-debug.md +88 -0
- package/docs/import.md +59 -0
- package/docs/known-issues.md +33 -0
- package/docs/livetests.md +31 -0
- package/docs/local.md +73 -0
- package/docs/logging.md +67 -0
- package/docs/manual-testing.md +78 -0
- package/docs/mcp.md +44 -0
- package/docs/migration.md +77 -0
- package/docs/pnpm-mcp-migration.md +15 -0
- package/docs/refactor.md +76 -0
- package/docs/shortcuts.md +31 -0
- package/docs/spec.md +86 -0
- package/docs/subagent.md +39 -0
- package/docs/supabase-auth-issue.md +53 -0
- package/docs/tmux.md +30 -0
- package/docs/tool-calling.md +73 -0
- package/docs/windows.md +25 -0
- package/examples/context7-headlines.ts +72 -0
- package/git +3 -0
- package/mcporter.png +0 -0
- package/mcporter.schema.json +263 -0
- package/package.json +105 -0
- package/pnpm-workspace.yaml +2 -0
- package/runner +13 -0
- package/scripts/agent-send.ts +179 -0
- package/scripts/build-bun.ts +125 -0
- package/scripts/committer +53 -0
- package/scripts/docs-list.ts +132 -0
- package/scripts/generate-json-schema.ts +50 -0
- package/scripts/git-policy.ts +165 -0
- package/scripts/mcp_signoz_retry_patch.cjs +9 -0
- package/scripts/release.sh +86 -0
- package/scripts/runner.ts +1556 -0
- package/scripts/test-runner.js +39 -0
- package/src/cli/adhoc-server.ts +263 -0
- package/src/cli/auth-command.ts +290 -0
- package/src/cli/call-argument-expression.ts +61 -0
- package/src/cli/call-argument-values.ts +95 -0
- package/src/cli/call-arguments.ts +246 -0
- package/src/cli/call-command.ts +478 -0
- package/src/cli/call-expression-parser.ts +210 -0
- package/src/cli/cli-factory.ts +51 -0
- package/src/cli/command-inference.ts +99 -0
- package/src/cli/config/add.ts +308 -0
- package/src/cli/config/auth.ts +23 -0
- package/src/cli/config/doctor.ts +27 -0
- package/src/cli/config/get.ts +47 -0
- package/src/cli/config/help.ts +213 -0
- package/src/cli/config/import.ts +97 -0
- package/src/cli/config/index.ts +1 -0
- package/src/cli/config/list.ts +81 -0
- package/src/cli/config/remove.ts +20 -0
- package/src/cli/config/render.ts +119 -0
- package/src/cli/config/shared.ts +159 -0
- package/src/cli/config/types.ts +8 -0
- package/src/cli/config-command.ts +72 -0
- package/src/cli/daemon-command.ts +260 -0
- package/src/cli/emit-ts-command.ts +260 -0
- package/src/cli/emit-ts-templates.ts +161 -0
- package/src/cli/ephemeral-flags.ts +128 -0
- package/src/cli/ephemeral-target.ts +134 -0
- package/src/cli/errors.ts +6 -0
- package/src/cli/flag-utils.ts +29 -0
- package/src/cli/generate/artifacts.ts +308 -0
- package/src/cli/generate/definition.ts +325 -0
- package/src/cli/generate/flag-parser.ts +50 -0
- package/src/cli/generate/flags.ts +248 -0
- package/src/cli/generate/fs-helpers.ts +34 -0
- package/src/cli/generate/name-utils.ts +176 -0
- package/src/cli/generate/output.ts +27 -0
- package/src/cli/generate/runtime.ts +38 -0
- package/src/cli/generate/server-utils.ts +38 -0
- package/src/cli/generate/template-data.ts +126 -0
- package/src/cli/generate/template-help.ts +112 -0
- package/src/cli/generate/template.ts +407 -0
- package/src/cli/generate/tools.ts +354 -0
- package/src/cli/generate/types.ts +1 -0
- package/src/cli/generate-cli-runner.ts +82 -0
- package/src/cli/help-output.ts +207 -0
- package/src/cli/http-utils.ts +89 -0
- package/src/cli/identifier-helpers.ts +107 -0
- package/src/cli/image-output.ts +62 -0
- package/src/cli/inspect-cli-command.ts +89 -0
- package/src/cli/json-output.ts +60 -0
- package/src/cli/list-command.ts +432 -0
- package/src/cli/list-detail-helpers.ts +179 -0
- package/src/cli/list-doc-comments.ts +129 -0
- package/src/cli/list-format.ts +150 -0
- package/src/cli/list-output.ts +224 -0
- package/src/cli/list-signature.ts +217 -0
- package/src/cli/logger-context.ts +36 -0
- package/src/cli/output-format.ts +63 -0
- package/src/cli/output-utils.ts +161 -0
- package/src/cli/path-utils.ts +13 -0
- package/src/cli/runtime-debug.ts +141 -0
- package/src/cli/server-lookup.ts +22 -0
- package/src/cli/terminal.ts +41 -0
- package/src/cli/timeouts.ts +67 -0
- package/src/cli/tool-cache.ts +43 -0
- package/src/cli/transport-utils.ts +10 -0
- package/src/cli-metadata.ts +164 -0
- package/src/cli.ts +234 -0
- package/src/config/imports/external.ts +284 -0
- package/src/config/imports/paths-utils.ts +29 -0
- package/src/config/imports/paths.ts +145 -0
- package/src/config/imports/shared.ts +27 -0
- package/src/config/path-discovery.ts +79 -0
- package/src/config/read-config.ts +91 -0
- package/src/config-imports.ts +12 -0
- package/src/config-normalize.ts +220 -0
- package/src/config-schema.ts +175 -0
- package/src/config.ts +136 -0
- package/src/daemon/client.ts +350 -0
- package/src/daemon/config-layers.ts +23 -0
- package/src/daemon/host.ts +455 -0
- package/src/daemon/launch.ts +45 -0
- package/src/daemon/log-context.ts +78 -0
- package/src/daemon/paths.ts +35 -0
- package/src/daemon/protocol.ts +57 -0
- package/src/daemon/request-utils.ts +67 -0
- package/src/daemon/runtime-wrapper.ts +135 -0
- package/src/env.ts +107 -0
- package/src/error-classifier.ts +158 -0
- package/src/fs-json.ts +21 -0
- package/src/generate-cli.ts +211 -0
- package/src/index.ts +14 -0
- package/src/lifecycle.ts +138 -0
- package/src/logging.ts +93 -0
- package/src/oauth-manual.ts +103 -0
- package/src/oauth-persistence.ts +316 -0
- package/src/oauth-vault.ts +128 -0
- package/src/oauth.ts +494 -0
- package/src/result-utils.ts +278 -0
- package/src/runtime/errors.ts +17 -0
- package/src/runtime/oauth.ts +112 -0
- package/src/runtime/transport.ts +198 -0
- package/src/runtime/utils.ts +54 -0
- package/src/runtime-header-utils.ts +23 -0
- package/src/runtime-oauth-support.ts +24 -0
- package/src/runtime-process-utils.ts +324 -0
- package/src/runtime.ts +321 -0
- package/src/schema-cache.ts +49 -0
- package/src/sdk-patches.ts +498 -0
- package/src/server-proxy.ts +407 -0
- package/tests/adhoc-server.test.ts +49 -0
- package/tests/call-arguments.test.ts +111 -0
- package/tests/cli-auth-help.test.ts +43 -0
- package/tests/cli-auth-retry.test.ts +41 -0
- package/tests/cli-auth.test.ts +96 -0
- package/tests/cli-call-args.test.ts +69 -0
- package/tests/cli-call-errors.test.ts +27 -0
- package/tests/cli-call-execution.test.ts +279 -0
- package/tests/cli-call-help.test.ts +43 -0
- package/tests/cli-command-inference.test.ts +73 -0
- package/tests/cli-config-command.test.ts +371 -0
- package/tests/cli-config-fallback.test.ts +259 -0
- package/tests/cli-config-routing.test.ts +20 -0
- package/tests/cli-ephemeral-flags.test.ts +54 -0
- package/tests/cli-flag-utils.test.ts +17 -0
- package/tests/cli-generate-artifacts.test.ts +52 -0
- package/tests/cli-generate-cli.integration.test.ts +675 -0
- package/tests/cli-generate-runner.test.ts +156 -0
- package/tests/cli-global-flags.test.ts +61 -0
- package/tests/cli-help-shortcuts.test.ts +42 -0
- package/tests/cli-image-output.test.ts +65 -0
- package/tests/cli-inspect-command.test.ts +15 -0
- package/tests/cli-list-classification.test.ts +291 -0
- package/tests/cli-list-flags.test.ts +83 -0
- package/tests/cli-list-formatting.test.ts +358 -0
- package/tests/cli-list-help.test.ts +43 -0
- package/tests/cli-list-json.test.ts +55 -0
- package/tests/cli-list-stdio-logs.test.ts +108 -0
- package/tests/cli-list-verbose-e2e.test.ts +83 -0
- package/tests/cli-oauth-timeout-flag.test.ts +94 -0
- package/tests/cli-output-utils.test.ts +129 -0
- package/tests/cli-regenerate.test.ts +261 -0
- package/tests/cli-version.test.ts +24 -0
- package/tests/config-add-dry-run.test.ts +45 -0
- package/tests/config-add-flags.test.ts +61 -0
- package/tests/config-add-imports.test.ts +28 -0
- package/tests/config-add-persist.test.ts +27 -0
- package/tests/config-add-scope-behavior.test.ts +46 -0
- package/tests/config-add-scope.test.ts +101 -0
- package/tests/config-add-sse.test.ts +23 -0
- package/tests/config-command-string.test.ts +96 -0
- package/tests/config-doctor.test.ts +45 -0
- package/tests/config-get-json.test.ts +24 -0
- package/tests/config-import-dedupe.test.ts +27 -0
- package/tests/config-import-paths.test.ts +49 -0
- package/tests/config-import.test.ts +64 -0
- package/tests/config-imports-unit.test.ts +337 -0
- package/tests/config-imports.test.ts +417 -0
- package/tests/config-layered.test.ts +178 -0
- package/tests/config-list-text-footer.test.ts +33 -0
- package/tests/config-list.test.ts +62 -0
- package/tests/config-missing.test.ts +140 -0
- package/tests/config-normalize.test.ts +71 -0
- package/tests/config-remove.test.ts +44 -0
- package/tests/config-render.test.ts +61 -0
- package/tests/config-resolution.test.ts +94 -0
- package/tests/config-schema-file.test.ts +29 -0
- package/tests/config-shared.test.ts +41 -0
- package/tests/config-sources.test.ts +58 -0
- package/tests/daemon-cli-command.test.ts +112 -0
- package/tests/daemon-client-config-stale.test.ts +222 -0
- package/tests/daemon-client-timeout.test.ts +114 -0
- package/tests/daemon-client.test.ts +61 -0
- package/tests/daemon-host.test.ts +33 -0
- package/tests/daemon.integration.test.ts +175 -0
- package/tests/emit-ts.test.ts +125 -0
- package/tests/ephemeral-target.test.ts +26 -0
- package/tests/error-classifier.test.ts +46 -0
- package/tests/fixtures/ansi.ts +18 -0
- package/tests/fixtures/cli-list-fixtures.ts +43 -0
- package/tests/fixtures/config-fixture.ts +29 -0
- package/tests/fixtures/imports/.claude/mcp.json +8 -0
- package/tests/fixtures/imports/.claude/settings.json +10 -0
- package/tests/fixtures/imports/.claude/settings.local.json +10 -0
- package/tests/fixtures/imports/.codeium/windsurf/mcp_config.json +14 -0
- package/tests/fixtures/imports/.codex/config.toml +7 -0
- package/tests/fixtures/imports/.config/opencode/opencode.jsonc +10 -0
- package/tests/fixtures/imports/.cursor/mcp.json +14 -0
- package/tests/fixtures/imports/Library/Application Support/Code/User/mcp.json +11 -0
- package/tests/fixtures/imports/config/mcporter.json +11 -0
- package/tests/fixtures/imports/home/.claude/settings.json +7 -0
- package/tests/fixtures/imports/home/.codeium/windsurf/mcp_config.json +14 -0
- package/tests/fixtures/imports/home/.codex/config.toml +7 -0
- package/tests/fixtures/imports/home/Library/Application Support/Code/User/mcp.json +11 -0
- package/tests/fixtures/imports/opencode.jsonc +11 -0
- package/tests/fixtures/mcporter.json +64 -0
- package/tests/fixtures/stdio-filesystem-server.mjs +63 -0
- package/tests/fixtures/stdio-memory-server.mjs +58 -0
- package/tests/fixtures/test-helpers.ts +24 -0
- package/tests/fixtures/tool-fixtures.ts +35 -0
- package/tests/fs-json.test.ts +35 -0
- package/tests/generate-cli-helpers.test.ts +162 -0
- package/tests/generate-cli.test.ts +595 -0
- package/tests/generate-definition.test.ts +25 -0
- package/tests/generator-flag-parser.test.ts +19 -0
- package/tests/index-api.test.ts +136 -0
- package/tests/keep-alive-runtime.test.ts +152 -0
- package/tests/lifecycle.test.ts +29 -0
- package/tests/list-detail-helpers.test.ts +204 -0
- package/tests/list-format.test.ts +40 -0
- package/tests/list-inline-stdio.test.ts +71 -0
- package/tests/list-output.test.ts +138 -0
- package/tests/live/deepwiki-live.test.ts +53 -0
- package/tests/oauth-callback.test.ts +108 -0
- package/tests/oauth-open-external.test.ts +29 -0
- package/tests/oauth-persistence.test.ts +146 -0
- package/tests/oauth-session.test.ts +216 -0
- package/tests/result-utils.test.ts +254 -0
- package/tests/runtime-call-timeout.test.ts +75 -0
- package/tests/runtime-compose.test.ts +298 -0
- package/tests/runtime-error-reset.test.ts +65 -0
- package/tests/runtime-header-utils.test.ts +36 -0
- package/tests/runtime-integration.test.ts +113 -0
- package/tests/runtime-oauth-connect.test.ts +72 -0
- package/tests/runtime-oauth-detection.test.ts +72 -0
- package/tests/runtime-oauth-timeout.test.ts +60 -0
- package/tests/runtime-oauth-utils.test.ts +14 -0
- package/tests/runtime-process-utils.test.ts +53 -0
- package/tests/runtime-transport.test.ts +69 -0
- package/tests/runtime-utils.test.ts +31 -0
- package/tests/runtime.test.ts +94 -0
- package/tests/sdk-patches.test.ts +24 -0
- package/tests/server-proxy.test.ts +336 -0
- package/tests/stdio-servers.integration.test.ts +139 -0
- package/tests/tool-cache.test.ts +42 -0
- package/tests/version-consistency.test.ts +11 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +17 -0
- package/vitest.config.ts +18 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { buildToolMetadata } from '../src/cli/generate/tools.js';
|
|
3
|
+
import type { ListSummaryResult } from '../src/cli/list-format.js';
|
|
4
|
+
import {
|
|
5
|
+
buildAuthCommandHint,
|
|
6
|
+
buildJsonListEntry,
|
|
7
|
+
createEmptyStatusCounts,
|
|
8
|
+
printSingleServerHeader,
|
|
9
|
+
printToolDetail,
|
|
10
|
+
} from '../src/cli/list-output.js';
|
|
11
|
+
import type { ServerDefinition } from '../src/config.js';
|
|
12
|
+
import type { ServerToolInfo } from '../src/runtime.js';
|
|
13
|
+
|
|
14
|
+
describe('list output helpers', () => {
|
|
15
|
+
const definition: ServerDefinition = {
|
|
16
|
+
name: 'demo',
|
|
17
|
+
description: 'Demo server',
|
|
18
|
+
command: { kind: 'http', url: new URL('https://demo.example.com/mcp') },
|
|
19
|
+
source: { kind: 'local', path: '/tmp/mcporter.json' },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
it('renders single server headers with tool counts and transport info', () => {
|
|
23
|
+
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
24
|
+
const summary = printSingleServerHeader(definition, 2, 42, 'HTTP https://demo.example.com/mcp', 'config/demo');
|
|
25
|
+
expect(summary).toContain('2 tools');
|
|
26
|
+
expect(summary).toContain('42ms');
|
|
27
|
+
expect(summary).toContain('HTTP https://demo.example.com/mcp');
|
|
28
|
+
logSpy.mockRestore();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('prints tool details and indicates optional fields', () => {
|
|
32
|
+
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
33
|
+
const tool: ServerToolInfo = {
|
|
34
|
+
name: 'add',
|
|
35
|
+
description: 'Add numbers',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
a: { type: 'number', description: 'First operand' },
|
|
40
|
+
b: { type: 'number', description: 'Second operand' },
|
|
41
|
+
format: { type: 'string', enum: ['json', 'markdown'], description: 'Format' },
|
|
42
|
+
projectId: { type: 'string', description: 'Project context' },
|
|
43
|
+
initiativeId: { type: 'string', description: 'Initiative context' },
|
|
44
|
+
creatorId: { type: 'string', description: 'Creator filter' },
|
|
45
|
+
},
|
|
46
|
+
required: ['a', 'b'],
|
|
47
|
+
},
|
|
48
|
+
outputSchema: { type: 'number' },
|
|
49
|
+
};
|
|
50
|
+
const metadata = buildToolMetadata(tool);
|
|
51
|
+
const detail = printToolDetail(definition, metadata, true, true);
|
|
52
|
+
expect(detail.optionalOmitted).toBe(true);
|
|
53
|
+
expect(detail.examples.length).toBeGreaterThan(0);
|
|
54
|
+
logSpy.mockRestore();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('prints URL-based examples for ad-hoc HTTP servers', () => {
|
|
58
|
+
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
59
|
+
const adhocDefinition: ServerDefinition = {
|
|
60
|
+
name: 'mcp-sentry-dev-mcp',
|
|
61
|
+
description: 'Ad-hoc Sentry',
|
|
62
|
+
command: { kind: 'http', url: new URL('https://mcp.sentry.dev/mcp?agent=1') },
|
|
63
|
+
source: { kind: 'local', path: '<adhoc>' },
|
|
64
|
+
};
|
|
65
|
+
const tool: ServerToolInfo = {
|
|
66
|
+
name: 'use_sentry',
|
|
67
|
+
description: 'Proxy to Sentry',
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: {
|
|
71
|
+
request: { type: 'string', description: 'Instruction' },
|
|
72
|
+
},
|
|
73
|
+
required: ['request'],
|
|
74
|
+
},
|
|
75
|
+
outputSchema: { type: 'object' },
|
|
76
|
+
};
|
|
77
|
+
const metadata = buildToolMetadata(tool);
|
|
78
|
+
const detail = printToolDetail(adhocDefinition, metadata, false, true);
|
|
79
|
+
expect(detail.examples[0]).toContain("'https://mcp.sentry.dev/mcp?agent=1.use_sentry(");
|
|
80
|
+
logSpy.mockRestore();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('builds JSON summaries for successful servers', () => {
|
|
84
|
+
const summary: ListSummaryResult = {
|
|
85
|
+
status: 'ok',
|
|
86
|
+
server: definition,
|
|
87
|
+
durationMs: 12,
|
|
88
|
+
tools: [
|
|
89
|
+
{ name: 'add', description: 'Add numbers', inputSchema: { type: 'object' }, outputSchema: { type: 'number' } },
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
const entry = buildJsonListEntry(summary, 30, { includeSchemas: true });
|
|
93
|
+
expect(entry.status).toBe('ok');
|
|
94
|
+
expect(entry.tools?.[0]?.name).toBe('add');
|
|
95
|
+
expect(entry.tools?.[0]?.inputSchema).toBeDefined();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('includes auth hints for error summaries', () => {
|
|
99
|
+
const summary: ListSummaryResult = {
|
|
100
|
+
status: 'error',
|
|
101
|
+
server: definition,
|
|
102
|
+
durationMs: 1000,
|
|
103
|
+
error: new Error('HTTP error 401'),
|
|
104
|
+
};
|
|
105
|
+
const entry = buildJsonListEntry(summary, 5, { includeSchemas: false });
|
|
106
|
+
expect(entry.status).toBe('auth');
|
|
107
|
+
expect(entry.authCommand).toBe(buildAuthCommandHint(definition));
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('exposes source list in JSON only when includeSources is true', () => {
|
|
111
|
+
const withSources: ServerDefinition = {
|
|
112
|
+
...definition,
|
|
113
|
+
source: { kind: 'local', path: '/project/config/mcporter.json' },
|
|
114
|
+
sources: [
|
|
115
|
+
{ kind: 'local', path: '/project/config/mcporter.json' },
|
|
116
|
+
{ kind: 'import', path: '/home/.cursor/mcp.json' },
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
const summary: ListSummaryResult = {
|
|
120
|
+
status: 'ok',
|
|
121
|
+
server: withSources,
|
|
122
|
+
durationMs: 10,
|
|
123
|
+
tools: [],
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const minimal = buildJsonListEntry(summary, 30, { includeSchemas: false });
|
|
127
|
+
expect(minimal.sources).toBeUndefined();
|
|
128
|
+
|
|
129
|
+
const verbose = buildJsonListEntry(summary, 30, { includeSchemas: false, includeSources: true });
|
|
130
|
+
expect(verbose.sources).toEqual(withSources.sources);
|
|
131
|
+
expect(verbose.source).toEqual(withSources.source);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('creates empty status counts with zeroed categories', () => {
|
|
135
|
+
const counts = createEmptyStatusCounts();
|
|
136
|
+
expect(counts).toEqual({ ok: 0, auth: 0, offline: 0, http: 0, error: 0 });
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
|
|
5
|
+
const LIVE_FLAG = process.env.MCP_LIVE_TESTS === '1';
|
|
6
|
+
const ENDPOINTS = [
|
|
7
|
+
{ name: 'streamable-http', url: 'https://mcp.deepwiki.com/mcp' },
|
|
8
|
+
{ name: 'sse', url: 'https://mcp.deepwiki.com/sse' },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const execFileAsync = promisify(execFile);
|
|
12
|
+
|
|
13
|
+
function skipReason(): string | undefined {
|
|
14
|
+
if (!LIVE_FLAG) {
|
|
15
|
+
return 'set MCP_LIVE_TESTS=1 to run live MCP tests';
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe.skipIf(Boolean(skipReason()))('deepwiki live', () => {
|
|
21
|
+
ENDPOINTS.forEach(({ name, url }) => {
|
|
22
|
+
it(`lists wiki structure via ${name}`, async () => {
|
|
23
|
+
const { stdout, stderr } = await execFileAsync('node', [
|
|
24
|
+
'dist/cli.js',
|
|
25
|
+
'call',
|
|
26
|
+
url,
|
|
27
|
+
'read_wiki_structure',
|
|
28
|
+
'repoName:facebook/react',
|
|
29
|
+
'--output',
|
|
30
|
+
'json',
|
|
31
|
+
]);
|
|
32
|
+
const normalized = stdout.trim() || stderr.trim();
|
|
33
|
+
// Response comes back as a JS-object literal string; just assert it contains the section list.
|
|
34
|
+
expect(normalized).toContain('Available pages for facebook/react');
|
|
35
|
+
expect(normalized).toContain('Overview');
|
|
36
|
+
}, 30_000);
|
|
37
|
+
|
|
38
|
+
it(`prints plain text when default output is used via ${name}`, async () => {
|
|
39
|
+
const { stdout, stderr } = await execFileAsync('node', [
|
|
40
|
+
'dist/cli.js',
|
|
41
|
+
'call',
|
|
42
|
+
url,
|
|
43
|
+
'read_wiki_structure',
|
|
44
|
+
'repoName:facebook/react',
|
|
45
|
+
]);
|
|
46
|
+
const normalized = (stdout || stderr).trim();
|
|
47
|
+
expect(normalized).toContain('Available pages for facebook/react');
|
|
48
|
+
// Ensure we rendered the text content, not the JSON envelope.
|
|
49
|
+
expect(normalized).not.toContain('"type"');
|
|
50
|
+
expect(normalized.startsWith('{')).toBe(false);
|
|
51
|
+
}, 30_000);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
6
|
+
import type { ServerDefinition } from '../src/config.js';
|
|
7
|
+
import { createOAuthSession } from '../src/oauth.js';
|
|
8
|
+
|
|
9
|
+
const makeDefinition = (overrides: Partial<ServerDefinition> = {}): ServerDefinition => ({
|
|
10
|
+
name: overrides.name ?? 'svc',
|
|
11
|
+
description: 'test',
|
|
12
|
+
command: { kind: 'http', url: new URL('https://example.com/mcp') },
|
|
13
|
+
tokenCacheDir: overrides.tokenCacheDir ?? path.join(os.tmpdir(), 'mcporter-oauth-test', randomUUID()),
|
|
14
|
+
auth: 'oauth',
|
|
15
|
+
...overrides,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const logger = { info: () => {}, warn: () => {}, error: () => {} };
|
|
19
|
+
type StatefulProvider = { redirectUrl: string | URL; state: () => Promise<string> };
|
|
20
|
+
|
|
21
|
+
const requestStatus = (target: URL): Promise<number> =>
|
|
22
|
+
new Promise((resolve, reject) => {
|
|
23
|
+
const req = http.request(
|
|
24
|
+
{
|
|
25
|
+
hostname: target.hostname,
|
|
26
|
+
port: target.port,
|
|
27
|
+
path: `${target.pathname}${target.search}`,
|
|
28
|
+
family: 4,
|
|
29
|
+
method: 'GET',
|
|
30
|
+
},
|
|
31
|
+
(res) => {
|
|
32
|
+
const status = res.statusCode ?? 0;
|
|
33
|
+
res.resume();
|
|
34
|
+
resolve(status);
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
req.on('error', reject);
|
|
38
|
+
req.end();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
let cleanup: (() => Promise<void>) | null = null;
|
|
42
|
+
afterEach(async () => {
|
|
43
|
+
if (cleanup) {
|
|
44
|
+
await cleanup();
|
|
45
|
+
cleanup = null;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('oauth callback handling', () => {
|
|
50
|
+
it('rejects callbacks when state does not match', async () => {
|
|
51
|
+
const session = await createOAuthSession(makeDefinition(), logger);
|
|
52
|
+
cleanup = () => session.close();
|
|
53
|
+
const provider = session.provider as StatefulProvider;
|
|
54
|
+
const redirect = new URL(String(provider.redirectUrl));
|
|
55
|
+
redirect.hostname = '127.0.0.1';
|
|
56
|
+
|
|
57
|
+
// Persist expected state then send a mismatched one.
|
|
58
|
+
await provider.state();
|
|
59
|
+
const wait = session.waitForAuthorizationCode();
|
|
60
|
+
wait.catch(() => {});
|
|
61
|
+
const badUrl = new URL(redirect);
|
|
62
|
+
badUrl.searchParams.set('code', 'abc');
|
|
63
|
+
badUrl.searchParams.set('state', 'wrong-state');
|
|
64
|
+
|
|
65
|
+
const status = await requestStatus(badUrl);
|
|
66
|
+
expect(status).toBeGreaterThanOrEqual(400);
|
|
67
|
+
|
|
68
|
+
await expect(wait).rejects.toThrow(/state/i);
|
|
69
|
+
await wait.catch(() => {});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('honors custom callback paths in oauthRedirectUrl', async () => {
|
|
73
|
+
const session = await createOAuthSession(
|
|
74
|
+
makeDefinition({ oauthRedirectUrl: 'http://127.0.0.1:0/custom-cb' }),
|
|
75
|
+
logger
|
|
76
|
+
);
|
|
77
|
+
cleanup = () => session.close();
|
|
78
|
+
const provider = session.provider as StatefulProvider;
|
|
79
|
+
const redirect = new URL(String(provider.redirectUrl));
|
|
80
|
+
const state = await provider.state();
|
|
81
|
+
|
|
82
|
+
const wait = session.waitForAuthorizationCode();
|
|
83
|
+
const okUrl = new URL(redirect);
|
|
84
|
+
okUrl.searchParams.set('code', 'xyz');
|
|
85
|
+
okUrl.searchParams.set('state', state);
|
|
86
|
+
|
|
87
|
+
const status = await requestStatus(okUrl);
|
|
88
|
+
expect(status).toBe(200);
|
|
89
|
+
await expect(wait).resolves.toBe('xyz');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('accepts callbacks that omit state (compat servers)', async () => {
|
|
93
|
+
const session = await createOAuthSession(makeDefinition(), logger);
|
|
94
|
+
cleanup = () => session.close();
|
|
95
|
+
const provider = session.provider as StatefulProvider;
|
|
96
|
+
const redirect = new URL(String(provider.redirectUrl));
|
|
97
|
+
redirect.hostname = '127.0.0.1';
|
|
98
|
+
|
|
99
|
+
await provider.state();
|
|
100
|
+
const wait = session.waitForAuthorizationCode();
|
|
101
|
+
|
|
102
|
+
const okUrl = new URL(redirect);
|
|
103
|
+
okUrl.searchParams.set('code', 'nostate');
|
|
104
|
+
const status = await requestStatus(okUrl);
|
|
105
|
+
expect(status).toBe(200);
|
|
106
|
+
await expect(wait).resolves.toBe('nostate');
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { __oauthInternals } from '../src/oauth.js';
|
|
4
|
+
|
|
5
|
+
describe('openExternal', () => {
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
vi.restoreAllMocks();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('swallows xdg-open error events on linux', () => {
|
|
11
|
+
const child = new EventEmitter() as EventEmitter & { unref: () => void };
|
|
12
|
+
child.unref = vi.fn();
|
|
13
|
+
const launch = vi.fn(() => child as unknown as ReturnType<typeof import('node:child_process').spawn>);
|
|
14
|
+
|
|
15
|
+
expect(() =>
|
|
16
|
+
__oauthInternals.openExternal(
|
|
17
|
+
'https://example.com/auth',
|
|
18
|
+
'linux',
|
|
19
|
+
launch as unknown as typeof import('node:child_process').spawn
|
|
20
|
+
)
|
|
21
|
+
).not.toThrow();
|
|
22
|
+
expect(launch).toHaveBeenCalledWith('xdg-open', ['https://example.com/auth'], {
|
|
23
|
+
stdio: 'ignore',
|
|
24
|
+
detached: true,
|
|
25
|
+
});
|
|
26
|
+
expect(() => child.emit('error', Object.assign(new Error('ENOENT'), { code: 'ENOENT' }))).not.toThrow();
|
|
27
|
+
expect(child.unref).toHaveBeenCalled();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import type { ServerDefinition } from '../src/config.js';
|
|
6
|
+
import { readJsonFile } from '../src/fs-json.js';
|
|
7
|
+
import { buildOAuthPersistence, clearOAuthCaches } from '../src/oauth-persistence.js';
|
|
8
|
+
import { loadVaultEntry, vaultKeyForDefinition } from '../src/oauth-vault.js';
|
|
9
|
+
|
|
10
|
+
const mkDef = (name: string, tokenCacheDir?: string): ServerDefinition => ({
|
|
11
|
+
name,
|
|
12
|
+
description: `${name} server`,
|
|
13
|
+
command: { kind: 'http', url: new URL('https://example.com/mcp') },
|
|
14
|
+
auth: 'oauth',
|
|
15
|
+
tokenCacheDir,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('oauth persistence', () => {
|
|
19
|
+
const tempRoots: string[] = [];
|
|
20
|
+
let homedirSpy!: ReturnType<typeof vi.spyOn>;
|
|
21
|
+
let hasSpy = false;
|
|
22
|
+
|
|
23
|
+
afterEach(async () => {
|
|
24
|
+
if (hasSpy) {
|
|
25
|
+
homedirSpy.mockRestore();
|
|
26
|
+
hasSpy = false;
|
|
27
|
+
}
|
|
28
|
+
await Promise.all(tempRoots.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true })));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('prefers explicit tokenCacheDir before vault when reading tokens', async () => {
|
|
32
|
+
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'mcporter-oauth-'));
|
|
33
|
+
tempRoots.push(tmp);
|
|
34
|
+
homedirSpy = vi.spyOn(os, 'homedir').mockReturnValue(tmp);
|
|
35
|
+
hasSpy = true;
|
|
36
|
+
|
|
37
|
+
const cacheDir = path.join(tmp, 'cache');
|
|
38
|
+
await fs.mkdir(cacheDir, { recursive: true });
|
|
39
|
+
await fs.writeFile(
|
|
40
|
+
path.join(cacheDir, 'tokens.json'),
|
|
41
|
+
JSON.stringify({ access_token: 'from-cache', token_type: 'Bearer' })
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Vault also contains a token, but cache dir should win.
|
|
45
|
+
const vaultPath = path.join(tmp, '.mcporter', 'credentials.json');
|
|
46
|
+
await fs.mkdir(path.dirname(vaultPath), { recursive: true });
|
|
47
|
+
const definition = mkDef('service', cacheDir);
|
|
48
|
+
const key = vaultKeyForDefinition(definition);
|
|
49
|
+
await fs.writeFile(
|
|
50
|
+
vaultPath,
|
|
51
|
+
JSON.stringify({
|
|
52
|
+
version: 1,
|
|
53
|
+
entries: {
|
|
54
|
+
[key]: {
|
|
55
|
+
updatedAt: new Date().toISOString(),
|
|
56
|
+
tokens: { access_token: 'from-vault', token_type: 'Bearer' },
|
|
57
|
+
serverName: 'service',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const persistence = await buildOAuthPersistence(definition);
|
|
64
|
+
|
|
65
|
+
expect(await persistence.readTokens()).toEqual({ access_token: 'from-cache', token_type: 'Bearer' });
|
|
66
|
+
// Saving should propagate to both stores.
|
|
67
|
+
await persistence.saveTokens({ access_token: 'new-token', token_type: 'Bearer' });
|
|
68
|
+
const cacheTokens = (await readJsonFile(path.join(cacheDir, 'tokens.json'))) as
|
|
69
|
+
| { access_token: string }
|
|
70
|
+
| undefined;
|
|
71
|
+
expect(cacheTokens?.access_token).toBe('new-token');
|
|
72
|
+
const entry = await loadVaultEntry(definition);
|
|
73
|
+
expect(entry?.tokens?.access_token).toBe('new-token');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('migrates legacy per-server cache into the vault', async () => {
|
|
77
|
+
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'mcporter-oauth-'));
|
|
78
|
+
tempRoots.push(tmp);
|
|
79
|
+
homedirSpy = vi.spyOn(os, 'homedir').mockReturnValue(tmp);
|
|
80
|
+
hasSpy = true;
|
|
81
|
+
|
|
82
|
+
const legacyDir = path.join(tmp, '.mcporter', 'legacy-service');
|
|
83
|
+
await fs.mkdir(legacyDir, { recursive: true });
|
|
84
|
+
await fs.writeFile(
|
|
85
|
+
path.join(legacyDir, 'tokens.json'),
|
|
86
|
+
JSON.stringify({ access_token: 'legacy-token', token_type: 'Bearer' })
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const logger = { info: vi.fn(), warn: vi.fn(), error: vi.fn() } as const;
|
|
90
|
+
const definition = mkDef('legacy-service');
|
|
91
|
+
const persistence = await buildOAuthPersistence(definition, logger);
|
|
92
|
+
|
|
93
|
+
expect(await persistence.readTokens()).toEqual({ access_token: 'legacy-token', token_type: 'Bearer' });
|
|
94
|
+
const entry = await loadVaultEntry(definition);
|
|
95
|
+
expect(entry?.tokens?.access_token).toBe('legacy-token');
|
|
96
|
+
expect(logger.info).toHaveBeenCalledWith("Migrated legacy OAuth cache for 'legacy-service' into vault.");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('clears vault, legacy, tokenCacheDir, and provider-specific caches', async () => {
|
|
100
|
+
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'mcporter-oauth-'));
|
|
101
|
+
tempRoots.push(tmp);
|
|
102
|
+
homedirSpy = vi.spyOn(os, 'homedir').mockReturnValue(tmp);
|
|
103
|
+
hasSpy = true;
|
|
104
|
+
|
|
105
|
+
const cacheDir = path.join(tmp, 'cache');
|
|
106
|
+
await fs.mkdir(cacheDir, { recursive: true });
|
|
107
|
+
await fs.writeFile(
|
|
108
|
+
path.join(cacheDir, 'tokens.json'),
|
|
109
|
+
JSON.stringify({ access_token: 'cached', token_type: 'Bearer' })
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const legacyDir = path.join(tmp, '.mcporter', 'gmail');
|
|
113
|
+
await fs.mkdir(legacyDir, { recursive: true });
|
|
114
|
+
await fs.writeFile(
|
|
115
|
+
path.join(legacyDir, 'tokens.json'),
|
|
116
|
+
JSON.stringify({ access_token: 'legacy', token_type: 'Bearer' })
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const gmailLegacyFile = path.join(tmp, '.gmail-mcp', 'credentials.json');
|
|
120
|
+
await fs.mkdir(path.dirname(gmailLegacyFile), { recursive: true });
|
|
121
|
+
await fs.writeFile(gmailLegacyFile, '{}');
|
|
122
|
+
|
|
123
|
+
const vaultPath = path.join(tmp, '.mcporter', 'credentials.json');
|
|
124
|
+
await fs.mkdir(path.dirname(vaultPath), { recursive: true });
|
|
125
|
+
const logger = { info: vi.fn(), warn: vi.fn(), error: vi.fn() } as const;
|
|
126
|
+
const definition = mkDef('gmail', cacheDir);
|
|
127
|
+
const key = vaultKeyForDefinition(definition);
|
|
128
|
+
await fs.writeFile(
|
|
129
|
+
vaultPath,
|
|
130
|
+
JSON.stringify({
|
|
131
|
+
version: 1,
|
|
132
|
+
entries: {
|
|
133
|
+
[key]: { serverName: 'gmail', updatedAt: new Date().toISOString(), tokens: { access_token: 'vault' } },
|
|
134
|
+
},
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
await clearOAuthCaches(definition, logger, 'all');
|
|
139
|
+
|
|
140
|
+
await expect(fs.access(path.join(cacheDir, 'tokens.json'))).rejects.toThrow();
|
|
141
|
+
await expect(fs.access(path.join(legacyDir, 'tokens.json'))).rejects.toThrow();
|
|
142
|
+
await expect(fs.access(gmailLegacyFile)).rejects.toThrow();
|
|
143
|
+
const entry = await loadVaultEntry(definition);
|
|
144
|
+
expect(entry).toBeUndefined();
|
|
145
|
+
});
|
|
146
|
+
});
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
6
|
+
import type { ServerDefinition } from '../src/config.js';
|
|
7
|
+
import { __oauthInternals, createOAuthSession } from '../src/oauth.js';
|
|
8
|
+
|
|
9
|
+
type StatefulProvider = {
|
|
10
|
+
redirectUrl: string | URL;
|
|
11
|
+
state: () => Promise<string>;
|
|
12
|
+
redirectToAuthorization: (authorizationUrl: URL) => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const requestStatus = (target: URL): Promise<number> =>
|
|
16
|
+
new Promise((resolve, reject) => {
|
|
17
|
+
const req = http.request(
|
|
18
|
+
{
|
|
19
|
+
hostname: target.hostname,
|
|
20
|
+
port: target.port,
|
|
21
|
+
path: `${target.pathname}${target.search}`,
|
|
22
|
+
family: 4,
|
|
23
|
+
method: 'GET',
|
|
24
|
+
},
|
|
25
|
+
(res) => {
|
|
26
|
+
const status = res.statusCode ?? 0;
|
|
27
|
+
res.resume();
|
|
28
|
+
resolve(status);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
req.on('error', reject);
|
|
32
|
+
req.end();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('FileOAuthClientProvider session lifecycle', () => {
|
|
36
|
+
const tempDirs: string[] = [];
|
|
37
|
+
|
|
38
|
+
afterEach(async () => {
|
|
39
|
+
vi.restoreAllMocks();
|
|
40
|
+
await Promise.all(tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true })));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('rejects pending authorization waits when the session closes early', async () => {
|
|
44
|
+
const tokenCacheDir = await fs.mkdtemp(path.join(os.tmpdir(), 'mcporter-oauth-test-'));
|
|
45
|
+
tempDirs.push(tokenCacheDir);
|
|
46
|
+
const definition: ServerDefinition = {
|
|
47
|
+
name: 'test-oauth',
|
|
48
|
+
description: 'Test OAuth server',
|
|
49
|
+
command: { kind: 'http', url: new URL('https://example.com/mcp') },
|
|
50
|
+
auth: 'oauth',
|
|
51
|
+
tokenCacheDir,
|
|
52
|
+
};
|
|
53
|
+
const logger = {
|
|
54
|
+
info: vi.fn(),
|
|
55
|
+
warn: vi.fn(),
|
|
56
|
+
error: vi.fn(),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const session = await createOAuthSession(definition, logger);
|
|
60
|
+
const waitPromise = session.waitForAuthorizationCode();
|
|
61
|
+
await session.close();
|
|
62
|
+
await expect(waitPromise).rejects.toThrow(/closed before receiving authorization code/i);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('uses oauthScope when explicitly configured', async () => {
|
|
66
|
+
const tokenCacheDir = await fs.mkdtemp(path.join(os.tmpdir(), 'mcporter-oauth-test-'));
|
|
67
|
+
tempDirs.push(tokenCacheDir);
|
|
68
|
+
const definition: ServerDefinition = {
|
|
69
|
+
name: 'test-oauth-scope',
|
|
70
|
+
description: 'Test OAuth server',
|
|
71
|
+
command: { kind: 'http', url: new URL('https://example.com/mcp') },
|
|
72
|
+
auth: 'oauth',
|
|
73
|
+
tokenCacheDir,
|
|
74
|
+
oauthScope: 'openid email profile',
|
|
75
|
+
};
|
|
76
|
+
const logger = {
|
|
77
|
+
info: vi.fn(),
|
|
78
|
+
warn: vi.fn(),
|
|
79
|
+
error: vi.fn(),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const session = await createOAuthSession(definition, logger);
|
|
83
|
+
expect((session.provider as { clientMetadata: { scope?: string } }).clientMetadata.scope).toBe(
|
|
84
|
+
'openid email profile'
|
|
85
|
+
);
|
|
86
|
+
await session.close();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('clears stale client registrations when redirect URI changes with dynamic ports', async () => {
|
|
90
|
+
const tokenCacheDir = await fs.mkdtemp(path.join(os.tmpdir(), 'mcporter-oauth-test-'));
|
|
91
|
+
tempDirs.push(tokenCacheDir);
|
|
92
|
+
await fs.writeFile(
|
|
93
|
+
path.join(tokenCacheDir, 'client.json'),
|
|
94
|
+
JSON.stringify({ redirect_uris: ['http://127.0.0.1:9999/callback'] }, null, 2),
|
|
95
|
+
'utf8'
|
|
96
|
+
);
|
|
97
|
+
const definition: ServerDefinition = {
|
|
98
|
+
name: 'test-oauth-stale-client',
|
|
99
|
+
description: 'Test OAuth server',
|
|
100
|
+
command: { kind: 'http', url: new URL('https://example.com/mcp') },
|
|
101
|
+
auth: 'oauth',
|
|
102
|
+
tokenCacheDir,
|
|
103
|
+
};
|
|
104
|
+
const logger = {
|
|
105
|
+
info: vi.fn(),
|
|
106
|
+
warn: vi.fn(),
|
|
107
|
+
error: vi.fn(),
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const session = await createOAuthSession(definition, logger);
|
|
111
|
+
await session.close();
|
|
112
|
+
|
|
113
|
+
await expect(fs.readFile(path.join(tokenCacheDir, 'client.json'), 'utf8')).rejects.toMatchObject({
|
|
114
|
+
code: 'ENOENT',
|
|
115
|
+
});
|
|
116
|
+
expect(logger.info).toHaveBeenCalledWith(expect.stringContaining('clearing stale client registration'));
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('closes the callback server when stale-client reads throw', async () => {
|
|
120
|
+
const tokenCacheDir = await fs.mkdtemp(path.join(os.tmpdir(), 'mcporter-oauth-test-'));
|
|
121
|
+
tempDirs.push(tokenCacheDir);
|
|
122
|
+
await fs.writeFile(path.join(tokenCacheDir, 'client.json'), '{not-valid-json', 'utf8');
|
|
123
|
+
const definition: ServerDefinition = {
|
|
124
|
+
name: 'test-oauth-read-failure',
|
|
125
|
+
description: 'Test OAuth server',
|
|
126
|
+
command: { kind: 'http', url: new URL('https://example.com/mcp') },
|
|
127
|
+
auth: 'oauth',
|
|
128
|
+
tokenCacheDir,
|
|
129
|
+
};
|
|
130
|
+
const logger = {
|
|
131
|
+
info: vi.fn(),
|
|
132
|
+
warn: vi.fn(),
|
|
133
|
+
error: vi.fn(),
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const originalCreateServer = http.createServer.bind(http);
|
|
137
|
+
const createdServers: http.Server[] = [];
|
|
138
|
+
const createServerSpy = vi.spyOn(http, 'createServer').mockImplementation((...args) => {
|
|
139
|
+
const server = originalCreateServer(...args);
|
|
140
|
+
createdServers.push(server);
|
|
141
|
+
return server;
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
await expect(createOAuthSession(definition, logger)).rejects.toThrow(SyntaxError);
|
|
146
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
147
|
+
expect(createdServers).toHaveLength(1);
|
|
148
|
+
expect(createdServers[0]?.listening).toBe(false);
|
|
149
|
+
} finally {
|
|
150
|
+
createServerSpy.mockRestore();
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('resolves waiters created before redirectToAuthorization', async () => {
|
|
155
|
+
const tokenCacheDir = await fs.mkdtemp(path.join(os.tmpdir(), 'mcporter-oauth-test-'));
|
|
156
|
+
tempDirs.push(tokenCacheDir);
|
|
157
|
+
const definition: ServerDefinition = {
|
|
158
|
+
name: 'test-oauth-wait-before-redirect',
|
|
159
|
+
description: 'Test OAuth server',
|
|
160
|
+
command: { kind: 'http', url: new URL('https://example.com/mcp') },
|
|
161
|
+
auth: 'oauth',
|
|
162
|
+
tokenCacheDir,
|
|
163
|
+
};
|
|
164
|
+
const logger = {
|
|
165
|
+
info: vi.fn(),
|
|
166
|
+
warn: vi.fn(),
|
|
167
|
+
error: vi.fn(),
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const session = await createOAuthSession(definition, logger);
|
|
171
|
+
const provider = session.provider as StatefulProvider;
|
|
172
|
+
vi.spyOn(__oauthInternals, 'openExternal').mockImplementation(() => {});
|
|
173
|
+
const waitPromise = session.waitForAuthorizationCode();
|
|
174
|
+
await provider.redirectToAuthorization(new URL('https://example.com/auth'));
|
|
175
|
+
|
|
176
|
+
const callback = new URL(String(provider.redirectUrl));
|
|
177
|
+
callback.hostname = '127.0.0.1';
|
|
178
|
+
callback.searchParams.set('code', 'prewait-code');
|
|
179
|
+
const status = await requestStatus(callback);
|
|
180
|
+
expect(status).toBe(200);
|
|
181
|
+
await expect(waitPromise).resolves.toBe('prewait-code');
|
|
182
|
+
await session.close();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('does not replace the pending authorization deferred on repeated redirect calls', async () => {
|
|
186
|
+
const tokenCacheDir = await fs.mkdtemp(path.join(os.tmpdir(), 'mcporter-oauth-test-'));
|
|
187
|
+
tempDirs.push(tokenCacheDir);
|
|
188
|
+
const definition: ServerDefinition = {
|
|
189
|
+
name: 'test-oauth-repeat-redirect',
|
|
190
|
+
description: 'Test OAuth server',
|
|
191
|
+
command: { kind: 'http', url: new URL('https://example.com/mcp') },
|
|
192
|
+
auth: 'oauth',
|
|
193
|
+
tokenCacheDir,
|
|
194
|
+
};
|
|
195
|
+
const logger = {
|
|
196
|
+
info: vi.fn(),
|
|
197
|
+
warn: vi.fn(),
|
|
198
|
+
error: vi.fn(),
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const session = await createOAuthSession(definition, logger);
|
|
202
|
+
const provider = session.provider as StatefulProvider;
|
|
203
|
+
vi.spyOn(__oauthInternals, 'openExternal').mockImplementation(() => {});
|
|
204
|
+
const waitPromise = session.waitForAuthorizationCode();
|
|
205
|
+
await provider.redirectToAuthorization(new URL('https://example.com/auth-one'));
|
|
206
|
+
await provider.redirectToAuthorization(new URL('https://example.com/auth-two'));
|
|
207
|
+
|
|
208
|
+
const callback = new URL(String(provider.redirectUrl));
|
|
209
|
+
callback.hostname = '127.0.0.1';
|
|
210
|
+
callback.searchParams.set('code', 'stable-deferred-code');
|
|
211
|
+
const status = await requestStatus(callback);
|
|
212
|
+
expect(status).toBe(200);
|
|
213
|
+
await expect(waitPromise).resolves.toBe('stable-deferred-code');
|
|
214
|
+
await session.close();
|
|
215
|
+
});
|
|
216
|
+
});
|