-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
If the inspector connects to a STDIO MCP server, which sends messages to stderr when receiving SIGTERM, it will break when disconnecting.
The STDIO MCP server sends messages to stderr, then the inspector sends it through the webAppTrarnsport, which is already closed by now, which leads to an error that breaks the inspector and prevent further connections.
To Reproduce
Steps to reproduce the behavior:
- Write a STDIO MCP server that sends messages to stderr when receiving SIGTERM.
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
// Define a simple calculator tool
const CalculatorToolSchema = {
operation: z.enum(["add", "subtract", "multiply", "divide"]),
a: z.number(),
b: z.number(),
};
const createServer = () => {
// Create an MCP server instance
const server = new McpServer({
name: "stateless-mcp-server",
version: "1.0.0",
});
}
// ...register tools and anything
const server = createServer();
const transport = new StdioServerTransport();
await server.connect(transport);
process.on('SIGINT', () => {
console.error("SIGINT")
process.exit()
})
process.on('SIGTERM', () => {
console.error("SIGTERM")
process.exit()
})
process.on('SIGHUP', () => {
console.error("SIGHUP")
process.exit()
})- Run the inspector and connect to it, then disconnect, then connect again, and the inspect cannot go on.
Expected behavior
The error is true that the transport is closed and should not send though it, but it is not that important and should not block further interactions with the inspector. Maybe logging it is enough.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working