@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
package/src/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type { CommandSpec, ServerDefinition } from './config.js';
|
|
2
|
+
export { loadServerDefinitions } from './config.js';
|
|
3
|
+
export type { CallResult, ConnectionIssue, ImageContent } from './result-utils.js';
|
|
4
|
+
export { createCallResult, describeConnectionIssue, wrapCallResult } from './result-utils.js';
|
|
5
|
+
export type {
|
|
6
|
+
CallOptions,
|
|
7
|
+
ListToolsOptions,
|
|
8
|
+
Runtime,
|
|
9
|
+
RuntimeLogger,
|
|
10
|
+
ServerToolInfo,
|
|
11
|
+
} from './runtime.js';
|
|
12
|
+
export { callOnce, createRuntime } from './runtime.js';
|
|
13
|
+
export type { ServerProxyOptions } from './server-proxy.js';
|
|
14
|
+
export { createServerProxy } from './server-proxy.js';
|
package/src/lifecycle.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { CommandSpec, RawLifecycle, ServerDefinition, ServerLifecycle } from './config-schema.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_KEEP_ALIVE = new Set(['chrome-devtools', 'mobile-mcp', 'playwright']);
|
|
4
|
+
|
|
5
|
+
const includeOverride = parseList(process.env.MCPORTER_KEEPALIVE);
|
|
6
|
+
const excludeOverride = parseList(process.env.MCPORTER_DISABLE_KEEPALIVE ?? process.env.MCPORTER_NO_KEEPALIVE);
|
|
7
|
+
|
|
8
|
+
interface OverrideSet {
|
|
9
|
+
readonly all: boolean;
|
|
10
|
+
readonly names: Set<string>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface CommandSignature {
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly fragments: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const KEEP_ALIVE_COMMANDS: CommandSignature[] = [
|
|
19
|
+
{ label: 'chrome-devtools', fragments: ['chrome-devtools-mcp'] },
|
|
20
|
+
{ label: 'mobile-mcp', fragments: ['@mobilenext/mobile-mcp', 'mobile-mcp'] },
|
|
21
|
+
{ label: 'playwright', fragments: ['@playwright/mcp', 'playwright/mcp'] },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const CHROME_DEVTOOLS_URL_PLACEHOLDERS = [String.raw`\${CHROME_DEVTOOLS_URL}`, '$env:CHROME_DEVTOOLS_URL'];
|
|
25
|
+
|
|
26
|
+
export function resolveLifecycle(
|
|
27
|
+
name: string,
|
|
28
|
+
rawLifecycle: RawLifecycle | undefined,
|
|
29
|
+
command: CommandSpec
|
|
30
|
+
): ServerLifecycle | undefined {
|
|
31
|
+
const normalizedName = name.toLowerCase();
|
|
32
|
+
const canonicalName = canonicalKeepAliveName(command);
|
|
33
|
+
const candidateNames = new Set<string>([normalizedName]);
|
|
34
|
+
if (canonicalName) {
|
|
35
|
+
candidateNames.add(canonicalName);
|
|
36
|
+
}
|
|
37
|
+
const forcedDisable = excludeOverride.all || matchesOverride(excludeOverride.names, candidateNames);
|
|
38
|
+
const forcedEnable = includeOverride.all || matchesOverride(includeOverride.names, candidateNames);
|
|
39
|
+
|
|
40
|
+
if (forcedEnable) {
|
|
41
|
+
return { mode: 'keep-alive' };
|
|
42
|
+
}
|
|
43
|
+
if (forcedDisable) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const lifecycle = rawLifecycle ? coerceLifecycle(rawLifecycle) : undefined;
|
|
48
|
+
if (lifecycle) {
|
|
49
|
+
return lifecycle;
|
|
50
|
+
}
|
|
51
|
+
if (commandRequiresDynamicChromePort(command)) {
|
|
52
|
+
// Each Chrome DevTools MCP instance is tied to a specific Chrome port. Opt out of keep-alive so
|
|
53
|
+
// the runtime (and daemon) relaunches the bridge whenever CHROME_DEVTOOLS_URL changes.
|
|
54
|
+
return { mode: 'ephemeral' };
|
|
55
|
+
}
|
|
56
|
+
if (Array.from(candidateNames).some((candidate) => DEFAULT_KEEP_ALIVE.has(candidate))) {
|
|
57
|
+
return { mode: 'keep-alive' };
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function canonicalKeepAliveName(command: CommandSpec): string | undefined {
|
|
63
|
+
if (command.kind !== 'stdio') {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const tokens = [command.command, ...command.args].map((token) => token.toLowerCase());
|
|
67
|
+
const match = KEEP_ALIVE_COMMANDS.find((signature) =>
|
|
68
|
+
signature.fragments.some((fragment) => tokens.some((token) => token.includes(fragment)))
|
|
69
|
+
);
|
|
70
|
+
return match?.label;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function commandRequiresDynamicChromePort(command: CommandSpec): boolean {
|
|
74
|
+
if (command.kind !== 'stdio') {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const tokens = [command.command, ...command.args];
|
|
78
|
+
return tokens.some((token) => CHROME_DEVTOOLS_URL_PLACEHOLDERS.some((placeholder) => token.includes(placeholder)));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function parseList(value: string | undefined): OverrideSet {
|
|
82
|
+
if (!value) {
|
|
83
|
+
return { all: false, names: new Set() };
|
|
84
|
+
}
|
|
85
|
+
const names = value
|
|
86
|
+
.split(',')
|
|
87
|
+
.map((token) => token.trim().toLowerCase())
|
|
88
|
+
.filter((token) => token.length > 0);
|
|
89
|
+
if (names.includes('*')) {
|
|
90
|
+
return { all: true, names: new Set() };
|
|
91
|
+
}
|
|
92
|
+
return { all: false, names: new Set(names) };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function matchesOverride(names: Set<string>, candidates: Set<string>): boolean {
|
|
96
|
+
for (const candidate of candidates) {
|
|
97
|
+
if (names.has(candidate)) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function coerceLifecycle(raw: RawLifecycle): ServerLifecycle | undefined {
|
|
105
|
+
if (typeof raw === 'string') {
|
|
106
|
+
if (raw === 'keep-alive') {
|
|
107
|
+
return { mode: 'keep-alive' };
|
|
108
|
+
}
|
|
109
|
+
if (raw === 'ephemeral') {
|
|
110
|
+
return { mode: 'ephemeral' };
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
if (raw.mode === 'keep-alive') {
|
|
115
|
+
const timeout =
|
|
116
|
+
typeof raw.idleTimeoutMs === 'number' && Number.isFinite(raw.idleTimeoutMs) && raw.idleTimeoutMs > 0
|
|
117
|
+
? Math.trunc(raw.idleTimeoutMs)
|
|
118
|
+
: undefined;
|
|
119
|
+
return timeout ? { mode: 'keep-alive', idleTimeoutMs: timeout } : { mode: 'keep-alive' };
|
|
120
|
+
}
|
|
121
|
+
if (raw.mode === 'ephemeral') {
|
|
122
|
+
return { mode: 'ephemeral' };
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function isKeepAliveServer(definition: ServerDefinition | undefined): boolean {
|
|
128
|
+
return definition?.lifecycle?.mode === 'keep-alive';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function keepAliveIdleTimeout(definition: ServerDefinition): number | undefined {
|
|
132
|
+
if (definition.lifecycle?.mode !== 'keep-alive') {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
return definition.lifecycle.idleTimeoutMs;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { DEFAULT_KEEP_ALIVE };
|
package/src/logging.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const LOG_LEVEL_ORDER = {
|
|
2
|
+
debug: 10,
|
|
3
|
+
info: 20,
|
|
4
|
+
warn: 30,
|
|
5
|
+
error: 40,
|
|
6
|
+
} as const;
|
|
7
|
+
|
|
8
|
+
type LogLevelKey = keyof typeof LOG_LEVEL_ORDER;
|
|
9
|
+
|
|
10
|
+
const LOG_LEVEL_ALIASES: Record<string, LogLevelKey> = {
|
|
11
|
+
warning: 'warn',
|
|
12
|
+
verbose: 'debug',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type LogLevel = LogLevelKey;
|
|
16
|
+
|
|
17
|
+
export interface Logger {
|
|
18
|
+
info(message: string): void;
|
|
19
|
+
warn(message: string): void;
|
|
20
|
+
error(message: string, error?: unknown): void;
|
|
21
|
+
debug?(message: string): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// parseLogLevel normalizes arbitrary input into one of the supported log level keywords.
|
|
25
|
+
export function parseLogLevel(value: string | undefined, defaultLevel: LogLevel = 'warn'): LogLevel {
|
|
26
|
+
if (!value) {
|
|
27
|
+
return defaultLevel;
|
|
28
|
+
}
|
|
29
|
+
const normalized = value.trim().toLowerCase();
|
|
30
|
+
if (!normalized) {
|
|
31
|
+
return defaultLevel;
|
|
32
|
+
}
|
|
33
|
+
const alias = LOG_LEVEL_ALIASES[normalized];
|
|
34
|
+
const candidate = alias ?? (normalized in LOG_LEVEL_ORDER ? (normalized as LogLevel) : undefined);
|
|
35
|
+
if (!candidate) {
|
|
36
|
+
const allowed = [...Object.keys(LOG_LEVEL_ORDER), ...Object.keys(LOG_LEVEL_ALIASES)]
|
|
37
|
+
.filter((key, index, array) => array.indexOf(key) === index)
|
|
38
|
+
.join(', ');
|
|
39
|
+
throw new Error(`Invalid log level '${value}'. Expected one of: ${allowed}.`);
|
|
40
|
+
}
|
|
41
|
+
return candidate;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// resolveLogLevelFromEnv reads MCPORTER_LOG_LEVEL and falls back to the provided default when invalid.
|
|
45
|
+
export function resolveLogLevelFromEnv(
|
|
46
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
47
|
+
defaultLevel: LogLevel = 'warn'
|
|
48
|
+
): LogLevel {
|
|
49
|
+
try {
|
|
50
|
+
return parseLogLevel(env.MCPORTER_LOG_LEVEL, defaultLevel);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
const raw = env.MCPORTER_LOG_LEVEL;
|
|
53
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
54
|
+
console.warn(`[mcporter] Ignoring invalid MCPORTER_LOG_LEVEL value '${raw ?? ''}': ${message}`);
|
|
55
|
+
return defaultLevel;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// shouldLog determines whether a candidate level passes the configured threshold.
|
|
60
|
+
function shouldLog(level: LogLevel, threshold: LogLevel): boolean {
|
|
61
|
+
return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[threshold];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// createPrefixedConsoleLogger wraps console.* with a consistent prefix and level filtering.
|
|
65
|
+
export function createPrefixedConsoleLogger(prefix: string, level: LogLevel): Logger {
|
|
66
|
+
const threshold = parseLogLevel(level);
|
|
67
|
+
const format = (message: string) => `[${prefix}] ${message}`;
|
|
68
|
+
return {
|
|
69
|
+
debug(message) {
|
|
70
|
+
if (shouldLog('debug', threshold)) {
|
|
71
|
+
console.debug(format(message));
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
info(message) {
|
|
75
|
+
if (shouldLog('info', threshold)) {
|
|
76
|
+
console.log(format(message));
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
warn(message) {
|
|
80
|
+
if (shouldLog('warn', threshold)) {
|
|
81
|
+
console.warn(format(message));
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
error(message, error) {
|
|
85
|
+
if (shouldLog('error', threshold)) {
|
|
86
|
+
console.error(format(message));
|
|
87
|
+
if (error) {
|
|
88
|
+
console.error(error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { URL } from 'node:url';
|
|
2
|
+
|
|
3
|
+
export interface ParsedManualOAuthCallback {
|
|
4
|
+
readonly code?: string;
|
|
5
|
+
readonly state?: string;
|
|
6
|
+
readonly error?: string;
|
|
7
|
+
readonly errorDescription?: string;
|
|
8
|
+
readonly callbackUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function parseManualOAuthCallback(input: string): ParsedManualOAuthCallback {
|
|
12
|
+
const normalized = normalizeManualInput(input);
|
|
13
|
+
const candidates = extractUrlCandidates(normalized);
|
|
14
|
+
|
|
15
|
+
for (const candidate of candidates) {
|
|
16
|
+
const parsed = tryParseUrlPayload(candidate);
|
|
17
|
+
if (parsed) {
|
|
18
|
+
return parsed;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const inline = tryParseQueryPayload(normalized);
|
|
23
|
+
if (inline) {
|
|
24
|
+
return inline;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
throw new Error(
|
|
28
|
+
'Could not extract OAuth callback details. Paste the full redirected URL, the raw query string, or browser text containing the URL.'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function normalizeManualInput(input: string): string {
|
|
33
|
+
return input
|
|
34
|
+
.trim()
|
|
35
|
+
.replace(/^['"`<([]+/, '')
|
|
36
|
+
.replace(/['"`>\])\s.,;:!?]+$/, '')
|
|
37
|
+
.replace(/&/gi, '&');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function extractUrlCandidates(input: string): string[] {
|
|
41
|
+
const matches = input.match(/https?:\/\/[^\s"'<>]+/gi) ?? [];
|
|
42
|
+
if (matches.length > 0) {
|
|
43
|
+
return matches.map((match) => sanitizeUrlCandidate(match));
|
|
44
|
+
}
|
|
45
|
+
if (input.startsWith('http://') || input.startsWith('https://')) {
|
|
46
|
+
return [sanitizeUrlCandidate(input)];
|
|
47
|
+
}
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function sanitizeUrlCandidate(value: string): string {
|
|
52
|
+
return value.replace(/[),.;]+$/, '').replace(/&/gi, '&');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function tryParseUrlPayload(value: string): ParsedManualOAuthCallback | undefined {
|
|
56
|
+
try {
|
|
57
|
+
const url = new URL(value);
|
|
58
|
+
return extractPayload(url, value);
|
|
59
|
+
} catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function tryParseQueryPayload(value: string): ParsedManualOAuthCallback | undefined {
|
|
65
|
+
const query = value.startsWith('?') ? value.slice(1) : value;
|
|
66
|
+
if (!query.includes('=')) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const params = new URLSearchParams(query);
|
|
70
|
+
const payload = extractParams(params);
|
|
71
|
+
return payload ? { ...payload } : undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function extractPayload(url: URL, callbackUrl: string): ParsedManualOAuthCallback | undefined {
|
|
75
|
+
const direct = extractParams(url.searchParams);
|
|
76
|
+
if (direct) {
|
|
77
|
+
return { ...direct, callbackUrl };
|
|
78
|
+
}
|
|
79
|
+
if (url.hash.startsWith('#')) {
|
|
80
|
+
const hashParams = new URLSearchParams(url.hash.slice(1));
|
|
81
|
+
const hashed = extractParams(hashParams);
|
|
82
|
+
if (hashed) {
|
|
83
|
+
return { ...hashed, callbackUrl };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function extractParams(params: URLSearchParams): Omit<ParsedManualOAuthCallback, 'callbackUrl'> | undefined {
|
|
90
|
+
const code = params.get('code') ?? undefined;
|
|
91
|
+
const state = params.get('state') ?? undefined;
|
|
92
|
+
const error = params.get('error') ?? undefined;
|
|
93
|
+
const errorDescription = params.get('error_description') ?? undefined;
|
|
94
|
+
if (!code && !error) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
code: code?.trim() || undefined,
|
|
99
|
+
state: state?.trim() || undefined,
|
|
100
|
+
error: error?.trim() || undefined,
|
|
101
|
+
errorDescription: errorDescription?.trim() || undefined,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import type { OAuthClientInformationMixed, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
5
|
+
import type { ServerDefinition } from './config.js';
|
|
6
|
+
import { readJsonFile, writeJsonFile } from './fs-json.js';
|
|
7
|
+
import type { Logger } from './logging.js';
|
|
8
|
+
import { clearVaultEntry, loadVaultEntry, saveVaultEntry } from './oauth-vault.js';
|
|
9
|
+
|
|
10
|
+
export type OAuthClearScope = 'all' | 'client' | 'tokens' | 'verifier' | 'state';
|
|
11
|
+
|
|
12
|
+
export interface OAuthPersistence {
|
|
13
|
+
describe(): string;
|
|
14
|
+
readTokens(): Promise<OAuthTokens | undefined>;
|
|
15
|
+
saveTokens(tokens: OAuthTokens): Promise<void>;
|
|
16
|
+
readClientInfo(): Promise<OAuthClientInformationMixed | undefined>;
|
|
17
|
+
saveClientInfo(info: OAuthClientInformationMixed): Promise<void>;
|
|
18
|
+
readCodeVerifier(): Promise<string | undefined>;
|
|
19
|
+
saveCodeVerifier(value: string): Promise<void>;
|
|
20
|
+
readState(): Promise<string | undefined>;
|
|
21
|
+
saveState(value: string): Promise<void>;
|
|
22
|
+
clear(scope: OAuthClearScope): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class DirectoryPersistence implements OAuthPersistence {
|
|
26
|
+
private readonly tokenPath: string;
|
|
27
|
+
private readonly clientInfoPath: string;
|
|
28
|
+
private readonly codeVerifierPath: string;
|
|
29
|
+
private readonly statePath: string;
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
private readonly root: string,
|
|
33
|
+
private readonly logger?: Logger
|
|
34
|
+
) {
|
|
35
|
+
this.tokenPath = path.join(root, 'tokens.json');
|
|
36
|
+
this.clientInfoPath = path.join(root, 'client.json');
|
|
37
|
+
this.codeVerifierPath = path.join(root, 'code_verifier.txt');
|
|
38
|
+
this.statePath = path.join(root, 'state.txt');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe(): string {
|
|
42
|
+
return this.root;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private async ensureDir() {
|
|
46
|
+
await fs.mkdir(this.root, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async readTokens(): Promise<OAuthTokens | undefined> {
|
|
50
|
+
return readJsonFile<OAuthTokens>(this.tokenPath);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async saveTokens(tokens: OAuthTokens): Promise<void> {
|
|
54
|
+
await this.ensureDir();
|
|
55
|
+
await writeJsonFile(this.tokenPath, tokens);
|
|
56
|
+
this.logger?.debug?.(`Saved tokens to ${this.tokenPath}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async readClientInfo(): Promise<OAuthClientInformationMixed | undefined> {
|
|
60
|
+
return readJsonFile<OAuthClientInformationMixed>(this.clientInfoPath);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async saveClientInfo(info: OAuthClientInformationMixed): Promise<void> {
|
|
64
|
+
await this.ensureDir();
|
|
65
|
+
await writeJsonFile(this.clientInfoPath, info);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async readCodeVerifier(): Promise<string | undefined> {
|
|
69
|
+
try {
|
|
70
|
+
return (await fs.readFile(this.codeVerifierPath, 'utf8')).trim();
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async saveCodeVerifier(value: string): Promise<void> {
|
|
80
|
+
await this.ensureDir();
|
|
81
|
+
await fs.writeFile(this.codeVerifierPath, value, 'utf8');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async readState(): Promise<string | undefined> {
|
|
85
|
+
return readJsonFile<string>(this.statePath);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async saveState(value: string): Promise<void> {
|
|
89
|
+
await this.ensureDir();
|
|
90
|
+
await writeJsonFile(this.statePath, value);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async clear(scope: OAuthClearScope): Promise<void> {
|
|
94
|
+
const files: string[] = [];
|
|
95
|
+
if (scope === 'all' || scope === 'tokens') {
|
|
96
|
+
files.push(this.tokenPath);
|
|
97
|
+
}
|
|
98
|
+
if (scope === 'all' || scope === 'client') {
|
|
99
|
+
files.push(this.clientInfoPath);
|
|
100
|
+
}
|
|
101
|
+
if (scope === 'all' || scope === 'verifier') {
|
|
102
|
+
files.push(this.codeVerifierPath);
|
|
103
|
+
}
|
|
104
|
+
if (scope === 'all' || scope === 'state') {
|
|
105
|
+
files.push(this.statePath);
|
|
106
|
+
}
|
|
107
|
+
await Promise.all(
|
|
108
|
+
files.map(async (file) => {
|
|
109
|
+
try {
|
|
110
|
+
await fs.unlink(file);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
class VaultPersistence implements OAuthPersistence {
|
|
122
|
+
constructor(private readonly definition: ServerDefinition) {}
|
|
123
|
+
|
|
124
|
+
describe(): string {
|
|
125
|
+
return '~/.mcporter/credentials.json (vault)';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async readTokens(): Promise<OAuthTokens | undefined> {
|
|
129
|
+
return (await loadVaultEntry(this.definition))?.tokens;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async saveTokens(tokens: OAuthTokens): Promise<void> {
|
|
133
|
+
await saveVaultEntry(this.definition, { tokens });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async readClientInfo(): Promise<OAuthClientInformationMixed | undefined> {
|
|
137
|
+
return (await loadVaultEntry(this.definition))?.clientInfo;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async saveClientInfo(info: OAuthClientInformationMixed): Promise<void> {
|
|
141
|
+
await saveVaultEntry(this.definition, { clientInfo: info });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async readCodeVerifier(): Promise<string | undefined> {
|
|
145
|
+
return (await loadVaultEntry(this.definition))?.codeVerifier;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async saveCodeVerifier(value: string): Promise<void> {
|
|
149
|
+
await saveVaultEntry(this.definition, { codeVerifier: value });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async readState(): Promise<string | undefined> {
|
|
153
|
+
return (await loadVaultEntry(this.definition))?.state;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async saveState(value: string): Promise<void> {
|
|
157
|
+
await saveVaultEntry(this.definition, { state: value });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async clear(scope: OAuthClearScope): Promise<void> {
|
|
161
|
+
await clearVaultEntry(this.definition, scope);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
class CompositePersistence implements OAuthPersistence {
|
|
166
|
+
constructor(private readonly stores: OAuthPersistence[]) {}
|
|
167
|
+
|
|
168
|
+
describe(): string {
|
|
169
|
+
return this.stores.map((store) => store.describe()).join(' + ');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async readTokens(): Promise<OAuthTokens | undefined> {
|
|
173
|
+
for (const store of this.stores) {
|
|
174
|
+
const result = await store.readTokens();
|
|
175
|
+
if (result) {
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async saveTokens(tokens: OAuthTokens): Promise<void> {
|
|
183
|
+
await Promise.all(this.stores.map((store) => store.saveTokens(tokens)));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async readClientInfo(): Promise<OAuthClientInformationMixed | undefined> {
|
|
187
|
+
for (const store of this.stores) {
|
|
188
|
+
const result = await store.readClientInfo();
|
|
189
|
+
if (result) {
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async saveClientInfo(info: OAuthClientInformationMixed): Promise<void> {
|
|
197
|
+
await Promise.all(this.stores.map((store) => store.saveClientInfo(info)));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async readCodeVerifier(): Promise<string | undefined> {
|
|
201
|
+
for (const store of this.stores) {
|
|
202
|
+
const result = await store.readCodeVerifier();
|
|
203
|
+
if (result) {
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async saveCodeVerifier(value: string): Promise<void> {
|
|
211
|
+
await Promise.all(this.stores.map((store) => store.saveCodeVerifier(value)));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async readState(): Promise<string | undefined> {
|
|
215
|
+
for (const store of this.stores) {
|
|
216
|
+
const result = await store.readState();
|
|
217
|
+
if (result) {
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async saveState(value: string): Promise<void> {
|
|
225
|
+
await Promise.all(this.stores.map((store) => store.saveState(value)));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async clear(scope: OAuthClearScope): Promise<void> {
|
|
229
|
+
await Promise.all(this.stores.map((store) => store.clear(scope)));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export async function buildOAuthPersistence(definition: ServerDefinition, logger?: Logger): Promise<OAuthPersistence> {
|
|
234
|
+
const vault = new VaultPersistence(definition);
|
|
235
|
+
const stores: OAuthPersistence[] = [vault];
|
|
236
|
+
|
|
237
|
+
if (definition.tokenCacheDir) {
|
|
238
|
+
stores.unshift(new DirectoryPersistence(definition.tokenCacheDir, logger));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Migrate legacy default per-server cache (~/.mcporter/<name>) into the vault if present.
|
|
242
|
+
const legacyDir = path.join(os.homedir(), '.mcporter', definition.name);
|
|
243
|
+
if (!definition.tokenCacheDir && legacyDir) {
|
|
244
|
+
const legacy = new DirectoryPersistence(legacyDir, logger);
|
|
245
|
+
const legacyTokens = await legacy.readTokens();
|
|
246
|
+
const legacyClient = await legacy.readClientInfo();
|
|
247
|
+
const legacyVerifier = await legacy.readCodeVerifier();
|
|
248
|
+
const legacyState = await legacy.readState();
|
|
249
|
+
if (legacyTokens || legacyClient || legacyVerifier || legacyState) {
|
|
250
|
+
if (legacyTokens) {
|
|
251
|
+
await vault.saveTokens(legacyTokens);
|
|
252
|
+
}
|
|
253
|
+
if (legacyClient) {
|
|
254
|
+
await vault.saveClientInfo(legacyClient);
|
|
255
|
+
}
|
|
256
|
+
if (legacyVerifier) {
|
|
257
|
+
await vault.saveCodeVerifier(legacyVerifier);
|
|
258
|
+
}
|
|
259
|
+
if (legacyState) {
|
|
260
|
+
await vault.saveState(legacyState);
|
|
261
|
+
}
|
|
262
|
+
logger?.info?.(`Migrated legacy OAuth cache for '${definition.name}' into vault.`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return stores.length === 1 ? vault : new CompositePersistence(stores);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export async function clearOAuthCaches(
|
|
270
|
+
definition: ServerDefinition,
|
|
271
|
+
logger?: Logger,
|
|
272
|
+
scope: OAuthClearScope = 'all'
|
|
273
|
+
): Promise<void> {
|
|
274
|
+
const persistence = await buildOAuthPersistence(definition, logger);
|
|
275
|
+
await persistence.clear(scope);
|
|
276
|
+
|
|
277
|
+
const legacyDir = path.join(os.homedir(), '.mcporter', definition.name);
|
|
278
|
+
if (legacyDir && (!definition.tokenCacheDir || legacyDir !== definition.tokenCacheDir)) {
|
|
279
|
+
const legacy = new DirectoryPersistence(legacyDir, logger);
|
|
280
|
+
await legacy.clear(scope);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (definition.tokenCacheDir) {
|
|
284
|
+
await fs.rm(definition.tokenCacheDir, { recursive: true, force: true });
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Known provider-specific legacy paths (gmail server writes to ~/.gmail-mcp/credentials.json).
|
|
288
|
+
const legacyFiles: string[] = [];
|
|
289
|
+
if (definition.name.toLowerCase() === 'gmail') {
|
|
290
|
+
legacyFiles.push(path.join(os.homedir(), '.gmail-mcp', 'credentials.json'));
|
|
291
|
+
}
|
|
292
|
+
await Promise.all(
|
|
293
|
+
legacyFiles.map(async (file) => {
|
|
294
|
+
try {
|
|
295
|
+
await fs.unlink(file);
|
|
296
|
+
logger?.info?.(`Cleared legacy OAuth cache file ${file}`);
|
|
297
|
+
} catch (error) {
|
|
298
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
|
|
299
|
+
throw error;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
})
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export async function readCachedAccessToken(
|
|
307
|
+
definition: ServerDefinition,
|
|
308
|
+
logger?: Logger
|
|
309
|
+
): Promise<string | undefined> {
|
|
310
|
+
const persistence = await buildOAuthPersistence(definition, logger);
|
|
311
|
+
const tokens = await persistence.readTokens();
|
|
312
|
+
if (tokens && typeof tokens.access_token === 'string' && tokens.access_token.trim().length > 0) {
|
|
313
|
+
return tokens.access_token;
|
|
314
|
+
}
|
|
315
|
+
return undefined;
|
|
316
|
+
}
|