@@ -3,6 +3,7 @@ import process from "node:process";
33import { ReadBuffer , serializeMessage } from "../shared/stdio.js" ;
44import { JSONRPCMessage } from "../types.js" ;
55import { Transport } from "../shared/transport.js" ;
6+ import { Stream } from "node:stream" ;
67
78export 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