Open
Description
const transport = new StdioClientTransport({
command: argv.command,
args: argv.args,
env: process.env as Record<string, string>,
stderr: 'pipe',
});
const client = new Client(
{
name: "mcp-proxy",
version: "1.0.0",
},
{
capabilities: {},
},
);
Here, transport.stderr
is gonna be null
, which is a problem if the intent is to capture the error messages at the start time.
A somewhat workaround is something like this:
let stderrOutput = '';
try {
console.info('connecting to the MCP server...');
const connectionPromise = client.connect(transport);
transport?.stderr?.on('data', (chunk) => {
stderrOutput += chunk.toString();
});
await connectionPromise;
console.info('connected to the MCP server');
} catch (error) {
console.error('could not connect to the MCP server', error, prefixLines(stderrOutput, '> '));
await setTimeout(1000);
process.exit(1);
}
I've used it here punkpeye/mcp-proxy@4933267