mcp4openapi 0.2.7 → 0.3.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/README.md +147 -63
- package/dist/scripts/validate-profile.js +3 -3
- package/dist/scripts/validate-profile.js.map +1 -1
- package/dist/src/{oauth-provider.d.ts → auth/oauth-provider.d.ts} +7 -2
- package/dist/src/auth/oauth-provider.d.ts.map +1 -0
- package/dist/src/{oauth-provider.js → auth/oauth-provider.js} +30 -2
- package/dist/src/auth/oauth-provider.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 +124 -0
- package/dist/src/core/cli-config.js.map +1 -0
- package/dist/src/{constants.d.ts → core/constants.d.ts} +1 -0
- package/dist/src/core/constants.d.ts.map +1 -0
- package/dist/src/{constants.js → core/constants.js} +1 -0
- package/dist/src/core/constants.js.map +1 -0
- package/dist/src/{errors.d.ts → core/errors.d.ts} +6 -0
- package/dist/src/core/errors.d.ts.map +1 -0
- package/dist/src/{errors.js → core/errors.js} +15 -6
- 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 +275 -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/{logger.d.ts → core/logger.d.ts} +6 -13
- 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/{metrics.d.ts → core/metrics.d.ts} +11 -0
- package/dist/src/core/metrics.d.ts.map +1 -0
- package/dist/src/{metrics.js → core/metrics.js} +61 -0
- package/dist/src/core/metrics.js.map +1 -0
- package/dist/src/core/naming-warnings.d.ts.map +1 -0
- package/dist/src/{naming-warnings.js → core/naming-warnings.js} +6 -6
- package/dist/src/core/naming-warnings.js.map +1 -0
- package/dist/src/core/naming.d.ts.map +1 -0
- package/dist/src/core/naming.js.map +1 -0
- package/dist/src/generated-schemas.d.ts +281 -79
- package/dist/src/generated-schemas.d.ts.map +1 -1
- package/dist/src/generated-schemas.js +17 -3
- package/dist/src/generated-schemas.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 -156
- package/dist/src/index.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/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-server.d.ts → mcp/mcp-server.d.ts} +43 -3
- package/dist/src/mcp/mcp-server.d.ts.map +1 -0
- package/dist/src/{mcp-server.js → mcp/mcp-server.js} +639 -123
- package/dist/src/mcp/mcp-server.js.map +1 -0
- package/dist/src/{openapi-parser.d.ts → openapi/openapi-parser.d.ts} +1 -1
- package/dist/src/openapi/openapi-parser.d.ts.map +1 -0
- package/dist/src/{openapi-parser.js → openapi/openapi-parser.js} +2 -2
- package/dist/src/openapi/openapi-parser.js.map +1 -0
- package/dist/src/{profile-loader.d.ts → profile/profile-loader.d.ts} +3 -2
- package/dist/src/profile/profile-loader.d.ts.map +1 -0
- package/dist/src/{profile-loader.js → profile/profile-loader.js} +17 -6
- package/dist/src/profile/profile-loader.js.map +1 -0
- package/dist/src/profile/profile-registry.d.ts +18 -0
- package/dist/src/profile/profile-registry.d.ts.map +1 -0
- package/dist/src/profile/profile-registry.js +26 -0
- package/dist/src/profile/profile-registry.js.map +1 -0
- package/dist/src/profile/profile-resolver.d.ts +25 -0
- package/dist/src/profile/profile-resolver.d.ts.map +1 -0
- package/dist/src/profile/profile-resolver.js +204 -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/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/listen-support.d.ts +3 -0
- package/dist/src/testing/listen-support.d.ts.map +1 -0
- package/dist/src/testing/listen-support.js +50 -0
- package/dist/src/testing/listen-support.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/{composite-executor.d.ts → tooling/composite-executor.d.ts} +3 -3
- package/dist/src/tooling/composite-executor.d.ts.map +1 -0
- package/dist/src/{composite-executor.js → tooling/composite-executor.js} +1 -1
- package/dist/src/tooling/composite-executor.js.map +1 -0
- package/dist/src/{dag-executor.d.ts → tooling/dag-executor.d.ts} +1 -1
- package/dist/src/tooling/dag-executor.d.ts.map +1 -0
- package/dist/src/tooling/dag-executor.js.map +1 -0
- package/dist/src/{proxy-executor.d.ts → tooling/proxy-executor.d.ts} +19 -4
- package/dist/src/tooling/proxy-executor.d.ts.map +1 -0
- package/dist/src/tooling/proxy-executor.js +497 -0
- package/dist/src/tooling/proxy-executor.js.map +1 -0
- package/dist/src/{tool-generator.d.ts → tooling/tool-generator.d.ts} +4 -3
- package/dist/src/tooling/tool-generator.d.ts.map +1 -0
- package/dist/src/{tool-generator.js → tooling/tool-generator.js} +23 -7
- package/dist/src/tooling/tool-generator.js.map +1 -0
- package/dist/src/{http-client-factory.d.ts → transport/http-client-factory.d.ts} +4 -1
- package/dist/src/transport/http-client-factory.d.ts.map +1 -0
- package/dist/src/{http-client-factory.js → transport/http-client-factory.js} +13 -3
- 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 +62 -0
- package/dist/src/transport/http-transport-config.js.map +1 -0
- package/dist/src/{http-transport.d.ts → transport/http-transport.d.ts} +72 -14
- package/dist/src/transport/http-transport.d.ts.map +1 -0
- package/dist/src/transport/http-transport.js +2522 -0
- package/dist/src/transport/http-transport.js.map +1 -0
- package/dist/src/{interceptors.d.ts → transport/interceptors.d.ts} +6 -2
- package/dist/src/transport/interceptors.d.ts.map +1 -0
- package/dist/src/{interceptors.js → transport/interceptors.js} +77 -46
- package/dist/src/transport/interceptors.js.map +1 -0
- package/dist/src/types/http-transport.d.ts +25 -0
- package/dist/src/types/http-transport.d.ts.map +1 -1
- package/dist/src/types/profile.d.ts +31 -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.map +1 -0
- package/dist/src/validation/jsonrpc-validator.js.map +1 -0
- package/dist/src/{schema-validator.d.ts → validation/schema-validator.d.ts} +2 -2
- package/dist/src/validation/schema-validator.d.ts.map +1 -0
- package/dist/src/validation/schema-validator.js.map +1 -0
- package/dist/src/validation/validation-utils.d.ts.map +1 -0
- package/dist/src/validation/validation-utils.js.map +1 -0
- package/package.json +9 -3
- package/profile-schema.json +75 -3
- package/profiles/gitlab/developer-profile-oauth.json +1520 -0
- package/profiles/gitlab/developer-profile-oauth.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/composite-executor.d.ts.map +0 -1
- package/dist/src/composite-executor.js.map +0 -1
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/constants.js.map +0 -1
- package/dist/src/dag-executor.d.ts.map +0 -1
- package/dist/src/dag-executor.js.map +0 -1
- package/dist/src/errors.d.ts.map +0 -1
- package/dist/src/errors.js.map +0 -1
- package/dist/src/http-client-factory.d.ts.map +0 -1
- package/dist/src/http-client-factory.js.map +0 -1
- package/dist/src/http-transport.d.ts.map +0 -1
- package/dist/src/http-transport.js +0 -1826
- package/dist/src/http-transport.js.map +0 -1
- package/dist/src/interceptors.d.ts.map +0 -1
- package/dist/src/interceptors.js.map +0 -1
- package/dist/src/jsonrpc-validator.d.ts.map +0 -1
- package/dist/src/jsonrpc-validator.js.map +0 -1
- package/dist/src/logger.d.ts.map +0 -1
- package/dist/src/logger.js +0 -177
- package/dist/src/logger.js.map +0 -1
- package/dist/src/mcp-server.d.ts.map +0 -1
- package/dist/src/mcp-server.js.map +0 -1
- package/dist/src/metrics.d.ts.map +0 -1
- package/dist/src/metrics.js.map +0 -1
- package/dist/src/naming-warnings.d.ts.map +0 -1
- package/dist/src/naming-warnings.js.map +0 -1
- package/dist/src/naming.d.ts.map +0 -1
- package/dist/src/naming.js.map +0 -1
- package/dist/src/oauth-provider.d.ts.map +0 -1
- package/dist/src/oauth-provider.js.map +0 -1
- package/dist/src/openapi-parser.d.ts.map +0 -1
- package/dist/src/openapi-parser.js.map +0 -1
- package/dist/src/profile-loader.d.ts.map +0 -1
- package/dist/src/profile-loader.js.map +0 -1
- package/dist/src/proxy-executor.d.ts.map +0 -1
- package/dist/src/proxy-executor.js +0 -240
- package/dist/src/proxy-executor.js.map +0 -1
- package/dist/src/schema-validator.d.ts.map +0 -1
- package/dist/src/schema-validator.js.map +0 -1
- 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 -138
- package/dist/src/testing/mock-youtrack-server.js.map +0 -1
- package/dist/src/tool-generator.d.ts.map +0 -1
- package/dist/src/tool-generator.js.map +0 -1
- package/dist/src/validation-utils.d.ts.map +0 -1
- package/dist/src/validation-utils.js.map +0 -1
- /package/dist/src/{naming-warnings.d.ts → core/naming-warnings.d.ts} +0 -0
- /package/dist/src/{naming.d.ts → core/naming.d.ts} +0 -0
- /package/dist/src/{naming.js → core/naming.js} +0 -0
- /package/dist/src/{dag-executor.js → tooling/dag-executor.js} +0 -0
- /package/dist/src/{jsonrpc-validator.d.ts → validation/jsonrpc-validator.d.ts} +0 -0
- /package/dist/src/{jsonrpc-validator.js → validation/jsonrpc-validator.js} +0 -0
- /package/dist/src/{schema-validator.js → validation/schema-validator.js} +0 -0
- /package/dist/src/{validation-utils.d.ts → validation/validation-utils.d.ts} +0 -0
- /package/dist/src/{validation-utils.js → validation/validation-utils.js} +0 -0
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* simple (single operation) and composite (multi-step) tools.
|
|
6
6
|
*/
|
|
7
7
|
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
-
import type { ToolDefinition } from '
|
|
9
|
-
import type { OpenAPIParser } from '
|
|
8
|
+
import type { ToolDefinition } from '../types/profile.js';
|
|
9
|
+
import type { OpenAPIParser } from '../openapi/openapi-parser.js';
|
|
10
10
|
export declare class ToolGenerator {
|
|
11
11
|
private parser;
|
|
12
12
|
constructor(parser: OpenAPIParser);
|
|
@@ -25,6 +25,7 @@ export declare class ToolGenerator {
|
|
|
25
25
|
* Convert parameter definition to JSON Schema
|
|
26
26
|
*/
|
|
27
27
|
private parameterToJsonSchema;
|
|
28
|
+
private parameterTypeToSchema;
|
|
28
29
|
/**
|
|
29
30
|
* Validate tool arguments against parameter definitions
|
|
30
31
|
*
|
|
@@ -38,7 +39,7 @@ export declare class ToolGenerator {
|
|
|
38
39
|
* Why: Tools can have string operationIds OR proxy_download configs.
|
|
39
40
|
* This returns the raw definition before extracting operationId.
|
|
40
41
|
*/
|
|
41
|
-
getOperationDefinition(toolDef: ToolDefinition, args: Record<string, unknown>): import("
|
|
42
|
+
getOperationDefinition(toolDef: ToolDefinition, args: Record<string, unknown>): import("../types/profile.js").OperationDefinition | undefined;
|
|
42
43
|
/**
|
|
43
44
|
* Map tool action to OpenAPI operation ID
|
|
44
45
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-generator.d.ts","sourceRoot":"","sources":["../../../src/tooling/tool-generator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAsC,MAAM,qBAAqB,CAAC;AAC9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,qBAAa,aAAa;IACZ,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAEzC;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAU3C;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IA2B3B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAc7B,OAAO,CAAC,qBAAqB;IA0B7B;;;;;OAKG;IACH,iBAAiB,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IA4B/E;;;;;OAKG;IACH,sBAAsB,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAyB7E;;;;;;;OAOG;IACH,oBAAoB,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS;IAKhG;;;;;OAKG;IACH,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAMlD;;;;;OAKG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,SAAa,GAAG,QAAQ;CAyBvF"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Why: Translates profile config into MCP SDK tool definitions. Handles both
|
|
5
5
|
* simple (single operation) and composite (multi-step) tools.
|
|
6
6
|
*/
|
|
7
|
+
import { ValidationError } from '../core/errors.js';
|
|
7
8
|
export class ToolGenerator {
|
|
8
9
|
constructor(parser) {
|
|
9
10
|
this.parser = parser;
|
|
@@ -51,20 +52,29 @@ export class ToolGenerator {
|
|
|
51
52
|
* Convert parameter definition to JSON Schema
|
|
52
53
|
*/
|
|
53
54
|
parameterToJsonSchema(param) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
if (Array.isArray(param.type)) {
|
|
56
|
+
const oneOf = param.type.map(type => this.parameterTypeToSchema(type, param));
|
|
57
|
+
return {
|
|
58
|
+
description: param.description,
|
|
59
|
+
oneOf,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const schema = this.parameterTypeToSchema(param.type, param);
|
|
63
|
+
schema.description = param.description;
|
|
64
|
+
return schema;
|
|
65
|
+
}
|
|
66
|
+
parameterTypeToSchema(type, param) {
|
|
67
|
+
const schema = { type };
|
|
58
68
|
if (param.enum) {
|
|
59
69
|
schema.enum = param.enum;
|
|
60
70
|
}
|
|
61
71
|
if (param.default !== undefined) {
|
|
62
72
|
schema.default = param.default;
|
|
63
73
|
}
|
|
64
|
-
if (
|
|
74
|
+
if (type === 'array' && param.items) {
|
|
65
75
|
schema.items = { type: param.items.type };
|
|
66
76
|
}
|
|
67
|
-
if (
|
|
77
|
+
if (type === 'object') {
|
|
68
78
|
// Always include properties for object type (empty {} = free-form object)
|
|
69
79
|
schema.properties = param.properties || {};
|
|
70
80
|
}
|
|
@@ -159,7 +169,13 @@ export class ToolGenerator {
|
|
|
159
169
|
const mimeType = args['mimeType'] || 'application/octet-stream';
|
|
160
170
|
if (base64Content) {
|
|
161
171
|
// Convert base64 to Blob
|
|
162
|
-
|
|
172
|
+
let binaryString;
|
|
173
|
+
try {
|
|
174
|
+
binaryString = atob(base64Content);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
throw new ValidationError('Invalid base64 content');
|
|
178
|
+
}
|
|
163
179
|
const bytes = new Uint8Array(binaryString.length);
|
|
164
180
|
for (let i = 0; i < binaryString.length; i++) {
|
|
165
181
|
bytes[i] = binaryString.charCodeAt(i);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-generator.js","sourceRoot":"","sources":["../../../src/tooling/tool-generator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,OAAO,aAAa;IACxB,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAE7C;;OAEG;IACH,YAAY,CAAC,OAAuB;QAClC,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAEtD,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,WAAW;SACZ,CAAC;IACJ,CA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AC;gBACH,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;YACrC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,eAAe,CAAC,wBAAwB,CAAC,CAAC;YACtD,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC7C,KAAK,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACxC,CAAC;YACD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;YACnD,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* Provides consistent client lifecycle, auth handling, and caching
|
|
6
6
|
*/
|
|
7
7
|
import { HttpClient } from './interceptors.js';
|
|
8
|
-
import type {
|
|
8
|
+
import type { MetricsCollector } from '../core/metrics.js';
|
|
9
|
+
import type { Profile } from '../types/profile.js';
|
|
9
10
|
export interface HttpClientConfig {
|
|
10
11
|
profile: Profile;
|
|
11
12
|
baseUrl: string;
|
|
@@ -18,6 +19,7 @@ export interface HttpClientConfig {
|
|
|
18
19
|
export declare class HttpClientFactory {
|
|
19
20
|
private globalClient?;
|
|
20
21
|
private sessionClients;
|
|
22
|
+
private metrics;
|
|
21
23
|
/**
|
|
22
24
|
* Create global HTTP client (for stdio transport)
|
|
23
25
|
*/
|
|
@@ -46,6 +48,7 @@ export declare class HttpClientFactory {
|
|
|
46
48
|
* Check if session client exists
|
|
47
49
|
*/
|
|
48
50
|
hasSessionClient(sessionId: string): boolean;
|
|
51
|
+
setMetricsCollector(metrics: MetricsCollector | null): void;
|
|
49
52
|
/**
|
|
50
53
|
* Get auth token for client creation
|
|
51
54
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client-factory.d.ts","sourceRoot":"","sources":["../../../src/transport/http-client-factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAoB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAa;IAClC,OAAO,CAAC,cAAc,CAAiC;IACvD,OAAO,CAAC,OAAO,CAAiC;IAEhD;;OAEG;IACH,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU;IAOxD;;OAEG;IACH,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,UAAU;IAsBjF;;OAEG;IACH,eAAe,IAAI,UAAU;IAO7B;;OAEG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU;IAQ/C;;OAEG;IACH,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIhD;;OAEG;IACH,eAAe,IAAI,OAAO;IAI1B;;OAEG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAI5C,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI;IAU3D;;OAEG;IACH,OAAO,CAAC,YAAY;IAuBpB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAK9B;;OAEG;IACH,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;CAsBrD"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Provides consistent client lifecycle, auth handling, and caching
|
|
6
6
|
*/
|
|
7
7
|
import { InterceptorChain, HttpClient } from './interceptors.js';
|
|
8
|
-
import { ConfigurationError, AuthenticationError } from '
|
|
8
|
+
import { ConfigurationError, AuthenticationError } from '../core/errors.js';
|
|
9
9
|
/**
|
|
10
10
|
* Factory for creating and managing HTTP clients
|
|
11
11
|
* Handles both global and session-specific clients
|
|
@@ -13,13 +13,14 @@ import { ConfigurationError, AuthenticationError } from './errors.js';
|
|
|
13
13
|
export class HttpClientFactory {
|
|
14
14
|
constructor() {
|
|
15
15
|
this.sessionClients = new Map();
|
|
16
|
+
this.metrics = null;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Create global HTTP client (for stdio transport)
|
|
19
20
|
*/
|
|
20
21
|
createGlobalClient(config) {
|
|
21
22
|
const interceptors = this.createInterceptorChain(config);
|
|
22
|
-
const client = new HttpClient(config.baseUrl, interceptors);
|
|
23
|
+
const client = new HttpClient(config.baseUrl, interceptors, this.metrics);
|
|
23
24
|
this.globalClient = client;
|
|
24
25
|
return client;
|
|
25
26
|
}
|
|
@@ -34,7 +35,7 @@ export class HttpClientFactory {
|
|
|
34
35
|
}
|
|
35
36
|
// Create new client for session
|
|
36
37
|
const interceptors = this.createInterceptorChain(config);
|
|
37
|
-
const newClient = new HttpClient(config.baseUrl, interceptors);
|
|
38
|
+
const newClient = new HttpClient(config.baseUrl, interceptors, this.metrics);
|
|
38
39
|
// Double-check for race condition
|
|
39
40
|
const existingClient = this.sessionClients.get(sessionId);
|
|
40
41
|
if (existingClient) {
|
|
@@ -81,6 +82,15 @@ export class HttpClientFactory {
|
|
|
81
82
|
hasSessionClient(sessionId) {
|
|
82
83
|
return this.sessionClients.has(sessionId);
|
|
83
84
|
}
|
|
85
|
+
setMetricsCollector(metrics) {
|
|
86
|
+
this.metrics = metrics;
|
|
87
|
+
if (this.globalClient) {
|
|
88
|
+
this.globalClient.setMetricsCollector(metrics);
|
|
89
|
+
}
|
|
90
|
+
for (const client of this.sessionClients.values()) {
|
|
91
|
+
client.setMetricsCollector(metrics);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
84
94
|
/**
|
|
85
95
|
* Get auth token for client creation
|
|
86
96
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client-factory.js","sourceRoot":"","sources":["../../../src/transport/http-client-factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAQ5E;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAA9B;QAEU,mBAAc,GAAG,IAAI,GAAG,EAAsB,CAAC;QAC/C,YAAO,GAA4B,IAAI,CAAC;IAoJlD,CAAC;IAlJC;;OAEG;IACH,kBAAkB,CAAC,MAAwB;QACzC,MAAM,YAAY,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QACzD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1E,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,wBAAwB,CAAC,SAAiB,EAAE,MAAwB;QAClE,oBAAoB;QACpB,IAAI,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,gCAAgC;QAChC,MAAM,YAAY,GA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+
import type { HttpTransportConfig } from '../types/http-transport.js';
|
|
5
|
+
export declare function buildHttpTransportBaseConfig(host: string, port: number): HttpTransportConfig;
|
|
6
|
+
//# sourceMappingURL=http-transport-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-transport-config.d.ts","sourceRoot":"","sources":["../../../src/transport/http-transport-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAatE,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,mBAAmB,CA6C5F"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build base HTTP transport configuration from environment variables.
|
|
3
|
+
*/
|
|
4
|
+
import { TIMEOUTS } from '../core/constants.js';
|
|
5
|
+
import { ConfigurationError } from '../core/errors.js';
|
|
6
|
+
function parseTrustProxy(value) {
|
|
7
|
+
const normalized = value.trim().toLowerCase();
|
|
8
|
+
if (normalized === 'true')
|
|
9
|
+
return true;
|
|
10
|
+
if (normalized === 'false')
|
|
11
|
+
return false;
|
|
12
|
+
const numeric = Number.parseInt(value, 10);
|
|
13
|
+
if (!Number.isNaN(numeric) && String(numeric) === value.trim()) {
|
|
14
|
+
return numeric;
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
export function buildHttpTransportBaseConfig(host, port) {
|
|
19
|
+
return {
|
|
20
|
+
host,
|
|
21
|
+
port,
|
|
22
|
+
sessionTimeoutMs: parseInt(process.env.MCP4_SESSION_TIMEOUT_MS || String(TIMEOUTS.SESSION_TIMEOUT_MS), 10),
|
|
23
|
+
heartbeatEnabled: process.env.MCP4_HEARTBEAT_ENABLED === 'true',
|
|
24
|
+
heartbeatIntervalMs: parseInt(process.env.MCP4_HEARTBEAT_INTERVAL_MS || String(TIMEOUTS.HEARTBEAT_INTERVAL_MS), 10),
|
|
25
|
+
metricsEnabled: process.env.MCP4_METRICS_ENABLED === 'true',
|
|
26
|
+
metricsPath: process.env.MCP4_METRICS_PATH || '/metrics',
|
|
27
|
+
allowedOrigins: process.env.MCP4_ALLOWED_ORIGINS
|
|
28
|
+
? process.env.MCP4_ALLOWED_ORIGINS.split(',').map(o => o.trim())
|
|
29
|
+
: undefined,
|
|
30
|
+
rateLimitEnabled: process.env.MCP4_HTTP_RATE_LIMIT_ENABLED !== 'false', // default: true
|
|
31
|
+
rateLimitWindowMs: parseInt(process.env.MCP4_HTTP_RATE_LIMIT_WINDOW_MS || String(TIMEOUTS.RATE_LIMIT_WINDOW_MS), 10),
|
|
32
|
+
rateLimitMaxRequests: parseInt(process.env.MCP4_HTTP_RATE_LIMIT_MAX_REQUESTS || '100', 10),
|
|
33
|
+
rateLimitMetricsMax: parseInt(process.env.MCP4_HTTP_RATE_LIMIT_METRICS_MAX || '10', 10),
|
|
34
|
+
maxTokenLength: process.env.MCP4_TOKEN_MAX_LENGTH
|
|
35
|
+
? parseInt(process.env.MCP4_TOKEN_MAX_LENGTH, 10)
|
|
36
|
+
: undefined,
|
|
37
|
+
trustProxy: process.env.MCP4_TRUST_PROXY
|
|
38
|
+
? parseTrustProxy(process.env.MCP4_TRUST_PROXY)
|
|
39
|
+
: undefined,
|
|
40
|
+
sslCertFile: process.env.MCP4_SSL_CERT_FILE,
|
|
41
|
+
sslKeyFile: process.env.MCP4_SSL_KEY_FILE,
|
|
42
|
+
oauthSessionTimeoutMs: (() => {
|
|
43
|
+
if (process.env.MCP4_OAUTH_SESSION_TIMEOUT_MS === undefined)
|
|
44
|
+
return undefined;
|
|
45
|
+
const parsed = parseInt(process.env.MCP4_OAUTH_SESSION_TIMEOUT_MS, 10);
|
|
46
|
+
if (Number.isNaN(parsed)) {
|
|
47
|
+
throw new ConfigurationError(`Invalid MCP4_OAUTH_SESSION_TIMEOUT_MS: expected integer milliseconds, got '${process.env.MCP4_OAUTH_SESSION_TIMEOUT_MS}'`);
|
|
48
|
+
}
|
|
49
|
+
return parsed;
|
|
50
|
+
})(),
|
|
51
|
+
oauthRefreshThresholdMs: (() => {
|
|
52
|
+
if (process.env.MCP4_OAUTH_REFRESH_THRESHOLD_MS === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
const parsed = parseInt(process.env.MCP4_OAUTH_REFRESH_THRESHOLD_MS, 10);
|
|
55
|
+
if (Number.isNaN(parsed)) {
|
|
56
|
+
throw new ConfigurationError(`Invalid MCP4_OAUTH_REFRESH_THRESHOLD_MS: expected integer milliseconds, got '${process.env.MCP4_OAUTH_REFRESH_THRESHOLD_MS}'`);
|
|
57
|
+
}
|
|
58
|
+
return parsed;
|
|
59
|
+
})(),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=http-transport-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-transport-config.js","sourceRoot":"","sources":["../../../src/transport/http-transport-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,SAAS,eAAe,CAAC,KAAa;IACpC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IAAI,UAAU,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,UAAU,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IACzC,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/D,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;A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7,26 +7,38 @@
|
|
|
7
7
|
* Why: Enables remote MCP server access with SSE streaming, session management,
|
|
8
8
|
* and resumability for reliable communication over HTTP.
|
|
9
9
|
*/
|
|
10
|
-
import type { Logger } from '
|
|
11
|
-
import type { HttpTransportConfig } from '
|
|
10
|
+
import type { Logger } from '../core/logger.js';
|
|
11
|
+
import type { HttpTransportConfig, HttpProfileContext } from '../types/http-transport.js';
|
|
12
|
+
import { MetricsCollector } from '../core/metrics.js';
|
|
13
|
+
import type { SessionToolFilter, SessionToolFilterRequest } from '../types/http-transport.js';
|
|
12
14
|
export declare class HttpTransport {
|
|
13
15
|
private app;
|
|
14
16
|
private server;
|
|
15
|
-
private sessions;
|
|
16
17
|
private config;
|
|
17
18
|
private logger;
|
|
18
19
|
private metrics;
|
|
19
20
|
private cleanupInterval;
|
|
20
21
|
private messageHandler;
|
|
21
|
-
private
|
|
22
|
-
private
|
|
22
|
+
private profileContextProvider;
|
|
23
|
+
private profileStates;
|
|
24
|
+
private oauthRedirectHostCache;
|
|
25
|
+
private warnedMissingOAuthRedirectEnvVars;
|
|
26
|
+
private profileHintsByClient;
|
|
27
|
+
private static readonly PROFILE_HINT_TTL_MS;
|
|
23
28
|
constructor(config: HttpTransportConfig, logger: Logger);
|
|
29
|
+
getMetricsCollector(): MetricsCollector | null;
|
|
24
30
|
/**
|
|
25
31
|
* Setup Express middleware
|
|
26
32
|
*
|
|
27
33
|
* Why: Security (Origin validation, rate limiting), JSON parsing, session extraction, metrics
|
|
28
34
|
*/
|
|
29
35
|
private setupMiddleware;
|
|
36
|
+
setProfileContextProvider(provider: (profileId: string) => Promise<HttpProfileContext | null>): void;
|
|
37
|
+
private getDefaultProfileId;
|
|
38
|
+
private buildDefaultProfileContext;
|
|
39
|
+
private getProfileState;
|
|
40
|
+
private getProfileIdForRequest;
|
|
41
|
+
private getProfileStateForRequest;
|
|
30
42
|
private hasWarnedAboutBinding;
|
|
31
43
|
/**
|
|
32
44
|
* Check if origin is allowed
|
|
@@ -40,6 +52,16 @@ export declare class HttpTransport {
|
|
|
40
52
|
* - IPv4 exact: '192.168.1.100'
|
|
41
53
|
*/
|
|
42
54
|
private isAllowedOrigin;
|
|
55
|
+
private getOAuthRedirectHostPatterns;
|
|
56
|
+
private extractRedirectHostPatterns;
|
|
57
|
+
private resolveRedirectUriFromEnv;
|
|
58
|
+
private resolveProfileIdFromPath;
|
|
59
|
+
private getClientHintKey;
|
|
60
|
+
private storeProfileHint;
|
|
61
|
+
private resolveProfileIdFromHint;
|
|
62
|
+
private resolveProfileIdForOriginCheck;
|
|
63
|
+
private primeOAuthRedirectHosts;
|
|
64
|
+
private isAllowedOriginForRequest;
|
|
43
65
|
/**
|
|
44
66
|
* Match hostname against allowed origin pattern
|
|
45
67
|
*
|
|
@@ -76,12 +98,28 @@ export declare class HttpTransport {
|
|
|
76
98
|
*/
|
|
77
99
|
private createRateLimiter;
|
|
78
100
|
private formatRateLimitMessage;
|
|
101
|
+
private getProfilePrefix;
|
|
102
|
+
private buildProfilePath;
|
|
103
|
+
private getServerOrigin;
|
|
104
|
+
private buildProfileUrl;
|
|
105
|
+
private normalizeResourcePath;
|
|
106
|
+
private resolveProfileInfoFromResourceUrl;
|
|
107
|
+
private resolveProfileIdFromResourceUrl;
|
|
108
|
+
getOAuthProtectedResourceUrl(profileId?: string): string;
|
|
109
|
+
private respondProfileNotFound;
|
|
79
110
|
/**
|
|
80
111
|
* Setup MCP endpoint routes
|
|
81
112
|
*
|
|
82
113
|
* Why: Single endpoint for POST (client→server) and GET (SSE stream)
|
|
83
114
|
*/
|
|
84
115
|
private setupRoutes;
|
|
116
|
+
private getProfileIssuerUrl;
|
|
117
|
+
private handleOAuthProtectedResource;
|
|
118
|
+
private handleOAuthAuthorize;
|
|
119
|
+
private handleOAuthToken;
|
|
120
|
+
private handleOAuthCallback;
|
|
121
|
+
private handleOAuthAuthorizationServerMetadata;
|
|
122
|
+
private handleOAuthRegister;
|
|
85
123
|
/**
|
|
86
124
|
* Handle metrics endpoint
|
|
87
125
|
*
|
|
@@ -122,6 +160,10 @@ export declare class HttpTransport {
|
|
|
122
160
|
* Returns: { type: 'bearer' | 'oauth' | 'api-token', token: string, sessionId?: string }
|
|
123
161
|
*/
|
|
124
162
|
private extractAuthToken;
|
|
163
|
+
/**
|
|
164
|
+
* Lazy initialization of ToolFilterService
|
|
165
|
+
*/
|
|
166
|
+
private getToolFilterService;
|
|
125
167
|
/**
|
|
126
168
|
* Handle POST requests - Client sending messages to server
|
|
127
169
|
*
|
|
@@ -163,11 +205,13 @@ export declare class HttpTransport {
|
|
|
163
205
|
*
|
|
164
206
|
* Why: Server-initiated requests/notifications
|
|
165
207
|
*/
|
|
166
|
-
sendToClient(sessionId: string, message: unknown): void;
|
|
208
|
+
sendToClient(profileId: string, sessionId: string, message: unknown): void;
|
|
167
209
|
/**
|
|
168
210
|
* Determine message type (request, notification, response)
|
|
169
211
|
*/
|
|
170
212
|
private getMessageType;
|
|
213
|
+
private getFilteringHeaderValue;
|
|
214
|
+
private getToolFilterHeaderValue;
|
|
171
215
|
/**
|
|
172
216
|
* Create new session
|
|
173
217
|
*
|
|
@@ -193,7 +237,7 @@ export declare class HttpTransport {
|
|
|
193
237
|
*
|
|
194
238
|
* Why: Allows MCPServer to cleanup per-session HTTP clients
|
|
195
239
|
*/
|
|
196
|
-
onSessionDestroyed(listener: (sessionId: string) => void): void;
|
|
240
|
+
onSessionDestroyed(listener: (profileId: string, sessionId: string) => void): void;
|
|
197
241
|
/**
|
|
198
242
|
* Notify all listeners about session destruction
|
|
199
243
|
*/
|
|
@@ -219,14 +263,28 @@ export declare class HttpTransport {
|
|
|
219
263
|
*
|
|
220
264
|
* Why public: Allows MCPServer to securely access session tokens without breaking encapsulation
|
|
221
265
|
*/
|
|
222
|
-
getSessionToken(sessionId: string): string | undefined;
|
|
266
|
+
getSessionToken(profileId: string, sessionId: string): string | undefined;
|
|
267
|
+
getSessionFiltering(profileId: string, sessionId: string): Record<string, string[]> | undefined;
|
|
268
|
+
getSessionFilteringHeader(profileId: string, sessionId: string): string | undefined;
|
|
269
|
+
getSessionToolFilterRequest(profileId: string, sessionId: string): SessionToolFilterRequest | undefined;
|
|
270
|
+
getSessionToolFilter(profileId: string, sessionId: string): SessionToolFilter | undefined;
|
|
271
|
+
getSessionToolFilterHeader(profileId: string, sessionId: string): string | undefined;
|
|
272
|
+
setSessionToolFilter(profileId: string, sessionId: string, toolFilter: SessionToolFilter): void;
|
|
273
|
+
recordGlobalToolFilterMetrics(summary: {
|
|
274
|
+
originalCount: number;
|
|
275
|
+
allowedCount: number;
|
|
276
|
+
removedCount: number;
|
|
277
|
+
patternCounts: Record<string, number>;
|
|
278
|
+
}): void;
|
|
279
|
+
recordSessionToolFilterMetrics(sessionId: string, allowedCount: number, request: SessionToolFilterRequest): void;
|
|
280
|
+
recordToolFilterRejection(tool: string, source: 'env' | 'session'): void;
|
|
223
281
|
/**
|
|
224
282
|
* Ensure session has a valid access token, refreshing if necessary
|
|
225
283
|
*
|
|
226
284
|
* Why: Transparently refresh expired OAuth tokens before making API calls
|
|
227
285
|
* Returns true if token is valid (or was successfully refreshed), false otherwise
|
|
228
286
|
*/
|
|
229
|
-
ensureValidSessionToken(sessionId: string): Promise<boolean>;
|
|
287
|
+
ensureValidSessionToken(profileId: string, sessionId: string): Promise<boolean>;
|
|
230
288
|
/**
|
|
231
289
|
* Refresh access token using refresh token
|
|
232
290
|
*
|
|
@@ -237,23 +295,23 @@ export declare class HttpTransport {
|
|
|
237
295
|
/**
|
|
238
296
|
* Set message handler for processing incoming JSON-RPC messages
|
|
239
297
|
*/
|
|
240
|
-
setMessageHandler(handler: (message: unknown, sessionId?: string) => Promise<unknown>): void;
|
|
298
|
+
setMessageHandler(handler: (message: unknown, sessionId?: string, profileId?: string) => Promise<unknown>): void;
|
|
241
299
|
/**
|
|
242
300
|
* Check if OAuth provider is configured
|
|
243
301
|
*/
|
|
244
|
-
hasOAuthProvider(): boolean;
|
|
302
|
+
hasOAuthProvider(profileId?: string): boolean;
|
|
245
303
|
/**
|
|
246
304
|
* Get server URL
|
|
247
305
|
*/
|
|
248
|
-
getServerUrl(): string;
|
|
306
|
+
getServerUrl(profileId?: string): string;
|
|
249
307
|
/**
|
|
250
308
|
* Get OAuth authorization URL
|
|
251
309
|
*/
|
|
252
|
-
getOAuthAuthorizationUrl(): string;
|
|
310
|
+
getOAuthAuthorizationUrl(profileId?: string): string;
|
|
253
311
|
/**
|
|
254
312
|
* Get OAuth scopes
|
|
255
313
|
*/
|
|
256
|
-
getOAuthScopes(): string[];
|
|
314
|
+
getOAuthScopes(profileId?: string): string[];
|
|
257
315
|
/**
|
|
258
316
|
* Start HTTP server
|
|
259
317
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-transport.d.ts","sourceRoot":"","sources":["../../../src/transport/http-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAIV,mBAAmB,EACnB,kBAAkB,EAEnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AA2BtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAc9F,qBAAa,aAAa;IACxB,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,MAAM,CAAsC;IACpD,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,cAAc,CAAiG;IACvH,OAAO,CAAC,sBAAsB,CAA4E;IAC1G,OAAO,CAAC,aAAa,CAA+C;IACpE,OAAO,CAAC,sBAAsB,CAAoC;IAClE,OAAO,CAAC,iCAAiC,CAA0B;IACnE,OAAO,CAAC,oBAAoB,CAAmE;IAC/F,OA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