Skip to content

Commit c3495d2

Browse files
Merge pull request #56 from modelcontextprotocol/justin/configurable-stderr
Make stderr behavior configurable
2 parents 9db0057 + b59c381 commit c3495d2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/client/stdio.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import process from "node:process";
33
import { ReadBuffer, serializeMessage } from "../shared/stdio.js";
44
import { JSONRPCMessage } from "../types.js";
55
import { Transport } from "../shared/transport.js";
6+
import { Stream } from "node:stream";
67

78
export type StdioServerParameters = {
89
/**
@@ -21,6 +22,13 @@ export type StdioServerParameters = {
2122
* If not specified, the result of getDefaultEnvironment() will be used.
2223
*/
2324
env?: Record<string, string>;
25+
26+
/**
27+
* How to handle stderr of the child process. This matches the semantics of Node's `child_process.spawn`.
28+
*
29+
* The default is "inherit", meaning messages to stderr will be printed to the parent process's stderr.
30+
*/
31+
stderr?: "inherit" | "ignore" | Stream;
2432
};
2533

2634
/**
@@ -102,7 +110,7 @@ export class StdioClientTransport implements Transport {
102110
this._serverParams.args ?? [],
103111
{
104112
env: this._serverParams.env ?? getDefaultEnvironment(),
105-
stdio: ["pipe", "pipe", "inherit"],
113+
stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
106114
shell: false,
107115
signal: this._abortController.signal,
108116
},

0 commit comments

Comments
 (0)