@mcp-layer/gateway 0.2.0 → 0.2.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/package.json +11 -6
- package/types/call.d.ts +20 -0
- package/types/config/defaults.d.ts +32 -0
- package/types/config/validate.d.ts +46 -0
- package/types/index.d.ts +11 -0
- package/types/map.d.ts +24 -0
- package/types/resilience/breaker.d.ts +21 -0
- package/types/runtime.d.ts +41 -0
- package/types/telemetry/index.d.ts +23 -0
- package/types/validation/safety.d.ts +14 -0
- package/types/validation/trust.d.ts +7 -0
- package/types/validation/validator.d.ts +72 -0
- package/types/version.d.ts +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-layer/gateway",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Shared runtime primitives for MCP HTTP/GraphQL adapters with validation, resilience, telemetry, and catalog mapping.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,8 +18,10 @@
|
|
|
18
18
|
"telemetry"
|
|
19
19
|
],
|
|
20
20
|
"main": "src/index.js",
|
|
21
|
+
"types": "./types/index.d.ts",
|
|
21
22
|
"exports": {
|
|
22
23
|
".": {
|
|
24
|
+
"types": "./types/index.d.ts",
|
|
23
25
|
"import": "./src/index.js",
|
|
24
26
|
"default": "./src/index.js"
|
|
25
27
|
},
|
|
@@ -27,6 +29,7 @@
|
|
|
27
29
|
},
|
|
28
30
|
"files": [
|
|
29
31
|
"src",
|
|
32
|
+
"types",
|
|
30
33
|
"LICENSE"
|
|
31
34
|
],
|
|
32
35
|
"publishConfig": {
|
|
@@ -38,8 +41,8 @@
|
|
|
38
41
|
"json-schema-traverse": "^1.0.0",
|
|
39
42
|
"opossum": "^8.1.0",
|
|
40
43
|
"safe-regex2": "^2.0.0",
|
|
41
|
-
"@mcp-layer/error": "0.2.
|
|
42
|
-
"@mcp-layer/schema": "1.0.
|
|
44
|
+
"@mcp-layer/error": "0.2.1",
|
|
45
|
+
"@mcp-layer/schema": "1.0.3"
|
|
43
46
|
},
|
|
44
47
|
"peerDependencies": {
|
|
45
48
|
"@opentelemetry/api": "^1.9.0"
|
|
@@ -51,10 +54,12 @@
|
|
|
51
54
|
},
|
|
52
55
|
"devDependencies": {
|
|
53
56
|
"fastify": "^5.7.4",
|
|
54
|
-
"@mcp-layer/attach": "1.1.
|
|
55
|
-
"@mcp-layer/
|
|
57
|
+
"@mcp-layer/attach": "1.1.2",
|
|
58
|
+
"@mcp-layer/manager": "0.2.1",
|
|
59
|
+
"@mcp-layer/test-server": "1.0.4"
|
|
56
60
|
},
|
|
57
61
|
"scripts": {
|
|
58
|
-
"
|
|
62
|
+
"build:types": "tsc -p tsconfig.json",
|
|
63
|
+
"test": "node --test --experimental-test-coverage \"./test/**/*.test.js\""
|
|
59
64
|
}
|
|
60
65
|
}
|
package/types/call.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create telemetry helpers for a request lifecycle.
|
|
3
|
+
* @param {{ telemetry: ReturnType<import('./telemetry/index.js').createTelemetry> | null, spanName: string, attributes: Record<string, unknown>, labels: Record<string, string>, validationLabels?: Record<string, string> }} config - Telemetry context.
|
|
4
|
+
* @returns {{ recordValidation: () => void, recordSuccess: () => void, recordError: (error: Error & { code?: string | number }) => void, recordStatus: (status: string, errorType?: string | number) => void, finish: () => void }}
|
|
5
|
+
*/
|
|
6
|
+
export function createCallContext(config: {
|
|
7
|
+
telemetry: ReturnType<typeof import("./telemetry/index.js").createTelemetry> | null;
|
|
8
|
+
spanName: string;
|
|
9
|
+
attributes: Record<string, unknown>;
|
|
10
|
+
labels: Record<string, string>;
|
|
11
|
+
validationLabels?: Record<string, string>;
|
|
12
|
+
}): {
|
|
13
|
+
recordValidation: () => void;
|
|
14
|
+
recordSuccess: () => void;
|
|
15
|
+
recordError: (error: Error & {
|
|
16
|
+
code?: string | number;
|
|
17
|
+
}) => void;
|
|
18
|
+
recordStatus: (status: string, errorType?: string | number) => void;
|
|
19
|
+
finish: () => void;
|
|
20
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build runtime defaults for an adapter.
|
|
3
|
+
* @param {string} serviceName - Default telemetry service name.
|
|
4
|
+
* @returns {{ prefix: string | undefined, validation: { trustSchemas: 'auto' | true | false, maxSchemaDepth: number, maxSchemaSize: number, maxPatternLength: number, maxToolNameLength: number, maxTemplateParamLength: number }, resilience: { enabled: boolean, timeout: number, errorThresholdPercentage: number, resetTimeout: number, volumeThreshold: number }, telemetry: { enabled: boolean, serviceName: string, metricPrefix: string, api?: import('@opentelemetry/api') }, errors: { exposeDetails: boolean } }}
|
|
5
|
+
*/
|
|
6
|
+
export function defaults(serviceName: string): {
|
|
7
|
+
prefix: string | undefined;
|
|
8
|
+
validation: {
|
|
9
|
+
trustSchemas: "auto" | true | false;
|
|
10
|
+
maxSchemaDepth: number;
|
|
11
|
+
maxSchemaSize: number;
|
|
12
|
+
maxPatternLength: number;
|
|
13
|
+
maxToolNameLength: number;
|
|
14
|
+
maxTemplateParamLength: number;
|
|
15
|
+
};
|
|
16
|
+
resilience: {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
timeout: number;
|
|
19
|
+
errorThresholdPercentage: number;
|
|
20
|
+
resetTimeout: number;
|
|
21
|
+
volumeThreshold: number;
|
|
22
|
+
};
|
|
23
|
+
telemetry: {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
serviceName: string;
|
|
26
|
+
metricPrefix: string;
|
|
27
|
+
api?: typeof import("@opentelemetry/api");
|
|
28
|
+
};
|
|
29
|
+
errors: {
|
|
30
|
+
exposeDetails: boolean;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate base runtime options and apply defaults.
|
|
3
|
+
* @param {Record<string, unknown>} opts - User-supplied options.
|
|
4
|
+
* @param {{ name?: string, serviceName?: string }} [meta] - Validation metadata.
|
|
5
|
+
* @returns {{ session: unknown, manager?: { get: (request: import('fastify').FastifyRequest) => Promise<import('@mcp-layer/session').Session>, close?: () => Promise<void> }, prefix?: string | ((version: string, info: Record<string, unknown> | undefined, name: string) => string), validation: { trustSchemas: 'auto' | true | false, maxSchemaDepth: number, maxSchemaSize: number, maxPatternLength: number, maxToolNameLength: number, maxTemplateParamLength: number }, resilience: { enabled: boolean, timeout: number, errorThresholdPercentage: number, resetTimeout: number, volumeThreshold: number }, telemetry: { enabled: boolean, serviceName: string, metricPrefix: string, api?: import('@opentelemetry/api') }, errors: { exposeDetails: boolean }, normalizeError?: (error: Error & { code?: string | number }, instance: string, requestId?: string, options?: { exposeDetails?: boolean }) => unknown }}
|
|
6
|
+
*/
|
|
7
|
+
export function validateRuntimeOptions(opts: Record<string, unknown>, meta?: {
|
|
8
|
+
name?: string;
|
|
9
|
+
serviceName?: string;
|
|
10
|
+
}): {
|
|
11
|
+
session: unknown;
|
|
12
|
+
manager?: {
|
|
13
|
+
get: (request: import("fastify").FastifyRequest) => Promise<any>;
|
|
14
|
+
close?: () => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
prefix?: string | ((version: string, info: Record<string, unknown> | undefined, name: string) => string);
|
|
17
|
+
validation: {
|
|
18
|
+
trustSchemas: "auto" | true | false;
|
|
19
|
+
maxSchemaDepth: number;
|
|
20
|
+
maxSchemaSize: number;
|
|
21
|
+
maxPatternLength: number;
|
|
22
|
+
maxToolNameLength: number;
|
|
23
|
+
maxTemplateParamLength: number;
|
|
24
|
+
};
|
|
25
|
+
resilience: {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
timeout: number;
|
|
28
|
+
errorThresholdPercentage: number;
|
|
29
|
+
resetTimeout: number;
|
|
30
|
+
volumeThreshold: number;
|
|
31
|
+
};
|
|
32
|
+
telemetry: {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
serviceName: string;
|
|
35
|
+
metricPrefix: string;
|
|
36
|
+
api?: typeof import("@opentelemetry/api");
|
|
37
|
+
};
|
|
38
|
+
errors: {
|
|
39
|
+
exposeDetails: boolean;
|
|
40
|
+
};
|
|
41
|
+
normalizeError?: (error: Error & {
|
|
42
|
+
code?: string | number;
|
|
43
|
+
}, instance: string, requestId?: string, options?: {
|
|
44
|
+
exposeDetails?: boolean;
|
|
45
|
+
}) => unknown;
|
|
46
|
+
};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { createRuntime } from "./runtime.js";
|
|
2
|
+
export { createCallContext } from "./call.js";
|
|
3
|
+
export { createTelemetry } from "./telemetry/index.js";
|
|
4
|
+
export { shouldTrustSchemas } from "./validation/trust.js";
|
|
5
|
+
export { checkSchemaSafety } from "./validation/safety.js";
|
|
6
|
+
export { defaults } from "./config/defaults.js";
|
|
7
|
+
export { validateRuntimeOptions } from "./config/validate.js";
|
|
8
|
+
export { createMap, TYPES } from "./map.js";
|
|
9
|
+
export { deriveApiVersion, resolvePrefix } from "./version.js";
|
|
10
|
+
export { createCircuitBreaker, executeWithBreaker } from "./resilience/breaker.js";
|
|
11
|
+
export { createValidator, SchemaValidator } from "./validation/validator.js";
|
package/types/map.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a deterministic catalog map for adapters.
|
|
3
|
+
* @param {{ items?: Array<Record<string, unknown>> }} catalog - Extracted catalog.
|
|
4
|
+
* @returns {{ tools: Array<Record<string, unknown>>, prompts: Array<Record<string, unknown>>, resources: Array<Record<string, unknown>>, templates: Array<Record<string, unknown>>, entries: Array<{ type: string, root: 'query' | 'mutation', name: string, field: string, item: Record<string, unknown> }>, byType: (type: string) => Array<Record<string, unknown>>, find: (type: string, name: string) => Record<string, unknown> | undefined, findField: (type: string, name: string) => string | undefined }}
|
|
5
|
+
*/
|
|
6
|
+
export function createMap(catalog?: {
|
|
7
|
+
items?: Array<Record<string, unknown>>;
|
|
8
|
+
}): {
|
|
9
|
+
tools: Array<Record<string, unknown>>;
|
|
10
|
+
prompts: Array<Record<string, unknown>>;
|
|
11
|
+
resources: Array<Record<string, unknown>>;
|
|
12
|
+
templates: Array<Record<string, unknown>>;
|
|
13
|
+
entries: Array<{
|
|
14
|
+
type: string;
|
|
15
|
+
root: "query" | "mutation";
|
|
16
|
+
name: string;
|
|
17
|
+
field: string;
|
|
18
|
+
item: Record<string, unknown>;
|
|
19
|
+
}>;
|
|
20
|
+
byType: (type: string) => Array<Record<string, unknown>>;
|
|
21
|
+
find: (type: string, name: string) => Record<string, unknown> | undefined;
|
|
22
|
+
findField: (type: string, name: string) => string | undefined;
|
|
23
|
+
};
|
|
24
|
+
export const TYPES: string[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a circuit breaker for an MCP session.
|
|
3
|
+
* @param {import('@mcp-layer/session').Session} session - MCP session.
|
|
4
|
+
* @param {{ timeout: number, errorThresholdPercentage: number, resetTimeout: number, volumeThreshold: number }} config - Breaker configuration.
|
|
5
|
+
* @returns {CircuitBreaker}
|
|
6
|
+
*/
|
|
7
|
+
export function createCircuitBreaker(session: any, config: {
|
|
8
|
+
timeout: number;
|
|
9
|
+
errorThresholdPercentage: number;
|
|
10
|
+
resetTimeout: number;
|
|
11
|
+
volumeThreshold: number;
|
|
12
|
+
}): CircuitBreaker;
|
|
13
|
+
/**
|
|
14
|
+
* Execute an MCP call through a circuit breaker if enabled.
|
|
15
|
+
* @param {CircuitBreaker | null} breaker - Breaker instance or null if disabled.
|
|
16
|
+
* @param {import('@mcp-layer/session').Session} session - MCP session.
|
|
17
|
+
* @param {string} method - MCP method name.
|
|
18
|
+
* @param {Record<string, unknown>} params - MCP parameters.
|
|
19
|
+
* @returns {Promise<Record<string, unknown>>}
|
|
20
|
+
*/
|
|
21
|
+
export function executeWithBreaker(breaker: CircuitBreaker | null, session: any, method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create shared runtime contexts for MCP adapters.
|
|
3
|
+
* @param {Record<string, unknown>} opts - Runtime options.
|
|
4
|
+
* @param {{ name?: string, serviceName?: string }} [meta] - Runtime metadata.
|
|
5
|
+
* @returns {Promise<{ config: ReturnType<typeof validateRuntimeOptions>, contexts: Array<{ session: import('@mcp-layer/session').Session, catalog: { server?: { info?: Record<string, unknown> }, items?: Array<Record<string, unknown>> }, info: Record<string, unknown> | undefined, version: string, prefix: string, validator: import('./validation/validator.js').SchemaValidator, telemetry: ReturnType<typeof createTelemetry> | null, resolve: (request: import('fastify').FastifyRequest) => Promise<{ session: import('@mcp-layer/session').Session, breaker: import('opossum') | null }>, execute: (request: import('fastify').FastifyRequest, method: string, params: Record<string, unknown>) => Promise<Record<string, unknown>>, normalize: (error: Error & { code?: string | number }, instance: string, requestId?: string) => unknown }>, breakers: Map<string, import('opossum')>, normalize: (error: Error & { code?: string | number }, instance: string, requestId?: string) => unknown, close: () => Promise<void> }>}
|
|
6
|
+
*/
|
|
7
|
+
export function createRuntime(opts: Record<string, unknown>, meta?: {
|
|
8
|
+
name?: string;
|
|
9
|
+
serviceName?: string;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
config: ReturnType<typeof validateRuntimeOptions>;
|
|
12
|
+
contexts: Array<{
|
|
13
|
+
session: any;
|
|
14
|
+
catalog: {
|
|
15
|
+
server?: {
|
|
16
|
+
info?: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
items?: Array<Record<string, unknown>>;
|
|
19
|
+
};
|
|
20
|
+
info: Record<string, unknown> | undefined;
|
|
21
|
+
version: string;
|
|
22
|
+
prefix: string;
|
|
23
|
+
validator: import("./validation/validator.js").SchemaValidator;
|
|
24
|
+
telemetry: ReturnType<typeof createTelemetry> | null;
|
|
25
|
+
resolve: (request: import("fastify").FastifyRequest) => Promise<{
|
|
26
|
+
session: any;
|
|
27
|
+
breaker: any | null;
|
|
28
|
+
}>;
|
|
29
|
+
execute: (request: import("fastify").FastifyRequest, method: string, params: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
30
|
+
normalize: (error: Error & {
|
|
31
|
+
code?: string | number;
|
|
32
|
+
}, instance: string, requestId?: string) => unknown;
|
|
33
|
+
}>;
|
|
34
|
+
breakers: Map<string, any>;
|
|
35
|
+
normalize: (error: Error & {
|
|
36
|
+
code?: string | number;
|
|
37
|
+
}, instance: string, requestId?: string) => unknown;
|
|
38
|
+
close: () => Promise<void>;
|
|
39
|
+
}>;
|
|
40
|
+
import { validateRuntimeOptions } from './config/validate.js';
|
|
41
|
+
import { createTelemetry } from './telemetry/index.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a telemetry helper for adapter runtimes.
|
|
3
|
+
* @param {{ enabled?: boolean, serviceName: string, metricPrefix?: string, api?: import('@opentelemetry/api') }} config - Telemetry configuration.
|
|
4
|
+
* @returns {{ tracer: import('@opentelemetry/api').Tracer, meter: import('@opentelemetry/api').Meter, context: import('@opentelemetry/api').ContextAPI, propagation: import('@opentelemetry/api').PropagationAPI, metrics: { callDuration: import('@opentelemetry/api').Histogram, callErrors: import('@opentelemetry/api').Counter, validationErrors: import('@opentelemetry/api').Counter, circuitState: import('@opentelemetry/api').ObservableGauge }, setCircuitState: (session: string, state: string) => void } | null}
|
|
5
|
+
*/
|
|
6
|
+
export function createTelemetry(config: {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
serviceName: string;
|
|
9
|
+
metricPrefix?: string;
|
|
10
|
+
api?: typeof import("@opentelemetry/api");
|
|
11
|
+
}): {
|
|
12
|
+
tracer: import("@opentelemetry/api").Tracer;
|
|
13
|
+
meter: import("@opentelemetry/api").Meter;
|
|
14
|
+
context: import("@opentelemetry/api").ContextAPI;
|
|
15
|
+
propagation: import("@opentelemetry/api").PropagationAPI;
|
|
16
|
+
metrics: {
|
|
17
|
+
callDuration: import("@opentelemetry/api").Histogram;
|
|
18
|
+
callErrors: import("@opentelemetry/api").Counter;
|
|
19
|
+
validationErrors: import("@opentelemetry/api").Counter;
|
|
20
|
+
circuitState: import("@opentelemetry/api").ObservableGauge;
|
|
21
|
+
};
|
|
22
|
+
setCircuitState: (session: string, state: string) => void;
|
|
23
|
+
} | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check a JSON Schema for safety constraints.
|
|
3
|
+
* @param {Record<string, unknown>} schema - JSON Schema to inspect.
|
|
4
|
+
* @param {{ maxSchemaDepth: number, maxSchemaSize: number, maxPatternLength: number }} config - Safety limits.
|
|
5
|
+
* @returns {{ safe: boolean, reason?: string }}
|
|
6
|
+
*/
|
|
7
|
+
export function checkSchemaSafety(schema: Record<string, unknown>, config: {
|
|
8
|
+
maxSchemaDepth: number;
|
|
9
|
+
maxSchemaSize: number;
|
|
10
|
+
maxPatternLength: number;
|
|
11
|
+
}): {
|
|
12
|
+
safe: boolean;
|
|
13
|
+
reason?: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine whether schemas from a session should be trusted.
|
|
3
|
+
* @param {import('@mcp-layer/session').Session} session - MCP session to evaluate.
|
|
4
|
+
* @param {'auto' | true | false} policy - Trust policy.
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
export function shouldTrustSchemas(session: any, policy: "auto" | true | false): boolean;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a schema validator instance.
|
|
3
|
+
* @param {{ trustSchemas: 'auto' | true | false, maxSchemaDepth: number, maxSchemaSize: number, maxPatternLength: number, maxToolNameLength: number, maxTemplateParamLength: number }} config - Validation configuration.
|
|
4
|
+
* @param {import('@mcp-layer/session').Session} session - MCP session.
|
|
5
|
+
* @returns {SchemaValidator}
|
|
6
|
+
*/
|
|
7
|
+
export function createValidator(config: {
|
|
8
|
+
trustSchemas: "auto" | true | false;
|
|
9
|
+
maxSchemaDepth: number;
|
|
10
|
+
maxSchemaSize: number;
|
|
11
|
+
maxPatternLength: number;
|
|
12
|
+
maxToolNameLength: number;
|
|
13
|
+
maxTemplateParamLength: number;
|
|
14
|
+
}, session: any): SchemaValidator;
|
|
15
|
+
/**
|
|
16
|
+
* Schema validator for MCP tool and prompt inputs.
|
|
17
|
+
*/
|
|
18
|
+
export class SchemaValidator {
|
|
19
|
+
/**
|
|
20
|
+
* @param {{ trustSchemas: 'auto' | true | false, maxSchemaDepth: number, maxSchemaSize: number, maxPatternLength: number, maxToolNameLength: number, maxTemplateParamLength: number }} config - Validation configuration.
|
|
21
|
+
* @param {import('@mcp-layer/session').Session} session - MCP session.
|
|
22
|
+
*/
|
|
23
|
+
constructor(config: {
|
|
24
|
+
trustSchemas: "auto" | true | false;
|
|
25
|
+
maxSchemaDepth: number;
|
|
26
|
+
maxSchemaSize: number;
|
|
27
|
+
maxPatternLength: number;
|
|
28
|
+
maxToolNameLength: number;
|
|
29
|
+
maxTemplateParamLength: number;
|
|
30
|
+
}, session: any);
|
|
31
|
+
/**
|
|
32
|
+
* Register a tool schema for validation.
|
|
33
|
+
* @param {string} name - Tool name.
|
|
34
|
+
* @param {Record<string, unknown> | undefined} schema - JSON Schema for input.
|
|
35
|
+
* @returns {{ success: boolean, error?: string, skipped?: boolean, reason?: string }}
|
|
36
|
+
*/
|
|
37
|
+
registerToolSchema(name: string, schema: Record<string, unknown> | undefined): {
|
|
38
|
+
success: boolean;
|
|
39
|
+
error?: string;
|
|
40
|
+
skipped?: boolean;
|
|
41
|
+
reason?: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Register a prompt schema for validation.
|
|
45
|
+
* @param {string} name - Prompt name.
|
|
46
|
+
* @param {Record<string, unknown> | undefined} schema - JSON Schema for input.
|
|
47
|
+
* @returns {{ success: boolean, error?: string, skipped?: boolean, reason?: string }}
|
|
48
|
+
*/
|
|
49
|
+
registerPromptSchema(name: string, schema: Record<string, unknown> | undefined): {
|
|
50
|
+
success: boolean;
|
|
51
|
+
error?: string;
|
|
52
|
+
skipped?: boolean;
|
|
53
|
+
reason?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Validate a request payload against a registered schema.
|
|
57
|
+
* @param {'tool' | 'prompt'} type - Schema type.
|
|
58
|
+
* @param {string} name - Tool or prompt name.
|
|
59
|
+
* @param {unknown} input - Request payload.
|
|
60
|
+
* @returns {{ valid: boolean, errors?: Array<{ path: string, keyword?: string, message?: string, params?: Record<string, unknown> }> }}
|
|
61
|
+
*/
|
|
62
|
+
validate(type: "tool" | "prompt", name: string, input: unknown): {
|
|
63
|
+
valid: boolean;
|
|
64
|
+
errors?: Array<{
|
|
65
|
+
path: string;
|
|
66
|
+
keyword?: string;
|
|
67
|
+
message?: string;
|
|
68
|
+
params?: Record<string, unknown>;
|
|
69
|
+
}>;
|
|
70
|
+
};
|
|
71
|
+
#private;
|
|
72
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive an API version prefix from MCP server info.
|
|
3
|
+
* @param {{ version?: string } | undefined} info - MCP server info object.
|
|
4
|
+
* @returns {string}
|
|
5
|
+
*/
|
|
6
|
+
export function deriveApiVersion(info: {
|
|
7
|
+
version?: string;
|
|
8
|
+
} | undefined): string;
|
|
9
|
+
/**
|
|
10
|
+
* Resolve a route prefix for a runtime context.
|
|
11
|
+
* @param {string | ((version: string, info: Record<string, unknown> | undefined, name: string) => string) | undefined} prefixOption - Prefix option.
|
|
12
|
+
* @param {string} version - API version.
|
|
13
|
+
* @param {Record<string, unknown> | undefined} info - Server info.
|
|
14
|
+
* @param {string} name - Session name.
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*/
|
|
17
|
+
export function resolvePrefix(prefixOption: string | ((version: string, info: Record<string, unknown> | undefined, name: string) => string) | undefined, version: string, info: Record<string, unknown> | undefined, name: string): string;
|