From 1025b3fc557fb06c3a4f62f0e2e90fbe2f8e11e0 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Wed, 20 Nov 2024 21:19:06 +0000 Subject: [PATCH 1/2] Add way to get child process stderr pipe --- src/client/stdio.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/client/stdio.ts b/src/client/stdio.ts index 4c78b3562..47824b2d6 100644 --- a/src/client/stdio.ts +++ b/src/client/stdio.ts @@ -1,4 +1,4 @@ -import { ChildProcess, spawn } from "node:child_process"; +import { ChildProcess, IOType, spawn } from "node:child_process"; import process from "node:process"; import { ReadBuffer, serializeMessage } from "../shared/stdio.js"; import { JSONRPCMessage } from "../types.js"; @@ -28,7 +28,7 @@ export type StdioServerParameters = { * * The default is "inherit", meaning messages to stderr will be printed to the parent process's stderr. */ - stderr?: "inherit" | "ignore" | Stream; + stderr?: IOType | Stream | number; }; /** @@ -123,7 +123,7 @@ export class StdioClientTransport implements Transport { // (i.e. via `electron-forge start`) vs a production environment // (i.e. YourApp.exe). detached: process.platform === "win32" && isElectron(), - } + }, ); this._process.on("error", (error) => { @@ -161,6 +161,15 @@ export class StdioClientTransport implements Transport { }); } + /** + * The stderr stream of the child process, if `StdioServerParameters.stderr` was set to "pipe" or "overlapped". + * + * This is only available after the process has been started. + */ + get stderr(): Stream | null { + return this._process?.stderr ?? null; + } + private processReadBuffer() { while (true) { try { From 4103ef53ed1e62360e3f5213e6baa783c16a800f Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Wed, 20 Nov 2024 21:19:15 +0000 Subject: [PATCH 2/2] Bump package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bf9d62ed3..1a084648d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@modelcontextprotocol/sdk", - "version": "0.6.1", + "version": "0.7.0", "description": "Model Context Protocol implementation for TypeScript", "license": "MIT", "author": "Anthropic, PBC (https://anthropic.com)",