@orkestrel/mcp 0.0.22 → 0.0.23
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.d.cts +5 -0
- package/dist/src/core/index.d.ts +5 -0
- package/dist/src/server/index.cjs +59 -3
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +35 -2
- package/dist/src/server/index.d.ts +35 -2
- package/dist/src/server/index.js +59 -4
- package/dist/src/server/index.js.map +1 -1
- package/package.json +11 -9
|
@@ -1484,8 +1484,10 @@ export declare interface StdioServerOptions {
|
|
|
1484
1484
|
* emits `error` (never throws). `input`'s `close` bridges to this
|
|
1485
1485
|
* transport's `close`.
|
|
1486
1486
|
* - **Outbound (`send`).** `send(message)` writes one newline-terminated
|
|
1487
|
-
* `JSON.stringify`d line to `output
|
|
1488
|
-
*
|
|
1487
|
+
* `JSON.stringify`d line to `output` and awaits the writable completion callback. The
|
|
1488
|
+
* callback is the backpressure boundary and its error rejects the send.
|
|
1489
|
+
* - **`close()`** removes this transport's input and output subscriptions, rejects every
|
|
1490
|
+
* pending send, and fires its `close`
|
|
1489
1491
|
* event (idempotent). It pauses the input only when the caller was not already reading
|
|
1490
1492
|
* it at `start` (`readableFlowing !== true`) AND no `data` listener remains once this
|
|
1491
1493
|
* transport's own is removed — so a process holding `process.stdin` can exit, and a
|
|
@@ -1508,6 +1510,19 @@ export declare class StdioServerTransport implements MCPClientTransportInterface
|
|
|
1508
1510
|
get session(): string | undefined;
|
|
1509
1511
|
get duplex(): boolean;
|
|
1510
1512
|
start(): Promise<void>;
|
|
1513
|
+
/**
|
|
1514
|
+
* Sends one newline-delimited JSON-RPC message through the caller-owned output stream.
|
|
1515
|
+
*
|
|
1516
|
+
* @remarks
|
|
1517
|
+
* The writable completion callback is the backpressure boundary. This method awaits that
|
|
1518
|
+
* callback rather than adding a `drain` listener. Closing the transport rejects every send
|
|
1519
|
+
* whose callback has not settled.
|
|
1520
|
+
*
|
|
1521
|
+
* @param message - The message to serialize and write
|
|
1522
|
+
* @returns Resolves when the output confirms the write
|
|
1523
|
+
* @throws Thrown with `stdio transport is not connected` after the transport closes
|
|
1524
|
+
* @throws Thrown with the output callback error or synchronous write failure
|
|
1525
|
+
*/
|
|
1511
1526
|
send(message: JSONRPCMessage_2): Promise<void>;
|
|
1512
1527
|
close(): Promise<void>;
|
|
1513
1528
|
}
|
|
@@ -1684,4 +1699,22 @@ export declare class WebSocketServerTransport implements MCPClientTransportInter
|
|
|
1684
1699
|
close(): Promise<void>;
|
|
1685
1700
|
}
|
|
1686
1701
|
|
|
1702
|
+
/**
|
|
1703
|
+
* Writes one line to a Node writable stream and waits for its completion callback.
|
|
1704
|
+
*
|
|
1705
|
+
* @remarks
|
|
1706
|
+
* The completion callback is the writable channel's backpressure boundary. A callback error and
|
|
1707
|
+
* a synchronous `write` throw reject the returned promise with the original value.
|
|
1708
|
+
*
|
|
1709
|
+
* @param output - The writable stream that receives the line
|
|
1710
|
+
* @param line - The complete line to write
|
|
1711
|
+
* @returns Resolves when the stream confirms the write; rejects when the write fails
|
|
1712
|
+
*
|
|
1713
|
+
* @example
|
|
1714
|
+
* ```ts
|
|
1715
|
+
* await writeLine(process.stdout, '{"jsonrpc":"2.0","method":"ping"}\n')
|
|
1716
|
+
* ```
|
|
1717
|
+
*/
|
|
1718
|
+
export declare function writeLine(output: NodeJS.WritableStream, line: string): Promise<void>;
|
|
1719
|
+
|
|
1687
1720
|
export { }
|
|
@@ -1484,8 +1484,10 @@ export declare interface StdioServerOptions {
|
|
|
1484
1484
|
* emits `error` (never throws). `input`'s `close` bridges to this
|
|
1485
1485
|
* transport's `close`.
|
|
1486
1486
|
* - **Outbound (`send`).** `send(message)` writes one newline-terminated
|
|
1487
|
-
* `JSON.stringify`d line to `output
|
|
1488
|
-
*
|
|
1487
|
+
* `JSON.stringify`d line to `output` and awaits the writable completion callback. The
|
|
1488
|
+
* callback is the backpressure boundary and its error rejects the send.
|
|
1489
|
+
* - **`close()`** removes this transport's input and output subscriptions, rejects every
|
|
1490
|
+
* pending send, and fires its `close`
|
|
1489
1491
|
* event (idempotent). It pauses the input only when the caller was not already reading
|
|
1490
1492
|
* it at `start` (`readableFlowing !== true`) AND no `data` listener remains once this
|
|
1491
1493
|
* transport's own is removed — so a process holding `process.stdin` can exit, and a
|
|
@@ -1508,6 +1510,19 @@ export declare class StdioServerTransport implements MCPClientTransportInterface
|
|
|
1508
1510
|
get session(): string | undefined;
|
|
1509
1511
|
get duplex(): boolean;
|
|
1510
1512
|
start(): Promise<void>;
|
|
1513
|
+
/**
|
|
1514
|
+
* Sends one newline-delimited JSON-RPC message through the caller-owned output stream.
|
|
1515
|
+
*
|
|
1516
|
+
* @remarks
|
|
1517
|
+
* The writable completion callback is the backpressure boundary. This method awaits that
|
|
1518
|
+
* callback rather than adding a `drain` listener. Closing the transport rejects every send
|
|
1519
|
+
* whose callback has not settled.
|
|
1520
|
+
*
|
|
1521
|
+
* @param message - The message to serialize and write
|
|
1522
|
+
* @returns Resolves when the output confirms the write
|
|
1523
|
+
* @throws Thrown with `stdio transport is not connected` after the transport closes
|
|
1524
|
+
* @throws Thrown with the output callback error or synchronous write failure
|
|
1525
|
+
*/
|
|
1511
1526
|
send(message: JSONRPCMessage_2): Promise<void>;
|
|
1512
1527
|
close(): Promise<void>;
|
|
1513
1528
|
}
|
|
@@ -1684,4 +1699,22 @@ export declare class WebSocketServerTransport implements MCPClientTransportInter
|
|
|
1684
1699
|
close(): Promise<void>;
|
|
1685
1700
|
}
|
|
1686
1701
|
|
|
1702
|
+
/**
|
|
1703
|
+
* Writes one line to a Node writable stream and waits for its completion callback.
|
|
1704
|
+
*
|
|
1705
|
+
* @remarks
|
|
1706
|
+
* The completion callback is the writable channel's backpressure boundary. A callback error and
|
|
1707
|
+
* a synchronous `write` throw reject the returned promise with the original value.
|
|
1708
|
+
*
|
|
1709
|
+
* @param output - The writable stream that receives the line
|
|
1710
|
+
* @param line - The complete line to write
|
|
1711
|
+
* @returns Resolves when the stream confirms the write; rejects when the write fails
|
|
1712
|
+
*
|
|
1713
|
+
* @example
|
|
1714
|
+
* ```ts
|
|
1715
|
+
* await writeLine(process.stdout, '{"jsonrpc":"2.0","method":"ping"}\n')
|
|
1716
|
+
* ```
|
|
1717
|
+
*/
|
|
1718
|
+
export declare function writeLine(output: NodeJS.WritableStream, line: string): Promise<void>;
|
|
1719
|
+
|
|
1687
1720
|
export { }
|
package/dist/src/server/index.js
CHANGED
|
@@ -364,6 +364,34 @@ function extractLines(buffer, chunk) {
|
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
/**
|
|
367
|
+
* Writes one line to a Node writable stream and waits for its completion callback.
|
|
368
|
+
*
|
|
369
|
+
* @remarks
|
|
370
|
+
* The completion callback is the writable channel's backpressure boundary. A callback error and
|
|
371
|
+
* a synchronous `write` throw reject the returned promise with the original value.
|
|
372
|
+
*
|
|
373
|
+
* @param output - The writable stream that receives the line
|
|
374
|
+
* @param line - The complete line to write
|
|
375
|
+
* @returns Resolves when the stream confirms the write; rejects when the write fails
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```ts
|
|
379
|
+
* await writeLine(process.stdout, '{"jsonrpc":"2.0","method":"ping"}\n')
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
function writeLine(output, line) {
|
|
383
|
+
return new Promise((resolve, reject) => {
|
|
384
|
+
try {
|
|
385
|
+
output.write(line, (error) => {
|
|
386
|
+
if (error === void 0 || error === null) resolve();
|
|
387
|
+
else reject(error);
|
|
388
|
+
});
|
|
389
|
+
} catch (error) {
|
|
390
|
+
reject(error);
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
367
395
|
* Decodes and delivers each complete newline-framed line onto a {@link
|
|
368
396
|
* MCPClientTransportEventMap} emitter — the shared per-chunk dispatch step both stdio
|
|
369
397
|
* transports run their framed lines through: the server transport frames with {@link
|
|
@@ -1558,8 +1586,10 @@ var StdioClientTransport = class {
|
|
|
1558
1586
|
* emits `error` (never throws). `input`'s `close` bridges to this
|
|
1559
1587
|
* transport's `close`.
|
|
1560
1588
|
* - **Outbound (`send`).** `send(message)` writes one newline-terminated
|
|
1561
|
-
* `JSON.stringify`d line to `output
|
|
1562
|
-
*
|
|
1589
|
+
* `JSON.stringify`d line to `output` and awaits the writable completion callback. The
|
|
1590
|
+
* callback is the backpressure boundary and its error rejects the send.
|
|
1591
|
+
* - **`close()`** removes this transport's input and output subscriptions, rejects every
|
|
1592
|
+
* pending send, and fires its `close`
|
|
1563
1593
|
* event (idempotent). It pauses the input only when the caller was not already reading
|
|
1564
1594
|
* it at `start` (`readableFlowing !== true`) AND no `data` listener remains once this
|
|
1565
1595
|
* transport's own is removed — so a process holding `process.stdin` can exit, and a
|
|
@@ -1582,6 +1612,7 @@ var StdioServerTransport = class {
|
|
|
1582
1612
|
#data = (chunk) => this.#receive(chunk.toString());
|
|
1583
1613
|
#ending = () => this.#onClose();
|
|
1584
1614
|
#failure = (error) => this.#emitter.emit("error", error);
|
|
1615
|
+
#pending = /* @__PURE__ */ new Set();
|
|
1585
1616
|
#buffer = "";
|
|
1586
1617
|
#started = false;
|
|
1587
1618
|
#closed = false;
|
|
@@ -1605,9 +1636,30 @@ var StdioServerTransport = class {
|
|
|
1605
1636
|
this.#input.on("data", this.#data);
|
|
1606
1637
|
this.#input.on("close", this.#ending);
|
|
1607
1638
|
this.#input.on("error", this.#failure);
|
|
1639
|
+
this.#output.on("error", this.#failure);
|
|
1608
1640
|
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Sends one newline-delimited JSON-RPC message through the caller-owned output stream.
|
|
1643
|
+
*
|
|
1644
|
+
* @remarks
|
|
1645
|
+
* The writable completion callback is the backpressure boundary. This method awaits that
|
|
1646
|
+
* callback rather than adding a `drain` listener. Closing the transport rejects every send
|
|
1647
|
+
* whose callback has not settled.
|
|
1648
|
+
*
|
|
1649
|
+
* @param message - The message to serialize and write
|
|
1650
|
+
* @returns Resolves when the output confirms the write
|
|
1651
|
+
* @throws Thrown with `stdio transport is not connected` after the transport closes
|
|
1652
|
+
* @throws Thrown with the output callback error or synchronous write failure
|
|
1653
|
+
*/
|
|
1609
1654
|
async send(message) {
|
|
1610
|
-
this.#
|
|
1655
|
+
if (this.#closed) throw new Error("stdio transport is not connected");
|
|
1656
|
+
const pending = Promise.withResolvers();
|
|
1657
|
+
this.#pending.add(pending);
|
|
1658
|
+
try {
|
|
1659
|
+
await Promise.race([writeLine(this.#output, `${JSON.stringify(message)}\n`), pending.promise]);
|
|
1660
|
+
} finally {
|
|
1661
|
+
this.#pending.delete(pending);
|
|
1662
|
+
}
|
|
1611
1663
|
}
|
|
1612
1664
|
async close() {
|
|
1613
1665
|
if (this.#closed) return;
|
|
@@ -1630,6 +1682,9 @@ var StdioServerTransport = class {
|
|
|
1630
1682
|
this.#input.removeListener("data", this.#data);
|
|
1631
1683
|
this.#input.removeListener("close", this.#ending);
|
|
1632
1684
|
this.#input.removeListener("error", this.#failure);
|
|
1685
|
+
this.#output.removeListener("error", this.#failure);
|
|
1686
|
+
for (const pending of this.#pending) pending.reject(/* @__PURE__ */ new Error("stdio transport is not connected"));
|
|
1687
|
+
this.#pending.clear();
|
|
1633
1688
|
if (!this.#flowing && this.#input.listenerCount("data") === 0) this.#input.pause();
|
|
1634
1689
|
}
|
|
1635
1690
|
};
|
|
@@ -2137,6 +2192,6 @@ function createMCPSession(options) {
|
|
|
2137
2192
|
};
|
|
2138
2193
|
}
|
|
2139
2194
|
//#endregion
|
|
2140
|
-
export { DEFAULT_MCP_DELIVERY, DEFAULT_MCP_KEEPALIVE_INTERVAL, DEFAULT_MCP_PATH, DEFAULT_MCP_SESSION_CAPACITY, DEFAULT_MCP_SESSION_TTL, HTTPClientTransport, HTTPDisconnect, MCPSession, MCP_METHOD_HEADER, MCP_NAME_HEADER, MCP_PROTOCOL_VERSION_HEADER, MCP_SESSION_HEADER, MCP_WEBSOCKET_SUBPROTOCOL, SSE_BUFFERING_DISABLED, SSE_BUFFERING_HEADER, SSE_KEEPALIVE_COMMENT, StdioClientTransport, StdioServerTransport, WebSocketClientTransport, WebSocketServerTransport, acceptsEventStream, allowsOrigin, bridgeMessageTransport, createHTTPClientTransport, createMCPContinuation, createMCPPostHandler, createMCPRoutes, createMCPSession, createReadableStream, createStdioClientTransport, createStdioServer, createWebSocketClientTransport, createWebSocketServer, decodeEvent, dispatchLines, extractLines, inferHeaderIssue, inferLegacyVersion, inferStatus, readEventStream, readLastEventId, readSessionHeader, rejectUnknownSession, sendEventStream, upgradeRequestPath };
|
|
2195
|
+
export { DEFAULT_MCP_DELIVERY, DEFAULT_MCP_KEEPALIVE_INTERVAL, DEFAULT_MCP_PATH, DEFAULT_MCP_SESSION_CAPACITY, DEFAULT_MCP_SESSION_TTL, HTTPClientTransport, HTTPDisconnect, MCPSession, MCP_METHOD_HEADER, MCP_NAME_HEADER, MCP_PROTOCOL_VERSION_HEADER, MCP_SESSION_HEADER, MCP_WEBSOCKET_SUBPROTOCOL, SSE_BUFFERING_DISABLED, SSE_BUFFERING_HEADER, SSE_KEEPALIVE_COMMENT, StdioClientTransport, StdioServerTransport, WebSocketClientTransport, WebSocketServerTransport, acceptsEventStream, allowsOrigin, bridgeMessageTransport, createHTTPClientTransport, createMCPContinuation, createMCPPostHandler, createMCPRoutes, createMCPSession, createReadableStream, createStdioClientTransport, createStdioServer, createWebSocketClientTransport, createWebSocketServer, decodeEvent, dispatchLines, extractLines, inferHeaderIssue, inferLegacyVersion, inferStatus, readEventStream, readLastEventId, readSessionHeader, rejectUnknownSession, sendEventStream, upgradeRequestPath, writeLine };
|
|
2141
2196
|
|
|
2142
2197
|
//# sourceMappingURL=index.js.map
|