@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,407 @@
|
|
|
1
|
+
import { createCallResult } from './result-utils.js';
|
|
2
|
+
import type { CallOptions, ListToolsOptions, Runtime, ServerToolInfo } from './runtime.js';
|
|
3
|
+
import { readSchemaCache, writeSchemaCache } from './schema-cache.js';
|
|
4
|
+
|
|
5
|
+
type ToolCallOptions = CallOptions & { args?: unknown };
|
|
6
|
+
type ToolArguments = CallOptions['args'];
|
|
7
|
+
|
|
8
|
+
type ServerProxy = {
|
|
9
|
+
call(toolName: string, options?: ToolCallOptions): Promise<ReturnType<typeof createCallResult>>;
|
|
10
|
+
listTools(options?: ListToolsOptions): Promise<ServerToolInfo[]>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type ToolSchemaInfo = {
|
|
14
|
+
schema: Record<string, unknown>;
|
|
15
|
+
orderedKeys: string[];
|
|
16
|
+
requiredKeys: string[];
|
|
17
|
+
propertySet: Set<string>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const KNOWN_OPTION_KEYS = new Set(['tailLog', 'timeout', 'stream', 'streamLog', 'mimeType', 'metadata', 'log']);
|
|
21
|
+
|
|
22
|
+
export interface ServerProxyOptions {
|
|
23
|
+
readonly mapPropertyToTool?: (property: string | symbol) => string;
|
|
24
|
+
readonly cacheSchemas?: boolean;
|
|
25
|
+
readonly initialSchemas?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// defaultToolNameMapper converts camelCase property access into kebab-case tool names.
|
|
29
|
+
function defaultToolNameMapper(propertyKey: string | symbol): string {
|
|
30
|
+
if (typeof propertyKey !== 'string') {
|
|
31
|
+
throw new TypeError('Tool name must be a string when using server proxy.');
|
|
32
|
+
}
|
|
33
|
+
return propertyKey.replace(/([a-z\d])([A-Z])/g, '$1-$2').toLowerCase();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// canonicalizeToolName strips punctuation for loose matching of tool names.
|
|
37
|
+
function canonicalizeToolName(name: string): string {
|
|
38
|
+
return name.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// isPlainObject narrows unknown values to plain object records.
|
|
42
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
43
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// createToolSchemaInfo normalizes schema metadata used for argument mapping.
|
|
47
|
+
function createToolSchemaInfo(schemaRaw: unknown): ToolSchemaInfo | undefined {
|
|
48
|
+
if (!schemaRaw || typeof schemaRaw !== 'object') {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const schema = schemaRaw as Record<string, unknown>;
|
|
52
|
+
const propertiesRaw = schema.properties;
|
|
53
|
+
const propertyKeys =
|
|
54
|
+
propertiesRaw && typeof propertiesRaw === 'object' ? Object.keys(propertiesRaw as Record<string, unknown>) : [];
|
|
55
|
+
const requiredKeys = Array.isArray(schema.required) ? (schema.required as string[]) : [];
|
|
56
|
+
const orderedKeys: string[] = [];
|
|
57
|
+
const seen = new Set<string>();
|
|
58
|
+
|
|
59
|
+
for (const key of requiredKeys) {
|
|
60
|
+
if (typeof key === 'string' && !seen.has(key)) {
|
|
61
|
+
orderedKeys.push(key);
|
|
62
|
+
seen.add(key);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
for (const key of propertyKeys) {
|
|
67
|
+
if (!seen.has(key)) {
|
|
68
|
+
orderedKeys.push(key);
|
|
69
|
+
seen.add(key);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
schema,
|
|
75
|
+
orderedKeys,
|
|
76
|
+
requiredKeys,
|
|
77
|
+
propertySet: new Set([...propertyKeys, ...requiredKeys]),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// applyDefaults merges JSON-schema default values into the provided arguments.
|
|
82
|
+
function applyDefaults(meta: ToolSchemaInfo, args?: ToolArguments): ToolArguments {
|
|
83
|
+
const propertiesRaw = meta.schema.properties;
|
|
84
|
+
if (!propertiesRaw || typeof propertiesRaw !== 'object') {
|
|
85
|
+
return args;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const result: Record<string, unknown> = isPlainObject(args) ? { ...(args as Record<string, unknown>) } : {};
|
|
89
|
+
|
|
90
|
+
for (const [key, value] of Object.entries(propertiesRaw as Record<string, unknown>)) {
|
|
91
|
+
if (
|
|
92
|
+
value &&
|
|
93
|
+
typeof value === 'object' &&
|
|
94
|
+
'default' in (value as Record<string, unknown>) &&
|
|
95
|
+
result[key] === undefined
|
|
96
|
+
) {
|
|
97
|
+
result[key] = (value as Record<string, unknown>).default as unknown;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (Object.keys(result).length === 0 && !isPlainObject(args)) {
|
|
102
|
+
return args;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return result as ToolArguments;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// validateRequired ensures all schema-required fields are present before invocation.
|
|
109
|
+
function validateRequired(meta: ToolSchemaInfo, args?: ToolArguments): void {
|
|
110
|
+
if (meta.requiredKeys.length === 0) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (!isPlainObject(args)) {
|
|
114
|
+
throw new Error(`Missing required arguments: ${meta.requiredKeys.join(', ')}`);
|
|
115
|
+
}
|
|
116
|
+
const missing = meta.requiredKeys.filter((key) => (args as Record<string, unknown>)[key] === undefined);
|
|
117
|
+
if (missing.length > 0) {
|
|
118
|
+
throw new Error(`Missing required arguments: ${missing.join(', ')}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// createServerProxy returns a proxy that maps property access to MCP tool invocations.
|
|
123
|
+
export function createServerProxy(
|
|
124
|
+
runtime: Runtime,
|
|
125
|
+
serverName: string,
|
|
126
|
+
mapOrOptions?: ((property: string | symbol) => string) | ServerProxyOptions,
|
|
127
|
+
maybeOptions?: ServerProxyOptions
|
|
128
|
+
): ServerProxy {
|
|
129
|
+
let mapPropertyToTool = defaultToolNameMapper;
|
|
130
|
+
let options: ServerProxyOptions | undefined;
|
|
131
|
+
|
|
132
|
+
if (typeof mapOrOptions === 'function') {
|
|
133
|
+
mapPropertyToTool = mapOrOptions;
|
|
134
|
+
options = maybeOptions;
|
|
135
|
+
} else if (mapOrOptions) {
|
|
136
|
+
options = mapOrOptions;
|
|
137
|
+
if (typeof mapOrOptions.mapPropertyToTool === 'function') {
|
|
138
|
+
mapPropertyToTool = mapOrOptions.mapPropertyToTool;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const cacheSchemas = options?.cacheSchemas ?? true;
|
|
143
|
+
const initialSchemas = options?.initialSchemas ?? undefined;
|
|
144
|
+
|
|
145
|
+
const toolSchemaCache = new Map<string, ToolSchemaInfo>();
|
|
146
|
+
const persistedSchemas = new Map<string, Record<string, unknown>>();
|
|
147
|
+
const toolAliasMap = new Map<string, string>();
|
|
148
|
+
let schemaFetch: Promise<void> | null = null;
|
|
149
|
+
let diskLoad: Promise<void> | null = null;
|
|
150
|
+
let persistPromise: Promise<void> | null = null;
|
|
151
|
+
let refreshPending = false;
|
|
152
|
+
|
|
153
|
+
let definitionForCache: ReturnType<Runtime['getDefinition']> | undefined;
|
|
154
|
+
if (cacheSchemas) {
|
|
155
|
+
try {
|
|
156
|
+
definitionForCache = runtime.getDefinition(serverName);
|
|
157
|
+
} catch {
|
|
158
|
+
definitionForCache = undefined;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (cacheSchemas && !initialSchemas && definitionForCache) {
|
|
163
|
+
diskLoad = loadSchemasFromDisk(definitionForCache);
|
|
164
|
+
refreshPending = true;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (initialSchemas) {
|
|
168
|
+
for (const [key, schemaRaw] of Object.entries(initialSchemas)) {
|
|
169
|
+
storeSchema(key, schemaRaw);
|
|
170
|
+
}
|
|
171
|
+
persistPromise = persistSchemas();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// consumePersist waits for any in-flight disk persistence to finish before reading from cache maps.
|
|
175
|
+
async function consumePersist(): Promise<void> {
|
|
176
|
+
if (!persistPromise) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
await persistPromise;
|
|
181
|
+
} finally {
|
|
182
|
+
persistPromise = null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// ensureMetadata loads schema information for the requested tool, optionally refreshing from the server.
|
|
187
|
+
async function ensureMetadata(toolName: string): Promise<ToolSchemaInfo | undefined> {
|
|
188
|
+
await consumePersist();
|
|
189
|
+
const cached = toolSchemaCache.get(toolName);
|
|
190
|
+
if (cached && !refreshPending) {
|
|
191
|
+
return cached;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (diskLoad) {
|
|
195
|
+
try {
|
|
196
|
+
await diskLoad;
|
|
197
|
+
} finally {
|
|
198
|
+
diskLoad = null;
|
|
199
|
+
}
|
|
200
|
+
if (toolSchemaCache.has(toolName) && !refreshPending) {
|
|
201
|
+
return toolSchemaCache.get(toolName);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (!schemaFetch) {
|
|
206
|
+
schemaFetch = runtime
|
|
207
|
+
.listTools(serverName, { includeSchema: true })
|
|
208
|
+
.then((tools) => {
|
|
209
|
+
for (const tool of tools) {
|
|
210
|
+
if (!tool.inputSchema || typeof tool.inputSchema !== 'object') {
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
storeSchema(tool.name, tool.inputSchema);
|
|
214
|
+
}
|
|
215
|
+
persistPromise = persistSchemas();
|
|
216
|
+
refreshPending = false;
|
|
217
|
+
})
|
|
218
|
+
.catch((error) => {
|
|
219
|
+
schemaFetch = null;
|
|
220
|
+
throw error;
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
await schemaFetch;
|
|
225
|
+
await consumePersist();
|
|
226
|
+
return toolSchemaCache.get(toolName);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// storeSchema caches schema info locally and records aliases for lookup.
|
|
230
|
+
function storeSchema(key: string, schemaRaw: unknown) {
|
|
231
|
+
const info = createToolSchemaInfo(schemaRaw);
|
|
232
|
+
if (!info) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const canonical = mapPropertyToTool(key);
|
|
236
|
+
toolSchemaCache.set(canonical, info);
|
|
237
|
+
if (canonical !== key) {
|
|
238
|
+
toolSchemaCache.set(key, info);
|
|
239
|
+
}
|
|
240
|
+
const canonicalAlias = canonicalizeToolName(key);
|
|
241
|
+
if (!toolAliasMap.has(canonicalAlias)) {
|
|
242
|
+
toolAliasMap.set(canonicalAlias, key);
|
|
243
|
+
}
|
|
244
|
+
const mapperAlias = canonicalizeToolName(canonical);
|
|
245
|
+
if (!toolAliasMap.has(mapperAlias)) {
|
|
246
|
+
toolAliasMap.set(mapperAlias, key);
|
|
247
|
+
}
|
|
248
|
+
if (cacheSchemas && definitionForCache && isPlainObject(schemaRaw)) {
|
|
249
|
+
persistedSchemas.set(canonical, schemaRaw as Record<string, unknown>);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// loadSchemasFromDisk hydrates the in-memory cache from the persisted schema snapshot.
|
|
254
|
+
async function loadSchemasFromDisk(definition: ReturnType<Runtime['getDefinition']>): Promise<void> {
|
|
255
|
+
try {
|
|
256
|
+
const snapshot = await readSchemaCache(definition);
|
|
257
|
+
if (!snapshot) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
for (const [key, schemaRaw] of Object.entries(snapshot.tools)) {
|
|
261
|
+
storeSchema(key, schemaRaw);
|
|
262
|
+
}
|
|
263
|
+
} catch {
|
|
264
|
+
// ignore cache read failures
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// persistSchemas writes cached schema data to disk when enabled.
|
|
269
|
+
function persistSchemas(): Promise<void> | null {
|
|
270
|
+
if (!cacheSchemas || !definitionForCache || persistedSchemas.size === 0) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
const definition = definitionForCache;
|
|
274
|
+
const snapshot = {
|
|
275
|
+
updatedAt: new Date().toISOString(),
|
|
276
|
+
tools: Object.fromEntries(persistedSchemas.entries()),
|
|
277
|
+
};
|
|
278
|
+
return writeSchemaCache(definition, snapshot).catch(() => {
|
|
279
|
+
// best-effort persistence
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const base: ServerProxy = {
|
|
284
|
+
call: async (toolName: string, options?: ToolCallOptions) => {
|
|
285
|
+
const result = await runtime.callTool(serverName, toolName, options ?? {});
|
|
286
|
+
return createCallResult(result);
|
|
287
|
+
},
|
|
288
|
+
listTools: (options) => runtime.listTools(serverName, options),
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
return new Proxy(base as ServerProxy & Record<string | symbol, unknown>, {
|
|
292
|
+
get(target, property, receiver) {
|
|
293
|
+
if (Reflect.has(target, property)) {
|
|
294
|
+
return Reflect.get(target, property, receiver);
|
|
295
|
+
}
|
|
296
|
+
const propertyKey = property;
|
|
297
|
+
const canonicalKey = typeof propertyKey === 'string' ? canonicalizeToolName(propertyKey) : null;
|
|
298
|
+
let resolvedToolName =
|
|
299
|
+
typeof propertyKey === 'string' && canonicalKey
|
|
300
|
+
? (toolAliasMap.get(canonicalKey) ?? mapPropertyToTool(propertyKey))
|
|
301
|
+
: mapPropertyToTool(propertyKey);
|
|
302
|
+
|
|
303
|
+
return async (...callArgs: unknown[]) => {
|
|
304
|
+
let schemaInfo: ToolSchemaInfo | undefined;
|
|
305
|
+
try {
|
|
306
|
+
schemaInfo = await ensureMetadata(resolvedToolName);
|
|
307
|
+
} catch {
|
|
308
|
+
schemaInfo = undefined;
|
|
309
|
+
}
|
|
310
|
+
if (typeof propertyKey === 'string' && canonicalKey) {
|
|
311
|
+
const alias = toolAliasMap.get(canonicalKey);
|
|
312
|
+
if (alias && alias !== resolvedToolName) {
|
|
313
|
+
resolvedToolName = alias;
|
|
314
|
+
try {
|
|
315
|
+
schemaInfo = await ensureMetadata(resolvedToolName);
|
|
316
|
+
} catch {
|
|
317
|
+
// ignore and keep prior schema if available
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const positional: unknown[] = [];
|
|
323
|
+
const argsAccumulator: Record<string, unknown> = {};
|
|
324
|
+
const optionsAccumulator: ToolCallOptions = {};
|
|
325
|
+
|
|
326
|
+
for (const arg of callArgs) {
|
|
327
|
+
if (isPlainObject(arg)) {
|
|
328
|
+
const keys = Object.keys(arg);
|
|
329
|
+
const treatAsArgs =
|
|
330
|
+
schemaInfo !== undefined &&
|
|
331
|
+
keys.length > 0 &&
|
|
332
|
+
(keys.every((key) => schemaInfo.propertySet.has(key)) ||
|
|
333
|
+
keys.every((key) => !KNOWN_OPTION_KEYS.has(key)));
|
|
334
|
+
|
|
335
|
+
if (treatAsArgs) {
|
|
336
|
+
Object.assign(argsAccumulator, arg as Record<string, unknown>);
|
|
337
|
+
} else {
|
|
338
|
+
Object.assign(optionsAccumulator, arg as ToolCallOptions);
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
positional.push(arg);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const explicitArgs = optionsAccumulator.args as ToolArguments | undefined;
|
|
346
|
+
if (explicitArgs !== undefined) {
|
|
347
|
+
delete (optionsAccumulator as Record<string, unknown>).args;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const finalOptions: ToolCallOptions = { ...optionsAccumulator };
|
|
351
|
+
let combinedArgs: ToolArguments | undefined = explicitArgs;
|
|
352
|
+
|
|
353
|
+
if (schemaInfo) {
|
|
354
|
+
const schema = schemaInfo;
|
|
355
|
+
|
|
356
|
+
if (positional.length > schema.orderedKeys.length) {
|
|
357
|
+
throw new Error(`Too many positional arguments for tool "${resolvedToolName}"`);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (positional.length > 0) {
|
|
361
|
+
const baseArgs = isPlainObject(combinedArgs) ? { ...(combinedArgs as Record<string, unknown>) } : {};
|
|
362
|
+
positional.forEach((value, idx) => {
|
|
363
|
+
const key = schema.orderedKeys[idx];
|
|
364
|
+
if (key) {
|
|
365
|
+
baseArgs[key] = value;
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
combinedArgs = baseArgs as ToolArguments;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (Object.keys(argsAccumulator).length > 0) {
|
|
372
|
+
const baseArgs = isPlainObject(combinedArgs) ? { ...(combinedArgs as Record<string, unknown>) } : {};
|
|
373
|
+
Object.assign(baseArgs, argsAccumulator);
|
|
374
|
+
combinedArgs = baseArgs as ToolArguments;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (combinedArgs !== undefined) {
|
|
378
|
+
combinedArgs = applyDefaults(schema, combinedArgs);
|
|
379
|
+
} else {
|
|
380
|
+
const defaults = applyDefaults(schema, undefined);
|
|
381
|
+
if (defaults && typeof defaults === 'object') {
|
|
382
|
+
combinedArgs = defaults as ToolArguments;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
validateRequired(schema, combinedArgs);
|
|
387
|
+
} else {
|
|
388
|
+
if (positional.length > 0) {
|
|
389
|
+
combinedArgs = positional as unknown as ToolArguments;
|
|
390
|
+
}
|
|
391
|
+
if (Object.keys(argsAccumulator).length > 0) {
|
|
392
|
+
const baseArgs = isPlainObject(combinedArgs) ? { ...(combinedArgs as Record<string, unknown>) } : {};
|
|
393
|
+
Object.assign(baseArgs, argsAccumulator);
|
|
394
|
+
combinedArgs = baseArgs as ToolArguments;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if (combinedArgs !== undefined) {
|
|
399
|
+
finalOptions.args = combinedArgs;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const result = await runtime.callTool(serverName, resolvedToolName, finalOptions);
|
|
403
|
+
return createCallResult(result);
|
|
404
|
+
};
|
|
405
|
+
},
|
|
406
|
+
});
|
|
407
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { resolveEphemeralServer } from '../src/cli/adhoc-server.js';
|
|
3
|
+
|
|
4
|
+
describe('resolveEphemeralServer', () => {
|
|
5
|
+
it('injects Accept header for HTTP definitions', () => {
|
|
6
|
+
const { definition } = resolveEphemeralServer({ httpUrl: 'https://example.com/mcp' });
|
|
7
|
+
expect(definition.command.kind).toBe('http');
|
|
8
|
+
const headers = definition.command.kind === 'http' ? definition.command.headers : undefined;
|
|
9
|
+
expect(headers?.accept?.toLowerCase()).toContain('application/json');
|
|
10
|
+
expect(headers?.accept?.toLowerCase()).toContain('text/event-stream');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('auto-enables keep-alive for STDIO commands that match known signatures', () => {
|
|
14
|
+
const { definition, persistedEntry } = resolveEphemeralServer({
|
|
15
|
+
stdioCommand: 'npx -y chrome-devtools-mcp@latest',
|
|
16
|
+
});
|
|
17
|
+
expect(definition.name).toBe('chrome-devtools');
|
|
18
|
+
expect(definition.lifecycle?.mode).toBe('keep-alive');
|
|
19
|
+
expect(persistedEntry.lifecycle).toBe('keep-alive');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('infers package names instead of wrapper flags for npx workflows', () => {
|
|
23
|
+
const { definition } = resolveEphemeralServer({
|
|
24
|
+
stdioCommand: 'npx -y xcodebuildmcp',
|
|
25
|
+
});
|
|
26
|
+
expect(definition.name).toBe('xcodebuildmcp');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('drops versions when inferring scoped npm package names', () => {
|
|
30
|
+
const { definition } = resolveEphemeralServer({
|
|
31
|
+
stdioCommand: 'npx -y @scope/example-mcp@latest',
|
|
32
|
+
});
|
|
33
|
+
expect(definition.name).toBe('scope-example-mcp');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('ignores additional positional args after double-dash when inferring package names', () => {
|
|
37
|
+
const { definition } = resolveEphemeralServer({
|
|
38
|
+
stdioCommand: 'npx -y @scope/xcodebuildmcp@canary -- --port 1234',
|
|
39
|
+
});
|
|
40
|
+
expect(definition.name).toBe('scope-xcodebuildmcp');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('normalizes mixed-case package tokens and --yes flag variants', () => {
|
|
44
|
+
const { definition } = resolveEphemeralServer({
|
|
45
|
+
stdioCommand: 'npx --yes XcodeBuildMCP@1.2.3 doctor',
|
|
46
|
+
});
|
|
47
|
+
expect(definition.name).toBe('xcodebuildmcp');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { parseCallArguments } from '../src/cli/call-arguments.js';
|
|
3
|
+
|
|
4
|
+
describe('parseCallArguments', () => {
|
|
5
|
+
it('parses legacy selector + key=value pairs', () => {
|
|
6
|
+
const args = ['linear.list_documents', 'limit=5', 'format=json'];
|
|
7
|
+
const parsed = parseCallArguments([...args]);
|
|
8
|
+
expect(parsed.selector).toBe('linear.list_documents');
|
|
9
|
+
expect(parsed.tool).toBeUndefined();
|
|
10
|
+
expect(parsed.args.limit).toBe(5);
|
|
11
|
+
expect(parsed.args.format).toBe('json');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it.each(['--server', '--mcp'] as const)('captures %s as server override', (flag) => {
|
|
15
|
+
const parsed = parseCallArguments([flag, 'linear', 'list_documents']);
|
|
16
|
+
expect(parsed.server).toBe('linear');
|
|
17
|
+
expect(parsed.tool).toBe('list_documents');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('consumes function-style call expressions with HTTP selectors', () => {
|
|
21
|
+
const call = 'https://example.com/mcp.getComponents(limit: 3, projectId: "123")';
|
|
22
|
+
const parsed = parseCallArguments([call]);
|
|
23
|
+
expect(parsed.server).toBe('https://example.com/mcp');
|
|
24
|
+
expect(parsed.tool).toBe('getComponents');
|
|
25
|
+
expect(parsed.args.limit).toBe(3);
|
|
26
|
+
expect(parsed.args.projectId).toBe('123');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('merges --args JSON blobs with positional fragments', () => {
|
|
30
|
+
const parsed = parseCallArguments([
|
|
31
|
+
'--args',
|
|
32
|
+
'{"query":"open issues"}',
|
|
33
|
+
'linear',
|
|
34
|
+
'list_documents',
|
|
35
|
+
'orderBy=updatedAt',
|
|
36
|
+
]);
|
|
37
|
+
expect(parsed.selector).toBe('linear');
|
|
38
|
+
expect(parsed.tool).toBe('list_documents');
|
|
39
|
+
expect(parsed.args.query).toBe('open issues');
|
|
40
|
+
expect(parsed.args.orderBy).toBe('updatedAt');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('throws when flags conflict with call expression content', () => {
|
|
44
|
+
expect(() => parseCallArguments(['--server', 'linear', 'cursor.list_documents(limit:1)'])).toThrow(
|
|
45
|
+
/Conflicting server names/
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('warns when colon-style arguments omit a value', () => {
|
|
50
|
+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
51
|
+
const parsed = parseCallArguments(['iterm-mcp.write_to_terminal', 'command:']);
|
|
52
|
+
expect(parsed.args.command).toBe('');
|
|
53
|
+
expect(warnSpy).toHaveBeenCalledWith(
|
|
54
|
+
expect.stringContaining("[mcporter] Argument 'command' was provided without a value.")
|
|
55
|
+
);
|
|
56
|
+
warnSpy.mockRestore();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it.each([
|
|
60
|
+
['default', [], 123456, 'number'],
|
|
61
|
+
['raw-strings', ['--raw-strings'], '123456', 'string'],
|
|
62
|
+
['no-coerce', ['--no-coerce'], '123456', 'string'],
|
|
63
|
+
] as const)('handles numeric coercion in %s mode', (_mode, flags, expected, expectedType) => {
|
|
64
|
+
const parsed = parseCallArguments([...flags, 'server.tool', 'code=123456']);
|
|
65
|
+
expect(parsed.args.code).toBe(expected);
|
|
66
|
+
expect(typeof parsed.args.code).toBe(expectedType);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('preserves leading zeros when --raw-strings flag is used', () => {
|
|
70
|
+
const parsed = parseCallArguments(['--raw-strings', 'server.tool', 'pin=000123']);
|
|
71
|
+
expect(parsed.args.pin).toBe('000123');
|
|
72
|
+
expect(typeof parsed.args.pin).toBe('string');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('still coerces booleans, nulls, and JSON with --raw-strings', () => {
|
|
76
|
+
const parsed = parseCallArguments(['--raw-strings', 'server.tool', 'enabled=true', 'value=null', 'meta={"a":1}']);
|
|
77
|
+
expect(parsed.args.enabled).toBe(true);
|
|
78
|
+
expect(parsed.args.value).toBeNull();
|
|
79
|
+
expect(parsed.args.meta).toEqual({ a: 1 });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('keeps every value as a string when --no-coerce alias is used', () => {
|
|
83
|
+
const parsed = parseCallArguments([
|
|
84
|
+
'--no-coerce',
|
|
85
|
+
'server.tool',
|
|
86
|
+
'id=007',
|
|
87
|
+
'enabled=true',
|
|
88
|
+
'value=null',
|
|
89
|
+
'meta={"a":1}',
|
|
90
|
+
'123',
|
|
91
|
+
]);
|
|
92
|
+
expect(parsed.args.id).toBe('007');
|
|
93
|
+
expect(parsed.args.enabled).toBe('true');
|
|
94
|
+
expect(parsed.args.value).toBe('null');
|
|
95
|
+
expect(parsed.args.meta).toBe('{"a":1}');
|
|
96
|
+
expect(typeof parsed.args.id).toBe('string');
|
|
97
|
+
expect(parsed.positionalArgs).toEqual(['123']);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('captures --save-images output directory', () => {
|
|
101
|
+
const parsed = parseCallArguments(['--save-images', './tmp/images', 'server.tool']);
|
|
102
|
+
expect(parsed.saveImagesDir).toBe('./tmp/images');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it.each([
|
|
106
|
+
['--save-images', /--save-images requires a directory path/],
|
|
107
|
+
['--args', /--args requires a JSON value/],
|
|
108
|
+
] as const)('throws when %s is missing a value', (flag, expectedError) => {
|
|
109
|
+
expect(() => parseCallArguments([flag])).toThrow(expectedError);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
process.env.MCPORTER_DISABLE_AUTORUN = '1';
|
|
4
|
+
const cliModulePromise = import('../src/cli.js');
|
|
5
|
+
|
|
6
|
+
describe('mcporter auth help shortcut', () => {
|
|
7
|
+
let previousNoForceExit: string | undefined;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
previousNoForceExit = process.env.MCPORTER_NO_FORCE_EXIT;
|
|
11
|
+
process.env.MCPORTER_NO_FORCE_EXIT = '1';
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
vi.restoreAllMocks();
|
|
16
|
+
process.exitCode = undefined;
|
|
17
|
+
if (previousNoForceExit === undefined) {
|
|
18
|
+
delete process.env.MCPORTER_NO_FORCE_EXIT;
|
|
19
|
+
} else {
|
|
20
|
+
process.env.MCPORTER_NO_FORCE_EXIT = previousNoForceExit;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('prints auth-specific help when --help is used', async () => {
|
|
25
|
+
const { runCli } = await cliModulePromise;
|
|
26
|
+
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
27
|
+
|
|
28
|
+
await runCli(['auth', '--help']);
|
|
29
|
+
|
|
30
|
+
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Usage: mcporter auth'));
|
|
31
|
+
expect(process.exitCode).toBe(0);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('prints auth-specific help when the bare help token follows the command', async () => {
|
|
35
|
+
const { runCli } = await cliModulePromise;
|
|
36
|
+
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
37
|
+
|
|
38
|
+
await runCli(['auth', 'help']);
|
|
39
|
+
|
|
40
|
+
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Usage: mcporter auth'));
|
|
41
|
+
expect(process.exitCode).toBe(0);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
process.env.MCPORTER_DISABLE_AUTORUN = '1';
|
|
4
|
+
const cliModulePromise = import('../src/cli.js');
|
|
5
|
+
|
|
6
|
+
const baseDefinition = {
|
|
7
|
+
name: 'adhoc-server',
|
|
8
|
+
command: { kind: 'http' as const, url: new URL('https://example.com/mcp') },
|
|
9
|
+
source: { kind: 'local' as const, path: '<adhoc>' },
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
describe('handleAuth retry logic', () => {
|
|
13
|
+
it('retries once when the first attempt is unauthorized', async () => {
|
|
14
|
+
const { handleAuth } = await cliModulePromise;
|
|
15
|
+
const listTools = vi
|
|
16
|
+
.fn()
|
|
17
|
+
.mockRejectedValueOnce(new Error('SSE error: Non-200 status code (401)'))
|
|
18
|
+
.mockResolvedValueOnce([{ name: 'ok' }]);
|
|
19
|
+
const runtime = {
|
|
20
|
+
registerDefinition: vi.fn(),
|
|
21
|
+
getDefinition: vi.fn().mockReturnValue(baseDefinition),
|
|
22
|
+
listTools,
|
|
23
|
+
} as unknown as Awaited<ReturnType<typeof import('../src/runtime.js')['createRuntime']>>;
|
|
24
|
+
|
|
25
|
+
await expect(handleAuth(runtime, ['adhoc-server'])).resolves.toBeUndefined();
|
|
26
|
+
expect(listTools).toHaveBeenCalledTimes(2);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('throws after the second unauthorized attempt', async () => {
|
|
30
|
+
const { handleAuth } = await cliModulePromise;
|
|
31
|
+
const listTools = vi.fn().mockRejectedValue(new Error('SSE error: Non-200 status code (401)'));
|
|
32
|
+
const runtime = {
|
|
33
|
+
registerDefinition: vi.fn(),
|
|
34
|
+
getDefinition: vi.fn().mockReturnValue(baseDefinition),
|
|
35
|
+
listTools,
|
|
36
|
+
} as unknown as Awaited<ReturnType<typeof import('../src/runtime.js')['createRuntime']>>;
|
|
37
|
+
|
|
38
|
+
await expect(handleAuth(runtime, ['adhoc-server'])).rejects.toThrow(/Failed to authorize/);
|
|
39
|
+
expect(listTools).toHaveBeenCalledTimes(2);
|
|
40
|
+
});
|
|
41
|
+
});
|