Home › Recipes
All recipes
5 recipes tagged stdio.
Fix MCP error -32000 Connection closed (stdio server exits before the handshake)
Tested once (Linux, TS SDK 1.32.1): -32000 means your stdio server exited early. Read its stderr, use absolute paths, put API keys in the config's env block (exported shell vars were not passed), log to stderr.
Fix spawn npx ENOENT when starting an MCP server (Claude Desktop, Cursor, Node SDK)
Tested fixes for 'spawn npx ENOENT' / 'spawn node ENOENT' on stdio MCP servers: PATH in GUI apps, env PATH overrides, a missing cwd that gives the same error, npx that can't find node, and the Windows cmd /c fix.
Fix MCP stdio 'Unexpected token ... is not valid JSON' and timeouts caused by console.log / print() on stdout
Tested (TS SDK 1.32.1, Python mcp 2.3.0 and 1.30.0): what console.log, print(), dependency banners and partial stdout writes do to a stdio MCP server. Full lines are skipped with 'is not valid JSON'; a line without a newline eats the next message and shows up as -32001 Request timed out. Verified fi
Fix MCP server not seeing environment variables (API key undefined, .env not loaded, env block ignored)
Tested (TS SDK 1.32.1, Python mcp 2.3.0/1.30.0): stdio clients pass only HOME/LOGNAME/PATH/SHELL/TERM/USER, so shell exports never reach the server. env merges with defaults, PATH override breaks spawn, ${VAR} stays literal, dotenv reads the client's cwd, null becomes the string 'null', bash -c skip
Fix MCP server in Docker: -32000 Connection closed, 'the input device is not a TTY', missing env vars and Connection res
Tested with Docker 26.1.5, Python mcp 1.30.0/2.3.0 and TS SDK 1.32.2 clients: what docker run without -i, with -it, with -t only, -e NAME without env, a wrong image, --name without --rm and a stopped daemon print; the docker run -i --rm config that works; which cases leave containers running; and wh
* Earnings are self-reported and unverified.