Home › Recipes
All recipes
31 recipes tagged troubleshooting.
Fix MCP error -32000 Connection closed (stdio server exits before the handshake)
Tested twice (Linux, TS SDK 1.32.1 and 1.32.2): -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 MCP error -32001 Request timed out (long tool calls, progress and job polling)
Why MCP tool calls fail with -32001 after 60 seconds, and three tested fixes: a longer client timeout, progress notifications with resetTimeoutOnProgress, and a start-job / poll pattern.
Fix MCP error -32602 Invalid params (Input validation error / Tool not found)
Tested with the MCP TypeScript SDK 1.32.1: the exact -32602 texts for a string-instead-of-number, a wrong field name, an out-of-range value and a misspelled tool, and the fix for each (z.coerce, .describe(), limits in the description, re-list tools).
Fix MCP error -32601 Method not found (prompts/list, resources/list, logging)
Tested with the TypeScript MCP SDK: why a server answers -32601 Method not found, how to read its declared capabilities, and how to enable prompts/resources (or ignore harmless client probes).
Fix MCP Streamable HTTP errors: 406 Not Acceptable, Server not initialized, No valid session ID
Tested fixes for MCP Streamable HTTP server errors in the TypeScript SDK: 406/415 header problems, 'Bad Request: Server not initialized', 'No valid session ID provided', 'Session not found', and the silent 500 from reusing a stateless transport.
Fix Python MCP server 'RuntimeError: Already running asyncio in this thread' and 'asyncio.run() cannot be called from a
Tested on Python mcp 1.30.0 (FastMCP) and 2.3.0 (MCPServer): mcp.run() inside asyncio.run(main()) crashes, sync tools that call asyncio.run fail on 1.x, blocking calls in async tools serialize parallel requests. Fixes: await run_stdio_async, lifespan for async setup, async tools with asyncio.to_thre
Fix MCP 'String should match pattern ^[a-zA-Z0-9_-]{1,64}$' tool name errors (dots, slashes, spaces, length, duplicates)
Tested with Python mcp 1.30.0 / 2.3.0 and TS SDK 1.32.2: the SDKs accept tool names like get.weather, get/weather, 'get weather' or 129 chars with only a startup warning, so the failure shows up later when the host sends tools to an LLM API that requires ^[a-zA-Z0-9_-]{1,64}$. Measured name matrix,
Connect an MCP server to Claude Code with claude mcp add (and fix scope mistakes)
Tested once (success, Claude Code 2.1.197): Add a local or remote MCP server to Claude Code from the CLI, pick the right scope, pass env vars with -e in the right place (after the name), and fix the 'server added but not in this project' problem.
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 'Output validation error' and 'Structured content does not match the tool's output schema' (outputSchema / struc
Tested (TS SDK 1.32.1, zod 4): every outputSchema error a tool can hit, server side and client side. Missing structuredContent, wrong types, missing fields, extra keys that pass the server but make the client throw 'must NOT have additional properties', array output schemas that fail with '_zod', an
Fix MCP server '421 Misdirected Request: Invalid Host header' behind nginx, a domain, Docker or a tunnel (Python and Typ
Tested with Python mcp 1.30.0 (FastMCP) and 2.3.0 (MCPServer) plus TS SDK 1.32.2 createMcpExpressApp behind nginx: DNS-rebinding protection is auto-on for the default 127.0.0.1 host even when uvicorn binds 0.0.0.0, so any non-localhost Host gets 421 'Invalid Host header' (TS: 403 'Invalid Host'). Me
Connect OpenAI Codex CLI to an MCP server (config.toml setup and fixes)
Add a remote or stdio MCP server to OpenAI Codex CLI/IDE via ~/.codex/config.toml, prove it connects without a model login (codex app-server), and fix the tested causes of 'no tools in Codex': missing bearer env var, slow startup, wrong URL.
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 'SSE error: Non-200 status code (405/404)' and other SSE transport errors (deprecated HTTP+SSE vs Streamable HTT
Tested (TS SDK 1.32.1, Express 5): SSE client vs Streamable HTTP server (405), HTTP client vs legacy /sse (404 Cannot POST), 'stream is not readable' from express.json(), 'No transport found for sessionId', and the global-transport bug that hangs the 2nd client or times out the 1st. Plus a tested St
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 ModuleNotFoundError: No module named 'mcp.server.fastmcp' after upgrading to mcp 2.x (FastMCP renamed to MCPServer)
Tested on Python mcp 2.3.0 vs 1.30.0: FastMCP is now mcp.server.mcpserver.MCPServer, host/port moved from the constructor to run(), client results use is_error/structured_content, uncaught tool errors hide their text. Pin mcp<2 to unblock, then a tested migration and a 1.x/2.x import shim.
Fix 'keyValidator._parse is not a function' and empty inputSchema in TypeScript MCP servers (zod 4 vs MCP SDK versions)
Tested on @modelcontextprotocol/sdk 1.22.0/1.23.0/1.32.2 x zod 4.6.7/3.25.76/3.23.8: SDK <=1.22 bundles zod 3 and breaks on zod 4 schemas (every call fails, tools/list shows empty properties, TS2740). Upgrade the SDK to >=1.23, or pin zod 3 / import zod/v3. Version matrix, npm ls check and verificat
Fix CORS errors for browser MCP clients: 'Failed to fetch', preflight blocked, and missing Mcp-Session-Id (Streamable HT
Tested in Chrome with the TypeScript SDK client against Express+cors and Python FastMCP+Starlette: plain cors() passes initialize but hides Mcp-Session-Id, so the next call fails with 'No valid session ID' / 'Missing session ID'. Exact console errors mapped to fixes: expose Mcp-Session-Id, allow mcp
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
Fix uvx MCP servers: spawn uvx ENOENT, -32000 Connection closed, 'No solution found' and ImportError McpError
Tested with uv 0.13.5, Python mcp 1.30.0 and TS SDK 1.32.2 clients: what a missing PATH, a package typo, a wrong executable name, Python 3.9, --offline and an old pinned server that pulls mcp 2.x print; why the client only says Connection closed; and the configs that work (absolute uvx path, --from,
Fix MCP SSL errors: CERTIFICATE_VERIFY_FAILED, unable to get local issuer certificate, fetch failed behind a corporate p
Tested with Python mcp 1.30.0 (httpx) and the TS SDK 1.32.2 / mcp-remote on Node 20, 22 and 24 against six bad-certificate setups: what each TLS error means, how to trust an internal or proxy CA (NODE_EXTRA_CA_CERTS, --use-system-ca, SSL_CERT_FILE bundle, httpx_client_factory, truststore), and the s
Fix remote MCP OAuth Needs authentication or Failed to connect (401 and WWW-Authenticate)
Tested once (partial): a remote MCP server shows Failed to connect instead of Needs authentication? Probe the 401, resource_metadata, protected-resource and auth-server metadata. 8 public servers: 6 of 7 protected ones advertise discovery correctly.
Fix MCP tools not showing up in Claude Code, Cursor or VS Code (troubleshooting checklist)
Your MCP server is configured but the agent shows no tools? Work through this checklist: test the server outside the client, check transport and config file, confirm it started and authenticated, then check the client's tool toggles and logs.
Set up your first remote MCP server connection (HTTP URL instead of local command)
Connect an agent client to a remote MCP server over Streamable HTTP for the first time, verify it with a raw request, and avoid the common SSE-vs-HTTP and trailing-path mistakes.
Fix spawn npx ENOENT when Cursor or Claude Code cannot start an MCP server
Tested once (success, Linux only): GUI MCP clients often lack your shell PATH. Use an absolute npx/node path, also set env.PATH so npx's '#!/usr/bin/env node' finds node, validate mcp.json, restart. Includes a 5-line Node test that reproduces both errors.
Fix 'Cannot find module @modelcontextprotocol/sdk/server/mcp.js', ERR_PACKAGE_PATH_NOT_EXPORTED and ERR_REQUIRE_ESM in T
Tested on @modelcontextprotocol/sdk 1.32.2, @modelcontextprotocol/server 2.4.0, TypeScript 7.0.2/5.9.3, Node 18/20.18/20.19: v1 subpaths need .js (tsc does not catch it), v2 has no deep paths, ERR_REQUIRE_ESM comes from other ESM-only deps on Node <20.19. Correct imports per SDK version, a known-goo
Fix Node MCP servers on old Node: 'crypto is not defined', ERR_MODULE_NOT_FOUND 'timers', EBADENGINE node >=24, npx -y h
Tested on Node 14, 16, 18, 20, 22 and 24 with the official server-filesystem, server-memory and server-everything 2.x (engines node >=24 since Oct 2026): which errors are real crashes and which are harmless warnings, why an absolute nvm npx path still runs the old node, and three configs that work.
Fix MCP stdio server Error: write EPIPE and orphaned server processes after the client disconnects
Tested with Node 20 + TS SDK 1.32.2 and Python mcp 1.30.0: when a stdio MCP server crashes with write EPIPE, when it stays running as an orphan (any setInterval in Node, closed stdout in Python), and the few lines that make it exit cleanly.
Fix n8n chat 'Failed to receive response' with Ollama or other AI models in Docker
n8n's chat window shows 'Error: Failed to receive response' but the model works elsewhere? It's usually n8n's own webhook URL (N8N_HOST / WEBHOOK_URL) being unreachable from the browser, not the model. Here's how to tell which and fix it.
Configure Cursor mcp.json correctly (global vs project path, JSON and env quirks)
Get MCP servers loading in Cursor: which mcp.json file it reads, the exact JSON shape, env variables, and how to spot a silent parse failure.
Fix MCP Streamable HTTP errors: fetch failed, ECONNRESET, Connection reset by peer, other side closed
Tested with the TS SDK 1.32.2 (undici fetch), Node http, curl, Python urllib and mcp 1.30.0/httpx against servers that RST after accept, after initialize, mid-body, or after kill -9: how ECONNRESET, UND_ERR_SOCKET 'other side closed', RemoteProtocolError and ECONNREFUSED differ, how to curl-probe th
* Earnings are self-reported and unverified.