@orkestrel/mcp 0.0.35 → 0.0.36
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 +24 -1
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +25 -0
- package/dist/src/core/index.d.ts +25 -0
- package/dist/src/core/index.js +24 -1
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +66 -27
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +51 -18
- package/dist/src/server/index.d.ts +51 -18
- package/dist/src/server/index.js +68 -30
- package/dist/src/server/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -2297,6 +2297,8 @@ export declare const JSONRPC_PARSE_ERROR = -32700;
|
|
|
2297
2297
|
* Retained for the legacy branch alone. A modern fault answers
|
|
2298
2298
|
* {@link JSONRPC_INTERNAL_ERROR}; this code survives only where an old-wire peer was
|
|
2299
2299
|
* already characterized against it.
|
|
2300
|
+
* A `handshake` hook that rejects with an `MCPError` answers the legacy `initialize`
|
|
2301
|
+
* with that error's own code and data.
|
|
2300
2302
|
*/
|
|
2301
2303
|
export declare const JSONRPC_SERVER_ERROR = -32000;
|
|
2302
2304
|
|
|
@@ -3466,6 +3468,19 @@ export declare interface MCPExecutionContext {
|
|
|
3466
3468
|
/** Executes one canonical tool call or returns a fully formed complete MCP result. */
|
|
3467
3469
|
export declare type MCPExecutionHandler = (context: MCPExecutionContext) => ToolResult | MCPCallResult | Promise<ToolResult | MCPCallResult>;
|
|
3468
3470
|
|
|
3471
|
+
/**
|
|
3472
|
+
* Gates a legacy `initialize` response on consumer readiness.
|
|
3473
|
+
*
|
|
3474
|
+
* @remarks
|
|
3475
|
+
* Only legacy initialization awaits this hook. An `MCPError` rejection preserves its
|
|
3476
|
+
* code, message, and context; another rejection emits `error` and answers `Server error`.
|
|
3477
|
+
* Observe `options.signal` to stop when the request ends.
|
|
3478
|
+
*
|
|
3479
|
+
* @param options - The resolved request lifetime and optional caller context
|
|
3480
|
+
* @returns Completion when initialization may answer
|
|
3481
|
+
*/
|
|
3482
|
+
export declare type MCPHandshakeHandler = (options: MCPMethodOptions) => Promise<void>;
|
|
3483
|
+
|
|
3469
3484
|
/**
|
|
3470
3485
|
* Represents one `x-mcp-header` projection a tool's `inputSchema` declares.
|
|
3471
3486
|
*
|
|
@@ -3758,6 +3773,8 @@ export declare interface MCPLegacyOptions {
|
|
|
3758
3773
|
readonly dispatcher: MCPDispatcherInterface;
|
|
3759
3774
|
/** Holds the identity returned by the legacy `initialize` handshake. */
|
|
3760
3775
|
readonly identity: MCPIdentity;
|
|
3776
|
+
/** Holds the optional readiness hook awaited before the initialization result. */
|
|
3777
|
+
readonly handshake?: MCPHandshakeHandler;
|
|
3761
3778
|
}
|
|
3762
3779
|
|
|
3763
3780
|
/**
|
|
@@ -4668,6 +4685,7 @@ export declare class MCPServer implements MCPServerInterface {
|
|
|
4668
4685
|
constructor(options: MCPServerOptions);
|
|
4669
4686
|
get emitter(): EmitterInterface<MCPServerEventMap>;
|
|
4670
4687
|
get identity(): MCPIdentity;
|
|
4688
|
+
get handshake(): MCPHandshakeHandler | undefined;
|
|
4671
4689
|
get methods(): MCPMethodManagerInterface;
|
|
4672
4690
|
get limit(): Required<MCPLimitOptions>;
|
|
4673
4691
|
dispatch(request: JSONRPCRequest, options?: MCPDispatchOptions): Promise<JSONRPCResponse | MCPStreamControllerInterface>;
|
|
@@ -4782,6 +4800,8 @@ export declare type MCPServerEventMap = {
|
|
|
4782
4800
|
*/
|
|
4783
4801
|
export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
4784
4802
|
readonly identity: MCPIdentity;
|
|
4803
|
+
/** Holds the readiness hook consumed by the legacy decorator. */
|
|
4804
|
+
readonly handshake: MCPHandshakeHandler | undefined;
|
|
4785
4805
|
/** Holds the modern method registry this server dispatches through (built-ins included). */
|
|
4786
4806
|
readonly methods: MCPMethodManagerInterface;
|
|
4787
4807
|
/**
|
|
@@ -4865,6 +4885,9 @@ export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
|
4865
4885
|
*
|
|
4866
4886
|
* @remarks
|
|
4867
4887
|
* `identity` identifies the server in the `initialize` handshake (`serverInfo`).
|
|
4888
|
+
* `handshake` is the optional readiness hook that the legacy decorator awaits before
|
|
4889
|
+
* answering `initialize`; it receives the request signal and optional caller context.
|
|
4890
|
+
* The hook must observe the signal to stop pending work. Other methods do not await it.
|
|
4868
4891
|
* `tools` is the live registry the server dispatches `tools/list` / `tools/call`
|
|
4869
4892
|
* over — its `definitions()` advertise the tools and its `execute()` runs a call
|
|
4870
4893
|
* (the manager already isolates a tool throw into a `success: false` result, so
|
|
@@ -4891,6 +4914,8 @@ export declare interface MCPServerOptions {
|
|
|
4891
4914
|
/** Holds the emitter's listener-error handler — a listener throw routes here, not to a domain event. */
|
|
4892
4915
|
readonly error?: EmitterErrorHandler;
|
|
4893
4916
|
readonly identity: MCPIdentity;
|
|
4917
|
+
/** Holds the optional readiness hook awaited only by legacy initialization. */
|
|
4918
|
+
readonly handshake?: MCPHandshakeHandler;
|
|
4894
4919
|
/** Holds the live tool registry the server exposes over `tools/list` / `tools/call`. */
|
|
4895
4920
|
readonly tools: ToolManagerInterface;
|
|
4896
4921
|
/**
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -2297,6 +2297,8 @@ export declare const JSONRPC_PARSE_ERROR = -32700;
|
|
|
2297
2297
|
* Retained for the legacy branch alone. A modern fault answers
|
|
2298
2298
|
* {@link JSONRPC_INTERNAL_ERROR}; this code survives only where an old-wire peer was
|
|
2299
2299
|
* already characterized against it.
|
|
2300
|
+
* A `handshake` hook that rejects with an `MCPError` answers the legacy `initialize`
|
|
2301
|
+
* with that error's own code and data.
|
|
2300
2302
|
*/
|
|
2301
2303
|
export declare const JSONRPC_SERVER_ERROR = -32000;
|
|
2302
2304
|
|
|
@@ -3466,6 +3468,19 @@ export declare interface MCPExecutionContext {
|
|
|
3466
3468
|
/** Executes one canonical tool call or returns a fully formed complete MCP result. */
|
|
3467
3469
|
export declare type MCPExecutionHandler = (context: MCPExecutionContext) => ToolResult | MCPCallResult | Promise<ToolResult | MCPCallResult>;
|
|
3468
3470
|
|
|
3471
|
+
/**
|
|
3472
|
+
* Gates a legacy `initialize` response on consumer readiness.
|
|
3473
|
+
*
|
|
3474
|
+
* @remarks
|
|
3475
|
+
* Only legacy initialization awaits this hook. An `MCPError` rejection preserves its
|
|
3476
|
+
* code, message, and context; another rejection emits `error` and answers `Server error`.
|
|
3477
|
+
* Observe `options.signal` to stop when the request ends.
|
|
3478
|
+
*
|
|
3479
|
+
* @param options - The resolved request lifetime and optional caller context
|
|
3480
|
+
* @returns Completion when initialization may answer
|
|
3481
|
+
*/
|
|
3482
|
+
export declare type MCPHandshakeHandler = (options: MCPMethodOptions) => Promise<void>;
|
|
3483
|
+
|
|
3469
3484
|
/**
|
|
3470
3485
|
* Represents one `x-mcp-header` projection a tool's `inputSchema` declares.
|
|
3471
3486
|
*
|
|
@@ -3758,6 +3773,8 @@ export declare interface MCPLegacyOptions {
|
|
|
3758
3773
|
readonly dispatcher: MCPDispatcherInterface;
|
|
3759
3774
|
/** Holds the identity returned by the legacy `initialize` handshake. */
|
|
3760
3775
|
readonly identity: MCPIdentity;
|
|
3776
|
+
/** Holds the optional readiness hook awaited before the initialization result. */
|
|
3777
|
+
readonly handshake?: MCPHandshakeHandler;
|
|
3761
3778
|
}
|
|
3762
3779
|
|
|
3763
3780
|
/**
|
|
@@ -4668,6 +4685,7 @@ export declare class MCPServer implements MCPServerInterface {
|
|
|
4668
4685
|
constructor(options: MCPServerOptions);
|
|
4669
4686
|
get emitter(): EmitterInterface<MCPServerEventMap>;
|
|
4670
4687
|
get identity(): MCPIdentity;
|
|
4688
|
+
get handshake(): MCPHandshakeHandler | undefined;
|
|
4671
4689
|
get methods(): MCPMethodManagerInterface;
|
|
4672
4690
|
get limit(): Required<MCPLimitOptions>;
|
|
4673
4691
|
dispatch(request: JSONRPCRequest, options?: MCPDispatchOptions): Promise<JSONRPCResponse | MCPStreamControllerInterface>;
|
|
@@ -4782,6 +4800,8 @@ export declare type MCPServerEventMap = {
|
|
|
4782
4800
|
*/
|
|
4783
4801
|
export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
4784
4802
|
readonly identity: MCPIdentity;
|
|
4803
|
+
/** Holds the readiness hook consumed by the legacy decorator. */
|
|
4804
|
+
readonly handshake: MCPHandshakeHandler | undefined;
|
|
4785
4805
|
/** Holds the modern method registry this server dispatches through (built-ins included). */
|
|
4786
4806
|
readonly methods: MCPMethodManagerInterface;
|
|
4787
4807
|
/**
|
|
@@ -4865,6 +4885,9 @@ export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
|
4865
4885
|
*
|
|
4866
4886
|
* @remarks
|
|
4867
4887
|
* `identity` identifies the server in the `initialize` handshake (`serverInfo`).
|
|
4888
|
+
* `handshake` is the optional readiness hook that the legacy decorator awaits before
|
|
4889
|
+
* answering `initialize`; it receives the request signal and optional caller context.
|
|
4890
|
+
* The hook must observe the signal to stop pending work. Other methods do not await it.
|
|
4868
4891
|
* `tools` is the live registry the server dispatches `tools/list` / `tools/call`
|
|
4869
4892
|
* over — its `definitions()` advertise the tools and its `execute()` runs a call
|
|
4870
4893
|
* (the manager already isolates a tool throw into a `success: false` result, so
|
|
@@ -4891,6 +4914,8 @@ export declare interface MCPServerOptions {
|
|
|
4891
4914
|
/** Holds the emitter's listener-error handler — a listener throw routes here, not to a domain event. */
|
|
4892
4915
|
readonly error?: EmitterErrorHandler;
|
|
4893
4916
|
readonly identity: MCPIdentity;
|
|
4917
|
+
/** Holds the optional readiness hook awaited only by legacy initialization. */
|
|
4918
|
+
readonly handshake?: MCPHandshakeHandler;
|
|
4894
4919
|
/** Holds the live tool registry the server exposes over `tools/list` / `tools/call`. */
|
|
4895
4920
|
readonly tools: ToolManagerInterface;
|
|
4896
4921
|
/**
|
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
|
/**
|
|
@@ -4751,6 +4753,23 @@ var MCPLegacy = class {
|
|
|
4751
4753
|
}) === void 0) return buildJSONRPCError(void 0, JSONRPC_INVALID_REQUEST, "Invalid Request");
|
|
4752
4754
|
switch (invocation.method) {
|
|
4753
4755
|
case "initialize": {
|
|
4756
|
+
if (this.#options.handshake !== void 0) {
|
|
4757
|
+
const closure = new AbortController();
|
|
4758
|
+
const resolved = buildMethodOptions(options ?? {}, closure.signal);
|
|
4759
|
+
try {
|
|
4760
|
+
await this.#options.handshake(resolved);
|
|
4761
|
+
} catch (error) {
|
|
4762
|
+
if (resolved.signal.aborted) throw error;
|
|
4763
|
+
if (isMCPError(error)) {
|
|
4764
|
+
const context = attempt(() => parseJSON(JSON.stringify(error.context)));
|
|
4765
|
+
return buildJSONRPCError(id, error.code, error.message, context.success ? context.value : void 0);
|
|
4766
|
+
}
|
|
4767
|
+
this.emitter.emit("error", error);
|
|
4768
|
+
return buildJSONRPCError(id, JSONRPC_INTERNAL_ERROR, "Server error");
|
|
4769
|
+
} finally {
|
|
4770
|
+
closure.abort();
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4754
4773
|
const requested = invocation.params?.["protocolVersion"];
|
|
4755
4774
|
return buildJSONRPCResult(id, buildInitializeResult(this.#options.identity.name, this.#options.identity.version, isString(requested) ? requested : void 0));
|
|
4756
4775
|
}
|
|
@@ -5110,6 +5129,9 @@ var MCPServer = class {
|
|
|
5110
5129
|
get identity() {
|
|
5111
5130
|
return this.#options.identity;
|
|
5112
5131
|
}
|
|
5132
|
+
get handshake() {
|
|
5133
|
+
return this.#options.handshake;
|
|
5134
|
+
}
|
|
5113
5135
|
get methods() {
|
|
5114
5136
|
return this.#methods;
|
|
5115
5137
|
}
|
|
@@ -6752,7 +6774,8 @@ function createMCPServer(options) {
|
|
|
6752
6774
|
function createMCPLegacy(server) {
|
|
6753
6775
|
return new MCPLegacy({
|
|
6754
6776
|
dispatcher: server,
|
|
6755
|
-
identity: server.identity
|
|
6777
|
+
identity: server.identity,
|
|
6778
|
+
...server.handshake === void 0 ? {} : { handshake: server.handshake }
|
|
6756
6779
|
});
|
|
6757
6780
|
}
|
|
6758
6781
|
/**
|