@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
|
@@ -2300,6 +2300,11 @@ export declare interface MCPClientTransportInterface {
|
|
|
2300
2300
|
* throwing. The client cannot enforce this from its side — the throw and the write are
|
|
2301
2301
|
* indistinguishable to it — so it is stated here, on the contract that owns it.
|
|
2302
2302
|
*
|
|
2303
|
+
* A transport whose channel confirms the write rejects on its failure. A transport whose
|
|
2304
|
+
* exchange reports through the emitter resolves. A transport whose channel cannot confirm a
|
|
2305
|
+
* write answers a closed channel from its own state, and each states which in its own
|
|
2306
|
+
* remarks.
|
|
2307
|
+
*
|
|
2303
2308
|
* @param message - The message to write to the wire
|
|
2304
2309
|
* @returns Resolves once the message has been sent, and rejects — never throws — when the
|
|
2305
2310
|
* write fails
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -2300,6 +2300,11 @@ export declare interface MCPClientTransportInterface {
|
|
|
2300
2300
|
* throwing. The client cannot enforce this from its side — the throw and the write are
|
|
2301
2301
|
* indistinguishable to it — so it is stated here, on the contract that owns it.
|
|
2302
2302
|
*
|
|
2303
|
+
* A transport whose channel confirms the write rejects on its failure. A transport whose
|
|
2304
|
+
* exchange reports through the emitter resolves. A transport whose channel cannot confirm a
|
|
2305
|
+
* write answers a closed channel from its own state, and each states which in its own
|
|
2306
|
+
* remarks.
|
|
2307
|
+
*
|
|
2303
2308
|
* @param message - The message to write to the wire
|
|
2304
2309
|
* @returns Resolves once the message has been sent, and rejects — never throws — when the
|
|
2305
2310
|
* write fails
|
|
@@ -365,6 +365,34 @@ function extractLines(buffer, chunk) {
|
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
367
|
/**
|
|
368
|
+
* Writes one line to a Node writable stream and waits for its completion callback.
|
|
369
|
+
*
|
|
370
|
+
* @remarks
|
|
371
|
+
* The completion callback is the writable channel's backpressure boundary. A callback error and
|
|
372
|
+
* a synchronous `write` throw reject the returned promise with the original value.
|
|
373
|
+
*
|
|
374
|
+
* @param output - The writable stream that receives the line
|
|
375
|
+
* @param line - The complete line to write
|
|
376
|
+
* @returns Resolves when the stream confirms the write; rejects when the write fails
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```ts
|
|
380
|
+
* await writeLine(process.stdout, '{"jsonrpc":"2.0","method":"ping"}\n')
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
function writeLine(output, line) {
|
|
384
|
+
return new Promise((resolve, reject) => {
|
|
385
|
+
try {
|
|
386
|
+
output.write(line, (error) => {
|
|
387
|
+
if (error === void 0 || error === null) resolve();
|
|
388
|
+
else reject(error);
|
|
389
|
+
});
|
|
390
|
+
} catch (error) {
|
|
391
|
+
reject(error);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
368
396
|
* Decodes and delivers each complete newline-framed line onto a {@link
|
|
369
397
|
* MCPClientTransportEventMap} emitter — the shared per-chunk dispatch step both stdio
|
|
370
398
|
* transports run their framed lines through: the server transport frames with {@link
|
|
@@ -1559,8 +1587,10 @@ var StdioClientTransport = class {
|
|
|
1559
1587
|
* emits `error` (never throws). `input`'s `close` bridges to this
|
|
1560
1588
|
* transport's `close`.
|
|
1561
1589
|
* - **Outbound (`send`).** `send(message)` writes one newline-terminated
|
|
1562
|
-
* `JSON.stringify`d line to `output
|
|
1563
|
-
*
|
|
1590
|
+
* `JSON.stringify`d line to `output` and awaits the writable completion callback. The
|
|
1591
|
+
* callback is the backpressure boundary and its error rejects the send.
|
|
1592
|
+
* - **`close()`** removes this transport's input and output subscriptions, rejects every
|
|
1593
|
+
* pending send, and fires its `close`
|
|
1564
1594
|
* event (idempotent). It pauses the input only when the caller was not already reading
|
|
1565
1595
|
* it at `start` (`readableFlowing !== true`) AND no `data` listener remains once this
|
|
1566
1596
|
* transport's own is removed — so a process holding `process.stdin` can exit, and a
|
|
@@ -1583,6 +1613,7 @@ var StdioServerTransport = class {
|
|
|
1583
1613
|
#data = (chunk) => this.#receive(chunk.toString());
|
|
1584
1614
|
#ending = () => this.#onClose();
|
|
1585
1615
|
#failure = (error) => this.#emitter.emit("error", error);
|
|
1616
|
+
#pending = /* @__PURE__ */ new Set();
|
|
1586
1617
|
#buffer = "";
|
|
1587
1618
|
#started = false;
|
|
1588
1619
|
#closed = false;
|
|
@@ -1606,9 +1637,30 @@ var StdioServerTransport = class {
|
|
|
1606
1637
|
this.#input.on("data", this.#data);
|
|
1607
1638
|
this.#input.on("close", this.#ending);
|
|
1608
1639
|
this.#input.on("error", this.#failure);
|
|
1640
|
+
this.#output.on("error", this.#failure);
|
|
1609
1641
|
}
|
|
1642
|
+
/**
|
|
1643
|
+
* Sends one newline-delimited JSON-RPC message through the caller-owned output stream.
|
|
1644
|
+
*
|
|
1645
|
+
* @remarks
|
|
1646
|
+
* The writable completion callback is the backpressure boundary. This method awaits that
|
|
1647
|
+
* callback rather than adding a `drain` listener. Closing the transport rejects every send
|
|
1648
|
+
* whose callback has not settled.
|
|
1649
|
+
*
|
|
1650
|
+
* @param message - The message to serialize and write
|
|
1651
|
+
* @returns Resolves when the output confirms the write
|
|
1652
|
+
* @throws Thrown with `stdio transport is not connected` after the transport closes
|
|
1653
|
+
* @throws Thrown with the output callback error or synchronous write failure
|
|
1654
|
+
*/
|
|
1610
1655
|
async send(message) {
|
|
1611
|
-
this.#
|
|
1656
|
+
if (this.#closed) throw new Error("stdio transport is not connected");
|
|
1657
|
+
const pending = Promise.withResolvers();
|
|
1658
|
+
this.#pending.add(pending);
|
|
1659
|
+
try {
|
|
1660
|
+
await Promise.race([writeLine(this.#output, `${JSON.stringify(message)}\n`), pending.promise]);
|
|
1661
|
+
} finally {
|
|
1662
|
+
this.#pending.delete(pending);
|
|
1663
|
+
}
|
|
1612
1664
|
}
|
|
1613
1665
|
async close() {
|
|
1614
1666
|
if (this.#closed) return;
|
|
@@ -1631,6 +1683,9 @@ var StdioServerTransport = class {
|
|
|
1631
1683
|
this.#input.removeListener("data", this.#data);
|
|
1632
1684
|
this.#input.removeListener("close", this.#ending);
|
|
1633
1685
|
this.#input.removeListener("error", this.#failure);
|
|
1686
|
+
this.#output.removeListener("error", this.#failure);
|
|
1687
|
+
for (const pending of this.#pending) pending.reject(/* @__PURE__ */ new Error("stdio transport is not connected"));
|
|
1688
|
+
this.#pending.clear();
|
|
1634
1689
|
if (!this.#flowing && this.#input.listenerCount("data") === 0) this.#input.pause();
|
|
1635
1690
|
}
|
|
1636
1691
|
};
|
|
@@ -2183,5 +2238,6 @@ exports.readSessionHeader = readSessionHeader;
|
|
|
2183
2238
|
exports.rejectUnknownSession = rejectUnknownSession;
|
|
2184
2239
|
exports.sendEventStream = sendEventStream;
|
|
2185
2240
|
exports.upgradeRequestPath = upgradeRequestPath;
|
|
2241
|
+
exports.writeLine = writeLine;
|
|
2186
2242
|
|
|
2187
2243
|
//# sourceMappingURL=index.cjs.map
|