@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,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Lightweight wrapper to translate `--filter foo` into Vitest include globs so
|
|
3
|
+
// callers can run `pnpm test --filter my-test` without hitting the Vitest CLI
|
|
4
|
+
// "Unknown option --filter" error.
|
|
5
|
+
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const translated = [];
|
|
12
|
+
const positional = [];
|
|
13
|
+
|
|
14
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
15
|
+
const token = args[i];
|
|
16
|
+
if (token === '--filter' || token === '-f') {
|
|
17
|
+
const pattern = args[i + 1];
|
|
18
|
+
if (!pattern) {
|
|
19
|
+
console.error('[test-runner] --filter requires a pattern');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
positional.push(pattern);
|
|
23
|
+
i += 1; // skip pattern
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
translated.push(token);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const require = createRequire(import.meta.url);
|
|
30
|
+
const vitestPkg = require.resolve('vitest/package.json');
|
|
31
|
+
const vitestRoot = path.dirname(vitestPkg);
|
|
32
|
+
const vitestBin = path.join(vitestRoot, 'vitest.mjs');
|
|
33
|
+
|
|
34
|
+
const result = spawnSync(process.execPath, [vitestBin, 'run', ...positional, ...translated], {
|
|
35
|
+
stdio: 'inherit',
|
|
36
|
+
env: process.env,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
process.exit(result.status ?? 1);
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import type { CommandSpec, ServerDefinition } from '../config.js';
|
|
4
|
+
import { __configInternals } from '../config.js';
|
|
5
|
+
import { expandHome } from '../env.js';
|
|
6
|
+
import { canonicalKeepAliveName, resolveLifecycle } from '../lifecycle.js';
|
|
7
|
+
|
|
8
|
+
export interface EphemeralServerSpec {
|
|
9
|
+
name?: string;
|
|
10
|
+
httpUrl?: string;
|
|
11
|
+
allowInsecureHttp?: boolean;
|
|
12
|
+
stdioCommand?: string;
|
|
13
|
+
stdioArgs?: string[];
|
|
14
|
+
cwd?: string;
|
|
15
|
+
env?: Record<string, string>;
|
|
16
|
+
description?: string;
|
|
17
|
+
persistPath?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface EphemeralServerResolution {
|
|
21
|
+
definition: ServerDefinition;
|
|
22
|
+
name: string;
|
|
23
|
+
persistedEntry: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const TEMP_SOURCE = { kind: 'local', path: '<adhoc>' } as const;
|
|
27
|
+
|
|
28
|
+
export function resolveEphemeralServer(spec: EphemeralServerSpec): EphemeralServerResolution {
|
|
29
|
+
if (!spec.httpUrl && !spec.stdioCommand) {
|
|
30
|
+
throw new Error('Ad-hoc servers require either --http-url or --stdio.');
|
|
31
|
+
}
|
|
32
|
+
if (spec.httpUrl && spec.stdioCommand) {
|
|
33
|
+
throw new Error('Cannot combine --http-url and --stdio in the same ad-hoc server.');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (spec.httpUrl) {
|
|
37
|
+
const url = new URL(spec.httpUrl);
|
|
38
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:') {
|
|
39
|
+
throw new Error(`Unsupported protocol '${url.protocol}' for --http-url.`);
|
|
40
|
+
}
|
|
41
|
+
if (url.protocol === 'http:' && !spec.allowInsecureHttp) {
|
|
42
|
+
throw new Error('HTTP endpoints require --allow-http to confirm insecure usage.');
|
|
43
|
+
}
|
|
44
|
+
const command: CommandSpec = {
|
|
45
|
+
kind: 'http',
|
|
46
|
+
url,
|
|
47
|
+
headers: __configInternals.ensureHttpAcceptHeader(undefined),
|
|
48
|
+
};
|
|
49
|
+
const canonical = spec.name ? undefined : canonicalKeepAliveName(command);
|
|
50
|
+
const name = slugify(spec.name ?? canonical ?? inferNameFromUrl(url));
|
|
51
|
+
const lifecycle = resolveLifecycle(name, undefined, command);
|
|
52
|
+
const definition: ServerDefinition = {
|
|
53
|
+
name,
|
|
54
|
+
description: spec.description,
|
|
55
|
+
command,
|
|
56
|
+
env: spec.env && Object.keys(spec.env).length > 0 ? spec.env : undefined,
|
|
57
|
+
source: TEMP_SOURCE,
|
|
58
|
+
lifecycle,
|
|
59
|
+
};
|
|
60
|
+
const persistedEntry: Record<string, unknown> = {
|
|
61
|
+
baseUrl: url.href,
|
|
62
|
+
...(spec.description ? { description: spec.description } : {}),
|
|
63
|
+
...(spec.env && Object.keys(spec.env).length > 0 ? { env: spec.env } : {}),
|
|
64
|
+
...(lifecycle ? { lifecycle: serializeLifecycle(lifecycle) } : {}),
|
|
65
|
+
};
|
|
66
|
+
return { definition, name, persistedEntry };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const stdioCommand = spec.stdioCommand as string;
|
|
70
|
+
const parts = splitCommandLine(stdioCommand);
|
|
71
|
+
if (parts.length === 0) {
|
|
72
|
+
throw new Error('--stdio requires a non-empty command.');
|
|
73
|
+
}
|
|
74
|
+
const [commandBinary, ...commandRest] = parts as [string, ...string[]];
|
|
75
|
+
const commandArgs = commandRest.concat(spec.stdioArgs ?? []);
|
|
76
|
+
const cwd = spec.cwd ? path.resolve(spec.cwd) : process.cwd();
|
|
77
|
+
const command: CommandSpec = {
|
|
78
|
+
kind: 'stdio',
|
|
79
|
+
command: commandBinary,
|
|
80
|
+
args: commandArgs,
|
|
81
|
+
cwd,
|
|
82
|
+
};
|
|
83
|
+
const canonical = spec.name ? undefined : canonicalKeepAliveName(command);
|
|
84
|
+
const name = slugify(spec.name ?? canonical ?? inferNameFromCommand(parts));
|
|
85
|
+
const lifecycle = resolveLifecycle(name, undefined, command);
|
|
86
|
+
const definition: ServerDefinition = {
|
|
87
|
+
name,
|
|
88
|
+
description: spec.description,
|
|
89
|
+
command,
|
|
90
|
+
env: spec.env && Object.keys(spec.env).length > 0 ? spec.env : undefined,
|
|
91
|
+
source: TEMP_SOURCE,
|
|
92
|
+
lifecycle,
|
|
93
|
+
};
|
|
94
|
+
const persistedEntry: Record<string, unknown> = {
|
|
95
|
+
command: commandBinary,
|
|
96
|
+
...(commandArgs.length > 0 ? { args: commandArgs } : {}),
|
|
97
|
+
...(spec.description ? { description: spec.description } : {}),
|
|
98
|
+
...(spec.env && Object.keys(spec.env).length > 0 ? { env: spec.env } : {}),
|
|
99
|
+
...(lifecycle ? { lifecycle: serializeLifecycle(lifecycle) } : {}),
|
|
100
|
+
};
|
|
101
|
+
if (spec.cwd) {
|
|
102
|
+
persistedEntry.cwd = spec.cwd;
|
|
103
|
+
}
|
|
104
|
+
return { definition, name, persistedEntry };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export async function persistEphemeralServer(resolution: EphemeralServerResolution, rawPath: string): Promise<void> {
|
|
108
|
+
const resolvedPath = path.resolve(expandHome(rawPath));
|
|
109
|
+
let existing: Record<string, unknown>;
|
|
110
|
+
try {
|
|
111
|
+
const buffer = await fs.readFile(resolvedPath, 'utf8');
|
|
112
|
+
existing = JSON.parse(buffer) as Record<string, unknown>;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
existing = { mcpServers: {} };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (typeof existing.mcpServers !== 'object' || existing.mcpServers === null) {
|
|
121
|
+
existing.mcpServers = {};
|
|
122
|
+
}
|
|
123
|
+
const servers = existing.mcpServers as Record<string, unknown>;
|
|
124
|
+
servers[resolution.name] = resolution.persistedEntry;
|
|
125
|
+
|
|
126
|
+
await fs.mkdir(path.dirname(resolvedPath), { recursive: true });
|
|
127
|
+
const serialized = `${JSON.stringify(existing, null, 2)}\n`;
|
|
128
|
+
await fs.writeFile(resolvedPath, serialized, 'utf8');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function inferNameFromUrl(url: URL): string {
|
|
132
|
+
const host = url.hostname.replace(/^www\./, '');
|
|
133
|
+
const pathSegments = url.pathname.split('/').filter(Boolean);
|
|
134
|
+
if (pathSegments.length === 0) {
|
|
135
|
+
return host;
|
|
136
|
+
}
|
|
137
|
+
return `${host}-${pathSegments[pathSegments.length - 1]}`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function inferNameFromCommand(parts: string[]): string {
|
|
141
|
+
const wrapperPackage = inferPackageFromWrapper(parts);
|
|
142
|
+
if (wrapperPackage) {
|
|
143
|
+
return wrapperPackage;
|
|
144
|
+
}
|
|
145
|
+
const executable = path.basename(parts[0] ?? 'command');
|
|
146
|
+
if (parts.length === 1) {
|
|
147
|
+
return executable;
|
|
148
|
+
}
|
|
149
|
+
const script = parts.find((segment) => segment.endsWith('.ts') || segment.endsWith('.js'));
|
|
150
|
+
if (script) {
|
|
151
|
+
return `${executable}-${path.basename(script, path.extname(script))}`;
|
|
152
|
+
}
|
|
153
|
+
const fallback = parts[1] ?? 'tool';
|
|
154
|
+
return `${executable}-${fallback}`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function inferPackageFromWrapper(parts: string[]): string | undefined {
|
|
158
|
+
if (parts.length < 2) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
const executable = path.basename(parts[0] ?? '');
|
|
162
|
+
if (executable !== 'npx') {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
for (let index = 1; index < parts.length; index += 1) {
|
|
166
|
+
const token = parts[index];
|
|
167
|
+
if (!token) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (token === '--') {
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
if (token.startsWith('-')) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
return stripPackageVersion(token);
|
|
177
|
+
}
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function stripPackageVersion(token: string): string {
|
|
182
|
+
if (token.startsWith('@')) {
|
|
183
|
+
const secondAt = token.indexOf('@', 1);
|
|
184
|
+
if (secondAt !== -1) {
|
|
185
|
+
return token.slice(0, secondAt);
|
|
186
|
+
}
|
|
187
|
+
return token;
|
|
188
|
+
}
|
|
189
|
+
const versionAt = token.indexOf('@');
|
|
190
|
+
if (versionAt > 0) {
|
|
191
|
+
return token.slice(0, versionAt);
|
|
192
|
+
}
|
|
193
|
+
return token;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function slugify(value: string): string {
|
|
197
|
+
return value
|
|
198
|
+
.trim()
|
|
199
|
+
.toLowerCase()
|
|
200
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
201
|
+
.replace(/^-+|-+$/g, '')
|
|
202
|
+
.replace(/-{2,}/g, '-');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function splitCommandLine(input: string): string[] {
|
|
206
|
+
const result: string[] = [];
|
|
207
|
+
let current = '';
|
|
208
|
+
let inSingle = false;
|
|
209
|
+
let inDouble = false;
|
|
210
|
+
|
|
211
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
212
|
+
const char = input.charAt(i);
|
|
213
|
+
if (char === "'" && !inDouble) {
|
|
214
|
+
inSingle = !inSingle;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (char === '"' && !inSingle) {
|
|
218
|
+
inDouble = !inDouble;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (!inSingle && !inDouble && /\s/.test(char)) {
|
|
222
|
+
if (current !== '') {
|
|
223
|
+
result.push(current);
|
|
224
|
+
current = '';
|
|
225
|
+
}
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (char === '\\' && !inSingle && i + 1 < input.length) {
|
|
229
|
+
const next = input.charAt(i + 1);
|
|
230
|
+
if (inDouble && next !== '"' && next !== '\\' && next !== '$') {
|
|
231
|
+
current += char;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
current += next;
|
|
235
|
+
i += 1;
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
current += char;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (inSingle || inDouble) {
|
|
242
|
+
throw new Error('Unterminated quote in --stdio command.');
|
|
243
|
+
}
|
|
244
|
+
if (current !== '') {
|
|
245
|
+
result.push(current);
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function serializeLifecycle(
|
|
251
|
+
lifecycle: ReturnType<typeof resolveLifecycle>
|
|
252
|
+
): string | { mode: 'keep-alive'; idleTimeoutMs?: number } | undefined {
|
|
253
|
+
if (!lifecycle) {
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
if (lifecycle.mode === 'keep-alive' && lifecycle.idleTimeoutMs === undefined) {
|
|
257
|
+
return 'keep-alive';
|
|
258
|
+
}
|
|
259
|
+
if (lifecycle.mode === 'keep-alive') {
|
|
260
|
+
return { mode: 'keep-alive', idleTimeoutMs: lifecycle.idleTimeoutMs };
|
|
261
|
+
}
|
|
262
|
+
return 'ephemeral';
|
|
263
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import type { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
3
|
+
import { auth as mcpAuth } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
4
|
+
import type { ServerDefinition } from '../config-schema.js';
|
|
5
|
+
import { analyzeConnectionError } from '../error-classifier.js';
|
|
6
|
+
import { createCodeExchangeProvider, createManualOAuthSession } from '../oauth.js';
|
|
7
|
+
import { parseManualOAuthCallback } from '../oauth-manual.js';
|
|
8
|
+
import { buildOAuthPersistence, clearOAuthCaches } from '../oauth-persistence.js';
|
|
9
|
+
import type { VaultEntry } from '../oauth-vault.js';
|
|
10
|
+
import { findServerNameByState } from '../oauth-vault.js';
|
|
11
|
+
import type { createRuntime } from '../runtime.js';
|
|
12
|
+
import type { EphemeralServerSpec } from './adhoc-server.js';
|
|
13
|
+
import { extractEphemeralServerFlags } from './ephemeral-flags.js';
|
|
14
|
+
import { prepareEphemeralServerTarget } from './ephemeral-target.js';
|
|
15
|
+
import { looksLikeHttpUrl } from './http-utils.js';
|
|
16
|
+
import { buildConnectionIssueEnvelope } from './json-output.js';
|
|
17
|
+
import { logInfo, logWarn } from './logger-context.js';
|
|
18
|
+
import { consumeOutputFormat } from './output-format.js';
|
|
19
|
+
|
|
20
|
+
type Runtime = Awaited<ReturnType<typeof createRuntime>>;
|
|
21
|
+
|
|
22
|
+
export async function handleAuth(runtime: Runtime, args: string[]): Promise<void> {
|
|
23
|
+
// Route `auth complete` before any other flag parsing.
|
|
24
|
+
if (args[0] === 'complete') {
|
|
25
|
+
args.shift();
|
|
26
|
+
return handleAuthComplete(runtime, args);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const resetIndex = args.indexOf('--reset');
|
|
30
|
+
const shouldReset = resetIndex !== -1;
|
|
31
|
+
if (shouldReset) {
|
|
32
|
+
args.splice(resetIndex, 1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Parse --browser <mode>
|
|
36
|
+
const browserIndex = args.indexOf('--browser');
|
|
37
|
+
let browserMode: 'open' | 'none' = 'open';
|
|
38
|
+
if (browserIndex !== -1) {
|
|
39
|
+
const value = args[browserIndex + 1];
|
|
40
|
+
if (value === 'none') {
|
|
41
|
+
browserMode = 'none';
|
|
42
|
+
args.splice(browserIndex, 2);
|
|
43
|
+
} else if (value === 'open') {
|
|
44
|
+
args.splice(browserIndex, 2);
|
|
45
|
+
} else {
|
|
46
|
+
throw new Error(`Unknown --browser mode: ${String(value)}. Valid values: open, none`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const format = consumeOutputFormat(args, {
|
|
51
|
+
defaultFormat: 'text',
|
|
52
|
+
allowed: ['text', 'json'],
|
|
53
|
+
enableRawShortcut: false,
|
|
54
|
+
jsonShortcutFlag: '--json',
|
|
55
|
+
}) as 'text' | 'json';
|
|
56
|
+
const ephemeralSpec: EphemeralServerSpec | undefined = extractEphemeralServerFlags(args);
|
|
57
|
+
let target = args.shift();
|
|
58
|
+
const nameHints: string[] = [];
|
|
59
|
+
if (ephemeralSpec && target && !looksLikeHttpUrl(target)) {
|
|
60
|
+
nameHints.push(target);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const prepared = await prepareEphemeralServerTarget({
|
|
64
|
+
runtime,
|
|
65
|
+
target,
|
|
66
|
+
ephemeral: ephemeralSpec,
|
|
67
|
+
nameHints,
|
|
68
|
+
reuseFromSpec: true,
|
|
69
|
+
});
|
|
70
|
+
target = prepared.target;
|
|
71
|
+
|
|
72
|
+
if (!target) {
|
|
73
|
+
throw new Error('Usage: mcporter auth <server | url> [--http-url <url> | --stdio <command>]');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const definition = runtime.getDefinition(target);
|
|
77
|
+
if (shouldReset) {
|
|
78
|
+
await clearOAuthCaches(definition);
|
|
79
|
+
logInfo(`Cleared cached credentials for '${target}'.`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (definition.command.kind === 'stdio' && definition.oauthCommand) {
|
|
83
|
+
logInfo(`Starting auth helper for '${target}' (stdio). Leave this running until the browser flow completes.`);
|
|
84
|
+
await runStdioAuth(definition);
|
|
85
|
+
logInfo(`Auth helper for '${target}' finished. You can now call tools.`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (browserMode === 'none') {
|
|
90
|
+
return runManualBrowserFlow(target, definition);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
94
|
+
try {
|
|
95
|
+
logInfo(`Initiating OAuth flow for '${target}'...`);
|
|
96
|
+
const tools = await runtime.listTools(target, { autoAuthorize: true });
|
|
97
|
+
logInfo(`Authorization complete. ${tools.length} tool${tools.length === 1 ? '' : 's'} available.`);
|
|
98
|
+
return;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (attempt === 0 && shouldRetryAuthError(error)) {
|
|
101
|
+
logWarn('Server signaled OAuth after the initial attempt. Retrying with browser flow...');
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
105
|
+
if (format === 'json') {
|
|
106
|
+
const payload = buildConnectionIssueEnvelope({
|
|
107
|
+
server: target,
|
|
108
|
+
error,
|
|
109
|
+
issue: analyzeConnectionError(error),
|
|
110
|
+
});
|
|
111
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
112
|
+
process.exitCode = 1;
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
throw new Error(`Failed to authorize '${target}': ${message}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// runManualBrowserFlow drives the OAuth initiation without opening a browser.
|
|
121
|
+
// It prints the authorization URL and exits; the user completes the flow via `auth complete`.
|
|
122
|
+
async function runManualBrowserFlow(target: string, definition: ServerDefinition): Promise<void> {
|
|
123
|
+
if (definition.command.kind !== 'http') {
|
|
124
|
+
throw new Error(`--browser none requires an HTTP server; '${target}' uses ${definition.command.kind} transport.`);
|
|
125
|
+
}
|
|
126
|
+
const logger = makeLogger();
|
|
127
|
+
logInfo(`Starting manual OAuth flow for '${target}'...`);
|
|
128
|
+
const { provider, close } = await createManualOAuthSession(definition, logger);
|
|
129
|
+
try {
|
|
130
|
+
await mcpAuth(provider as OAuthClientProvider, { serverUrl: definition.command.url });
|
|
131
|
+
// auth() calls provider.redirectToAuthorization() which prints the URL, then returns 'REDIRECT'.
|
|
132
|
+
console.log(`Open the URL above in your local browser. When the redirect fails, paste it into:`);
|
|
133
|
+
console.log(` mcporter auth complete '<pasted-redirect-url>'`);
|
|
134
|
+
} finally {
|
|
135
|
+
await close();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// handleAuthComplete exchanges an authorization code captured from a failed browser redirect.
|
|
140
|
+
async function handleAuthComplete(runtime: Runtime, args: string[]): Promise<void> {
|
|
141
|
+
const pastedInput = args.shift();
|
|
142
|
+
if (!pastedInput) {
|
|
143
|
+
throw new Error('Usage: mcporter auth complete <pasted-redirect-url>');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const parsed = parseManualOAuthCallback(pastedInput);
|
|
147
|
+
|
|
148
|
+
if (parsed.error) {
|
|
149
|
+
const detail = parsed.errorDescription ? ` — ${parsed.errorDescription}` : '';
|
|
150
|
+
throw new Error(`OAuth error in callback: ${parsed.error}${detail}`);
|
|
151
|
+
}
|
|
152
|
+
if (!parsed.code) {
|
|
153
|
+
throw new Error('No authorization code found in the pasted URL.');
|
|
154
|
+
}
|
|
155
|
+
if (!parsed.state) {
|
|
156
|
+
throw new Error('No OAuth state found in the pasted URL. Cannot identify the pending auth session.');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const vaultEntry = await findServerNameByState(parsed.state);
|
|
160
|
+
if (!vaultEntry) {
|
|
161
|
+
throw new Error(
|
|
162
|
+
`No pending auth session found matching that state. Did you run 'mcporter auth <server> --browser none' first?`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const definition = resolveDefinitionForComplete(runtime, vaultEntry);
|
|
167
|
+
if (definition.command.kind !== 'http') {
|
|
168
|
+
throw new Error(`Server '${vaultEntry.serverName}' does not use HTTP transport; cannot complete OAuth manually.`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const logger = makeLogger();
|
|
172
|
+
const persistence = await buildOAuthPersistence(definition, logger);
|
|
173
|
+
const clientInfo = await persistence.readClientInfo();
|
|
174
|
+
const redirectUri = (clientInfo as Record<string, unknown> | undefined)?.redirect_uris;
|
|
175
|
+
const redirectUriStr = Array.isArray(redirectUri) ? (redirectUri[0] as string | undefined) : undefined;
|
|
176
|
+
if (!redirectUriStr) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
`No saved client registration for '${definition.name}'. Run 'mcporter auth ${definition.name} --browser none' again to restart the flow.`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
console.log(`Completing authorization for '${definition.name}'...`);
|
|
183
|
+
const provider = await createCodeExchangeProvider(definition, new URL(redirectUriStr), logger);
|
|
184
|
+
|
|
185
|
+
await mcpAuth(provider, { serverUrl: definition.command.url, authorizationCode: parsed.code });
|
|
186
|
+
|
|
187
|
+
// Clear the state so it can't be replayed.
|
|
188
|
+
await persistence.clear('state');
|
|
189
|
+
|
|
190
|
+
console.log(`Authorization complete for '${definition.name}'. You can now use mcporter commands.`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// resolveDefinitionForComplete tries to get the definition from the runtime config; falls back to
|
|
194
|
+
// constructing a minimal ad-hoc HTTP definition from the vault entry's serverUrl for transient
|
|
195
|
+
// servers (e.g. bare URLs passed directly to `auth --browser none`).
|
|
196
|
+
function resolveDefinitionForComplete(runtime: Runtime, entry: VaultEntry): ServerDefinition {
|
|
197
|
+
try {
|
|
198
|
+
return runtime.getDefinition(entry.serverName);
|
|
199
|
+
} catch {
|
|
200
|
+
if (!entry.serverUrl) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
`Server '${entry.serverName}' is not in the current config and has no saved URL. Cannot complete OAuth.`
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
name: entry.serverName,
|
|
207
|
+
command: { kind: 'http', url: new URL(entry.serverUrl) },
|
|
208
|
+
auth: 'oauth',
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function runStdioAuth(definition: ServerDefinition): Promise<void> {
|
|
214
|
+
const authArgs = [...(definition.command.kind === 'stdio' ? (definition.command.args ?? []) : [])];
|
|
215
|
+
if (definition.oauthCommand) {
|
|
216
|
+
authArgs.push(...definition.oauthCommand.args);
|
|
217
|
+
}
|
|
218
|
+
return new Promise((resolve, reject) => {
|
|
219
|
+
const child = spawn(definition.command.kind === 'stdio' ? definition.command.command : '', authArgs, {
|
|
220
|
+
stdio: 'inherit',
|
|
221
|
+
cwd: definition.command.kind === 'stdio' ? definition.command.cwd : process.cwd(),
|
|
222
|
+
env: process.env,
|
|
223
|
+
});
|
|
224
|
+
child.on('error', reject);
|
|
225
|
+
child.on('exit', (code) => {
|
|
226
|
+
if (code === 0) {
|
|
227
|
+
resolve();
|
|
228
|
+
} else {
|
|
229
|
+
reject(new Error(`Auth helper exited with code ${code ?? 'null'}`));
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function shouldRetryAuthError(error: unknown): boolean {
|
|
236
|
+
return analyzeConnectionError(error).kind === 'auth';
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// makeLogger returns a minimal OAuthLogger that delegates to the CLI logger context.
|
|
240
|
+
function makeLogger() {
|
|
241
|
+
return {
|
|
242
|
+
info: (msg: string) => logInfo(msg),
|
|
243
|
+
warn: (msg: string) => logWarn(msg),
|
|
244
|
+
error: (msg: string, err?: unknown) => {
|
|
245
|
+
const detail =
|
|
246
|
+
err instanceof Error
|
|
247
|
+
? `: ${err.message}`
|
|
248
|
+
: err != null
|
|
249
|
+
? `: ${typeof err === 'object' ? JSON.stringify(err) : String(err as string)}`
|
|
250
|
+
: '';
|
|
251
|
+
logWarn(`${msg}${detail}`);
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function printAuthHelp(): void {
|
|
257
|
+
const lines = [
|
|
258
|
+
'Usage: mcporter auth <server | url> [flags]',
|
|
259
|
+
' mcporter auth complete <pasted-url-or-query>',
|
|
260
|
+
'',
|
|
261
|
+
'Purpose:',
|
|
262
|
+
' Run the authentication flow for a server without listing tools.',
|
|
263
|
+
'',
|
|
264
|
+
'Common flags:',
|
|
265
|
+
' --reset Clear cached credentials before re-authorizing.',
|
|
266
|
+
' --browser <mode> Browser behavior: open (default) or none.',
|
|
267
|
+
' --json Emit a JSON envelope on failure.',
|
|
268
|
+
'',
|
|
269
|
+
'Ad-hoc targets:',
|
|
270
|
+
' --http-url <url> Register an HTTP server for this run.',
|
|
271
|
+
' --allow-http Permit plain http:// URLs with --http-url.',
|
|
272
|
+
' --stdio <command> Run a stdio MCP server (repeat --stdio-arg for args).',
|
|
273
|
+
' --stdio-arg <value> Append args to the stdio command (repeatable).',
|
|
274
|
+
' --env KEY=value Inject env vars for stdio servers (repeatable).',
|
|
275
|
+
' --cwd <path> Working directory for stdio servers.',
|
|
276
|
+
' --name <value> Override the display name for ad-hoc servers.',
|
|
277
|
+
' --description <text> Override the description for ad-hoc servers.',
|
|
278
|
+
' --persist <path> Write the ad-hoc definition to config/mcporter.json.',
|
|
279
|
+
' --yes Skip confirmation prompts when persisting.',
|
|
280
|
+
'',
|
|
281
|
+
'Examples:',
|
|
282
|
+
' mcporter auth linear',
|
|
283
|
+
' mcporter auth linear --browser none',
|
|
284
|
+
' mcporter auth complete "http://127.0.0.1/callback?code=abc&state=xyz"',
|
|
285
|
+
' mcporter auth https://mcp.example.com/mcp',
|
|
286
|
+
' mcporter auth --stdio "npx -y chrome-devtools-mcp@latest"',
|
|
287
|
+
' mcporter auth --http-url http://localhost:3000/mcp --allow-http',
|
|
288
|
+
];
|
|
289
|
+
console.error(lines.join('\n'));
|
|
290
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { parseCallExpressionFragment } from './call-expression-parser.js';
|
|
2
|
+
import { CliUsageError } from './errors.js';
|
|
3
|
+
import { splitHttpToolSelector } from './http-utils.js';
|
|
4
|
+
|
|
5
|
+
type ParsedCallExpression = NonNullable<ReturnType<typeof parseCallExpressionFragment>>;
|
|
6
|
+
|
|
7
|
+
export function parseLeadingCallExpression(rawToken: string): ParsedCallExpression | null {
|
|
8
|
+
try {
|
|
9
|
+
return extractHttpCallExpression(rawToken) ?? parseCallExpressionFragment(rawToken);
|
|
10
|
+
} catch (error) {
|
|
11
|
+
throw buildCallExpressionUsageError(error);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function extractHttpCallExpression(raw: string): ParsedCallExpression | null {
|
|
16
|
+
const trimmed = raw.trim();
|
|
17
|
+
const openParen = trimmed.indexOf('(');
|
|
18
|
+
const prefix = openParen === -1 ? trimmed : trimmed.slice(0, openParen);
|
|
19
|
+
const split = splitHttpToolSelector(prefix);
|
|
20
|
+
if (!split) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
if (openParen === -1) {
|
|
24
|
+
return { server: split.baseUrl, tool: split.tool, args: {} };
|
|
25
|
+
}
|
|
26
|
+
if (!trimmed.endsWith(')')) {
|
|
27
|
+
throw new Error('Function-call syntax requires a closing ) character.');
|
|
28
|
+
}
|
|
29
|
+
const argsPortion = trimmed.slice(openParen);
|
|
30
|
+
const parsed = parseCallExpressionFragment(`${split.tool}${argsPortion}`);
|
|
31
|
+
if (!parsed) {
|
|
32
|
+
return { server: split.baseUrl, tool: split.tool, args: {} };
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
server: split.baseUrl,
|
|
36
|
+
tool: split.tool,
|
|
37
|
+
args: parsed.args,
|
|
38
|
+
positionalArgs: parsed.positionalArgs ?? [],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function buildCallExpressionUsageError(error: unknown): CliUsageError {
|
|
43
|
+
const reason =
|
|
44
|
+
error instanceof Error
|
|
45
|
+
? error.message
|
|
46
|
+
: typeof error === 'string'
|
|
47
|
+
? error
|
|
48
|
+
: JSON.stringify(error ?? 'Unknown error');
|
|
49
|
+
const lines = [
|
|
50
|
+
'Unable to parse function-style call.',
|
|
51
|
+
`Reason: ${reason}`,
|
|
52
|
+
'',
|
|
53
|
+
'Examples:',
|
|
54
|
+
' mcporter \'context7.resolve-library-id(libraryName: "react")\'',
|
|
55
|
+
' mcporter \'context7.resolve-library-id("react")\'',
|
|
56
|
+
' mcporter context7.resolve-library-id libraryName=react',
|
|
57
|
+
'',
|
|
58
|
+
'Tip: wrap the entire expression in single quotes so the shell preserves parentheses and commas.',
|
|
59
|
+
];
|
|
60
|
+
return new CliUsageError(lines.join('\n'));
|
|
61
|
+
}
|