mcp4openapi 0.3.0 → 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/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.map +1 -1
- package/dist/src/auth/oauth-provider.js +5 -2
- package/dist/src/auth/oauth-provider.js.map +1 -1
- 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/composite-executor.d.ts +77 -0
- package/dist/src/composite-executor.d.ts.map +1 -0
- package/dist/src/composite-executor.js +193 -0
- package/dist/src/composite-executor.js.map +1 -0
- package/dist/src/constants.d.ts +85 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +85 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/core/cli-config.d.ts.map +1 -1
- package/dist/src/core/cli-config.js +1 -0
- package/dist/src/core/cli-config.js.map +1 -1
- package/dist/src/core/index.d.ts.map +1 -1
- package/dist/src/core/index.js +1 -0
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/dag-executor.d.ts +49 -0
- package/dist/src/dag-executor.d.ts.map +1 -0
- package/dist/src/dag-executor.js +138 -0
- package/dist/src/dag-executor.js.map +1 -0
- package/dist/src/errors.d.ts +59 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +119 -0
- package/dist/src/errors.js.map +1 -0
- 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 +45 -0
- package/dist/src/generated-schemas.d.ts.map +1 -1
- package/dist/src/generated-schemas.js +3 -0
- package/dist/src/generated-schemas.js.map +1 -1
- package/dist/src/http-client-factory.d.ts +62 -0
- package/dist/src/http-client-factory.d.ts.map +1 -0
- package/dist/src/http-client-factory.js +133 -0
- package/dist/src/http-client-factory.js.map +1 -0
- 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 +316 -0
- package/dist/src/http-transport.d.ts.map +1 -0
- package/dist/src/http-transport.js +2412 -0
- package/dist/src/http-transport.js.map +1 -0
- package/dist/src/index.js +0 -0
- package/dist/src/interceptors.d.ts +116 -0
- package/dist/src/interceptors.d.ts.map +1 -0
- package/dist/src/interceptors.js +392 -0
- package/dist/src/interceptors.js.map +1 -0
- package/dist/src/jsonrpc-validator.d.ts +27 -0
- package/dist/src/jsonrpc-validator.d.ts.map +1 -0
- package/dist/src/jsonrpc-validator.js +58 -0
- package/dist/src/jsonrpc-validator.js.map +1 -0
- package/dist/src/logger.d.ts +59 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +177 -0
- package/dist/src/logger.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 +203 -0
- package/dist/src/mcp-server.d.ts.map +1 -0
- package/dist/src/mcp-server.js +1369 -0
- package/dist/src/mcp-server.js.map +1 -0
- package/dist/src/metrics.d.ts +97 -0
- package/dist/src/metrics.d.ts.map +1 -0
- package/dist/src/metrics.js +273 -0
- package/dist/src/metrics.js.map +1 -0
- package/dist/src/naming-warnings.d.ts +23 -0
- package/dist/src/naming-warnings.d.ts.map +1 -0
- package/dist/src/naming-warnings.js +83 -0
- package/dist/src/naming-warnings.js.map +1 -0
- package/dist/src/naming.d.ts +58 -0
- package/dist/src/naming.d.ts.map +1 -0
- package/dist/src/naming.js +510 -0
- package/dist/src/naming.js.map +1 -0
- package/dist/src/oauth-provider.d.ts +131 -0
- package/dist/src/oauth-provider.d.ts.map +1 -0
- package/dist/src/oauth-provider.js +836 -0
- package/dist/src/oauth-provider.js.map +1 -0
- package/dist/src/openapi/openapi-parser.d.ts.map +1 -1
- package/dist/src/openapi/openapi-parser.js +22 -0
- package/dist/src/openapi/openapi-parser.js.map +1 -1
- package/dist/src/openapi-parser.d.ts +70 -0
- package/dist/src/openapi-parser.d.ts.map +1 -0
- package/dist/src/openapi-parser.js +436 -0
- package/dist/src/openapi-parser.js.map +1 -0
- package/dist/src/profile/profile-loader.d.ts.map +1 -1
- package/dist/src/profile/profile-loader.js +8 -1
- package/dist/src/profile/profile-loader.js.map +1 -1
- package/dist/src/profile/profile-registry.d.ts +2 -1
- package/dist/src/profile/profile-registry.d.ts.map +1 -1
- package/dist/src/profile/profile-registry.js +18 -1
- package/dist/src/profile/profile-registry.js.map +1 -1
- package/dist/src/profile/profile-resolver.d.ts +16 -0
- package/dist/src/profile/profile-resolver.d.ts.map +1 -1
- package/dist/src/profile/profile-resolver.js +120 -0
- package/dist/src/profile/profile-resolver.js.map +1 -1
- package/dist/src/profile-loader.d.ts +78 -0
- package/dist/src/profile-loader.d.ts.map +1 -0
- package/dist/src/profile-loader.js +483 -0
- package/dist/src/profile-loader.js.map +1 -0
- 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 +86 -0
- package/dist/src/proxy-executor.d.ts.map +1 -0
- package/dist/src/proxy-executor.js +497 -0
- package/dist/src/proxy-executor.js.map +1 -0
- package/dist/src/schema-validator.d.ts +30 -0
- package/dist/src/schema-validator.d.ts.map +1 -0
- package/dist/src/schema-validator.js +128 -0
- package/dist/src/schema-validator.js.map +1 -0
- 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/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 +67 -0
- package/dist/src/tool-generator.d.ts.map +1 -0
- package/dist/src/tool-generator.js +182 -0
- package/dist/src/tool-generator.js.map +1 -0
- package/dist/src/tooling/composite-executor.d.ts.map +1 -1
- package/dist/src/tooling/composite-executor.js +7 -2
- package/dist/src/tooling/composite-executor.js.map +1 -1
- package/dist/src/tooling/proxy-executor.d.ts.map +1 -1
- package/dist/src/tooling/proxy-executor.js +4 -0
- package/dist/src/tooling/proxy-executor.js.map +1 -1
- package/dist/src/tooling/tool-generator.d.ts.map +1 -1
- package/dist/src/tooling/tool-generator.js +36 -3
- package/dist/src/tooling/tool-generator.js.map +1 -1
- package/dist/src/transport/http-transport-config.d.ts.map +1 -1
- package/dist/src/transport/http-transport-config.js +1 -0
- package/dist/src/transport/http-transport-config.js.map +1 -1
- package/dist/src/transport/http-transport.d.ts +5 -0
- package/dist/src/transport/http-transport.d.ts.map +1 -1
- package/dist/src/transport/http-transport.js +63 -1
- package/dist/src/transport/http-transport.js.map +1 -1
- 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 +1 -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 +3 -0
- package/dist/src/types/profile.d.ts.map +1 -1
- package/dist/src/validation/validation-utils.d.ts.map +1 -1
- package/dist/src/validation/validation-utils.js +1 -0
- package/dist/src/validation/validation-utils.js.map +1 -1
- package/dist/src/validation-utils.d.ts +49 -0
- package/dist/src/validation-utils.d.ts.map +1 -0
- package/dist/src/validation-utils.js +138 -0
- package/dist/src/validation-utils.js.map +1 -0
- package/html/profile-index.html +386 -0
- package/package.json +2 -1
- package/profile-schema.json +14 -0
- package/profiles/gitlab/developer-profile-oauth.json +1 -1
- package/profiles/gitlab/developer-profile.json +1508 -0
- package/profiles/gitlab/developer-profile.test.json +3432 -0
- package/profiles/n8n/profile-optimized.json +1 -1
- package/profiles/n8n/profile.json +1 -1
- package/profiles/n8n-nodes/profile-nodes.json +1 -1
- package/profiles/semgrep/profile.json +1 -1
- package/profiles/youtrack/profile.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request body schema validator
|
|
3
|
+
*
|
|
4
|
+
* Why: Catch invalid requests before sending to API. Better error messages for users.
|
|
5
|
+
* Validates against OpenAPI schema definitions.
|
|
6
|
+
*/
|
|
7
|
+
import { isEmail, isUri } from './validation-utils.js';
|
|
8
|
+
export class SchemaValidator {
|
|
9
|
+
/**
|
|
10
|
+
* Validate request body against OpenAPI schema
|
|
11
|
+
*
|
|
12
|
+
* Why: Prevents sending malformed requests. OpenAPI schema is the source of truth.
|
|
13
|
+
*/
|
|
14
|
+
validateRequestBody(operation, body) {
|
|
15
|
+
if (!operation.requestBody?.content['application/json']?.schema) {
|
|
16
|
+
return { valid: true };
|
|
17
|
+
}
|
|
18
|
+
const schema = operation.requestBody.content['application/json'].schema;
|
|
19
|
+
const errors = [];
|
|
20
|
+
this.validateAgainstSchema(body, schema, '', errors);
|
|
21
|
+
return {
|
|
22
|
+
valid: errors.length === 0,
|
|
23
|
+
errors: errors.length > 0 ? errors : undefined,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Recursively validate data against schema
|
|
28
|
+
*/
|
|
29
|
+
validateAgainstSchema(data, schema, path, errors) {
|
|
30
|
+
// Null/undefined handling
|
|
31
|
+
if (data === null || data === undefined) {
|
|
32
|
+
if (schema.type && schema.type !== 'null') {
|
|
33
|
+
errors.push({
|
|
34
|
+
path: path || '(root)',
|
|
35
|
+
message: `Expected ${schema.type}, got ${data}`,
|
|
36
|
+
schema,
|
|
37
|
+
value: data,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// Type validation
|
|
43
|
+
if (schema.type) {
|
|
44
|
+
const actualType = Array.isArray(data) ? 'array' : typeof data;
|
|
45
|
+
// OpenAPI 'integer' is a subtype of 'number' with format constraint
|
|
46
|
+
const expectedType = schema.type === 'integer' ? 'number' : schema.type;
|
|
47
|
+
if (actualType !== expectedType) {
|
|
48
|
+
errors.push({
|
|
49
|
+
path: path || '(root)',
|
|
50
|
+
message: `Expected ${schema.type}, got ${actualType}`,
|
|
51
|
+
schema,
|
|
52
|
+
value: data,
|
|
53
|
+
});
|
|
54
|
+
return; // Stop validation if type is wrong
|
|
55
|
+
}
|
|
56
|
+
// Additional integer validation: check it's actually an integer
|
|
57
|
+
if (schema.type === 'integer' && typeof data === 'number') {
|
|
58
|
+
if (!Number.isInteger(data)) {
|
|
59
|
+
errors.push({
|
|
60
|
+
path: path || '(root)',
|
|
61
|
+
message: `Expected integer, got number`,
|
|
62
|
+
schema,
|
|
63
|
+
value: data,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Enum validation
|
|
69
|
+
// Note: Using 'as any' here is safe - we're checking if value exists in enum array
|
|
70
|
+
// TypeScript doesn't know the enum values at compile time
|
|
71
|
+
if (schema.enum && !schema.enum.includes(data)) {
|
|
72
|
+
errors.push({
|
|
73
|
+
path: path || '(root)',
|
|
74
|
+
message: `Value must be one of: ${schema.enum.join(', ')}`,
|
|
75
|
+
schema,
|
|
76
|
+
value: data,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Object properties validation
|
|
80
|
+
if (schema.type === 'object' && schema.properties) {
|
|
81
|
+
const obj = data;
|
|
82
|
+
// Check required properties
|
|
83
|
+
for (const required of schema.required || []) {
|
|
84
|
+
if (obj[required] === undefined) {
|
|
85
|
+
errors.push({
|
|
86
|
+
path: path ? `${path}.${required}` : required,
|
|
87
|
+
message: 'Required property is missing',
|
|
88
|
+
schema,
|
|
89
|
+
value: undefined,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Validate each property
|
|
94
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
95
|
+
if (schema.properties[key]) {
|
|
96
|
+
this.validateAgainstSchema(value, schema.properties[key], path ? `${path}.${key}` : key, errors);
|
|
97
|
+
}
|
|
98
|
+
// Note: Not validating additionalProperties (too strict for most APIs)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Array items validation
|
|
102
|
+
if (schema.type === 'array' && schema.items && Array.isArray(data)) {
|
|
103
|
+
data.forEach((item, index) => {
|
|
104
|
+
this.validateAgainstSchema(item, schema.items, `${path}[${index}]`, errors);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
// String format validation (basic)
|
|
108
|
+
if (schema.type === 'string' && schema.format && typeof data === 'string') {
|
|
109
|
+
if (schema.format === 'email' && !isEmail(data)) {
|
|
110
|
+
errors.push({
|
|
111
|
+
path: path || '(root)',
|
|
112
|
+
message: 'Invalid email format',
|
|
113
|
+
schema,
|
|
114
|
+
value: data,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (schema.format === 'uri' && !isUri(data)) {
|
|
118
|
+
errors.push({
|
|
119
|
+
path: path || '(root)',
|
|
120
|
+
message: 'Invalid URI format',
|
|
121
|
+
schema,
|
|
122
|
+
value: data,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=schema-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-validator.js","sourceRoot":"","sources":["../../src/schema-validator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAcvD,MAAM,OAAO,eAAe;IAC1B;;;;OAIG;IACH,mBAAmB,CACjB,SAAwB,EACxB,IAA6B;QAE7B,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;YAChE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAED,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC;QACxE,MAAM,MAAM,GAAsB,EAAE,CAAC;QAErC,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAErD,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SAC/C,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,qBAAqB,CAC3B,IAAa,EACb,MAAkB,EAClB,IAAY,EACZ,MAAyB;QAEzB,0BAA0B;QAC1B,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACxC,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBAC1C,MAAM,CAAC,IAA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,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACnE,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBAC3B,IAAI,CAAC,qBAAqB,CACxB,IAAI,EACJ,MAAM,CAAC,KAAM,EACb,GAAG,IAAI,IAAI,KAAK,GAAG,EACnB,MAAM,CACP,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;QAED,mCAAmC;QACnC,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC1E,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChD,MAAM,CAAC,IAAI,CAAC;oBACV,IAAI,EAAE,IAAI,IAAI,QAAQ;oBACtB,OAAO,EAAE,sBAAsB;oBAC/B,MAAM;oBACN,KAAK,EAAE,IAAI;iBACZ,CAAC,CAAC;YACL,CAAC;YACD,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5C,MAAM,CAAC,IAAI,CAAC;oBACV,IAAI,EAAE,IAAI,IAAI,QAAQ;oBACtB,OAAO,EAAE,oBAAoB;oBAC7B,MAAM;oBACN,KAAK,EAAE,IAAI;iBACZ,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CAEF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ResolvedProfile } from './profile-resolver.js';
|
|
2
|
+
interface StartupProfileOptions {
|
|
3
|
+
specPathEnv?: string;
|
|
4
|
+
profilePath?: string;
|
|
5
|
+
profileId?: string;
|
|
6
|
+
profilesDir?: string;
|
|
7
|
+
}
|
|
8
|
+
interface StartupProfileResult {
|
|
9
|
+
specPath?: string;
|
|
10
|
+
profilePath?: string;
|
|
11
|
+
profileId?: string;
|
|
12
|
+
defaultProfile?: ResolvedProfile;
|
|
13
|
+
hasExplicitSpecPath: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function resolveStartupProfile(options: StartupProfileOptions): Promise<StartupProfileResult>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=startup-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup-profile.d.ts","sourceRoot":"","sources":["../../src/startup-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEzG,UAAU,qBAAqB;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA4BzG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { resolveProfileById, resolveProfileFromPath } from './profile-resolver.js';
|
|
2
|
+
export async function resolveStartupProfile(options) {
|
|
3
|
+
const hasExplicitSpecPath = !!options.specPathEnv;
|
|
4
|
+
let specPath = options.specPathEnv;
|
|
5
|
+
let profilePath = options.profilePath;
|
|
6
|
+
let profileId = options.profileId;
|
|
7
|
+
let defaultProfile;
|
|
8
|
+
if (!profilePath && profileId) {
|
|
9
|
+
const resolved = await resolveProfileById(profileId, options.profilesDir, { specPathOverride: specPath });
|
|
10
|
+
defaultProfile = resolved;
|
|
11
|
+
profilePath = resolved.profilePath;
|
|
12
|
+
profileId = resolved.profileId;
|
|
13
|
+
specPath = resolved.specPath;
|
|
14
|
+
}
|
|
15
|
+
else if (profilePath) {
|
|
16
|
+
const resolved = await resolveProfileFromPath(profilePath, { specPathOverride: specPath });
|
|
17
|
+
defaultProfile = resolved;
|
|
18
|
+
profilePath = resolved.profilePath;
|
|
19
|
+
profileId = resolved.profileId;
|
|
20
|
+
specPath = resolved.specPath;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
specPath,
|
|
24
|
+
profilePath,
|
|
25
|
+
profileId,
|
|
26
|
+
defaultProfile,
|
|
27
|
+
hasExplicitSpecPath,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=startup-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup-profile.js","sourceRoot":"","sources":["../../src/startup-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAwB,MAAM,uBAAuB,CAAC;AAiBzG,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAA8B;IACxE,MAAM,mBAAmB,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;IAClD,IAAI,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC;IACnC,IAAI,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACtC,IAAI,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAClC,IAAI,cAA2C,CAAC;IAEhD,IAAI,CAAC,WAAW,IAAI,SAAS,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1G,cAAc,GAAG,QAAQ,CAAC;QAC1B,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;QACnC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;QAC/B,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;IAC/B,CAAC;SAAM,IAAI,WAAW,EAAE,CAAC;QACvB,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC,WAAW,EAAE,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC3F,cAAc,GAAG,QAAQ,CAAC;QAC1B,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;QACnC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;QAC/B,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED,OAAO;QACL,QAAQ;QACR,WAAW;QACX,SAAS;QACT,cAAc;QACd,mBAAmB;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Startup validation helpers for CLI.
|
|
3
|
+
*/
|
|
4
|
+
export declare const HTTP_PROFILE_ROUTING_ERROR: string;
|
|
5
|
+
export declare function getHttpProfileRoutingErrorMessage(options: {
|
|
6
|
+
transport: string;
|
|
7
|
+
profileRoutingEnabled: boolean;
|
|
8
|
+
hasDefaultProfile: boolean;
|
|
9
|
+
hasSpecPath: boolean;
|
|
10
|
+
}): string | null;
|
|
11
|
+
//# sourceMappingURL=startup-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup-validation.d.ts","sourceRoot":"","sources":["../../src/startup-validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,0BAA0B,QAEkG,CAAC;AAE1I,wBAAgB,iCAAiC,CAAC,OAAO,EAAE;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE,OAAO,CAAC;CACtB,GAAG,MAAM,GAAG,IAAI,CAchB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Startup validation helpers for CLI.
|
|
3
|
+
*/
|
|
4
|
+
export const HTTP_PROFILE_ROUTING_ERROR = 'HTTP profile routing is disabled and no default profile is configured.\n' +
|
|
5
|
+
'Set MCP4_HTTP_PROFILE_ROUTING=true to enable /profile/:id/mcp routes, or provide MCP4_PROFILE_PATH (or --profile-path) to serve /mcp.';
|
|
6
|
+
export function getHttpProfileRoutingErrorMessage(options) {
|
|
7
|
+
if (options.transport !== 'http') {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
if (options.hasDefaultProfile) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (options.hasSpecPath) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (options.profileRoutingEnabled) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return HTTP_PROFILE_ROUTING_ERROR;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=startup-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup-validation.js","sourceRoot":"","sources":["../../src/startup-validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,0BAA0B,GACrC,0EAA0E;IAC1E,uIAAuI,CAAC;AAE1I,MAAM,UAAU,iCAAiC,CAAC,OAKjD;IACC,IAAI,OAAO,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,0BAA0B,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ToolDefinition } from './types/profile.js';
|
|
2
|
+
import type { OperationInfo } from './types/openapi.js';
|
|
3
|
+
export interface ToolFilterConfig {
|
|
4
|
+
allowList: Set<string>;
|
|
5
|
+
denyList: Set<string>;
|
|
6
|
+
allowRegex: RegExp[];
|
|
7
|
+
denyRegex: RegExp[];
|
|
8
|
+
allowCategories: Set<'list' | 'read'>;
|
|
9
|
+
hasAllowRules: boolean;
|
|
10
|
+
sources: {
|
|
11
|
+
allowList: string[];
|
|
12
|
+
allowRegex: string[];
|
|
13
|
+
denyList: string[];
|
|
14
|
+
denyRegex: string[];
|
|
15
|
+
allowCategories: string[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface ToolFilterResult {
|
|
19
|
+
allowed: ToolDefinition[];
|
|
20
|
+
removed: ToolDefinition[];
|
|
21
|
+
reasons: Map<string, string[]>;
|
|
22
|
+
}
|
|
23
|
+
export interface SessionToolFilterRequest {
|
|
24
|
+
exactNames: Set<string>;
|
|
25
|
+
regexPatterns: RegExp[];
|
|
26
|
+
allowComposite: {
|
|
27
|
+
allowList: boolean;
|
|
28
|
+
allowRead: boolean;
|
|
29
|
+
};
|
|
30
|
+
normalizedHeader: string;
|
|
31
|
+
rawEntries: string[];
|
|
32
|
+
hasRules: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface SessionToolFilter {
|
|
35
|
+
allowedToolNames: Set<string>;
|
|
36
|
+
reasons: Map<string, string[]>;
|
|
37
|
+
patterns: {
|
|
38
|
+
allow: RegExp[];
|
|
39
|
+
};
|
|
40
|
+
allowComposite: {
|
|
41
|
+
allowList: boolean;
|
|
42
|
+
allowRead: boolean;
|
|
43
|
+
};
|
|
44
|
+
normalizedHeader: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ToolFilterOperationResolver {
|
|
47
|
+
getOperationById?: (operationId: string) => OperationInfo | undefined;
|
|
48
|
+
getOperationForCall?: (call: string) => OperationInfo | undefined;
|
|
49
|
+
}
|
|
50
|
+
export declare function normalizeToolName(name: string): string;
|
|
51
|
+
export declare function normalizeToolFilterHeaderValue(value?: string): string | undefined;
|
|
52
|
+
export declare function parseToolFilterConfig(env: NodeJS.ProcessEnv): ToolFilterConfig | undefined;
|
|
53
|
+
export declare function parseSessionToolFilterHeader(headerValue: string, maxEntries?: number): SessionToolFilterRequest;
|
|
54
|
+
export declare function applyToolFilter(tools: ToolDefinition[], config: ToolFilterConfig, resolver?: ToolFilterOperationResolver): ToolFilterResult;
|
|
55
|
+
export declare function applySessionToolFilter(tools: ToolDefinition[], request: SessionToolFilterRequest, resolver?: ToolFilterOperationResolver): SessionToolFilter;
|
|
56
|
+
export declare function detectListReadOperations(tool: ToolDefinition, resolver?: ToolFilterOperationResolver): {
|
|
57
|
+
isList: boolean;
|
|
58
|
+
isRead: boolean;
|
|
59
|
+
};
|
|
60
|
+
export declare function validateRegexPattern(pattern: string): {
|
|
61
|
+
valid: boolean;
|
|
62
|
+
error?: string;
|
|
63
|
+
};
|
|
64
|
+
export declare function getSessionToolFilterMaxEntries(): number;
|
|
65
|
+
//# sourceMappingURL=tool-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-filter.d.ts","sourceRoot":"","sources":["../../src/tool-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOxD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACtC,aAAa,EAAE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