@orkestrel/mcp 0.0.35 → 0.0.37
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/core/index.cjs +50 -6
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +52 -1
- package/dist/src/core/index.d.ts +52 -1
- package/dist/src/core/index.js +50 -7
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +81 -34
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +58 -23
- package/dist/src/server/index.d.ts +58 -23
- package/dist/src/server/index.js +84 -38
- package/dist/src/server/index.js.map +1 -1
- package/package.json +9 -9
|
@@ -2208,6 +2208,24 @@ export declare function isMCPVersion(value: unknown): value is MCPVersion;
|
|
|
2208
2208
|
*/
|
|
2209
2209
|
export declare function isModernRequest(value: unknown): value is JSONRPCInvocation;
|
|
2210
2210
|
|
|
2211
|
+
/**
|
|
2212
|
+
* Determines whether a parsed value is a legacy MCP `ping` request.
|
|
2213
|
+
*
|
|
2214
|
+
* @remarks
|
|
2215
|
+
* Requires a valid request id and excludes the modern per-request wire shape.
|
|
2216
|
+
* Notifications and hostile or malformed values return false.
|
|
2217
|
+
*
|
|
2218
|
+
* @param value - The already-parsed value to test
|
|
2219
|
+
* @returns True if `value` is a legacy `ping` request; false otherwise
|
|
2220
|
+
*
|
|
2221
|
+
* @example
|
|
2222
|
+
* ```ts
|
|
2223
|
+
* isPingRequest({ jsonrpc: '2.0', method: 'ping', id: 1 }) // true
|
|
2224
|
+
* isPingRequest({ jsonrpc: '2.0', method: 'ping' }) // false
|
|
2225
|
+
* ```
|
|
2226
|
+
*/
|
|
2227
|
+
export declare function isPingRequest(value: unknown): value is JSONRPCRequest;
|
|
2228
|
+
|
|
2211
2229
|
/**
|
|
2212
2230
|
* Determines whether a value is one RFC 3339 `full-date` naming a real calendar day.
|
|
2213
2231
|
*
|
|
@@ -2297,6 +2315,8 @@ export declare const JSONRPC_PARSE_ERROR = -32700;
|
|
|
2297
2315
|
* Retained for the legacy branch alone. A modern fault answers
|
|
2298
2316
|
* {@link JSONRPC_INTERNAL_ERROR}; this code survives only where an old-wire peer was
|
|
2299
2317
|
* already characterized against it.
|
|
2318
|
+
* A `handshake` hook that rejects with an `MCPError` answers the legacy `initialize`
|
|
2319
|
+
* with that error's own code and data.
|
|
2300
2320
|
*/
|
|
2301
2321
|
export declare const JSONRPC_SERVER_ERROR = -32000;
|
|
2302
2322
|
|
|
@@ -3466,6 +3486,19 @@ export declare interface MCPExecutionContext {
|
|
|
3466
3486
|
/** Executes one canonical tool call or returns a fully formed complete MCP result. */
|
|
3467
3487
|
export declare type MCPExecutionHandler = (context: MCPExecutionContext) => ToolResult | MCPCallResult | Promise<ToolResult | MCPCallResult>;
|
|
3468
3488
|
|
|
3489
|
+
/**
|
|
3490
|
+
* Gates a legacy `initialize` response on consumer readiness.
|
|
3491
|
+
*
|
|
3492
|
+
* @remarks
|
|
3493
|
+
* Only legacy initialization awaits this hook. An `MCPError` rejection preserves its
|
|
3494
|
+
* code, message, and context; another rejection emits `error` and answers `Server error`.
|
|
3495
|
+
* Observe `options.signal` to stop when the request ends.
|
|
3496
|
+
*
|
|
3497
|
+
* @param options - The resolved request lifetime and optional caller context
|
|
3498
|
+
* @returns Completion when initialization may answer
|
|
3499
|
+
*/
|
|
3500
|
+
export declare type MCPHandshakeHandler = (options: MCPMethodOptions) => Promise<void>;
|
|
3501
|
+
|
|
3469
3502
|
/**
|
|
3470
3503
|
* Represents one `x-mcp-header` projection a tool's `inputSchema` declares.
|
|
3471
3504
|
*
|
|
@@ -3540,10 +3573,18 @@ export declare interface MCPInputContext {
|
|
|
3540
3573
|
*/
|
|
3541
3574
|
export declare type MCPInputHandler = (context: MCPInputContext, options: MCPMethodOptions) => MCPInputRound | undefined | Promise<MCPInputRound | undefined>;
|
|
3542
3575
|
|
|
3543
|
-
/**
|
|
3576
|
+
/**
|
|
3577
|
+
* Configures the consumer policy for the server's multi-round-trip input mechanism.
|
|
3578
|
+
* The injected clock is trusted and must return finite epoch milliseconds.
|
|
3579
|
+
*/
|
|
3544
3580
|
export declare interface MCPInputOptions {
|
|
3545
3581
|
/** Holds the host-neutral integrity/storage port for the opaque continuation carrier. */
|
|
3546
3582
|
readonly continuation: MCPContinuationInterface;
|
|
3583
|
+
/**
|
|
3584
|
+
* Supplies epoch milliseconds for continuation expiry checks.
|
|
3585
|
+
* The injected clock is trusted and must return finite epoch milliseconds. Default: `Date.now`.
|
|
3586
|
+
*/
|
|
3587
|
+
readonly clock?: () => number;
|
|
3547
3588
|
/**
|
|
3548
3589
|
* Sets the continuation lifetime in milliseconds; required so MCP never invents an expiry policy.
|
|
3549
3590
|
*/
|
|
@@ -3758,6 +3799,8 @@ export declare interface MCPLegacyOptions {
|
|
|
3758
3799
|
readonly dispatcher: MCPDispatcherInterface;
|
|
3759
3800
|
/** Holds the identity returned by the legacy `initialize` handshake. */
|
|
3760
3801
|
readonly identity: MCPIdentity;
|
|
3802
|
+
/** Holds the optional readiness hook awaited before the initialization result. */
|
|
3803
|
+
readonly handshake?: MCPHandshakeHandler;
|
|
3761
3804
|
}
|
|
3762
3805
|
|
|
3763
3806
|
/**
|
|
@@ -4668,6 +4711,7 @@ export declare class MCPServer implements MCPServerInterface {
|
|
|
4668
4711
|
constructor(options: MCPServerOptions);
|
|
4669
4712
|
get emitter(): EmitterInterface<MCPServerEventMap>;
|
|
4670
4713
|
get identity(): MCPIdentity;
|
|
4714
|
+
get handshake(): MCPHandshakeHandler | undefined;
|
|
4671
4715
|
get methods(): MCPMethodManagerInterface;
|
|
4672
4716
|
get limit(): Required<MCPLimitOptions>;
|
|
4673
4717
|
dispatch(request: JSONRPCRequest, options?: MCPDispatchOptions): Promise<JSONRPCResponse | MCPStreamControllerInterface>;
|
|
@@ -4782,6 +4826,8 @@ export declare type MCPServerEventMap = {
|
|
|
4782
4826
|
*/
|
|
4783
4827
|
export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
4784
4828
|
readonly identity: MCPIdentity;
|
|
4829
|
+
/** Holds the readiness hook consumed by the legacy decorator. */
|
|
4830
|
+
readonly handshake: MCPHandshakeHandler | undefined;
|
|
4785
4831
|
/** Holds the modern method registry this server dispatches through (built-ins included). */
|
|
4786
4832
|
readonly methods: MCPMethodManagerInterface;
|
|
4787
4833
|
/**
|
|
@@ -4865,6 +4911,9 @@ export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
|
4865
4911
|
*
|
|
4866
4912
|
* @remarks
|
|
4867
4913
|
* `identity` identifies the server in the `initialize` handshake (`serverInfo`).
|
|
4914
|
+
* `handshake` is the optional readiness hook that the legacy decorator awaits before
|
|
4915
|
+
* answering `initialize`; it receives the request signal and optional caller context.
|
|
4916
|
+
* The hook must observe the signal to stop pending work. Other methods do not await it.
|
|
4868
4917
|
* `tools` is the live registry the server dispatches `tools/list` / `tools/call`
|
|
4869
4918
|
* over — its `definitions()` advertise the tools and its `execute()` runs a call
|
|
4870
4919
|
* (the manager already isolates a tool throw into a `success: false` result, so
|
|
@@ -4891,6 +4940,8 @@ export declare interface MCPServerOptions {
|
|
|
4891
4940
|
/** Holds the emitter's listener-error handler — a listener throw routes here, not to a domain event. */
|
|
4892
4941
|
readonly error?: EmitterErrorHandler;
|
|
4893
4942
|
readonly identity: MCPIdentity;
|
|
4943
|
+
/** Holds the optional readiness hook awaited only by legacy initialization. */
|
|
4944
|
+
readonly handshake?: MCPHandshakeHandler;
|
|
4894
4945
|
/** Holds the live tool registry the server exposes over `tools/list` / `tools/call`. */
|
|
4895
4946
|
readonly tools: ToolManagerInterface;
|
|
4896
4947
|
/**
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -2208,6 +2208,24 @@ export declare function isMCPVersion(value: unknown): value is MCPVersion;
|
|
|
2208
2208
|
*/
|
|
2209
2209
|
export declare function isModernRequest(value: unknown): value is JSONRPCInvocation;
|
|
2210
2210
|
|
|
2211
|
+
/**
|
|
2212
|
+
* Determines whether a parsed value is a legacy MCP `ping` request.
|
|
2213
|
+
*
|
|
2214
|
+
* @remarks
|
|
2215
|
+
* Requires a valid request id and excludes the modern per-request wire shape.
|
|
2216
|
+
* Notifications and hostile or malformed values return false.
|
|
2217
|
+
*
|
|
2218
|
+
* @param value - The already-parsed value to test
|
|
2219
|
+
* @returns True if `value` is a legacy `ping` request; false otherwise
|
|
2220
|
+
*
|
|
2221
|
+
* @example
|
|
2222
|
+
* ```ts
|
|
2223
|
+
* isPingRequest({ jsonrpc: '2.0', method: 'ping', id: 1 }) // true
|
|
2224
|
+
* isPingRequest({ jsonrpc: '2.0', method: 'ping' }) // false
|
|
2225
|
+
* ```
|
|
2226
|
+
*/
|
|
2227
|
+
export declare function isPingRequest(value: unknown): value is JSONRPCRequest;
|
|
2228
|
+
|
|
2211
2229
|
/**
|
|
2212
2230
|
* Determines whether a value is one RFC 3339 `full-date` naming a real calendar day.
|
|
2213
2231
|
*
|
|
@@ -2297,6 +2315,8 @@ export declare const JSONRPC_PARSE_ERROR = -32700;
|
|
|
2297
2315
|
* Retained for the legacy branch alone. A modern fault answers
|
|
2298
2316
|
* {@link JSONRPC_INTERNAL_ERROR}; this code survives only where an old-wire peer was
|
|
2299
2317
|
* already characterized against it.
|
|
2318
|
+
* A `handshake` hook that rejects with an `MCPError` answers the legacy `initialize`
|
|
2319
|
+
* with that error's own code and data.
|
|
2300
2320
|
*/
|
|
2301
2321
|
export declare const JSONRPC_SERVER_ERROR = -32000;
|
|
2302
2322
|
|
|
@@ -3466,6 +3486,19 @@ export declare interface MCPExecutionContext {
|
|
|
3466
3486
|
/** Executes one canonical tool call or returns a fully formed complete MCP result. */
|
|
3467
3487
|
export declare type MCPExecutionHandler = (context: MCPExecutionContext) => ToolResult | MCPCallResult | Promise<ToolResult | MCPCallResult>;
|
|
3468
3488
|
|
|
3489
|
+
/**
|
|
3490
|
+
* Gates a legacy `initialize` response on consumer readiness.
|
|
3491
|
+
*
|
|
3492
|
+
* @remarks
|
|
3493
|
+
* Only legacy initialization awaits this hook. An `MCPError` rejection preserves its
|
|
3494
|
+
* code, message, and context; another rejection emits `error` and answers `Server error`.
|
|
3495
|
+
* Observe `options.signal` to stop when the request ends.
|
|
3496
|
+
*
|
|
3497
|
+
* @param options - The resolved request lifetime and optional caller context
|
|
3498
|
+
* @returns Completion when initialization may answer
|
|
3499
|
+
*/
|
|
3500
|
+
export declare type MCPHandshakeHandler = (options: MCPMethodOptions) => Promise<void>;
|
|
3501
|
+
|
|
3469
3502
|
/**
|
|
3470
3503
|
* Represents one `x-mcp-header` projection a tool's `inputSchema` declares.
|
|
3471
3504
|
*
|
|
@@ -3540,10 +3573,18 @@ export declare interface MCPInputContext {
|
|
|
3540
3573
|
*/
|
|
3541
3574
|
export declare type MCPInputHandler = (context: MCPInputContext, options: MCPMethodOptions) => MCPInputRound | undefined | Promise<MCPInputRound | undefined>;
|
|
3542
3575
|
|
|
3543
|
-
/**
|
|
3576
|
+
/**
|
|
3577
|
+
* Configures the consumer policy for the server's multi-round-trip input mechanism.
|
|
3578
|
+
* The injected clock is trusted and must return finite epoch milliseconds.
|
|
3579
|
+
*/
|
|
3544
3580
|
export declare interface MCPInputOptions {
|
|
3545
3581
|
/** Holds the host-neutral integrity/storage port for the opaque continuation carrier. */
|
|
3546
3582
|
readonly continuation: MCPContinuationInterface;
|
|
3583
|
+
/**
|
|
3584
|
+
* Supplies epoch milliseconds for continuation expiry checks.
|
|
3585
|
+
* The injected clock is trusted and must return finite epoch milliseconds. Default: `Date.now`.
|
|
3586
|
+
*/
|
|
3587
|
+
readonly clock?: () => number;
|
|
3547
3588
|
/**
|
|
3548
3589
|
* Sets the continuation lifetime in milliseconds; required so MCP never invents an expiry policy.
|
|
3549
3590
|
*/
|
|
@@ -3758,6 +3799,8 @@ export declare interface MCPLegacyOptions {
|
|
|
3758
3799
|
readonly dispatcher: MCPDispatcherInterface;
|
|
3759
3800
|
/** Holds the identity returned by the legacy `initialize` handshake. */
|
|
3760
3801
|
readonly identity: MCPIdentity;
|
|
3802
|
+
/** Holds the optional readiness hook awaited before the initialization result. */
|
|
3803
|
+
readonly handshake?: MCPHandshakeHandler;
|
|
3761
3804
|
}
|
|
3762
3805
|
|
|
3763
3806
|
/**
|
|
@@ -4668,6 +4711,7 @@ export declare class MCPServer implements MCPServerInterface {
|
|
|
4668
4711
|
constructor(options: MCPServerOptions);
|
|
4669
4712
|
get emitter(): EmitterInterface<MCPServerEventMap>;
|
|
4670
4713
|
get identity(): MCPIdentity;
|
|
4714
|
+
get handshake(): MCPHandshakeHandler | undefined;
|
|
4671
4715
|
get methods(): MCPMethodManagerInterface;
|
|
4672
4716
|
get limit(): Required<MCPLimitOptions>;
|
|
4673
4717
|
dispatch(request: JSONRPCRequest, options?: MCPDispatchOptions): Promise<JSONRPCResponse | MCPStreamControllerInterface>;
|
|
@@ -4782,6 +4826,8 @@ export declare type MCPServerEventMap = {
|
|
|
4782
4826
|
*/
|
|
4783
4827
|
export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
4784
4828
|
readonly identity: MCPIdentity;
|
|
4829
|
+
/** Holds the readiness hook consumed by the legacy decorator. */
|
|
4830
|
+
readonly handshake: MCPHandshakeHandler | undefined;
|
|
4785
4831
|
/** Holds the modern method registry this server dispatches through (built-ins included). */
|
|
4786
4832
|
readonly methods: MCPMethodManagerInterface;
|
|
4787
4833
|
/**
|
|
@@ -4865,6 +4911,9 @@ export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
|
4865
4911
|
*
|
|
4866
4912
|
* @remarks
|
|
4867
4913
|
* `identity` identifies the server in the `initialize` handshake (`serverInfo`).
|
|
4914
|
+
* `handshake` is the optional readiness hook that the legacy decorator awaits before
|
|
4915
|
+
* answering `initialize`; it receives the request signal and optional caller context.
|
|
4916
|
+
* The hook must observe the signal to stop pending work. Other methods do not await it.
|
|
4868
4917
|
* `tools` is the live registry the server dispatches `tools/list` / `tools/call`
|
|
4869
4918
|
* over — its `definitions()` advertise the tools and its `execute()` runs a call
|
|
4870
4919
|
* (the manager already isolates a tool throw into a `success: false` result, so
|
|
@@ -4891,6 +4940,8 @@ export declare interface MCPServerOptions {
|
|
|
4891
4940
|
/** Holds the emitter's listener-error handler — a listener throw routes here, not to a domain event. */
|
|
4892
4941
|
readonly error?: EmitterErrorHandler;
|
|
4893
4942
|
readonly identity: MCPIdentity;
|
|
4943
|
+
/** Holds the optional readiness hook awaited only by legacy initialization. */
|
|
4944
|
+
readonly handshake?: MCPHandshakeHandler;
|
|
4894
4945
|
/** Holds the live tool registry the server exposes over `tools/list` / `tools/call`. */
|
|
4895
4946
|
readonly tools: ToolManagerInterface;
|
|
4896
4947
|
/**
|
package/dist/src/core/index.js
CHANGED
|
@@ -248,6 +248,8 @@ var JSONRPC_INTERNAL_ERROR = -32603;
|
|
|
248
248
|
* Retained for the legacy branch alone. A modern fault answers
|
|
249
249
|
* {@link JSONRPC_INTERNAL_ERROR}; this code survives only where an old-wire peer was
|
|
250
250
|
* already characterized against it.
|
|
251
|
+
* A `handshake` hook that rejects with an `MCPError` answers the legacy `initialize`
|
|
252
|
+
* with that error's own code and data.
|
|
251
253
|
*/
|
|
252
254
|
var JSONRPC_SERVER_ERROR = -32e3;
|
|
253
255
|
/**
|
|
@@ -4112,6 +4114,26 @@ function isInitializeRequest(value) {
|
|
|
4112
4114
|
return owned.success && isJSONRPCInvocation(owned.value) && owned.value["method"] === "initialize";
|
|
4113
4115
|
}
|
|
4114
4116
|
/**
|
|
4117
|
+
* Determines whether a parsed value is a legacy MCP `ping` request.
|
|
4118
|
+
*
|
|
4119
|
+
* @remarks
|
|
4120
|
+
* Requires a valid request id and excludes the modern per-request wire shape.
|
|
4121
|
+
* Notifications and hostile or malformed values return false.
|
|
4122
|
+
*
|
|
4123
|
+
* @param value - The already-parsed value to test
|
|
4124
|
+
* @returns True if `value` is a legacy `ping` request; false otherwise
|
|
4125
|
+
*
|
|
4126
|
+
* @example
|
|
4127
|
+
* ```ts
|
|
4128
|
+
* isPingRequest({ jsonrpc: '2.0', method: 'ping', id: 1 }) // true
|
|
4129
|
+
* isPingRequest({ jsonrpc: '2.0', method: 'ping' }) // false
|
|
4130
|
+
* ```
|
|
4131
|
+
*/
|
|
4132
|
+
function isPingRequest(value) {
|
|
4133
|
+
const owned = attempt(() => cloneJSONRecord(value));
|
|
4134
|
+
return owned.success && isJSONRPCRequest(owned.value) && owned.value.method === "ping" && !isModernRequest(owned.value);
|
|
4135
|
+
}
|
|
4136
|
+
/**
|
|
4115
4137
|
* Determines whether a JSON-RPC invocation uses the modern per-request MCP wire shape.
|
|
4116
4138
|
*
|
|
4117
4139
|
* @remarks
|
|
@@ -4751,6 +4773,23 @@ var MCPLegacy = class {
|
|
|
4751
4773
|
}) === void 0) return buildJSONRPCError(void 0, JSONRPC_INVALID_REQUEST, "Invalid Request");
|
|
4752
4774
|
switch (invocation.method) {
|
|
4753
4775
|
case "initialize": {
|
|
4776
|
+
if (this.#options.handshake !== void 0) {
|
|
4777
|
+
const closure = new AbortController();
|
|
4778
|
+
const resolved = buildMethodOptions(options ?? {}, closure.signal);
|
|
4779
|
+
try {
|
|
4780
|
+
await this.#options.handshake(resolved);
|
|
4781
|
+
} catch (error) {
|
|
4782
|
+
if (resolved.signal.aborted) throw error;
|
|
4783
|
+
if (isMCPError(error)) {
|
|
4784
|
+
const context = attempt(() => parseJSON(JSON.stringify(error.context)));
|
|
4785
|
+
return buildJSONRPCError(id, error.code, error.message, context.success ? context.value : void 0);
|
|
4786
|
+
}
|
|
4787
|
+
this.emitter.emit("error", error);
|
|
4788
|
+
return buildJSONRPCError(id, JSONRPC_INTERNAL_ERROR, "Server error");
|
|
4789
|
+
} finally {
|
|
4790
|
+
closure.abort();
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4754
4793
|
const requested = invocation.params?.["protocolVersion"];
|
|
4755
4794
|
return buildJSONRPCResult(id, buildInitializeResult(this.#options.identity.name, this.#options.identity.version, isString(requested) ? requested : void 0));
|
|
4756
4795
|
}
|
|
@@ -5110,6 +5149,9 @@ var MCPServer = class {
|
|
|
5110
5149
|
get identity() {
|
|
5111
5150
|
return this.#options.identity;
|
|
5112
5151
|
}
|
|
5152
|
+
get handshake() {
|
|
5153
|
+
return this.#options.handshake;
|
|
5154
|
+
}
|
|
5113
5155
|
get methods() {
|
|
5114
5156
|
return this.#methods;
|
|
5115
5157
|
}
|
|
@@ -5526,7 +5568,7 @@ var MCPServer = class {
|
|
|
5526
5568
|
if (!isBoundedString(verified, this.#limits.state) || verified.length === 0) return this.#contain(/* @__PURE__ */ new Error("Continuation port opened a value outside the configured state bound"), id);
|
|
5527
5569
|
const state = parseMCPInputState(verified);
|
|
5528
5570
|
if (state === void 0) return this.#contain(/* @__PURE__ */ new Error("Continuation port opened a malformed protected payload"), id);
|
|
5529
|
-
if (state.expiry <= Date.now() || state.id === id || state.version !== context.version || state.method !== request.method || state.name !== name || state.digest !== digest) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
|
|
5571
|
+
if (state.expiry <= (configured.clock ?? Date.now)() || state.id === id || state.version !== context.version || state.method !== request.method || state.name !== name || state.digest !== digest) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
|
|
5530
5572
|
const responses = this.#checkAnswers(state.requests, inputResponses);
|
|
5531
5573
|
if (responses === void 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: an input response is missing or malformed");
|
|
5532
5574
|
const principal = await configured.principal(request, options);
|
|
@@ -5538,7 +5580,7 @@ var MCPServer = class {
|
|
|
5538
5580
|
responses,
|
|
5539
5581
|
...state.state !== void 0 ? { state: state.state } : {}
|
|
5540
5582
|
}, options);
|
|
5541
|
-
if (state.expiry <= Date.now()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
|
|
5583
|
+
if (state.expiry <= (configured.clock ?? Date.now)()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
|
|
5542
5584
|
if (selected === void 0) return void 0;
|
|
5543
5585
|
const round = this.#ownRound(selected);
|
|
5544
5586
|
if (round === void 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: input policy returned an invalid round or continuation context");
|
|
@@ -5579,8 +5621,8 @@ var MCPServer = class {
|
|
|
5579
5621
|
depth: this.#limits.depth
|
|
5580
5622
|
});
|
|
5581
5623
|
if (configured === void 0 || context === void 0 || !isString(principal) || principal.length === 0 || !isFiniteNumber(configured.ttl) || configured.ttl <= 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: input policy returned an invalid round or continuation context");
|
|
5582
|
-
if (previous !== void 0 && previous <= Date.now()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
|
|
5583
|
-
const expiry = Date.now() + configured.ttl;
|
|
5624
|
+
if (previous !== void 0 && previous <= (configured.clock ?? Date.now)()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
|
|
5625
|
+
const expiry = (configured.clock ?? Date.now)() + configured.ttl;
|
|
5584
5626
|
const protectedState = {
|
|
5585
5627
|
principal,
|
|
5586
5628
|
expiry,
|
|
@@ -5603,7 +5645,7 @@ var MCPServer = class {
|
|
|
5603
5645
|
if (serialized === void 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state exceeds the configured limit");
|
|
5604
5646
|
const requestState = await configured.continuation.seal(serialized);
|
|
5605
5647
|
if (!isBoundedString(requestState, this.#limits.state) || requestState.length === 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state exceeds the configured limit");
|
|
5606
|
-
if (expiry <= Date.now() || previous !== void 0 && previous <= Date.now()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, previous === void 0 ? "Invalid params: request state expired before it could be issued" : "Invalid params: request state could not be verified for this retry");
|
|
5648
|
+
if (expiry <= (configured.clock ?? Date.now)() || previous !== void 0 && previous <= (configured.clock ?? Date.now)()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, previous === void 0 ? "Invalid params: request state expired before it could be issued" : "Invalid params: request state could not be verified for this retry");
|
|
5607
5649
|
return buildJSONRPCResult(id, {
|
|
5608
5650
|
resultType: "input_required",
|
|
5609
5651
|
inputRequests: round.requests,
|
|
@@ -6752,7 +6794,8 @@ function createMCPServer(options) {
|
|
|
6752
6794
|
function createMCPLegacy(server) {
|
|
6753
6795
|
return new MCPLegacy({
|
|
6754
6796
|
dispatcher: server,
|
|
6755
|
-
identity: server.identity
|
|
6797
|
+
identity: server.identity,
|
|
6798
|
+
...server.handshake === void 0 ? {} : { handshake: server.handshake }
|
|
6756
6799
|
});
|
|
6757
6800
|
}
|
|
6758
6801
|
/**
|
|
@@ -6861,6 +6904,6 @@ function createDuplexClientTransport(transport) {
|
|
|
6861
6904
|
};
|
|
6862
6905
|
}
|
|
6863
6906
|
//#endregion
|
|
6864
|
-
export { DEFAULT_MCP_CACHE_TTL, DEFAULT_MCP_CLIENT_NAME, DEFAULT_MCP_CLIENT_VERSION, DEFAULT_MCP_LIMITS, DEFAULT_MCP_REQUEST_TIMEOUT, DEFAULT_MCP_SUBSCRIPTION_CAPACITY, EMPTY_MCP_ARGUMENTS, HTTPClientTransport, JSONRPC_INTERNAL_ERROR, JSONRPC_INVALID_PARAMS, JSONRPC_INVALID_REQUEST, JSONRPC_METHOD_NOT_FOUND, JSONRPC_PARSE_ERROR, JSONRPC_SERVER_ERROR, MCPClient, MCPError, MCPLegacy, MCPLegacyClientTransport, MCPMethodManager, MCPProgressReporter, MCPServer, MCPStreamController, MCPTaskClient, MCPTextStreamController, MCP_EXTENSION_TASKS, MCP_FALLBACK_VERSION, MCP_HANDSHAKE_VERSION, MCP_HEADER_ANNOTATION, MCP_HEADER_MISMATCH, MCP_LOOKUP_PAGES, MCP_META_CAPABILITIES, MCP_META_CLIENT, MCP_META_SERVER, MCP_META_SUBSCRIPTION, MCP_META_VERSION, MCP_METHOD_HEADER, MCP_MISSING_CAPABILITY, MCP_MODERN_VERSION, MCP_NAME_HEADER, MCP_PARAM_PREFIX, MCP_PROTOCOL_VERSION_HEADER, MCP_SENTINEL_PREFIX, MCP_SENTINEL_SUFFIX, MCP_SESSION_HEADER, MCP_UNSUPPORTED_VERSION, MCP_WEBSOCKET_SUBPROTOCOL, SUPPORTED_LEGACY_PROTOCOL_VERSIONS, SUPPORTED_MCP_VERSIONS, SUPPORTED_MODERN_PROTOCOL_VERSIONS, bindClient, bindServer, buildCallOutcome, buildCancelledNotification, buildDiscoverResult, buildHeaderParameters, buildHeaderProjection, buildInitializeResult, buildJSONRPCError, buildJSONRPCResult, buildMethodOptions, buildModernResult, buildProgressNotification, buildResponseError, buildSubscriptionAcknowledgement, buildSubscriptionFilter, buildSubscriptionResult, buildToolCall, buildToolDescriptors, computeMissingCapabilities, countHeaderAnnotations, createDuplexClientTransport, createMCPClient, createMCPLegacy, createMCPLegacyClientTransport, createMCPServer, decodeBoundedMessage, decodeEvent, decodeSentinel, deliverMessage, digestJSON, encodeSentinel, extractContentText, extractHeaderAnnotations, extractToolSchema, inferEra, inferRequestEra, inferRequestVersion, inferVersion, isAbsoluteURI, isBoundedJSON, isBoundedString, isElicitContent, isFieldToken, isInitializeRequest, isJSONObject, isJSONRPCError, isJSONRPCErrorResponse, isJSONRPCId, isJSONRPCInvocation, isJSONRPCMessage, isJSONRPCNotification, isJSONRPCRequest, isJSONRPCResponse, isJSONRPCResultResponse, isMCPAnnotations, isMCPBlobResource, isMCPCallResult, isMCPClientCapabilities, isMCPCompletion, isMCPCompletionParams, isMCPCompletionReference, isMCPCompletionResult, isMCPConsumerFilter, isMCPContent, isMCPElicitFieldSchema, isMCPElicitForm, isMCPElicitRequest, isMCPElicitResult, isMCPElicitSchema, isMCPElicitURL, isMCPError, isMCPHeaderPrimitive, isMCPIcon, isMCPIdentity, isMCPInputRequest, isMCPInputRequestMap, isMCPInputResponse, isMCPInputResult, isMCPLegacyResult, isMCPLegacyVersion, isMCPLoggingLevel, isMCPMetaKey, isMCPMetaObject, isMCPModernVersion, isMCPNotificationMetaObject, isMCPPaginationParams, isMCPProgress, isMCPPrompt, isMCPPromptArgument, isMCPPromptGetResult, isMCPPromptMessage, isMCPPromptPage, isMCPResource, isMCPResourceContents, isMCPResourcePage, isMCPResourceTemplate, isMCPResourceTemplatePage, isMCPResult, isMCPResultMetaObject, isMCPRoot, isMCPRootResult, isMCPSampleContent, isMCPSampleResult, isMCPServerCapabilities, isMCPStringArguments, isMCPSubscriptionFilter, isMCPSubscriptionResult, isMCPTaskDetail, isMCPTaskDetailResult, isMCPTaskNotification, isMCPTaskResult, isMCPTaskStatus, isMCPTextResource, isMCPToolAnnotations, isMCPVersion, isModernRequest, isRFC3339Date, isRFC3339DateTime, isStandardBase64, legacyInvocationToModern, legacyResultToModern, matchesResultType, matchesSubscriptionNotification, mcpAnnotationsToTool, modernInvocationToLegacy, modernResultToLegacy, parseJSONRPCMessage, parseMCPInputState, parseRequestContext, readCancelledId, readEventStream, renderHeaderValue, sendStream, serializeJSON, snapshotJSON, snapshotToolResult, stampSubscriptionNotification, supportsFormElicitation, supportsTask, toolAnnotationsToMCP };
|
|
6907
|
+
export { DEFAULT_MCP_CACHE_TTL, DEFAULT_MCP_CLIENT_NAME, DEFAULT_MCP_CLIENT_VERSION, DEFAULT_MCP_LIMITS, DEFAULT_MCP_REQUEST_TIMEOUT, DEFAULT_MCP_SUBSCRIPTION_CAPACITY, EMPTY_MCP_ARGUMENTS, HTTPClientTransport, JSONRPC_INTERNAL_ERROR, JSONRPC_INVALID_PARAMS, JSONRPC_INVALID_REQUEST, JSONRPC_METHOD_NOT_FOUND, JSONRPC_PARSE_ERROR, JSONRPC_SERVER_ERROR, MCPClient, MCPError, MCPLegacy, MCPLegacyClientTransport, MCPMethodManager, MCPProgressReporter, MCPServer, MCPStreamController, MCPTaskClient, MCPTextStreamController, MCP_EXTENSION_TASKS, MCP_FALLBACK_VERSION, MCP_HANDSHAKE_VERSION, MCP_HEADER_ANNOTATION, MCP_HEADER_MISMATCH, MCP_LOOKUP_PAGES, MCP_META_CAPABILITIES, MCP_META_CLIENT, MCP_META_SERVER, MCP_META_SUBSCRIPTION, MCP_META_VERSION, MCP_METHOD_HEADER, MCP_MISSING_CAPABILITY, MCP_MODERN_VERSION, MCP_NAME_HEADER, MCP_PARAM_PREFIX, MCP_PROTOCOL_VERSION_HEADER, MCP_SENTINEL_PREFIX, MCP_SENTINEL_SUFFIX, MCP_SESSION_HEADER, MCP_UNSUPPORTED_VERSION, MCP_WEBSOCKET_SUBPROTOCOL, SUPPORTED_LEGACY_PROTOCOL_VERSIONS, SUPPORTED_MCP_VERSIONS, SUPPORTED_MODERN_PROTOCOL_VERSIONS, bindClient, bindServer, buildCallOutcome, buildCancelledNotification, buildDiscoverResult, buildHeaderParameters, buildHeaderProjection, buildInitializeResult, buildJSONRPCError, buildJSONRPCResult, buildMethodOptions, buildModernResult, buildProgressNotification, buildResponseError, buildSubscriptionAcknowledgement, buildSubscriptionFilter, buildSubscriptionResult, buildToolCall, buildToolDescriptors, computeMissingCapabilities, countHeaderAnnotations, createDuplexClientTransport, createMCPClient, createMCPLegacy, createMCPLegacyClientTransport, createMCPServer, decodeBoundedMessage, decodeEvent, decodeSentinel, deliverMessage, digestJSON, encodeSentinel, extractContentText, extractHeaderAnnotations, extractToolSchema, inferEra, inferRequestEra, inferRequestVersion, inferVersion, isAbsoluteURI, isBoundedJSON, isBoundedString, isElicitContent, isFieldToken, isInitializeRequest, isJSONObject, isJSONRPCError, isJSONRPCErrorResponse, isJSONRPCId, isJSONRPCInvocation, isJSONRPCMessage, isJSONRPCNotification, isJSONRPCRequest, isJSONRPCResponse, isJSONRPCResultResponse, isMCPAnnotations, isMCPBlobResource, isMCPCallResult, isMCPClientCapabilities, isMCPCompletion, isMCPCompletionParams, isMCPCompletionReference, isMCPCompletionResult, isMCPConsumerFilter, isMCPContent, isMCPElicitFieldSchema, isMCPElicitForm, isMCPElicitRequest, isMCPElicitResult, isMCPElicitSchema, isMCPElicitURL, isMCPError, isMCPHeaderPrimitive, isMCPIcon, isMCPIdentity, isMCPInputRequest, isMCPInputRequestMap, isMCPInputResponse, isMCPInputResult, isMCPLegacyResult, isMCPLegacyVersion, isMCPLoggingLevel, isMCPMetaKey, isMCPMetaObject, isMCPModernVersion, isMCPNotificationMetaObject, isMCPPaginationParams, isMCPProgress, isMCPPrompt, isMCPPromptArgument, isMCPPromptGetResult, isMCPPromptMessage, isMCPPromptPage, isMCPResource, isMCPResourceContents, isMCPResourcePage, isMCPResourceTemplate, isMCPResourceTemplatePage, isMCPResult, isMCPResultMetaObject, isMCPRoot, isMCPRootResult, isMCPSampleContent, isMCPSampleResult, isMCPServerCapabilities, isMCPStringArguments, isMCPSubscriptionFilter, isMCPSubscriptionResult, isMCPTaskDetail, isMCPTaskDetailResult, isMCPTaskNotification, isMCPTaskResult, isMCPTaskStatus, isMCPTextResource, isMCPToolAnnotations, isMCPVersion, isModernRequest, isPingRequest, isRFC3339Date, isRFC3339DateTime, isStandardBase64, legacyInvocationToModern, legacyResultToModern, matchesResultType, matchesSubscriptionNotification, mcpAnnotationsToTool, modernInvocationToLegacy, modernResultToLegacy, parseJSONRPCMessage, parseMCPInputState, parseRequestContext, readCancelledId, readEventStream, renderHeaderValue, sendStream, serializeJSON, snapshotJSON, snapshotToolResult, stampSubscriptionNotification, supportsFormElicitation, supportsTask, toolAnnotationsToMCP };
|
|
6865
6908
|
|
|
6866
6909
|
//# sourceMappingURL=index.js.map
|