mcp4openapi 0.2.8 → 0.3.1
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/README.md +143 -63
- package/dist/scripts/validate-profile.js +3 -3
- package/dist/scripts/validate-profile.js.map +1 -1
- package/dist/src/argument-normalizer.d.ts +5 -0
- package/dist/src/argument-normalizer.d.ts.map +1 -0
- package/dist/src/argument-normalizer.js +61 -0
- package/dist/src/argument-normalizer.js.map +1 -0
- package/dist/src/auth/oauth-provider.d.ts +131 -0
- package/dist/src/auth/oauth-provider.d.ts.map +1 -0
- package/dist/src/auth/oauth-provider.js +839 -0
- package/dist/src/auth/oauth-provider.js.map +1 -0
- package/dist/src/cli-config.d.ts +9 -0
- package/dist/src/cli-config.d.ts.map +1 -0
- package/dist/src/cli-config.js +111 -0
- package/dist/src/cli-config.js.map +1 -0
- package/dist/src/core/cli-config.d.ts +9 -0
- package/dist/src/core/cli-config.d.ts.map +1 -0
- package/dist/src/core/cli-config.js +125 -0
- package/dist/src/core/cli-config.js.map +1 -0
- package/dist/src/core/constants.d.ts +86 -0
- package/dist/src/core/constants.d.ts.map +1 -0
- package/dist/src/core/constants.js +86 -0
- package/dist/src/core/constants.js.map +1 -0
- package/dist/src/core/errors.d.ts +59 -0
- package/dist/src/core/errors.d.ts.map +1 -0
- package/dist/src/core/errors.js +119 -0
- package/dist/src/core/errors.js.map +1 -0
- package/dist/src/core/filtering.d.ts +19 -0
- package/dist/src/core/filtering.d.ts.map +1 -0
- package/dist/src/core/filtering.js +292 -0
- package/dist/src/core/filtering.js.map +1 -0
- package/dist/src/core/index.d.ts +26 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +276 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/lib.d.ts +8 -0
- package/dist/src/core/lib.d.ts.map +1 -0
- package/dist/src/core/lib.js +7 -0
- package/dist/src/core/lib.js.map +1 -0
- package/dist/src/core/logger.d.ts +59 -0
- package/dist/src/core/logger.d.ts.map +1 -0
- package/dist/src/core/logger.js +197 -0
- package/dist/src/core/logger.js.map +1 -0
- package/dist/src/core/metrics.d.ts +97 -0
- package/dist/src/core/metrics.d.ts.map +1 -0
- package/dist/src/core/metrics.js +273 -0
- package/dist/src/core/metrics.js.map +1 -0
- package/dist/src/core/naming-warnings.d.ts +23 -0
- package/dist/src/core/naming-warnings.d.ts.map +1 -0
- package/dist/src/core/naming-warnings.js +83 -0
- package/dist/src/core/naming-warnings.js.map +1 -0
- package/dist/src/core/naming.d.ts +58 -0
- package/dist/src/core/naming.d.ts.map +1 -0
- package/dist/src/core/naming.js +510 -0
- package/dist/src/core/naming.js.map +1 -0
- package/dist/src/errors.d.ts +6 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +15 -6
- package/dist/src/errors.js.map +1 -1
- package/dist/src/filtering.d.ts +19 -0
- package/dist/src/filtering.d.ts.map +1 -0
- package/dist/src/filtering.js +292 -0
- package/dist/src/filtering.js.map +1 -0
- package/dist/src/generated-schemas.d.ts +290 -79
- package/dist/src/generated-schemas.d.ts.map +1 -1
- package/dist/src/generated-schemas.js +17 -2
- package/dist/src/generated-schemas.js.map +1 -1
- package/dist/src/http-transport-config.d.ts +6 -0
- package/dist/src/http-transport-config.d.ts.map +1 -0
- package/dist/src/http-transport-config.js +47 -0
- package/dist/src/http-transport-config.js.map +1 -0
- package/dist/src/http-transport.d.ts +63 -13
- package/dist/src/http-transport.d.ts.map +1 -1
- package/dist/src/http-transport.js +1045 -482
- package/dist/src/http-transport.js.map +1 -1
- package/dist/src/index.d.ts +1 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -170
- package/dist/src/index.js.map +1 -1
- package/dist/src/interceptors.d.ts +1 -0
- package/dist/src/interceptors.d.ts.map +1 -1
- package/dist/src/interceptors.js +73 -63
- package/dist/src/interceptors.js.map +1 -1
- package/dist/src/lib.d.ts +1 -7
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +1 -6
- package/dist/src/lib.js.map +1 -1
- package/dist/src/logger.d.ts +5 -0
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/logger.js +9 -1
- package/dist/src/logger.js.map +1 -1
- package/dist/src/mcp/mcp-server-manager.d.ts +20 -0
- package/dist/src/mcp/mcp-server-manager.d.ts.map +1 -0
- package/dist/src/mcp/mcp-server-manager.js +38 -0
- package/dist/src/mcp/mcp-server-manager.js.map +1 -0
- package/dist/src/mcp/mcp-server.d.ts +205 -0
- package/dist/src/mcp/mcp-server.d.ts.map +1 -0
- package/dist/src/mcp/mcp-server.js +1473 -0
- package/dist/src/mcp/mcp-server.js.map +1 -0
- package/dist/src/mcp-server-manager.d.ts +20 -0
- package/dist/src/mcp-server-manager.d.ts.map +1 -0
- package/dist/src/mcp-server-manager.js +38 -0
- package/dist/src/mcp-server-manager.js.map +1 -0
- package/dist/src/mcp-server.d.ts +28 -0
- package/dist/src/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp-server.js +406 -109
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/metrics.d.ts +11 -0
- package/dist/src/metrics.d.ts.map +1 -1
- package/dist/src/metrics.js +61 -0
- package/dist/src/metrics.js.map +1 -1
- package/dist/src/oauth-provider.d.ts +5 -0
- package/dist/src/oauth-provider.d.ts.map +1 -1
- package/dist/src/oauth-provider.js +29 -1
- package/dist/src/oauth-provider.js.map +1 -1
- package/dist/src/openapi/openapi-parser.d.ts +70 -0
- package/dist/src/openapi/openapi-parser.d.ts.map +1 -0
- package/dist/src/openapi/openapi-parser.js +458 -0
- package/dist/src/openapi/openapi-parser.js.map +1 -0
- package/dist/src/profile/profile-loader.d.ts +78 -0
- package/dist/src/profile/profile-loader.d.ts.map +1 -0
- package/dist/src/profile/profile-loader.js +490 -0
- package/dist/src/profile/profile-loader.js.map +1 -0
- package/dist/src/profile/profile-registry.d.ts +19 -0
- package/dist/src/profile/profile-registry.d.ts.map +1 -0
- package/dist/src/profile/profile-registry.js +43 -0
- package/dist/src/profile/profile-registry.js.map +1 -0
- package/dist/src/profile/profile-resolver.d.ts +41 -0
- package/dist/src/profile/profile-resolver.d.ts.map +1 -0
- package/dist/src/profile/profile-resolver.js +324 -0
- package/dist/src/profile/profile-resolver.js.map +1 -0
- package/dist/src/profile/startup-profile.d.ts +17 -0
- package/dist/src/profile/startup-profile.d.ts.map +1 -0
- package/dist/src/profile/startup-profile.js +30 -0
- package/dist/src/profile/startup-profile.js.map +1 -0
- package/dist/src/profile/startup-validation.d.ts +11 -0
- package/dist/src/profile/startup-validation.d.ts.map +1 -0
- package/dist/src/profile/startup-validation.js +21 -0
- package/dist/src/profile/startup-validation.js.map +1 -0
- package/dist/src/profile-loader.d.ts +1 -0
- package/dist/src/profile-loader.d.ts.map +1 -1
- package/dist/src/profile-loader.js +14 -3
- package/dist/src/profile-loader.js.map +1 -1
- package/dist/src/profile-registry.d.ts +18 -0
- package/dist/src/profile-registry.d.ts.map +1 -0
- package/dist/src/profile-registry.js +26 -0
- package/dist/src/profile-registry.js.map +1 -0
- package/dist/src/profile-resolver.d.ts +19 -0
- package/dist/src/profile-resolver.d.ts.map +1 -0
- package/dist/src/profile-resolver.js +167 -0
- package/dist/src/profile-resolver.js.map +1 -0
- package/dist/src/proxy-executor.d.ts.map +1 -1
- package/dist/src/proxy-executor.js +7 -0
- package/dist/src/proxy-executor.js.map +1 -1
- package/dist/src/startup-profile.d.ts +17 -0
- package/dist/src/startup-profile.d.ts.map +1 -0
- package/dist/src/startup-profile.js +30 -0
- package/dist/src/startup-profile.js.map +1 -0
- package/dist/src/startup-validation.d.ts +11 -0
- package/dist/src/startup-validation.d.ts.map +1 -0
- package/dist/src/startup-validation.js +21 -0
- package/dist/src/startup-validation.js.map +1 -0
- package/dist/src/testing/dynamic-mock-server.d.ts +24 -0
- package/dist/src/testing/dynamic-mock-server.d.ts.map +1 -0
- package/dist/src/testing/dynamic-mock-server.js +138 -0
- package/dist/src/testing/dynamic-mock-server.js.map +1 -0
- package/dist/src/testing/request-assertions.d.ts +5 -0
- package/dist/src/testing/request-assertions.d.ts.map +1 -0
- package/dist/src/testing/request-assertions.js +165 -0
- package/dist/src/testing/request-assertions.js.map +1 -0
- package/dist/src/testing/template-utils.d.ts +10 -0
- package/dist/src/testing/template-utils.d.ts.map +1 -0
- package/dist/src/testing/template-utils.js +72 -0
- package/dist/src/testing/template-utils.js.map +1 -0
- package/dist/src/testing/test-http-utils.d.ts +1 -1
- package/dist/src/testing/test-http-utils.d.ts.map +1 -1
- package/dist/src/testing/test-http-utils.js +1 -1
- package/dist/src/testing/test-http-utils.js.map +1 -1
- package/dist/src/testing/test-loader.d.ts +6 -0
- package/dist/src/testing/test-loader.d.ts.map +1 -0
- package/dist/src/testing/test-loader.js +212 -0
- package/dist/src/testing/test-loader.js.map +1 -0
- package/dist/src/testing/test-schema.d.ts +1270 -0
- package/dist/src/testing/test-schema.d.ts.map +1 -0
- package/dist/src/testing/test-schema.js +76 -0
- package/dist/src/testing/test-schema.js.map +1 -0
- package/dist/src/tool-filter/compat.d.ts +49 -0
- package/dist/src/tool-filter/compat.d.ts.map +1 -0
- package/dist/src/tool-filter/compat.js +72 -0
- package/dist/src/tool-filter/compat.js.map +1 -0
- package/dist/src/tool-filter/config/env-config-parser.d.ts +38 -0
- package/dist/src/tool-filter/config/env-config-parser.d.ts.map +1 -0
- package/dist/src/tool-filter/config/env-config-parser.js +103 -0
- package/dist/src/tool-filter/config/env-config-parser.js.map +1 -0
- package/dist/src/tool-filter/config/header-config-parser.d.ts +37 -0
- package/dist/src/tool-filter/config/header-config-parser.d.ts.map +1 -0
- package/dist/src/tool-filter/config/header-config-parser.js +118 -0
- package/dist/src/tool-filter/config/header-config-parser.js.map +1 -0
- package/dist/src/tool-filter/errors.d.ts +18 -0
- package/dist/src/tool-filter/errors.d.ts.map +1 -0
- package/dist/src/tool-filter/errors.js +21 -0
- package/dist/src/tool-filter/errors.js.map +1 -0
- package/dist/src/tool-filter/filter/filter-engine.d.ts +45 -0
- package/dist/src/tool-filter/filter/filter-engine.d.ts.map +1 -0
- package/dist/src/tool-filter/filter/filter-engine.js +94 -0
- package/dist/src/tool-filter/filter/filter-engine.js.map +1 -0
- package/dist/src/tool-filter/filter/filter-rules.d.ts +44 -0
- package/dist/src/tool-filter/filter/filter-rules.d.ts.map +1 -0
- package/dist/src/tool-filter/filter/filter-rules.js +72 -0
- package/dist/src/tool-filter/filter/filter-rules.js.map +1 -0
- package/dist/src/tool-filter/filter/global-tool-filter.d.ts +40 -0
- package/dist/src/tool-filter/filter/global-tool-filter.d.ts.map +1 -0
- package/dist/src/tool-filter/filter/global-tool-filter.js +92 -0
- package/dist/src/tool-filter/filter/global-tool-filter.js.map +1 -0
- package/dist/src/tool-filter/filter/session-tool-filter.d.ts +29 -0
- package/dist/src/tool-filter/filter/session-tool-filter.d.ts.map +1 -0
- package/dist/src/tool-filter/filter/session-tool-filter.js +69 -0
- package/dist/src/tool-filter/filter/session-tool-filter.js.map +1 -0
- package/dist/src/tool-filter/index.d.ts +25 -0
- package/dist/src/tool-filter/index.d.ts.map +1 -0
- package/dist/src/tool-filter/index.js +30 -0
- package/dist/src/tool-filter/index.js.map +1 -0
- package/dist/src/tool-filter/integration/tool-filter-service.d.ts +44 -0
- package/dist/src/tool-filter/integration/tool-filter-service.d.ts.map +1 -0
- package/dist/src/tool-filter/integration/tool-filter-service.js +68 -0
- package/dist/src/tool-filter/integration/tool-filter-service.js.map +1 -0
- package/dist/src/tool-filter/operation/operation-classifier.d.ts +20 -0
- package/dist/src/tool-filter/operation/operation-classifier.d.ts.map +1 -0
- package/dist/src/tool-filter/operation/operation-classifier.js +26 -0
- package/dist/src/tool-filter/operation/operation-classifier.js.map +1 -0
- package/dist/src/tool-filter/operation/operation-detector.d.ts +30 -0
- package/dist/src/tool-filter/operation/operation-detector.d.ts.map +1 -0
- package/dist/src/tool-filter/operation/operation-detector.js +96 -0
- package/dist/src/tool-filter/operation/operation-detector.js.map +1 -0
- package/dist/src/tool-filter/operation/operation-resolver.d.ts +22 -0
- package/dist/src/tool-filter/operation/operation-resolver.d.ts.map +1 -0
- package/dist/src/tool-filter/operation/operation-resolver.js +32 -0
- package/dist/src/tool-filter/operation/operation-resolver.js.map +1 -0
- package/dist/src/tool-filter/regex/regex-compiler.d.ts +22 -0
- package/dist/src/tool-filter/regex/regex-compiler.d.ts.map +1 -0
- package/dist/src/tool-filter/regex/regex-compiler.js +56 -0
- package/dist/src/tool-filter/regex/regex-compiler.js.map +1 -0
- package/dist/src/tool-filter/regex/regex-validator.d.ts +24 -0
- package/dist/src/tool-filter/regex/regex-validator.d.ts.map +1 -0
- package/dist/src/tool-filter/regex/regex-validator.js +58 -0
- package/dist/src/tool-filter/regex/regex-validator.js.map +1 -0
- package/dist/src/tool-filter/types.d.ts +92 -0
- package/dist/src/tool-filter/types.d.ts.map +1 -0
- package/dist/src/tool-filter/types.js +5 -0
- package/dist/src/tool-filter/types.js.map +1 -0
- package/dist/src/tool-filter/utils.d.ts +11 -0
- package/dist/src/tool-filter/utils.d.ts.map +1 -0
- package/dist/src/tool-filter/utils.js +13 -0
- package/dist/src/tool-filter/utils.js.map +1 -0
- package/dist/src/tool-filter.d.ts +65 -0
- package/dist/src/tool-filter.d.ts.map +1 -0
- package/dist/src/tool-filter.js +471 -0
- package/dist/src/tool-filter.js.map +1 -0
- package/dist/src/tool-generator.d.ts +1 -0
- package/dist/src/tool-generator.d.ts.map +1 -1
- package/dist/src/tool-generator.js +15 -6
- package/dist/src/tool-generator.js.map +1 -1
- package/dist/src/tooling/composite-executor.d.ts +77 -0
- package/dist/src/tooling/composite-executor.d.ts.map +1 -0
- package/dist/src/tooling/composite-executor.js +198 -0
- package/dist/src/tooling/composite-executor.js.map +1 -0
- package/dist/src/tooling/dag-executor.d.ts +49 -0
- package/dist/src/tooling/dag-executor.d.ts.map +1 -0
- package/dist/src/tooling/dag-executor.js +138 -0
- package/dist/src/tooling/dag-executor.js.map +1 -0
- package/dist/src/tooling/proxy-executor.d.ts +86 -0
- package/dist/src/tooling/proxy-executor.d.ts.map +1 -0
- package/dist/src/tooling/proxy-executor.js +501 -0
- package/dist/src/tooling/proxy-executor.js.map +1 -0
- package/dist/src/tooling/tool-generator.d.ts +67 -0
- package/dist/src/tooling/tool-generator.d.ts.map +1 -0
- package/dist/src/tooling/tool-generator.js +222 -0
- package/dist/src/tooling/tool-generator.js.map +1 -0
- package/dist/src/transport/http-client-factory.d.ts +65 -0
- package/dist/src/transport/http-client-factory.d.ts.map +1 -0
- package/dist/src/transport/http-client-factory.js +143 -0
- package/dist/src/transport/http-client-factory.js.map +1 -0
- package/dist/src/transport/http-transport-config.d.ts +6 -0
- package/dist/src/transport/http-transport-config.d.ts.map +1 -0
- package/dist/src/transport/http-transport-config.js +63 -0
- package/dist/src/transport/http-transport-config.js.map +1 -0
- package/dist/src/transport/http-transport.d.ts +329 -0
- package/dist/src/transport/http-transport.d.ts.map +1 -0
- package/dist/src/transport/http-transport.js +2584 -0
- package/dist/src/transport/http-transport.js.map +1 -0
- package/dist/src/transport/interceptors.d.ts +119 -0
- package/dist/src/transport/interceptors.d.ts.map +1 -0
- package/dist/src/transport/interceptors.js +413 -0
- package/dist/src/transport/interceptors.js.map +1 -0
- package/dist/src/transport/profile-index.d.ts +84 -0
- package/dist/src/transport/profile-index.d.ts.map +1 -0
- package/dist/src/transport/profile-index.js +405 -0
- package/dist/src/transport/profile-index.js.map +1 -0
- package/dist/src/types/http-transport.d.ts +26 -0
- package/dist/src/types/http-transport.d.ts.map +1 -1
- package/dist/src/types/openapi.d.ts +3 -0
- package/dist/src/types/openapi.d.ts.map +1 -1
- package/dist/src/types/profile.d.ts +16 -1
- package/dist/src/types/profile.d.ts.map +1 -1
- package/dist/src/validation/argument-normalizer.d.ts +6 -0
- package/dist/src/validation/argument-normalizer.d.ts.map +1 -0
- package/dist/src/validation/argument-normalizer.js +70 -0
- package/dist/src/validation/argument-normalizer.js.map +1 -0
- package/dist/src/validation/jsonrpc-validator.d.ts +27 -0
- package/dist/src/validation/jsonrpc-validator.d.ts.map +1 -0
- package/dist/src/validation/jsonrpc-validator.js +58 -0
- package/dist/src/validation/jsonrpc-validator.js.map +1 -0
- package/dist/src/validation/schema-validator.d.ts +30 -0
- package/dist/src/validation/schema-validator.d.ts.map +1 -0
- package/dist/src/validation/schema-validator.js +128 -0
- package/dist/src/validation/schema-validator.js.map +1 -0
- package/dist/src/validation/validation-utils.d.ts +49 -0
- package/dist/src/validation/validation-utils.d.ts.map +1 -0
- package/dist/src/validation/validation-utils.js +139 -0
- package/dist/src/validation/validation-utils.js.map +1 -0
- package/html/profile-index.html +386 -0
- package/package.json +10 -3
- package/profile-schema.json +77 -3
- package/profiles/gitlab/developer-profile-oauth.json +1520 -0
- package/profiles/gitlab/developer-profile-oauth.test.json +3432 -0
- package/profiles/gitlab/developer-profile.json +1508 -0
- package/profiles/gitlab/developer-profile.test.json +3432 -0
- package/profiles/gitlab/openapi.yaml +6891 -0
- package/profiles/n8n/openapi.yaml +2441 -0
- package/profiles/n8n/profile-optimized.json +965 -0
- package/profiles/n8n/profile-optimized.test.json +1078 -0
- package/profiles/n8n/profile.json +1033 -0
- package/profiles/n8n/profile.test.json +983 -0
- package/profiles/n8n-nodes/openapi.yaml +24 -0
- package/profiles/n8n-nodes/profile-nodes.json +44 -0
- package/profiles/n8n-nodes/profile-nodes.test.json +91 -0
- package/profiles/semgrep/openapi.yaml +4706 -0
- package/profiles/semgrep/profile.json +692 -0
- package/profiles/semgrep/profile.test.json +471 -0
- package/profiles/youtrack/openapi.json +16976 -0
- package/profiles/youtrack/profile.json +608 -0
- package/profiles/youtrack/profile.test.json +1926 -0
- package/dist/src/testing/fixtures.d.ts +0 -684
- package/dist/src/testing/fixtures.d.ts.map +0 -1
- package/dist/src/testing/fixtures.js +0 -528
- package/dist/src/testing/fixtures.js.map +0 -1
- package/dist/src/testing/mock-gitlab-server.d.ts +0 -43
- package/dist/src/testing/mock-gitlab-server.d.ts.map +0 -1
- package/dist/src/testing/mock-gitlab-server.js +0 -1026
- package/dist/src/testing/mock-gitlab-server.js.map +0 -1
- package/dist/src/testing/mock-semgrep-server.d.ts +0 -32
- package/dist/src/testing/mock-semgrep-server.d.ts.map +0 -1
- package/dist/src/testing/mock-semgrep-server.js +0 -213
- package/dist/src/testing/mock-semgrep-server.js.map +0 -1
- package/dist/src/testing/mock-youtrack-server.d.ts +0 -11
- package/dist/src/testing/mock-youtrack-server.d.ts.map +0 -1
- package/dist/src/testing/mock-youtrack-server.js +0 -152
- package/dist/src/testing/mock-youtrack-server.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,31 +13,7 @@ Universal MCP server that generates tools from any OpenAPI specification.
|
|
|
13
13
|
Transform any OpenAPI specification into MCP tools **without writing code**.
|
|
14
14
|
Configure everything via MCP profiles, reduce LLM context pollution, and get production-ready features out of the box.
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
+-------------------+
|
|
18
|
-
| MCP Client |
|
|
19
|
-
| (Claude/IDE etc.) |
|
|
20
|
-
+---------+---------+
|
|
21
|
-
|
|
|
22
|
-
v
|
|
23
|
-
+--+------+---------+
|
|
24
|
-
| | MCP Profile |
|
|
25
|
-
| | (autogenerated |
|
|
26
|
-
| | if missing) |
|
|
27
|
-
| +----------------+
|
|
28
|
-
| |
|
|
29
|
-
| MCP Server |
|
|
30
|
-
| |
|
|
31
|
-
| +----------------+
|
|
32
|
-
| | OpenAPI Spec |
|
|
33
|
-
| | (YAML/JSON) |
|
|
34
|
-
+--+------+---------+
|
|
35
|
-
|
|
|
36
|
-
v
|
|
37
|
-
+---------+---------+
|
|
38
|
-
| Service API |
|
|
39
|
-
+-------------------+
|
|
40
|
-
```
|
|
16
|
+
[](docs/mcp4openapi-principle.png)
|
|
41
17
|
|
|
42
18
|
## Use Cases
|
|
43
19
|
|
|
@@ -45,19 +21,19 @@ Configure everything via MCP profiles, reduce LLM context pollution, and get pro
|
|
|
45
21
|
2. **Multi-Environment**: Same server, different profiles (dev/staging/prod)
|
|
46
22
|
3. **Custom Workflows**: Composite tools for common multi-step operations
|
|
47
23
|
|
|
48
|
-
More about profiles: [docs/PROFILE-GUIDE.md](https://github.com/davidruzicka/mcp4openapi/blob/main/docs/PROFILE-GUIDE.md).
|
|
24
|
+
More about MCP profiles: [docs/PROFILE-GUIDE.md](https://github.com/davidruzicka/mcp4openapi/blob/main/docs/PROFILE-GUIDE.md).
|
|
49
25
|
|
|
50
26
|
## Key Features
|
|
51
27
|
|
|
52
28
|
### Core
|
|
53
|
-
- **Any OpenAPI API**: Works with OpenAPI 3.x specifications
|
|
54
|
-
- **Profiles**: Create JSON configuration transforming API to MCP tools LLM friendly in profiles
|
|
55
|
-
- **Tool Aggregation**: Reduce tool clutter - group related operations in profiles
|
|
56
|
-
- **Composite Actions**: Chain API calls into workflows in profiles
|
|
29
|
+
- **Any OpenAPI API**: Works with any OpenAPI 3.x specifications
|
|
30
|
+
- **Profiles**: Create JSON configuration transforming API to MCP tools LLM friendly in [MCP profiles](docs/PROFILE-GUIDE.md)
|
|
31
|
+
- **Tool Aggregation**: Reduce tool clutter - group related operations in MCP profiles
|
|
32
|
+
- **Composite Actions**: Chain API calls into workflows in MCP profiles for saving context and requests with repetitive complex operations
|
|
57
33
|
- **OAuth 2.0**: Browser-based authentication flow for HTTP transport (see [docs/OAUTH.md](./docs/OAUTH.md))
|
|
58
|
-
- **Multi-Auth**: Support multiple auth methods (OAuth + Bearer) with priority-based fallback (see [docs/MULTI-AUTH.md](./docs/MULTI-AUTH.md))
|
|
34
|
+
- **Multi-Auth**: Support multiple auth methods (OAuth + Bearer e.g.) with priority-based fallback (see [docs/MULTI-AUTH.md](./docs/MULTI-AUTH.md))
|
|
59
35
|
- **Multipart uploads**: HttpClient handles `multipart/form-data` (file attachments and mixed fields)
|
|
60
|
-
- **Observability**: Structured logging (console/JSON) with profile-aware
|
|
36
|
+
- **Observability**: Structured logging (console/JSON) with profile-aware secrets redaction, Prometheus metrics
|
|
61
37
|
|
|
62
38
|
## Security Note
|
|
63
39
|
|
|
@@ -102,16 +78,15 @@ Access Token (Bearer) example:
|
|
|
102
78
|
"command": "npx",
|
|
103
79
|
"args": ["mcp4openapi"],
|
|
104
80
|
"env": {
|
|
105
|
-
"
|
|
106
|
-
"MCP4_API_TOKEN": "${input:MCP4_API_TOKEN}",
|
|
81
|
+
"MCP4_API_TOKEN": "${input:api-token}",
|
|
107
82
|
"MCP4_API_BASE_URL": "https://api.example.com",
|
|
108
|
-
"MCP4_PROFILE_PATH": "path/to/mcp-profile.json"
|
|
83
|
+
"MCP4_PROFILE_PATH": "path/to/mcp-profile.json"
|
|
109
84
|
}
|
|
110
85
|
},
|
|
111
86
|
"inputs": [
|
|
112
87
|
{
|
|
113
88
|
"type": "promptString",
|
|
114
|
-
"id": "
|
|
89
|
+
"id": "api-token",
|
|
115
90
|
"description": "API Authorization Token",
|
|
116
91
|
"password": true
|
|
117
92
|
}
|
|
@@ -131,29 +106,47 @@ _`inputs` section prompts you for the token when the server starts, so environme
|
|
|
131
106
|
"command": "npx",
|
|
132
107
|
"args": ["mcp4openapi"],
|
|
133
108
|
"env": {
|
|
134
|
-
"MCP4_OPENAPI_SPEC_PATH": "path/to/openapi.yaml",
|
|
135
109
|
"MCP4_API_TOKEN": "${env:MCP4_API_TOKEN}",
|
|
136
110
|
"MCP4_API_BASE_URL": "https://api.example.com",
|
|
137
|
-
"MCP4_PROFILE_PATH": "path/to/mcp-profile.json"
|
|
111
|
+
"MCP4_PROFILE_PATH": "path/to/mcp-profile.json"
|
|
138
112
|
}
|
|
139
113
|
}
|
|
140
114
|
}
|
|
141
115
|
}
|
|
142
116
|
```
|
|
143
117
|
|
|
118
|
+
#### Profile shortcut
|
|
119
|
+
|
|
120
|
+
If profile defines `profile_id` (or `profile_name` or `profile_alias`), you can start with:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npx mcp4openapi --profile (profile-id/name/alias)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
List available profiles with:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npx mcp4openapi --list-profiles
|
|
130
|
+
npx mcp4openapi -l
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Predefined profiles in the `profiles/` directory contains names for easy reference:
|
|
134
|
+
- GitLab profile: `gitlab`
|
|
135
|
+
- YouTrack profile: `youtrack`
|
|
136
|
+
- SemGrep profile: `semgrep`
|
|
137
|
+
|
|
138
|
+
Profiles are resolved from `./profiles` path by default. If that directory is missing, the bundled npm package profiles are used. Override with `--profiles-dir` or `MCP4_PROFILES_DIR`.
|
|
139
|
+
|
|
144
140
|
##### ⚠️ Prerequisites
|
|
145
141
|
|
|
146
|
-
- `MCP4_API_TOKEN` with access token (Bearer) must be set.
|
|
142
|
+
- `MCP4_API_TOKEN` (or equivalent environment variable name defined in your profile) with access token (Bearer) must be set for stdio transport with authenticated APIs. OAuth authorization flow is supported for HTTP transport only.
|
|
147
143
|
|
|
148
144
|
#### Claude Code example:
|
|
149
145
|
|
|
150
146
|
```bash
|
|
151
147
|
claude mcp add --transport stdio mcp4openapi \
|
|
152
148
|
--env MCP4_API_TOKEN="${MCP4_API_TOKEN}" \
|
|
153
|
-
--
|
|
154
|
-
--env MCP4_API_BASE_URL=https://api.example.com \
|
|
155
|
-
--env MCP4_PROFILE_PATH=path/to/mcp-profile.json \
|
|
156
|
-
-- npx mcp4openapi
|
|
149
|
+
-- npx mcp4openapi --profile mcp-profile --api-base-url https://api.example.com
|
|
157
150
|
```
|
|
158
151
|
|
|
159
152
|
##### ⚠️ Prerequisites
|
|
@@ -167,12 +160,15 @@ claude mcp add --transport stdio mcp4openapi \
|
|
|
167
160
|
"servers": {
|
|
168
161
|
"mcp4openapi": {
|
|
169
162
|
"command": "npx",
|
|
170
|
-
"args": [
|
|
163
|
+
"args": [
|
|
164
|
+
"mcp4openapi",
|
|
165
|
+
"--profile",
|
|
166
|
+
"mcp-profile",
|
|
167
|
+
"--api-base-url",
|
|
168
|
+
"https://api.example.com"
|
|
169
|
+
],
|
|
171
170
|
"env": {
|
|
172
|
-
"
|
|
173
|
-
"MCP4_API_TOKEN": "${input:api_token}",
|
|
174
|
-
"MCP4_API_BASE_URL": "https://api.example.com",
|
|
175
|
-
"MCP4_PROFILE_PATH": "path/to/mcp-profile.json" //optional
|
|
171
|
+
"MCP4_API_TOKEN": "${input:api-token}",
|
|
176
172
|
}
|
|
177
173
|
}
|
|
178
174
|
}
|
|
@@ -181,7 +177,7 @@ claude mcp add --transport stdio mcp4openapi \
|
|
|
181
177
|
|
|
182
178
|
##### Note
|
|
183
179
|
|
|
184
|
-
- JetBrains IDEs show ⚠️ right next to `${input:
|
|
180
|
+
- JetBrains IDEs show ⚠️ right next to `${input:api-token}` to indicate that you need to enter the token manually in the IDE dialog.
|
|
185
181
|
|
|
186
182
|
### Option B: Docker
|
|
187
183
|
|
|
@@ -209,9 +205,16 @@ cp env.example .env
|
|
|
209
205
|
|
|
210
206
|
**4. Run:**
|
|
211
207
|
```bash
|
|
208
|
+
# uses .env for configuration
|
|
212
209
|
npm start
|
|
213
210
|
```
|
|
214
211
|
|
|
212
|
+
- alternatively, run with CLI flags:
|
|
213
|
+
```bash
|
|
214
|
+
export MCP4_API_TOKEN=glpat-xxxxxxxxxxxx
|
|
215
|
+
npm start --profile mcp-profile
|
|
216
|
+
```
|
|
217
|
+
|
|
215
218
|
See [docs/HTTP-TRANSPORT.md](./docs/HTTP-TRANSPORT.md) for transport options (stdio vs HTTP) and authentication modes.
|
|
216
219
|
|
|
217
220
|
## Custom CA Certificates
|
|
@@ -283,19 +286,45 @@ echo 'export NODE_EXTRA_CA_CERTS="$HOME/ca-bundle.pem"' >> $HOME/.bash_profile
|
|
|
283
286
|
## Environment Variables
|
|
284
287
|
|
|
285
288
|
### Required
|
|
286
|
-
- `MCP4_OPENAPI_SPEC_PATH`: Path or URL to OpenAPI spec (YAML/JSON, supports local files and HTTP/HTTPS URLs)
|
|
287
289
|
- `MCP4_API_TOKEN`: API token (default env var name; customizable via `MCP4_AUTH_ENV_VAR`)
|
|
288
290
|
- **Required for stdio** mode with authenticated APIs
|
|
289
291
|
- **Optional for HTTP** mode with per-session tokens sent in HTTP headers
|
|
290
292
|
- When using no profile mode, auth type is auto-detected from OpenAPI `security` schemes if present
|
|
291
293
|
|
|
292
294
|
### Optional - Core
|
|
295
|
+
- `MCP4_PROFILE`: Profile ID for resolving profiles from a directory (used by `--profile`)
|
|
296
|
+
- `MCP4_PROFILES_DIR`: Profiles root directory for profile ID resolution (default: `./profiles`)
|
|
293
297
|
- `MCP4_PROFILE_PATH`: Profile JSON path (default: auto-generate tools from OpenAPI spec; warning logged if tool exceeds 60 parameters)
|
|
298
|
+
- `MCP4_OPENAPI_SPEC_PATH`: Path or URL to OpenAPI spec (YAML/JSON, supports local files and HTTP/HTTPS URLs). Required when profile does not provide `openapi_spec_path`. In HTTP profile routing, this acts as a global fallback for profiles without `openapi_spec_path`.
|
|
294
299
|
- `MCP4_TRANSPORT`: `stdio` (default) or `http`
|
|
295
300
|
- `MCP4_API_BASE_URL`: Override OpenAPI server URL
|
|
296
301
|
|
|
302
|
+
**Profile auth env vars**: Use profile-specific names for `value_from_env` (for example, `GITLAB_TOKEN`, `YOUTRACK_TOKEN`) instead of the generic `MCP4_API_TOKEN`.
|
|
303
|
+
|
|
304
|
+
**CLI mapping rule**: Documented `MCP4_*` env vars can be passed as a CLI flag by dropping the `MCP4_` prefix and using kebab-case. Example: `MCP4_PROFILE_PATH` -> `--profile-path`, `MCP4_OPENAPI_SPEC_PATH` -> `--openapi-spec-path`. Unknown flags cause startup to fail.
|
|
305
|
+
|
|
306
|
+
### Optional - Tool Filtering
|
|
307
|
+
Global tool filtering removes tools during profile load for every session.
|
|
308
|
+
|
|
309
|
+
- `MCP4_TOOL_FILTER_ALLOW_NAMES`: Comma-separated tool names to keep (exact match, case-sensitive)
|
|
310
|
+
- `MCP4_TOOL_FILTER_ALLOW_NAME_REGEX`: Comma-separated regex patterns to allow (auto-anchored unless already wrapped with `^` and `$`)
|
|
311
|
+
- `MCP4_TOOL_FILTER_DENY_NAMES`: Comma-separated tool names to exclude
|
|
312
|
+
- `MCP4_TOOL_FILTER_DENY_NAME_REGEX`: Comma-separated regex patterns to exclude (auto-anchored)
|
|
313
|
+
- `MCP4_TOOL_FILTER_ALLOW_CATEGORIES`: Comma-separated operation categories to allow (`list` and/or `read`). Composite tools are allowed only if all steps are within the allowed categories.
|
|
314
|
+
- `MCP4_TOOL_FILTER_WARN_THRESHOLD_PCT`: Warn when filtered percentage exceeds this threshold (default: `90`)
|
|
315
|
+
- `MCP4_TOOL_FILTER_SESSION_MAX_TOOLS`: Max entries in `X-Mcp4-Tools` header (default: `100`)
|
|
316
|
+
|
|
317
|
+
Regex patterns are validated for length, nested quantifiers, and alternations with quantifiers to reduce ReDoS risk.
|
|
318
|
+
|
|
319
|
+
#### Tool Filtering Troubleshooting
|
|
320
|
+
- If startup fails with "Tool filter configuration has no effect", ensure allow or deny patterns actually change the tool set.
|
|
321
|
+
- If startup fails with "All tools filtered out", relax allow or deny settings to leave at least one tool.
|
|
322
|
+
- If session initialization fails with "X-Mcp4-Tools filter has no effect", remove empty headers or adjust entries to restrict tools.
|
|
323
|
+
- If session initialization fails with "X-Mcp4-Tools filtered out all tools", verify tool names or regex patterns match available tools.
|
|
324
|
+
- If regex validation fails, shorten patterns and avoid nested quantifiers or alternations with quantifiers.
|
|
325
|
+
|
|
297
326
|
### Optional - Authentication (No-Profile Mode)
|
|
298
|
-
When running without a profile, authentication is automatically configured from OpenAPI spec's `security` schemes:
|
|
327
|
+
When running without a profile (OpenAPI spec only), authentication is automatically configured from OpenAPI spec's `security` schemes:
|
|
299
328
|
|
|
300
329
|
- `MCP4_AUTH_ENV_VAR`: Environment variable name for auth token (default: `MCP4_API_TOKEN`)
|
|
301
330
|
|
|
@@ -308,12 +337,12 @@ When running without a profile, authentication is automatically configured from
|
|
|
308
337
|
|
|
309
338
|
**Example**: Use custom env var for GitLab own instance token:
|
|
310
339
|
```bash
|
|
311
|
-
export MCP4_API_TOKEN=
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
npm start
|
|
340
|
+
export MCP4_API_TOKEN=xxxxxxxxxxxx
|
|
341
|
+
npm start \
|
|
342
|
+
--api-base-url https://gitlab.example.com/api/v4 \
|
|
343
|
+
--openapi-spec-path https://gitlab.example.com/api/v4/openapi.yaml
|
|
316
344
|
```
|
|
345
|
+
_⚠️ Warning: Running without a profile may generate many tools with many parameters, leading to LLM context pollution._
|
|
317
346
|
|
|
318
347
|
#### Force Authentication Override
|
|
319
348
|
For APIs with incomplete OpenAPI specs (missing `security` definition but requiring authentication):
|
|
@@ -332,13 +361,13 @@ export MCP4_OPENAPI_SPEC_PATH=./incomplete-spec.yaml
|
|
|
332
361
|
npm start
|
|
333
362
|
```
|
|
334
363
|
|
|
335
|
-
|
|
364
|
+
CLI alternative:
|
|
336
365
|
```bash
|
|
337
|
-
export
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
366
|
+
export MCP4_API_TOKEN=your_token_here
|
|
367
|
+
npm start \
|
|
368
|
+
--auth-force true \
|
|
369
|
+
--auth-type bearer \
|
|
370
|
+
--openapi-spec-path ./incomplete-spec.yaml
|
|
342
371
|
```
|
|
343
372
|
|
|
344
373
|
**Note**: If OpenAPI spec has `security` defined, it takes precedence over force auth settings.
|
|
@@ -400,6 +429,56 @@ export MCP4_TOOLNAME_MAX=30
|
|
|
400
429
|
- `MCP4_OAUTH_REFRESH_THRESHOLD_MS`: Refresh access tokens this many ms before expiry (default: `60000` = 60s)
|
|
401
430
|
- `MCP4_HEARTBEAT_ENABLED`, `MCP4_HEARTBEAT_INTERVAL_MS`: SSE heartbeat settings
|
|
402
431
|
- `MCP4_TOKEN_MAX_LENGTH`: Maximum token length in characters (default: `1000`)
|
|
432
|
+
- `MCP4_FILTER_MAX_VALUES`: Max values per filtering key (default: `10`)
|
|
433
|
+
- `MCP4_HTTP_PROFILE_ROUTING`: Enable profile routing (`/profile/:id/mcp`). If enabled without a default profile, `/mcp` is not registered.
|
|
434
|
+
|
|
435
|
+
**Profile routing example**:
|
|
436
|
+
```bash
|
|
437
|
+
export MCP4_TRANSPORT=http
|
|
438
|
+
export MCP4_HTTP_PROFILE_ROUTING=true
|
|
439
|
+
export MCP4_PROFILES_DIR=./profiles
|
|
440
|
+
npx mcp4openapi
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
CLI alternative:
|
|
444
|
+
```bash
|
|
445
|
+
npx mcp4openapi --transport http \
|
|
446
|
+
--http-profile-routing true \
|
|
447
|
+
--profiles-dir ./profiles
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
**Test with curl**:
|
|
451
|
+
```bash
|
|
452
|
+
curl -X POST http://localhost:3003/profile/mcp-profile-name/mcp -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"initialize"}'
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
If `MCP4_PROFILE_PATH` (or `--profile-path`) is set, `/mcp` remains available alongside `/profile/:id/mcp`.
|
|
456
|
+
|
|
457
|
+
#### Parameter Filtering (HTTP: X-Mcp4-Params)
|
|
458
|
+
|
|
459
|
+
`X-Mcp4-Params` is a per-session header for constraining tool call parameters (not tool selection). It is parsed on session initialization and then enforced for the lifetime of the session: subsequent requests may omit the header, but if provided it must match the session value or the server returns a `400` validation error.
|
|
460
|
+
|
|
461
|
+
**Format**: comma-separated `key=value` pairs. Repeat keys to allow multiple values.
|
|
462
|
+
|
|
463
|
+
**Example for GitLab profile**:
|
|
464
|
+
```
|
|
465
|
+
X-Mcp4-Params: project_id=123, project_id=mcp/mcp-gitlab, _allow_list, _allow_read
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
**What this means**:
|
|
469
|
+
- The session is constrained to the GitLab project identified by either `123` or `mcp/mcp-gitlab` (both refer to the same project) for tools that accept `project_id` (or an alias mapped to it). If a tool call provides a different `project_id`, the server rejects it.
|
|
470
|
+
- This is useful for agent-style workflows (e.g., "code review only within project 123/456") because the client can enforce the scope at session init instead of relying on the agent to always remember to pass the correct project parameter.
|
|
471
|
+
- `_allow_list` and `_allow_read` relax filter enforcement for list and read operations; use them if you want list/read calls to be allowed even when they omit the filtered key, or when they pass a different value.
|
|
472
|
+
|
|
473
|
+
**Notes**:
|
|
474
|
+
- Keys are validated against the currently available tool parameters (including parameter aliases).
|
|
475
|
+
- Max values per key are limited by `MCP4_FILTER_MAX_VALUES`.
|
|
476
|
+
- Control keys (no value):
|
|
477
|
+
- `_allow_list`: allows list operations to omit the filtered key (only affects presence enforcement).
|
|
478
|
+
- `_allow_read`: allows read operations to omit the filtered key (only affects presence enforcement).
|
|
479
|
+
- If the filtered key is present in arguments, its value is not constrained for list/read operations.
|
|
480
|
+
- Control keys do not relax modify operations.
|
|
481
|
+
- Control keys are only meaningful when at least one `key=value` filter is present (otherwise there is nothing to enforce).
|
|
403
482
|
|
|
404
483
|
See [docs/HTTP-TRANSPORT.md](./docs/HTTP-TRANSPORT.md) for detailed HTTP transport configuration.
|
|
405
484
|
|
|
@@ -418,7 +497,7 @@ See [docs/OAUTH.md](./docs/OAUTH.md#ssltls-support) for SSL configuration with O
|
|
|
418
497
|
export MCP4_API_BASE_URL=https://www.gitlab.com/api/v4
|
|
419
498
|
export MCP4_OAUTH_CLIENT_ID=your_dcr_client_id
|
|
420
499
|
export MCP4_OAUTH_CLIENT_SECRET=your_dcr_client_secret
|
|
421
|
-
export MCP4_OAUTH_REDIRECT_URI=http://
|
|
500
|
+
export MCP4_OAUTH_REDIRECT_URI=http://127.0.0.1:3003/oauth/callback
|
|
422
501
|
# OAuth endpoints are automatically discovered from API base URL
|
|
423
502
|
```
|
|
424
503
|
**Note**: DCR and OAuth callback must be registered with the OAuth provider.
|
|
@@ -495,6 +574,7 @@ npm run validate:schema
|
|
|
495
574
|
### Run Tests
|
|
496
575
|
```bash
|
|
497
576
|
npm test
|
|
577
|
+
npm run test:e2e
|
|
498
578
|
```
|
|
499
579
|
|
|
500
580
|
## Troubleshooting MCP
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
import fs from 'fs/promises';
|
|
9
9
|
import path from 'path';
|
|
10
10
|
import { fileURLToPath } from 'url';
|
|
11
|
-
import { ProfileLoader } from '../src/profile-loader.js';
|
|
12
|
-
import { OpenAPIParser } from '../src/openapi-parser.js';
|
|
13
|
-
import { ToolGenerator } from '../src/tool-generator.js';
|
|
11
|
+
import { ProfileLoader } from '../src/profile/profile-loader.js';
|
|
12
|
+
import { OpenAPIParser } from '../src/openapi/openapi-parser.js';
|
|
13
|
+
import { ToolGenerator } from '../src/tooling/tool-generator.js';
|
|
14
14
|
const __filename = fileURLToPath(import.meta.url);
|
|
15
15
|
const __dirname = path.dirname(__filename);
|
|
16
16
|
async function validateProfile(profilePath, specPath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-profile.js","sourceRoot":"","sources":["../../scripts/validate-profile.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"validate-profile.js","sourceRoot":"","sources":["../../scripts/validate-profile.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD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,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE5E,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,YAAY,WAAW,EAAE,CAAC,CAAC;IACvC,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC5D,WAAW,CAAC,MAAM,CAAC,CAAC;IAEpB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;IACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ToolDefinition } from './types/profile.js';
|
|
2
|
+
type NormalizedArguments = Record<string, unknown>;
|
|
3
|
+
export declare function normalizeArguments(toolDef: ToolDefinition, args: Record<string, unknown>): NormalizedArguments;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=argument-normalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argument-normalizer.d.ts","sourceRoot":"","sources":["../../src/argument-normalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuB,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAE7E,KAAK,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAElD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,mBAAmB,CAsBrB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export function normalizeArguments(toolDef, args) {
|
|
2
|
+
const normalized = { ...args };
|
|
3
|
+
for (const [paramName, paramDef] of Object.entries(toolDef.parameters)) {
|
|
4
|
+
const value = normalized[paramName];
|
|
5
|
+
if (value === undefined) {
|
|
6
|
+
continue;
|
|
7
|
+
}
|
|
8
|
+
const mappedEntries = normalizeObjectEntries(paramDef, value);
|
|
9
|
+
if (mappedEntries !== undefined) {
|
|
10
|
+
normalized[paramName] = mappedEntries;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const mappedArrayItems = normalizeArrayItems(paramDef, value);
|
|
14
|
+
if (mappedArrayItems !== undefined) {
|
|
15
|
+
normalized[paramName] = mappedArrayItems;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return normalized;
|
|
19
|
+
}
|
|
20
|
+
function normalizeObjectEntries(paramDef, value) {
|
|
21
|
+
if (!paramDef.object_entries_to_array) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const { key_field, value_field, wrap_value_field } = paramDef.object_entries_to_array;
|
|
28
|
+
const entries = Object.entries(value);
|
|
29
|
+
return entries.map(([key, entryValue]) => ({
|
|
30
|
+
[key_field]: key,
|
|
31
|
+
[value_field]: wrapObjectValue(entryValue, wrap_value_field),
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
function wrapObjectValue(value, wrapValueField) {
|
|
35
|
+
if (!wrapValueField) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
if (typeof value === 'object' && value !== null) {
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
return { [wrapValueField]: value };
|
|
42
|
+
}
|
|
43
|
+
function normalizeArrayItems(paramDef, value) {
|
|
44
|
+
if (!paramDef.array_item_to_object) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
if (!Array.isArray(value)) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const { key_field } = paramDef.array_item_to_object;
|
|
51
|
+
return value.map(item => {
|
|
52
|
+
if (typeof item === 'object' && item !== null && !Array.isArray(item)) {
|
|
53
|
+
return item;
|
|
54
|
+
}
|
|
55
|
+
if (['string', 'number', 'boolean'].includes(typeof item)) {
|
|
56
|
+
return { [key_field]: item };
|
|
57
|
+
}
|
|
58
|
+
return item;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=argument-normalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argument-normalizer.js","sourceRoot":"","sources":["../../src/argument-normalizer.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,kBAAkB,CAChC,OAAuB,EACvB,IAA6B;IAE7B,MAAM,UAAU,GAAwB,EAAE,GAAG,IAAI,EAAE,CAAA;IAEnD,KAAK,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACvE,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;QACnC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,SAAQ;QACV,CAAC;QAED,MAAM,aAAa,GAAG,sBAAsB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QAC7D,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YAChC,UAAU,CAAC,SAAS,CAAC,GAAG,aAAa,CAAA;YACrC,SAAQ;QACV,CAAC;QAED,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QAC7D,IAAI,gBAAgB,KAAK,SAAS,EAAE,CA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AAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC,oBAAoB,CAAA;IAEnD,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACtB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACtE,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC;YAC1D,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth 2.0 Provider Adapter
|
|
3
|
+
*
|
|
4
|
+
* Implements MCP SDK OAuthServerProvider interface to integrate with external
|
|
5
|
+
* OAuth 2.0 authorization servers (e.g., GitLab, GitHub, etc.)
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* - This server acts as an OAuth client to the external provider (Proxy/Gateway)
|
|
9
|
+
* - Implements "Callback Mode":
|
|
10
|
+
* 1. Client -> MCP (Authorize) -> MCP redirects to Provider (with MCP callback URL)
|
|
11
|
+
* 2. Provider -> MCP (Callback) -> MCP exchanges code for tokens
|
|
12
|
+
* 3. MCP redirects to Client (with Internal Code)
|
|
13
|
+
* 4. Client -> MCP (Token) -> MCP returns stored tokens
|
|
14
|
+
*/
|
|
15
|
+
import { Request, Response } from 'express';
|
|
16
|
+
import type { OAuthServerProvider, AuthorizationParams } from '@modelcontextprotocol/sdk/server/auth/provider.js';
|
|
17
|
+
import type { OAuthRegisteredClientsStore } from '@modelcontextprotocol/sdk/server/auth/clients.js';
|
|
18
|
+
import type { OAuthClientInformationFull, OAuthTokens, OAuthTokenRevocationRequest } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
19
|
+
import type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
|
|
20
|
+
import type { OAuthConfig } from '../types/profile.js';
|
|
21
|
+
import type { Logger } from '../core/logger.js';
|
|
22
|
+
/**
|
|
23
|
+
* In-memory store for OAuth client registrations
|
|
24
|
+
*/
|
|
25
|
+
export declare class InMemoryClientsStore implements OAuthRegisteredClientsStore {
|
|
26
|
+
private clients;
|
|
27
|
+
getClient(clientId: string): Promise<OAuthClientInformationFull | undefined>;
|
|
28
|
+
registerClient(clientMetadata: OAuthClientInformationFull): Promise<OAuthClientInformationFull>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* OAuth Provider Adapter for external OAuth servers
|
|
32
|
+
*/
|
|
33
|
+
export declare class ExternalOAuthProvider implements OAuthServerProvider {
|
|
34
|
+
private config;
|
|
35
|
+
private logger;
|
|
36
|
+
private _clientsStore;
|
|
37
|
+
private authorizationCodes;
|
|
38
|
+
private accessTokens;
|
|
39
|
+
private stateStore;
|
|
40
|
+
private endpointsInitialized;
|
|
41
|
+
private initializationPromise;
|
|
42
|
+
constructor(config: OAuthConfig, logger: Logger);
|
|
43
|
+
/**
|
|
44
|
+
* Lazy initialization of OAuth endpoints (async)
|
|
45
|
+
* Public method to allow HttpTransport to ensure initialization before client validation
|
|
46
|
+
*/
|
|
47
|
+
ensureEndpointsInitialized(): Promise<void>;
|
|
48
|
+
get clientsStore(): OAuthRegisteredClientsStore;
|
|
49
|
+
get authorizationEndpoint(): string | undefined;
|
|
50
|
+
get redirectUri(): string | undefined;
|
|
51
|
+
get scopes(): string[];
|
|
52
|
+
/**
|
|
53
|
+
* Fetch OAuth Authorization Server Metadata (RFC 8414)
|
|
54
|
+
*/
|
|
55
|
+
private fetchOAuthMetadata;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve environment variable references in OAuth config
|
|
58
|
+
*/
|
|
59
|
+
private resolveEnvVars;
|
|
60
|
+
/**
|
|
61
|
+
* Derive OAuth endpoints from issuer if needed
|
|
62
|
+
*/
|
|
63
|
+
private deriveEndpointsFromIssuer;
|
|
64
|
+
/**
|
|
65
|
+
* Check if redirect URI host is allowed
|
|
66
|
+
* Prevents open redirect vulnerabilities (CWE-601)
|
|
67
|
+
*/
|
|
68
|
+
private isAllowedRedirectHost;
|
|
69
|
+
/**
|
|
70
|
+
* Match hostname against allowlist entry
|
|
71
|
+
*
|
|
72
|
+
* Supports:
|
|
73
|
+
* - Exact hostnames
|
|
74
|
+
* - Wildcard subdomains (*.example.com)
|
|
75
|
+
* - IPv4 exact matches
|
|
76
|
+
* - IPv4 CIDR ranges (e.g., 10.0.0.0/8)
|
|
77
|
+
* - IPv6 exact matches
|
|
78
|
+
* - IPv6 CIDR ranges (e.g., 2001:db8::/32)
|
|
79
|
+
*/
|
|
80
|
+
private matchRedirectHost;
|
|
81
|
+
/**
|
|
82
|
+
* Check if IP address is within CIDR range
|
|
83
|
+
*
|
|
84
|
+
* Example: '192.168.1.50' matches '192.168.1.0/24'
|
|
85
|
+
* '2001:db8::1' matches '2001:db8::/32'
|
|
86
|
+
*/
|
|
87
|
+
private matchCIDR;
|
|
88
|
+
/**
|
|
89
|
+
* Convert IPv4 address to 32-bit integer
|
|
90
|
+
*/
|
|
91
|
+
private ipv4ToInt;
|
|
92
|
+
/**
|
|
93
|
+
* Convert IPv6 address to 128-bit BigInt
|
|
94
|
+
*/
|
|
95
|
+
private ipv6ToBigInt;
|
|
96
|
+
private ipv6Mask;
|
|
97
|
+
private stripIpv6Brackets;
|
|
98
|
+
/**
|
|
99
|
+
* Begin authorization flow
|
|
100
|
+
* Stores state and redirects to External Provider with MCP Callback URI
|
|
101
|
+
*/
|
|
102
|
+
authorize(client: OAuthClientInformationFull, params: AuthorizationParams, res: Response): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Handle callback from External Provider
|
|
105
|
+
* Exchanges code for tokens and redirects to Client with Internal Code
|
|
106
|
+
*/
|
|
107
|
+
handleCallback(req: Request, res: Response): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Get code challenge for authorization code (Internal)
|
|
110
|
+
*/
|
|
111
|
+
challengeForAuthorizationCode(client: OAuthClientInformationFull, authorizationCode: string): Promise<string>;
|
|
112
|
+
/**
|
|
113
|
+
* Exchange authorization code for access token (Internal)
|
|
114
|
+
*/
|
|
115
|
+
exchangeAuthorizationCode(client: OAuthClientInformationFull, authorizationCode: string, codeVerifier?: string, redirectUri?: string, resource?: URL): Promise<OAuthTokens>;
|
|
116
|
+
/**
|
|
117
|
+
* Exchange authorization code with external OAuth provider
|
|
118
|
+
*/
|
|
119
|
+
private exchangeCodeWithProvider;
|
|
120
|
+
exchangeRefreshToken(client: OAuthClientInformationFull, refreshToken: string, scopes?: string[], resource?: URL): Promise<OAuthTokens>;
|
|
121
|
+
verifyAccessToken(token: string): Promise<AuthInfo>;
|
|
122
|
+
private introspectToken;
|
|
123
|
+
revokeToken(client: OAuthClientInformationFull, request: OAuthTokenRevocationRequest): Promise<void>;
|
|
124
|
+
private revokeTokenWithProvider;
|
|
125
|
+
/**
|
|
126
|
+
* Cleanup expired states, codes, and tokens
|
|
127
|
+
* Called periodically by HttpTransport
|
|
128
|
+
*/
|
|
129
|
+
cleanup(): void;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=oauth-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-provider.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,mDAAmD,CAA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