@@ -3,6 +3,7 @@ import process from "node:process";
3
3
import { ReadBuffer , serializeMessage } from "../shared/stdio.js" ;
4
4
import { JSONRPCMessage } from "../types.js" ;
5
5
import { Transport } from "../shared/transport.js" ;
6
+ import { Stream } from "node:stream" ;
6
7
7
8
export type StdioServerParameters = {
8
9
/**
@@ -21,6 +22,13 @@ export type StdioServerParameters = {
21
22
* If not specified, the result of getDefaultEnvironment() will be used.
22
23
*/
23
24
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 ;
24
32
} ;
25
33
26
34
/**
@@ -102,7 +110,7 @@ export class StdioClientTransport implements Transport {
102
110
this . _serverParams . args ?? [ ] ,
103
111
{
104
112
env : this . _serverParams . env ?? getDefaultEnvironment ( ) ,
105
- stdio : [ "pipe" , "pipe" , "inherit" ] ,
113
+ stdio : [ "pipe" , "pipe" , this . _serverParams . stderr ?? "inherit" ] ,
106
114
shell : false ,
107
115
signal : this . _abortController . signal ,
108
116
} ,
0 commit comments