@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,67 @@
|
|
|
1
|
+
import type { ServerDefinition } from '../config.js';
|
|
2
|
+
import { keepAliveIdleTimeout } from '../lifecycle.js';
|
|
3
|
+
import type { Runtime } from '../runtime.js';
|
|
4
|
+
import type { DaemonResponse } from './protocol.js';
|
|
5
|
+
|
|
6
|
+
export interface ServerActivity {
|
|
7
|
+
connected: boolean;
|
|
8
|
+
lastUsedAt?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function ensureManaged(server: string, managedServers: Map<string, ServerDefinition>): void {
|
|
12
|
+
if (!managedServers.has(server)) {
|
|
13
|
+
throw new Error(`Server '${server}' is not managed by the daemon.`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function markActivity(server: string, activity: Map<string, ServerActivity>): void {
|
|
18
|
+
const entry = activity.get(server);
|
|
19
|
+
if (entry) {
|
|
20
|
+
entry.connected = true;
|
|
21
|
+
entry.lastUsedAt = Date.now();
|
|
22
|
+
} else {
|
|
23
|
+
activity.set(server, { connected: true, lastUsedAt: Date.now() });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function evictIdleServers(
|
|
28
|
+
runtime: Runtime,
|
|
29
|
+
managedServers: Map<string, ServerDefinition>,
|
|
30
|
+
activity: Map<string, ServerActivity>
|
|
31
|
+
): Promise<void> {
|
|
32
|
+
const now = Date.now();
|
|
33
|
+
await Promise.all(
|
|
34
|
+
Array.from(managedServers.entries()).map(async ([name, definition]) => {
|
|
35
|
+
const timeout = keepAliveIdleTimeout(definition);
|
|
36
|
+
if (!timeout) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const entry = activity.get(name);
|
|
40
|
+
if (!entry?.lastUsedAt) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (now - entry.lastUsedAt < timeout) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
await runtime.close(name).catch(() => {});
|
|
47
|
+
activity.set(name, { connected: false });
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function buildErrorResponse(id: string, code: string, error?: unknown): DaemonResponse {
|
|
53
|
+
let message = code;
|
|
54
|
+
if (error instanceof Error) {
|
|
55
|
+
message = error.message;
|
|
56
|
+
} else if (typeof error === 'string') {
|
|
57
|
+
message = error;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
id,
|
|
61
|
+
ok: false,
|
|
62
|
+
error: {
|
|
63
|
+
code,
|
|
64
|
+
message,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { ListResourcesRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { ServerDefinition } from '../config.js';
|
|
4
|
+
import { isKeepAliveServer } from '../lifecycle.js';
|
|
5
|
+
import type { CallOptions, ListToolsOptions, Runtime } from '../runtime.js';
|
|
6
|
+
import type { DaemonClient } from './client.js';
|
|
7
|
+
|
|
8
|
+
interface KeepAliveRuntimeOptions {
|
|
9
|
+
readonly daemonClient: DaemonClient | null;
|
|
10
|
+
readonly keepAliveServers: Set<string>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function createKeepAliveRuntime(base: Runtime, options: KeepAliveRuntimeOptions): Runtime {
|
|
14
|
+
if (!options.daemonClient || options.keepAliveServers.size === 0) {
|
|
15
|
+
return base;
|
|
16
|
+
}
|
|
17
|
+
return new KeepAliveRuntime(base, options.daemonClient, options.keepAliveServers);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class KeepAliveRuntime implements Runtime {
|
|
21
|
+
constructor(
|
|
22
|
+
private readonly base: Runtime,
|
|
23
|
+
private readonly daemon: DaemonClient,
|
|
24
|
+
private readonly keepAliveServers: Set<string>
|
|
25
|
+
) {}
|
|
26
|
+
|
|
27
|
+
listServers(): string[] {
|
|
28
|
+
return this.base.listServers();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getDefinitions(): ServerDefinition[] {
|
|
32
|
+
return this.base.getDefinitions();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getDefinition(server: string): ServerDefinition {
|
|
36
|
+
return this.base.getDefinition(server);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
registerDefinition(definition: ServerDefinition, options?: { overwrite?: boolean }): void {
|
|
40
|
+
this.base.registerDefinition(definition, options);
|
|
41
|
+
if (isKeepAliveServer(definition)) {
|
|
42
|
+
this.keepAliveServers.add(definition.name);
|
|
43
|
+
} else {
|
|
44
|
+
this.keepAliveServers.delete(definition.name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async listTools(server: string, options?: ListToolsOptions): Promise<Awaited<ReturnType<Runtime['listTools']>>> {
|
|
49
|
+
if (this.shouldUseDaemon(server)) {
|
|
50
|
+
return (await this.invokeWithRestart(server, 'listTools', () =>
|
|
51
|
+
this.daemon.listTools({
|
|
52
|
+
server,
|
|
53
|
+
includeSchema: options?.includeSchema,
|
|
54
|
+
autoAuthorize: options?.autoAuthorize,
|
|
55
|
+
})
|
|
56
|
+
)) as Awaited<ReturnType<Runtime['listTools']>>;
|
|
57
|
+
}
|
|
58
|
+
return this.base.listTools(server, options);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async callTool(server: string, toolName: string, options?: CallOptions): Promise<unknown> {
|
|
62
|
+
if (this.shouldUseDaemon(server)) {
|
|
63
|
+
return this.invokeWithRestart(server, 'callTool', () =>
|
|
64
|
+
this.daemon.callTool({
|
|
65
|
+
server,
|
|
66
|
+
tool: toolName,
|
|
67
|
+
args: options?.args,
|
|
68
|
+
timeoutMs: options?.timeoutMs,
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return this.base.callTool(server, toolName, options);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async listResources(server: string, options?: Partial<ListResourcesRequest['params']>): Promise<unknown> {
|
|
76
|
+
if (this.shouldUseDaemon(server)) {
|
|
77
|
+
return this.invokeWithRestart(server, 'listResources', () =>
|
|
78
|
+
this.daemon.listResources({ server, params: options ?? {} })
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return this.base.listResources(server, options);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async connect(server: string): Promise<Awaited<ReturnType<Runtime['connect']>>> {
|
|
85
|
+
return this.base.connect(server);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async close(server?: string): Promise<void> {
|
|
89
|
+
if (!server) {
|
|
90
|
+
await this.base.close();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (this.shouldUseDaemon(server)) {
|
|
94
|
+
await this.daemon.closeServer({ server }).catch(() => {});
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
await this.base.close(server);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private shouldUseDaemon(server: string): boolean {
|
|
101
|
+
return this.keepAliveServers.has(server);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private async invokeWithRestart<T>(server: string, operation: string, action: () => Promise<T>): Promise<T> {
|
|
105
|
+
try {
|
|
106
|
+
return await action();
|
|
107
|
+
} catch (error) {
|
|
108
|
+
if (!shouldRestartDaemonServer(error)) {
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
// The daemon keeps STDIO transports warm; if a call fails due to a fatal error,
|
|
112
|
+
// force-close the cached server so the retry launches a fresh Chrome instance.
|
|
113
|
+
logDaemonRetry(server, operation, error);
|
|
114
|
+
await this.daemon.closeServer({ server }).catch(() => {});
|
|
115
|
+
return action();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const NON_FATAL_CODES = new Set([ErrorCode.InvalidRequest, ErrorCode.MethodNotFound, ErrorCode.InvalidParams]);
|
|
121
|
+
|
|
122
|
+
function shouldRestartDaemonServer(error: unknown): boolean {
|
|
123
|
+
if (!error) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (error instanceof McpError) {
|
|
127
|
+
return !NON_FATAL_CODES.has(error.code);
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function logDaemonRetry(server: string, operation: string, error: unknown): void {
|
|
133
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
134
|
+
console.log(`[mcporter] Restarting '${server}' before retrying ${operation}: ${reason}`);
|
|
135
|
+
}
|
package/src/env.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
|
|
3
|
+
const ENV_DEFAULT_PATTERN = /^\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-|:|-)?([^}]*)\}$/;
|
|
4
|
+
const ENV_INTERPOLATION_PATTERN = /\\?\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
5
|
+
const ENV_DIRECT_PREFIX = '$env:';
|
|
6
|
+
|
|
7
|
+
// expandHome replaces a leading '~' with the current user's home directory.
|
|
8
|
+
export function expandHome(input: string): string {
|
|
9
|
+
if (!input.startsWith('~')) {
|
|
10
|
+
return input;
|
|
11
|
+
}
|
|
12
|
+
const home = os.homedir();
|
|
13
|
+
if (input === '~') {
|
|
14
|
+
return home;
|
|
15
|
+
}
|
|
16
|
+
if (input.startsWith('~/')) {
|
|
17
|
+
return `${home}/${input.slice(2)}`;
|
|
18
|
+
}
|
|
19
|
+
return input;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// resolveEnvValue interprets ${VAR:-default} syntax and other primitive values for env overrides.
|
|
23
|
+
export function resolveEnvValue(raw: unknown): string {
|
|
24
|
+
if (typeof raw !== 'string') {
|
|
25
|
+
return String(raw);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const match = ENV_DEFAULT_PATTERN.exec(raw);
|
|
29
|
+
if (match) {
|
|
30
|
+
const envName = match[1];
|
|
31
|
+
const defaultValue = match[2] ?? '';
|
|
32
|
+
if (!envName) {
|
|
33
|
+
return raw;
|
|
34
|
+
}
|
|
35
|
+
const existing = process.env[envName];
|
|
36
|
+
if (existing && existing !== '') {
|
|
37
|
+
return existing;
|
|
38
|
+
}
|
|
39
|
+
return defaultValue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (raw.startsWith('$')) {
|
|
43
|
+
return resolveEnvPlaceholders(raw);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return raw;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// resolveEnvPlaceholders replaces ${VAR} or $env:VAR references using process.env, enforcing required values.
|
|
50
|
+
export function resolveEnvPlaceholders(value: string): string {
|
|
51
|
+
if (value.startsWith(ENV_DIRECT_PREFIX)) {
|
|
52
|
+
const envName = value.slice(ENV_DIRECT_PREFIX.length);
|
|
53
|
+
const envValue = process.env[envName];
|
|
54
|
+
if (envValue === undefined) {
|
|
55
|
+
throw new Error(`Environment variable '${envName}' is required for MCP header substitution.`);
|
|
56
|
+
}
|
|
57
|
+
return envValue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const missing = new Set<string>();
|
|
61
|
+
const replaced = value.replace(ENV_INTERPOLATION_PATTERN, (placeholder, envName: string) => {
|
|
62
|
+
const envValue = process.env[envName];
|
|
63
|
+
if (envValue === undefined) {
|
|
64
|
+
missing.add(envName);
|
|
65
|
+
return placeholder;
|
|
66
|
+
}
|
|
67
|
+
return envValue;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (missing.size > 0) {
|
|
71
|
+
const names = [...missing].sort().join(', ');
|
|
72
|
+
throw new Error(`Environment variable(s) ${names} must be set for MCP header substitution.`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return replaced;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// withEnvOverrides temporarily populates process.env keys while executing the provided callback.
|
|
79
|
+
export async function withEnvOverrides<T>(
|
|
80
|
+
envOverrides: Record<string, string> | undefined,
|
|
81
|
+
fn: () => Promise<T> | T
|
|
82
|
+
): Promise<T> {
|
|
83
|
+
if (!envOverrides || Object.keys(envOverrides).length === 0) {
|
|
84
|
+
return await fn();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const applied: string[] = [];
|
|
88
|
+
for (const [key, rawValue] of Object.entries(envOverrides)) {
|
|
89
|
+
if (process.env[key]) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const resolved = resolveEnvValue(rawValue);
|
|
93
|
+
if (resolved === '') {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
process.env[key] = resolved;
|
|
97
|
+
applied.push(key);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
return await fn();
|
|
102
|
+
} finally {
|
|
103
|
+
for (const key of applied) {
|
|
104
|
+
delete process.env[key];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { UnauthorizedError } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
2
|
+
|
|
3
|
+
export type ConnectionIssueKind = 'auth' | 'offline' | 'http' | 'stdio-exit' | 'other';
|
|
4
|
+
|
|
5
|
+
export interface ConnectionIssue {
|
|
6
|
+
kind: ConnectionIssueKind;
|
|
7
|
+
rawMessage: string;
|
|
8
|
+
statusCode?: number;
|
|
9
|
+
stdioExitCode?: number;
|
|
10
|
+
stdioSignal?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const AUTH_STATUSES = new Set([401, 403]);
|
|
14
|
+
const OFFLINE_PATTERNS = [
|
|
15
|
+
'fetch failed',
|
|
16
|
+
'econnrefused',
|
|
17
|
+
'connection refused',
|
|
18
|
+
'connection closed',
|
|
19
|
+
'connection reset',
|
|
20
|
+
'socket hang up',
|
|
21
|
+
'connect timeout',
|
|
22
|
+
'network is unreachable',
|
|
23
|
+
'timed out',
|
|
24
|
+
'timeout',
|
|
25
|
+
'timeout after',
|
|
26
|
+
'getaddrinfo',
|
|
27
|
+
'enotfound',
|
|
28
|
+
'enoent',
|
|
29
|
+
'eai_again',
|
|
30
|
+
'econnaborted',
|
|
31
|
+
'ehostunreach',
|
|
32
|
+
'no such host',
|
|
33
|
+
'failed to start',
|
|
34
|
+
'spawn enoent',
|
|
35
|
+
];
|
|
36
|
+
const HTTP_STATUS_FALLBACK = /\bhttps?:\/\/[^\s]+(?:\s+returned\s+)?(?:status|code)?\s*(\d{3})\b/i;
|
|
37
|
+
const STATUS_DIRECT_PATTERN = /\b(?:status(?:\s+code)?|http(?:\s+(?:status|code|error))?)[:\s]*(\d{3})\b/i;
|
|
38
|
+
const STDIO_EXIT_PATTERN = /exit(?:ed)?(?:\s+with)?(?:\s+(?:code|status))\s+(-?\d+)/i;
|
|
39
|
+
const STDIO_SIGNAL_PATTERN = /signal\s+([A-Z0-9]+)/i;
|
|
40
|
+
|
|
41
|
+
export function analyzeConnectionError(error: unknown): ConnectionIssue {
|
|
42
|
+
const rawMessage = extractMessage(error);
|
|
43
|
+
if (error instanceof UnauthorizedError) {
|
|
44
|
+
return { kind: 'auth', rawMessage };
|
|
45
|
+
}
|
|
46
|
+
const stdio = extractStdioExit(rawMessage);
|
|
47
|
+
if (stdio) {
|
|
48
|
+
return { kind: 'stdio-exit', rawMessage, ...stdio };
|
|
49
|
+
}
|
|
50
|
+
const statusCode = extractStatusCode(rawMessage);
|
|
51
|
+
const normalized = rawMessage.toLowerCase();
|
|
52
|
+
if (AUTH_STATUSES.has(statusCode ?? -1) || containsAuthToken(normalized)) {
|
|
53
|
+
return { kind: 'auth', rawMessage, statusCode };
|
|
54
|
+
}
|
|
55
|
+
if (statusCode && statusCode >= 400) {
|
|
56
|
+
return { kind: 'http', rawMessage, statusCode };
|
|
57
|
+
}
|
|
58
|
+
if (OFFLINE_PATTERNS.some((pattern) => normalized.includes(pattern))) {
|
|
59
|
+
return { kind: 'offline', rawMessage };
|
|
60
|
+
}
|
|
61
|
+
return { kind: 'other', rawMessage };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function isAuthIssue(issue: ConnectionIssue): boolean {
|
|
65
|
+
return issue.kind === 'auth';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function extractMessage(error: unknown): string {
|
|
69
|
+
if (error instanceof Error) {
|
|
70
|
+
return error.message ?? '';
|
|
71
|
+
}
|
|
72
|
+
if (typeof error === 'string') {
|
|
73
|
+
return error;
|
|
74
|
+
}
|
|
75
|
+
if (error === undefined || error === null) {
|
|
76
|
+
return '';
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
return JSON.stringify(error);
|
|
80
|
+
} catch {
|
|
81
|
+
return '';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function extractStatusCode(message: string): number | undefined {
|
|
86
|
+
const candidates = [
|
|
87
|
+
message.match(/status code\s*\((\d{3})\)/i)?.[1],
|
|
88
|
+
message.match(STATUS_DIRECT_PATTERN)?.[1],
|
|
89
|
+
message.match(HTTP_STATUS_FALLBACK)?.[1],
|
|
90
|
+
].filter(Boolean) as string[];
|
|
91
|
+
for (const candidate of candidates) {
|
|
92
|
+
const parsed = Number.parseInt(candidate, 10);
|
|
93
|
+
if (Number.isFinite(parsed)) {
|
|
94
|
+
return parsed;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const trimmed = message.trim();
|
|
98
|
+
if (trimmed.startsWith('{')) {
|
|
99
|
+
try {
|
|
100
|
+
const parsed = JSON.parse(trimmed);
|
|
101
|
+
const candidate = findStatusInObject(parsed);
|
|
102
|
+
if (typeof candidate === 'number') {
|
|
103
|
+
return candidate;
|
|
104
|
+
}
|
|
105
|
+
if (typeof candidate === 'string') {
|
|
106
|
+
const numeric = Number.parseInt(candidate, 10);
|
|
107
|
+
if (Number.isFinite(numeric)) {
|
|
108
|
+
return numeric;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} catch {
|
|
112
|
+
// fall through when the payload is not JSON
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function containsAuthToken(normalizedMessage: string): boolean {
|
|
119
|
+
return (
|
|
120
|
+
normalizedMessage.includes('401') ||
|
|
121
|
+
normalizedMessage.includes('unauthorized') ||
|
|
122
|
+
normalizedMessage.includes('invalid_token') ||
|
|
123
|
+
normalizedMessage.includes('forbidden')
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function extractStdioExit(message: string): { stdioExitCode?: number; stdioSignal?: string } | undefined {
|
|
128
|
+
if (!message.toLowerCase().includes('stdio') && !STDIO_EXIT_PATTERN.test(message)) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
const exitMatch = message.match(STDIO_EXIT_PATTERN);
|
|
132
|
+
const signalMatch = message.match(STDIO_SIGNAL_PATTERN);
|
|
133
|
+
if (!exitMatch && !signalMatch) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
const exitCode = exitMatch ? Number.parseInt(exitMatch[1] ?? '', 10) : undefined;
|
|
137
|
+
return {
|
|
138
|
+
stdioExitCode: Number.isFinite(exitCode) ? exitCode : undefined,
|
|
139
|
+
stdioSignal: signalMatch?.[1],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function findStatusInObject(value: unknown): unknown {
|
|
144
|
+
if (!value || typeof value !== 'object') {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
const record = value as Record<string, unknown>;
|
|
148
|
+
if (typeof record.status === 'number' || typeof record.status === 'string') {
|
|
149
|
+
return record.status;
|
|
150
|
+
}
|
|
151
|
+
if (typeof record.code === 'number' || typeof record.code === 'string') {
|
|
152
|
+
return record.code;
|
|
153
|
+
}
|
|
154
|
+
if (typeof record.error === 'object' && record.error !== null) {
|
|
155
|
+
return findStatusInObject(record.error);
|
|
156
|
+
}
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
package/src/fs-json.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
// readJsonFile reads a JSON file and returns undefined when the file does not exist.
|
|
5
|
+
export async function readJsonFile<T = unknown>(filePath: string): Promise<T | undefined> {
|
|
6
|
+
try {
|
|
7
|
+
const content = await fs.readFile(filePath, 'utf8');
|
|
8
|
+
return JSON.parse(content) as T;
|
|
9
|
+
} catch (error) {
|
|
10
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// writeJsonFile writes a JSON object to disk, ensuring parent directories are created first.
|
|
18
|
+
export async function writeJsonFile(filePath: string, data: unknown): Promise<void> {
|
|
19
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
20
|
+
await fs.writeFile(filePath, JSON.stringify(data, null, 2), 'utf8');
|
|
21
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {
|
|
4
|
+
bundleOutput,
|
|
5
|
+
compileBundleWithBun,
|
|
6
|
+
computeCompileTarget,
|
|
7
|
+
resolveBundleTarget,
|
|
8
|
+
} from './cli/generate/artifacts.js';
|
|
9
|
+
import { ensureInvocationDefaults, fetchTools, resolveServerDefinition } from './cli/generate/definition.js';
|
|
10
|
+
import { resolveRuntimeKind } from './cli/generate/runtime.js';
|
|
11
|
+
import { readPackageMetadata, writeTemplate } from './cli/generate/template.js';
|
|
12
|
+
import type { ToolMetadata } from './cli/generate/tools.js';
|
|
13
|
+
import { buildToolMetadata, toolsTestHelpers } from './cli/generate/tools.js';
|
|
14
|
+
import { type CliArtifactMetadata, serializeDefinition } from './cli-metadata.js';
|
|
15
|
+
import type { ServerToolInfo } from './runtime.js';
|
|
16
|
+
|
|
17
|
+
export interface GenerateCliOptions {
|
|
18
|
+
readonly serverRef: string;
|
|
19
|
+
readonly configPath?: string;
|
|
20
|
+
readonly rootDir?: string;
|
|
21
|
+
readonly outputPath?: string;
|
|
22
|
+
readonly runtime?: 'node' | 'bun';
|
|
23
|
+
readonly bundler?: 'rolldown' | 'bun';
|
|
24
|
+
readonly bundle?: boolean | string;
|
|
25
|
+
readonly timeoutMs?: number;
|
|
26
|
+
readonly minify?: boolean;
|
|
27
|
+
readonly compile?: boolean | string;
|
|
28
|
+
readonly includeTools?: string[];
|
|
29
|
+
readonly excludeTools?: string[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// generateCli produces a standalone CLI (and optional bundle/binary) for a given MCP server.
|
|
33
|
+
export async function generateCli(
|
|
34
|
+
options: GenerateCliOptions
|
|
35
|
+
): Promise<{ outputPath: string; bundlePath?: string; compilePath?: string }> {
|
|
36
|
+
const runtimeKind = await resolveRuntimeKind(options.runtime, options.compile);
|
|
37
|
+
const bundlerKind = options.bundler ?? (runtimeKind === 'bun' ? 'bun' : 'rolldown');
|
|
38
|
+
if (bundlerKind === 'bun' && runtimeKind !== 'bun') {
|
|
39
|
+
throw new Error('--bundler bun currently requires --runtime bun.');
|
|
40
|
+
}
|
|
41
|
+
const timeoutMs = options.timeoutMs ?? 30_000;
|
|
42
|
+
const { definition: baseDefinition, name } = await resolveServerDefinition(
|
|
43
|
+
options.serverRef,
|
|
44
|
+
options.configPath,
|
|
45
|
+
options.rootDir
|
|
46
|
+
);
|
|
47
|
+
const { tools: allTools, derivedDescription } = await fetchTools(
|
|
48
|
+
baseDefinition,
|
|
49
|
+
name,
|
|
50
|
+
options.configPath,
|
|
51
|
+
options.rootDir
|
|
52
|
+
);
|
|
53
|
+
const tools = applyToolFilters(allTools, options.includeTools, options.excludeTools);
|
|
54
|
+
const definition =
|
|
55
|
+
baseDefinition.description || !derivedDescription
|
|
56
|
+
? baseDefinition
|
|
57
|
+
: { ...baseDefinition, description: derivedDescription };
|
|
58
|
+
const toolMetadata: ToolMetadata[] = tools.map((tool) => buildToolMetadata(tool));
|
|
59
|
+
const generator = await readPackageMetadata();
|
|
60
|
+
const baseInvocation = ensureInvocationDefaults(
|
|
61
|
+
{
|
|
62
|
+
serverRef: options.serverRef,
|
|
63
|
+
configPath: options.configPath,
|
|
64
|
+
rootDir: options.rootDir,
|
|
65
|
+
runtime: runtimeKind,
|
|
66
|
+
bundler: bundlerKind,
|
|
67
|
+
outputPath: options.outputPath,
|
|
68
|
+
bundle: options.bundle,
|
|
69
|
+
compile: options.compile,
|
|
70
|
+
timeoutMs,
|
|
71
|
+
minify: options.minify ?? false,
|
|
72
|
+
includeTools: options.includeTools,
|
|
73
|
+
excludeTools: options.excludeTools,
|
|
74
|
+
},
|
|
75
|
+
definition
|
|
76
|
+
);
|
|
77
|
+
const embeddedMetadata: CliArtifactMetadata = {
|
|
78
|
+
schemaVersion: 1,
|
|
79
|
+
generatedAt: new Date().toISOString(),
|
|
80
|
+
generator,
|
|
81
|
+
server: {
|
|
82
|
+
name,
|
|
83
|
+
source: definition.source,
|
|
84
|
+
definition: serializeDefinition(definition),
|
|
85
|
+
},
|
|
86
|
+
artifact: {
|
|
87
|
+
path: '',
|
|
88
|
+
kind: 'template',
|
|
89
|
+
},
|
|
90
|
+
invocation: baseInvocation,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
let templateTmpDir: string | undefined;
|
|
94
|
+
let templateOutputPath = options.outputPath;
|
|
95
|
+
if (!templateOutputPath && options.compile) {
|
|
96
|
+
const tmpPrefix = path.join(process.cwd(), 'tmp', 'mcporter-cli-');
|
|
97
|
+
await fs.mkdir(path.dirname(tmpPrefix), { recursive: true });
|
|
98
|
+
templateTmpDir = await fs.mkdtemp(tmpPrefix);
|
|
99
|
+
templateOutputPath = path.join(templateTmpDir, `${name}.ts`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const outputPath = await writeTemplate({
|
|
103
|
+
outputPath: templateOutputPath,
|
|
104
|
+
runtimeKind,
|
|
105
|
+
timeoutMs,
|
|
106
|
+
definition,
|
|
107
|
+
serverName: name,
|
|
108
|
+
tools: toolMetadata,
|
|
109
|
+
generator,
|
|
110
|
+
metadata: embeddedMetadata,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
let bundlePath: string | undefined;
|
|
114
|
+
let compilePath: string | undefined;
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const shouldBundle = Boolean(options.bundle ?? options.compile);
|
|
118
|
+
if (shouldBundle) {
|
|
119
|
+
const targetPath = resolveBundleTarget({
|
|
120
|
+
bundle: options.bundle,
|
|
121
|
+
compile: options.compile,
|
|
122
|
+
outputPath,
|
|
123
|
+
});
|
|
124
|
+
bundlePath = await bundleOutput({
|
|
125
|
+
sourcePath: outputPath,
|
|
126
|
+
runtimeKind,
|
|
127
|
+
targetPath,
|
|
128
|
+
minify: options.minify ?? false,
|
|
129
|
+
bundler: bundlerKind,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (options.compile) {
|
|
133
|
+
if (runtimeKind !== 'bun') {
|
|
134
|
+
throw new Error('--compile is only supported when --runtime bun');
|
|
135
|
+
}
|
|
136
|
+
const compileTarget = computeCompileTarget(options.compile, bundlePath, name);
|
|
137
|
+
await compileBundleWithBun(bundlePath, compileTarget);
|
|
138
|
+
compilePath = compileTarget;
|
|
139
|
+
if (!options.bundle) {
|
|
140
|
+
await fs.rm(bundlePath).catch(() => {});
|
|
141
|
+
bundlePath = undefined;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
} finally {
|
|
146
|
+
if (templateTmpDir) {
|
|
147
|
+
await fs.rm(templateTmpDir, { recursive: true, force: true }).catch(() => {});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return { outputPath: options.outputPath ?? outputPath, bundlePath, compilePath };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function applyToolFilters(tools: ServerToolInfo[], includeTools?: string[], excludeTools?: string[]): ServerToolInfo[] {
|
|
155
|
+
if (includeTools && excludeTools) {
|
|
156
|
+
throw new Error('Internal error: both includeTools and excludeTools provided to generateCli.');
|
|
157
|
+
}
|
|
158
|
+
if (includeTools && includeTools.length === 0) {
|
|
159
|
+
throw new Error('--include-tools requires at least one tool name.');
|
|
160
|
+
}
|
|
161
|
+
if (excludeTools && excludeTools.length === 0) {
|
|
162
|
+
throw new Error('--exclude-tools requires at least one tool name.');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!includeTools && !excludeTools) {
|
|
166
|
+
return tools;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const toolMap = new Map(tools.map((tool) => [tool.name, tool]));
|
|
170
|
+
|
|
171
|
+
if (includeTools && includeTools.length > 0) {
|
|
172
|
+
const result: ServerToolInfo[] = [];
|
|
173
|
+
const missing: string[] = [];
|
|
174
|
+
|
|
175
|
+
for (const name of includeTools) {
|
|
176
|
+
const match = toolMap.get(name);
|
|
177
|
+
if (match) {
|
|
178
|
+
result.push(match);
|
|
179
|
+
} else {
|
|
180
|
+
missing.push(name);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (missing.length > 0) {
|
|
185
|
+
throw new Error(
|
|
186
|
+
`Requested tools not found on server: ${missing.join(', ')}. Available tools: ${tools.map((tool) => tool.name).join(', ')}`
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (result.length === 0) {
|
|
191
|
+
throw new Error('No tools remain after applying --include-tools filter.');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (excludeTools && excludeTools.length > 0) {
|
|
198
|
+
const excludeSet = new Set(excludeTools);
|
|
199
|
+
const filtered = tools.filter((tool) => !excludeSet.has(tool.name));
|
|
200
|
+
if (filtered.length === 0) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
`All tools were excluded. Exclude list: ${[...excludeSet].join(', ')}. Available tools: ${tools.map((tool) => tool.name).join(', ')}`
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
return filtered;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return tools;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export const __test = { ...toolsTestHelpers, applyToolFilters };
|