show server stderr in inspector UI

This commit is contained in:
Ashwin Bhat
2024-11-20 18:11:37 -08:00
parent 9196c1ddaf
commit 22bf78720b
4 changed files with 85 additions and 4 deletions

View File

@@ -42,7 +42,12 @@ const createTransport = async (query: express.Request["query"]) => {
console.log(
`Stdio transport: command=${command}, args=${args}, env=${JSON.stringify(env)}`,
);
const transport = new StdioClientTransport({ command, args, env });
const transport = new StdioClientTransport({
command,
args,
env,
stderr: "pipe",
});
await transport.start();
console.log("Spawned stdio transport");
return transport;
@@ -75,6 +80,18 @@ app.get("/sse", async (req, res) => {
await webAppTransport.start();
if (backingServerTransport.stderr) {
backingServerTransport.stderr.on("data", (chunk) => {
webAppTransport.send({
jsonrpc: "2.0",
method: "notifications/stderr",
params: {
content: chunk.toString(),
},
});
});
}
mcpProxy({
transportToClient: webAppTransport,
transportToServer: backingServerTransport,