@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,284 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { parse as parseToml } from '@iarna/toml';
|
|
4
|
+
import type { ImportKind, RawEntry } from '../../config-schema.js';
|
|
5
|
+
import { RawEntrySchema } from '../../config-schema.js';
|
|
6
|
+
import { normalizeProjectPath, pathsEqual } from './paths-utils.js';
|
|
7
|
+
import { fileExists, isRecord, parseJsonBuffer } from './shared.js';
|
|
8
|
+
|
|
9
|
+
interface ReadExternalEntryOptions {
|
|
10
|
+
readonly projectRoot?: string;
|
|
11
|
+
readonly importKind?: ImportKind;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function readExternalEntries(
|
|
15
|
+
filePath: string,
|
|
16
|
+
options: ReadExternalEntryOptions = {}
|
|
17
|
+
): Promise<Map<string, RawEntry> | null> {
|
|
18
|
+
if (!(await fileExists(filePath))) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const buffer = await fs.readFile(filePath, 'utf8');
|
|
23
|
+
if (!buffer.trim()) {
|
|
24
|
+
return new Map<string, RawEntry>();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
if (filePath.endsWith('.toml')) {
|
|
29
|
+
const parsed = parseToml(buffer) as Record<string, unknown>;
|
|
30
|
+
return extractFromCodexConfig(parsed);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const parsed = parseJsonBuffer(buffer);
|
|
34
|
+
return extractFromMcpJson(parsed, options, filePath);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (shouldIgnoreParseError(error)) {
|
|
37
|
+
return new Map<string, RawEntry>();
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function extractFromMcpJson(raw: unknown, options: ReadExternalEntryOptions, filePath?: string): Map<string, RawEntry> {
|
|
44
|
+
const map = new Map<string, RawEntry>();
|
|
45
|
+
if (!isRecord(raw)) {
|
|
46
|
+
return map;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const { importKind, projectRoot } = options;
|
|
50
|
+
const descriptor = resolveContainerDescriptor(importKind, filePath);
|
|
51
|
+
|
|
52
|
+
const containers: Record<string, unknown>[] = [];
|
|
53
|
+
if (descriptor.allowMcpServers && isRecord(raw.mcpServers)) {
|
|
54
|
+
containers.push(raw.mcpServers);
|
|
55
|
+
}
|
|
56
|
+
if (descriptor.allowServers && isRecord(raw.servers)) {
|
|
57
|
+
containers.push(raw.servers);
|
|
58
|
+
}
|
|
59
|
+
if (descriptor.allowMcp && isRecord(raw.mcp)) {
|
|
60
|
+
containers.push(raw.mcp);
|
|
61
|
+
}
|
|
62
|
+
if (descriptor.allowRootFallback && containers.length === 0) {
|
|
63
|
+
containers.push(raw);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
for (const container of containers) {
|
|
67
|
+
addEntriesFromContainer(container, map);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (projectRoot) {
|
|
71
|
+
const projectEntries = extractClaudeProjectEntries(raw, projectRoot);
|
|
72
|
+
for (const [name, entry] of projectEntries) {
|
|
73
|
+
if (!map.has(name)) {
|
|
74
|
+
map.set(name, entry);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return map;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function extractFromCodexConfig(raw: Record<string, unknown>): Map<string, RawEntry> {
|
|
83
|
+
const map = new Map<string, RawEntry>();
|
|
84
|
+
const serversRaw = raw.mcp_servers;
|
|
85
|
+
if (!serversRaw || typeof serversRaw !== 'object') {
|
|
86
|
+
return map;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
for (const [name, value] of Object.entries(serversRaw as Record<string, unknown>)) {
|
|
90
|
+
if (!value || typeof value !== 'object') {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const entry = convertExternalEntry(value as Record<string, unknown>);
|
|
94
|
+
if (entry) {
|
|
95
|
+
map.set(name, entry);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return map;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function convertExternalEntry(value: Record<string, unknown>): RawEntry | null {
|
|
103
|
+
const result: Record<string, unknown> = {};
|
|
104
|
+
|
|
105
|
+
if (typeof value.description === 'string') {
|
|
106
|
+
result.description = value.description;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const env = asStringRecord(value.env);
|
|
110
|
+
if (env) {
|
|
111
|
+
result.env = env;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const headers = buildExternalHeaders(value);
|
|
115
|
+
if (headers) {
|
|
116
|
+
result.headers = headers;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const auth = asString(value.auth);
|
|
120
|
+
if (auth) {
|
|
121
|
+
result.auth = auth;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const tokenCacheDir = asString(value.tokenCacheDir ?? value.token_cache_dir ?? value.token_cacheDir);
|
|
125
|
+
if (tokenCacheDir) {
|
|
126
|
+
result.tokenCacheDir = tokenCacheDir;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const clientName = asString(value.clientName ?? value.client_name);
|
|
130
|
+
if (clientName) {
|
|
131
|
+
result.clientName = clientName;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const url = asString(value.baseUrl ?? value.base_url ?? value.url ?? value.serverUrl ?? value.server_url);
|
|
135
|
+
if (url) {
|
|
136
|
+
result.baseUrl = url;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const commandValue = value.command ?? value.executable;
|
|
140
|
+
if (Array.isArray(commandValue) && commandValue.every((item) => typeof item === 'string')) {
|
|
141
|
+
result.command = commandValue;
|
|
142
|
+
} else if (typeof commandValue === 'string') {
|
|
143
|
+
result.command = commandValue;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (Array.isArray(value.args) && value.args.every((item) => typeof item === 'string')) {
|
|
147
|
+
result.args = value.args;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const hasHttpTarget = typeof result.baseUrl === 'string';
|
|
151
|
+
const hasCommandTarget =
|
|
152
|
+
typeof result.command === 'string' || (Array.isArray(result.command) && result.command.length > 0);
|
|
153
|
+
if (!hasHttpTarget && !hasCommandTarget) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const parsed = RawEntrySchema.safeParse(result);
|
|
158
|
+
return parsed.success ? parsed.data : null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function buildExternalHeaders(record: Record<string, unknown>): Record<string, string> | undefined {
|
|
162
|
+
const headers: Record<string, string> = {};
|
|
163
|
+
|
|
164
|
+
const literalHeaders = asStringRecord(record.headers);
|
|
165
|
+
if (literalHeaders) {
|
|
166
|
+
Object.assign(headers, literalHeaders);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const bearerToken = asString(record.bearerToken ?? record.bearer_token);
|
|
170
|
+
if (bearerToken) {
|
|
171
|
+
headers.Authorization = `Bearer ${bearerToken}`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const bearerTokenEnv = asString(record.bearerTokenEnv ?? record.bearer_token_env);
|
|
175
|
+
if (bearerTokenEnv) {
|
|
176
|
+
headers.Authorization = `$env:${bearerTokenEnv}`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return Object.keys(headers).length > 0 ? headers : undefined;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function extractClaudeProjectEntries(raw: Record<string, unknown>, projectRoot: string): Map<string, RawEntry> {
|
|
183
|
+
const map = new Map<string, RawEntry>();
|
|
184
|
+
if (!isRecord(raw.projects)) {
|
|
185
|
+
return map;
|
|
186
|
+
}
|
|
187
|
+
const projects = raw.projects as Record<string, unknown>;
|
|
188
|
+
const targetPath = normalizeProjectPath(projectRoot);
|
|
189
|
+
for (const [projectKey, value] of Object.entries(projects)) {
|
|
190
|
+
if (!isRecord(value) || !isRecord(value.mcpServers)) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const normalizedKey = normalizeProjectPath(projectKey);
|
|
194
|
+
if (!pathsEqual(normalizedKey, targetPath)) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
addEntriesFromContainer(value.mcpServers as Record<string, unknown>, map);
|
|
198
|
+
}
|
|
199
|
+
return map;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function addEntriesFromContainer(container: Record<string, unknown>, target: Map<string, RawEntry>): void {
|
|
203
|
+
for (const [name, value] of Object.entries(container)) {
|
|
204
|
+
if (!isRecord(value)) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (target.has(name)) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const entry = convertExternalEntry(value);
|
|
211
|
+
if (entry) {
|
|
212
|
+
target.set(name, entry);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function resolveContainerDescriptor(
|
|
218
|
+
importKind: ImportKind | undefined,
|
|
219
|
+
filePath?: string
|
|
220
|
+
): {
|
|
221
|
+
allowMcpServers: boolean;
|
|
222
|
+
allowServers: boolean;
|
|
223
|
+
allowMcp: boolean;
|
|
224
|
+
allowRootFallback: boolean;
|
|
225
|
+
} {
|
|
226
|
+
if (importKind === 'opencode') {
|
|
227
|
+
return {
|
|
228
|
+
allowMcpServers: false,
|
|
229
|
+
allowServers: false,
|
|
230
|
+
allowMcp: true,
|
|
231
|
+
allowRootFallback: false,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// For claude-code, only allow root fallback for legacy root-style files (.claude.json, .claude/mcp.json).
|
|
236
|
+
// Settings files like .claude/settings.json require proper mcpServers/servers/mcp containers.
|
|
237
|
+
if (importKind === 'claude-code' && filePath) {
|
|
238
|
+
const normalized = path.normalize(filePath);
|
|
239
|
+
const allowRootFallback =
|
|
240
|
+
normalized.endsWith('.claude.json') || normalized.endsWith(`${path.sep}.claude${path.sep}mcp.json`);
|
|
241
|
+
return {
|
|
242
|
+
allowMcpServers: true,
|
|
243
|
+
allowServers: true,
|
|
244
|
+
allowMcp: true,
|
|
245
|
+
allowRootFallback,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
allowMcpServers: true,
|
|
251
|
+
allowServers: true,
|
|
252
|
+
allowMcp: true,
|
|
253
|
+
allowRootFallback: true,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function asString(value: unknown): string | undefined {
|
|
258
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function asStringRecord(input: unknown): Record<string, string> | undefined {
|
|
262
|
+
if (!input || typeof input !== 'object') {
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
const record: Record<string, string> = {};
|
|
266
|
+
for (const [key, value] of Object.entries(input as Record<string, unknown>)) {
|
|
267
|
+
if (typeof value === 'string') {
|
|
268
|
+
record[key] = value;
|
|
269
|
+
} else if (typeof value === 'number' || typeof value === 'boolean') {
|
|
270
|
+
record[key] = String(value);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return Object.keys(record).length > 0 ? record : undefined;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function shouldIgnoreParseError(error: unknown): boolean {
|
|
277
|
+
if (error instanceof SyntaxError) {
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
if (!error || typeof error !== 'object') {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
return 'fromTOML' in error;
|
|
284
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
export function normalizeProjectPath(input: string): string {
|
|
5
|
+
if (!input || typeof input !== 'string') {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
return path.resolve(expandHomeShortcut(input));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function expandHomeShortcut(input: string): string {
|
|
12
|
+
if (input === '~') {
|
|
13
|
+
return os.homedir();
|
|
14
|
+
}
|
|
15
|
+
if (input.startsWith('~/') || input.startsWith('~\\')) {
|
|
16
|
+
return path.join(os.homedir(), input.slice(2));
|
|
17
|
+
}
|
|
18
|
+
return input;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function pathsEqual(a: string, b: string): boolean {
|
|
22
|
+
if (!a || !b) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (process.platform === 'win32') {
|
|
26
|
+
return a.toLowerCase() === b.toLowerCase();
|
|
27
|
+
}
|
|
28
|
+
return a === b;
|
|
29
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import type { ImportKind } from '../../config-schema.js';
|
|
4
|
+
|
|
5
|
+
export function pathsForImport(kind: ImportKind, rootDir: string): string[] {
|
|
6
|
+
switch (kind) {
|
|
7
|
+
case 'cursor':
|
|
8
|
+
return dedupePaths([
|
|
9
|
+
path.resolve(rootDir, '.cursor', 'mcp.json'),
|
|
10
|
+
path.join(os.homedir(), '.cursor', 'mcp.json'),
|
|
11
|
+
...defaultCursorUserConfigPaths(),
|
|
12
|
+
]);
|
|
13
|
+
case 'claude-code':
|
|
14
|
+
return dedupePaths([
|
|
15
|
+
path.resolve(rootDir, '.claude', 'settings.local.json'),
|
|
16
|
+
path.resolve(rootDir, '.claude', 'settings.json'),
|
|
17
|
+
path.resolve(rootDir, '.claude', 'mcp.json'),
|
|
18
|
+
path.join(os.homedir(), '.claude', 'settings.local.json'),
|
|
19
|
+
path.join(os.homedir(), '.claude', 'settings.json'),
|
|
20
|
+
path.join(os.homedir(), '.claude', 'mcp.json'),
|
|
21
|
+
path.join(os.homedir(), '.claude.json'),
|
|
22
|
+
]);
|
|
23
|
+
case 'claude-desktop':
|
|
24
|
+
return [defaultClaudeDesktopConfigPath()];
|
|
25
|
+
case 'codex':
|
|
26
|
+
return [path.resolve(rootDir, '.codex', 'config.toml'), path.join(os.homedir(), '.codex', 'config.toml')];
|
|
27
|
+
case 'windsurf':
|
|
28
|
+
return defaultWindsurfConfigPaths();
|
|
29
|
+
case 'opencode':
|
|
30
|
+
return opencodeConfigPaths(rootDir);
|
|
31
|
+
case 'vscode':
|
|
32
|
+
return dedupePaths([path.resolve(rootDir, '.vscode', 'mcp.json'), ...defaultVscodeConfigPaths()]);
|
|
33
|
+
default:
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function defaultCursorUserConfigPaths(): string[] {
|
|
39
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
40
|
+
const configs = xdgConfig ? [path.join(xdgConfig, 'Cursor', 'User', 'mcp.json')] : [];
|
|
41
|
+
return dedupePaths([
|
|
42
|
+
path.join(os.homedir(), 'AppData', 'Roaming', 'Cursor', 'User', 'mcp.json'),
|
|
43
|
+
path.join(os.homedir(), 'Library', 'Application Support', 'Cursor', 'User', 'mcp.json'),
|
|
44
|
+
...configs,
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function defaultWindsurfConfigPaths(): string[] {
|
|
49
|
+
const homeDir = os.homedir();
|
|
50
|
+
const paths = [
|
|
51
|
+
path.join(homeDir, '.codeium', 'windsurf', 'mcp_config.json'),
|
|
52
|
+
path.join(homeDir, '.codeium', 'windsurf-next', 'mcp_config.json'),
|
|
53
|
+
path.join(homeDir, '.windsurf', 'mcp_config.json'),
|
|
54
|
+
path.join(homeDir, '.config', '.codeium', 'windsurf', 'mcp_config.json'),
|
|
55
|
+
];
|
|
56
|
+
if (process.platform === 'win32') {
|
|
57
|
+
const appData = process.env.APPDATA ?? path.join(homeDir, 'AppData', 'Roaming');
|
|
58
|
+
paths.push(path.join(appData, 'Codeium', 'windsurf', 'mcp_config.json'));
|
|
59
|
+
}
|
|
60
|
+
return dedupePaths(paths);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function defaultVscodeConfigPaths(): string[] {
|
|
64
|
+
if (process.platform === 'darwin') {
|
|
65
|
+
return [
|
|
66
|
+
path.join(os.homedir(), 'Library', 'Application Support', 'Code', 'User', 'mcp.json'),
|
|
67
|
+
path.join(os.homedir(), 'Library', 'Application Support', 'Code - Insiders', 'User', 'mcp.json'),
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
if (process.platform === 'win32') {
|
|
71
|
+
const appData = process.env.APPDATA ?? path.join(os.homedir(), 'AppData', 'Roaming');
|
|
72
|
+
return [path.join(appData, 'Code', 'User', 'mcp.json'), path.join(appData, 'Code - Insiders', 'User', 'mcp.json')];
|
|
73
|
+
}
|
|
74
|
+
return [
|
|
75
|
+
path.join(os.homedir(), '.config', 'Code', 'User', 'mcp.json'),
|
|
76
|
+
path.join(os.homedir(), '.config', 'Code - Insiders', 'User', 'mcp.json'),
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function opencodeConfigPaths(rootDir: string): string[] {
|
|
81
|
+
const overrideConfig = process.env.OPENCODE_CONFIG;
|
|
82
|
+
const overrideDir = process.env.OPENCODE_CONFIG_DIR;
|
|
83
|
+
const envConfigPath = process.env.OPENAI_WORKDIR;
|
|
84
|
+
const xdg = process.env.XDG_CONFIG_HOME;
|
|
85
|
+
const configHome = xdg ?? path.join(process.env.HOME ?? '', '.config');
|
|
86
|
+
const paths: string[] = [
|
|
87
|
+
overrideConfig ?? '',
|
|
88
|
+
path.resolve(rootDir, 'opencode.jsonc'),
|
|
89
|
+
path.resolve(rootDir, 'opencode.json'),
|
|
90
|
+
];
|
|
91
|
+
if (overrideDir && overrideDir.length > 0) {
|
|
92
|
+
paths.push(path.join(overrideDir, 'opencode.jsonc'), path.join(overrideDir, 'opencode.json'));
|
|
93
|
+
}
|
|
94
|
+
paths.push(
|
|
95
|
+
path.resolve(rootDir, '.openai', 'config.json'),
|
|
96
|
+
envConfigPath ? path.resolve(envConfigPath, '.openai', 'config.json') : '',
|
|
97
|
+
path.join(configHome, 'openai', 'config.json')
|
|
98
|
+
);
|
|
99
|
+
for (const dir of defaultOpencodeConfigDirs()) {
|
|
100
|
+
paths.push(path.join(dir, 'opencode.jsonc'), path.join(dir, 'opencode.json'));
|
|
101
|
+
}
|
|
102
|
+
return dedupePaths(paths);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function defaultOpencodeConfigDirs(): string[] {
|
|
106
|
+
const dirs: string[] = [];
|
|
107
|
+
const xdg = process.env.XDG_CONFIG_HOME;
|
|
108
|
+
if (xdg && xdg.length > 0) {
|
|
109
|
+
dirs.push(path.join(xdg, 'opencode'));
|
|
110
|
+
} else if (process.platform === 'win32') {
|
|
111
|
+
const appData = process.env.APPDATA ?? path.join(os.homedir(), 'AppData', 'Roaming');
|
|
112
|
+
dirs.push(path.join(appData, 'opencode'));
|
|
113
|
+
} else {
|
|
114
|
+
dirs.push(path.join(os.homedir(), '.config', 'opencode'));
|
|
115
|
+
}
|
|
116
|
+
return dirs;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function defaultClaudeDesktopConfigPath(): string {
|
|
120
|
+
const homeDir = os.homedir();
|
|
121
|
+
const darwinPath = path.join(homeDir, 'Library', 'Application Support', 'Claude', 'settings.json');
|
|
122
|
+
const windowsPath = path.join(homeDir, 'AppData', 'Roaming', 'Claude', 'settings.json');
|
|
123
|
+
const linuxPath = path.join(homeDir, '.config', 'Claude', 'settings.json');
|
|
124
|
+
const platform = process.platform;
|
|
125
|
+
if (platform === 'darwin') {
|
|
126
|
+
return darwinPath;
|
|
127
|
+
}
|
|
128
|
+
if (platform === 'win32') {
|
|
129
|
+
return windowsPath;
|
|
130
|
+
}
|
|
131
|
+
return linuxPath;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function dedupePaths(paths: string[]): string[] {
|
|
135
|
+
const seen = new Set<string>();
|
|
136
|
+
const result: string[] = [];
|
|
137
|
+
for (const candidate of paths) {
|
|
138
|
+
if (!candidate || seen.has(candidate)) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
seen.add(candidate);
|
|
142
|
+
result.push(candidate);
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import type { ParseError } from 'jsonc-parser';
|
|
3
|
+
import { parse as parseJsonWithComments, printParseErrorCode } from 'jsonc-parser';
|
|
4
|
+
|
|
5
|
+
export async function fileExists(filePath: string): Promise<boolean> {
|
|
6
|
+
try {
|
|
7
|
+
await fs.access(filePath);
|
|
8
|
+
return true;
|
|
9
|
+
} catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function parseJsonBuffer(buffer: string): unknown {
|
|
15
|
+
const errors: ParseError[] = [];
|
|
16
|
+
const parsed = parseJsonWithComments(buffer, errors, { allowTrailingComma: true });
|
|
17
|
+
const first = errors[0];
|
|
18
|
+
if (first) {
|
|
19
|
+
const message = printParseErrorCode(first.error);
|
|
20
|
+
throw new SyntaxError(`Failed to parse JSON (offset ${first.offset}): ${message}`);
|
|
21
|
+
}
|
|
22
|
+
return parsed;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function isRecord(value: unknown): value is Record<string, unknown> {
|
|
26
|
+
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
27
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import fsSync from 'node:fs';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import type { LoadConfigOptions } from '../config-schema.js';
|
|
6
|
+
import { expandHome } from '../env.js';
|
|
7
|
+
|
|
8
|
+
export interface ResolvedConfigPath {
|
|
9
|
+
path: string;
|
|
10
|
+
explicit: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function listConfigLayerPaths(
|
|
14
|
+
options: LoadConfigOptions = {},
|
|
15
|
+
rootDir: string = process.cwd()
|
|
16
|
+
): Promise<string[]> {
|
|
17
|
+
const explicitPath = options.configPath ?? process.env.MCPORTER_CONFIG;
|
|
18
|
+
if (explicitPath) {
|
|
19
|
+
return [path.resolve(expandHome(explicitPath.trim()))];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const paths: string[] = [];
|
|
23
|
+
const homeCandidates = homeConfigCandidates();
|
|
24
|
+
const existingHome = homeCandidates.find((candidate) => pathExists(candidate));
|
|
25
|
+
if (existingHome) {
|
|
26
|
+
paths.push(existingHome);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const projectPath = path.resolve(rootDir, 'config', 'mcporter.json');
|
|
30
|
+
if (pathExists(projectPath)) {
|
|
31
|
+
paths.push(projectPath);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return paths;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function resolveConfigPath(configPath: string | undefined, rootDir: string): ResolvedConfigPath {
|
|
38
|
+
if (configPath) {
|
|
39
|
+
return { path: path.resolve(configPath), explicit: true };
|
|
40
|
+
}
|
|
41
|
+
const envConfig = process.env.MCPORTER_CONFIG;
|
|
42
|
+
if (envConfig && envConfig.trim().length > 0) {
|
|
43
|
+
return { path: path.resolve(expandHome(envConfig.trim())), explicit: true };
|
|
44
|
+
}
|
|
45
|
+
const projectPath = path.resolve(rootDir, 'config', 'mcporter.json');
|
|
46
|
+
if (pathExists(projectPath)) {
|
|
47
|
+
return { path: projectPath, explicit: false };
|
|
48
|
+
}
|
|
49
|
+
const homeCandidates = homeConfigCandidates();
|
|
50
|
+
const existingHome = homeCandidates.find((candidate) => pathExists(candidate));
|
|
51
|
+
if (existingHome) {
|
|
52
|
+
return { path: existingHome, explicit: false };
|
|
53
|
+
}
|
|
54
|
+
return { path: projectPath, explicit: false };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function homeConfigCandidates(): string[] {
|
|
58
|
+
const homeDir = os.homedir();
|
|
59
|
+
const base = path.join(homeDir, '.mcporter');
|
|
60
|
+
return [path.join(base, 'mcporter.json'), path.join(base, 'mcporter.jsonc')];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function pathExists(filePath: string): boolean {
|
|
64
|
+
try {
|
|
65
|
+
fsSync.accessSync(filePath);
|
|
66
|
+
return true;
|
|
67
|
+
} catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function pathExistsAsync(filePath: string): Promise<boolean> {
|
|
73
|
+
try {
|
|
74
|
+
await fs.access(filePath);
|
|
75
|
+
return true;
|
|
76
|
+
} catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { type LoadConfigOptions, type RawConfig, RawConfigSchema } from '../config-schema.js';
|
|
4
|
+
import { expandHome } from '../env.js';
|
|
5
|
+
import { parseJsonBuffer } from './imports/shared.js';
|
|
6
|
+
import { homeConfigCandidates, pathExists, pathExistsAsync } from './path-discovery.js';
|
|
7
|
+
|
|
8
|
+
export type ConfigLayer = {
|
|
9
|
+
config: RawConfig;
|
|
10
|
+
path: string;
|
|
11
|
+
explicit: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export async function loadConfigLayers(options: LoadConfigOptions, rootDir: string): Promise<ConfigLayer[]> {
|
|
15
|
+
const explicitPath = options.configPath ?? process.env.MCPORTER_CONFIG;
|
|
16
|
+
if (explicitPath) {
|
|
17
|
+
const resolvedPath = path.resolve(expandHome(explicitPath.trim()));
|
|
18
|
+
const config = await readConfigFile(resolvedPath, true);
|
|
19
|
+
return [{ config, path: resolvedPath, explicit: true }];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const layers: ConfigLayer[] = [];
|
|
23
|
+
|
|
24
|
+
const homeCandidates = homeConfigCandidates();
|
|
25
|
+
const existingHome = homeCandidates.find((candidate) => pathExists(candidate));
|
|
26
|
+
if (existingHome) {
|
|
27
|
+
layers.push({ config: await readConfigFile(existingHome, false), path: existingHome, explicit: false });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const projectPath = path.resolve(rootDir, 'config', 'mcporter.json');
|
|
31
|
+
if (pathExists(projectPath)) {
|
|
32
|
+
layers.push({ config: await readConfigFile(projectPath, false), path: projectPath, explicit: false });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (layers.length === 0) {
|
|
36
|
+
// Preserve prior behavior: a missing default config returns an empty list and assumes the project path.
|
|
37
|
+
layers.push({ config: { mcpServers: {} }, path: projectPath, explicit: false });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return layers;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function readConfigFile(configPath: string, explicit: boolean): Promise<RawConfig> {
|
|
44
|
+
if (!explicit && !(await pathExistsAsync(configPath))) {
|
|
45
|
+
return { mcpServers: {} };
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const buffer = await fs.readFile(configPath, 'utf8');
|
|
49
|
+
return RawConfigSchema.parse(parseJsonBuffer(buffer));
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (!explicit && isMissingConfigError(error)) {
|
|
52
|
+
return { mcpServers: {} };
|
|
53
|
+
}
|
|
54
|
+
if (!explicit && isSyntaxError(error)) {
|
|
55
|
+
warnConfigFallback(configPath, error);
|
|
56
|
+
return { mcpServers: {} };
|
|
57
|
+
}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function isErrno(error: unknown, code: string): error is NodeJS.ErrnoException {
|
|
63
|
+
return Boolean(error && typeof error === 'object' && (error as NodeJS.ErrnoException).code === code);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function isMissingConfigError(error: unknown): boolean {
|
|
67
|
+
return isErrno(error, 'ENOENT') || includesErrnoMessage(error, 'ENOENT');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function isSyntaxError(error: unknown): error is SyntaxError {
|
|
71
|
+
return error instanceof SyntaxError;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const warnedConfigPaths = new Set<string>();
|
|
75
|
+
|
|
76
|
+
function warnConfigFallback(configPath: string, error: unknown): void {
|
|
77
|
+
if (warnedConfigPaths.has(configPath)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
warnedConfigPaths.add(configPath);
|
|
81
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
82
|
+
console.warn(`[mcporter] Ignoring config at ${configPath}: ${reason}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function includesErrnoMessage(error: unknown, code: string): boolean {
|
|
86
|
+
if (!error || typeof error !== 'object') {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
const message = (error as { message?: unknown }).message;
|
|
90
|
+
return typeof message === 'string' && message.includes(code);
|
|
91
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { pathToFileURL } from 'node:url';
|
|
2
|
+
import { readExternalEntries } from './config/imports/external.js';
|
|
3
|
+
import { pathsForImport } from './config/imports/paths.js';
|
|
4
|
+
import type { ImportKind, RawEntry } from './config-schema.js';
|
|
5
|
+
|
|
6
|
+
export { pathsForImport, readExternalEntries };
|
|
7
|
+
|
|
8
|
+
export function toFileUrl(filePath: string): URL {
|
|
9
|
+
return pathToFileURL(filePath);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type { ImportKind, RawEntry };
|