@orkestrel/mcp 0.0.9 → 0.0.11
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 +9 -8
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +21 -4
- package/dist/src/core/index.d.ts +21 -4
- package/dist/src/core/index.js +9 -8
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +12 -5
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +48 -19
- package/dist/src/server/index.d.ts +48 -19
- package/dist/src/server/index.js +12 -5
- package/dist/src/server/index.js.map +1 -1
- package/package.json +10 -10
|
@@ -543,10 +543,13 @@ var HTTPDisconnect = class {
|
|
|
543
543
|
* explicitly delegated upstream. Modern dispatch errors use their protocol status map; legacy
|
|
544
544
|
* errors remain in-band at HTTP `200`. A streamed response composes the fetch-standard request
|
|
545
545
|
* signal with response-body cancellation and supplies the result to every dispatched modern
|
|
546
|
-
* handler through `MCPDispatchOptions.signal`.
|
|
546
|
+
* handler through `MCPDispatchOptions.signal`. After every transport validation and immediately
|
|
547
|
+
* before dispatch, the optional synchronous `caller` extractor reads front-middleware state; a
|
|
548
|
+
* defined value is added to `MCPDispatchOptions`, while `undefined` is omitted.
|
|
547
549
|
*
|
|
550
|
+
* @typeParam TState - The consumer's opaque per-request route state type
|
|
548
551
|
* @param mcp - The transport-agnostic MCP server to dispatch through
|
|
549
|
-
* @param options - Optional streaming, origin-validation,
|
|
552
|
+
* @param options - Optional streaming, origin-validation, SSE keepalive, and caller-extraction options
|
|
550
553
|
* @returns A request handler for the stateless MCP POST route
|
|
551
554
|
*
|
|
552
555
|
* @example
|
|
@@ -566,7 +569,7 @@ var HTTPDisconnect = class {
|
|
|
566
569
|
function createMCPPostHandler(mcp, options) {
|
|
567
570
|
const streaming = options?.streaming ?? true;
|
|
568
571
|
const origin = options?.origin;
|
|
569
|
-
return async (request) => {
|
|
572
|
+
return async (request, context) => {
|
|
570
573
|
if (!allowsOrigin(request, origin)) return new Response(null, { status: 403 });
|
|
571
574
|
let text;
|
|
572
575
|
try {
|
|
@@ -596,7 +599,11 @@ function createMCPPostHandler(mcp, options) {
|
|
|
596
599
|
}), { status: 400 });
|
|
597
600
|
}
|
|
598
601
|
const disconnect = new HTTPDisconnect(request.signal, options?.keepalive);
|
|
599
|
-
const
|
|
602
|
+
const caller = options?.caller?.(request, context);
|
|
603
|
+
const response = await mcp.dispatch(rpcRequest, {
|
|
604
|
+
signal: disconnect.signal,
|
|
605
|
+
...caller === void 0 ? {} : { caller }
|
|
606
|
+
});
|
|
600
607
|
if (response !== void 0 && Symbol.asyncIterator in response) {
|
|
601
608
|
const stream = (0, _orkestrel_server.openStream)();
|
|
602
609
|
stream.response.headers.set(SSE_BUFFERING_HEADER, "no");
|
|
@@ -1308,7 +1315,7 @@ var StdioServerTransport = class {
|
|
|
1308
1315
|
* @typeParam TState - The consumer's opaque per-request state type
|
|
1309
1316
|
* @param mcp - The transport-agnostic {@link MCPServerInterface} to expose over HTTP
|
|
1310
1317
|
* @param options - Optional `path` (default {@link DEFAULT_MCP_PATH}) and `streaming`
|
|
1311
|
-
* (default `true`), plus
|
|
1318
|
+
* (default `true`), plus shared origin, keepalive, and synchronous caller-extraction options; see
|
|
1312
1319
|
* {@link HTTPTransportOptions}
|
|
1313
1320
|
* @returns The {@link RouteInput}s to register with the router
|
|
1314
1321
|
*
|