3.1 KiB
3.1 KiB
name, description
| name | description |
|---|---|
| mcp-server-debugging | MCP server tools missing or fails to start ("Connection closed"): reproduce via stdio client, pin mcp<2, fix writable HOME/PATH. |
MCP Server Debugging
Diagnose and fix OpenClaw MCP servers whose tools never appear or that crash on startup.
Trigger
- A configured MCP server's tools are absent from the session, or a stdio MCP client fails
initializewithConnection closed. - A newly added MCP server does not show up as
<name>__*tools.
Steps
- Read the server definition: call
gatewaywithaction=config.get,path=mcp; notecommand,args,env,cwdfor the failing server. - Reproduce and capture the real error: run the configured command directly with stdin from
/dev/null(e.g.timeout 60 python3 <launcher> < /dev/null 2>&1 | head -40). Completion: stderr shows the underlying failure, not only the client-side "Connection closed". - Map the error to the fix:
ModuleNotFoundError: No module named 'mcp.server.fastmcp'→ the runner pulled mcp 2.x, whereFastMCPwas renamed toMCPServer. Fix: pin 1.x, e.g. runuvx --with "mcp<2" <package>, or add the pin inside the launcher'sos.execvpcall.Read-only file systemon a home/credentials path (launcher writes toPath.home()/.<name>) →HOMEis read-only. Fix: pointHOMEto a writable dir (e.g./tmp) or change the written path.FileNotFoundError: uvx→ prepend the uvx directory (normally/home/openclaw/.openclaw/bin) toPATH.
- Verify end-to-end with a minimal stdio client before declaring success: spawn the fixed command,
initialize,list_tools, then call the target tool and confirm real data returns. Useuv run --with mcp --python 3.12 python <client.py>where the client usesmcp.client.stdio.stdio_client+ClientSession, passingenvwith the correctedHOME/PATH. - Route config changes through the
openclawtool (human approval required); never edit gateway config files directly. Report the exact old → new command.
Tool calls fail with argument validation errors
- An MCP tool returning a pydantic
Unexpected keyword argumenterror means the argument names are wrong for that server, not that the server is down: read the real schema withtool_describeand retry with its exact parameters. - Home Assistant MCP:
ha_call_servicetakes{domain, service, entity_id, data}(notservice_data/target);ha_search_entitiestakes{query}only (nodomain). A successful call reportssuccess: trueinstructuredContent. - A type/filter variant that errors with
'NoneType' object has no attribute 'get'(e.g. Spotify MCPtypes=playlist) → switch to a working type (types=trackoralbum), act on that URI, and report the server bug instead of retrying the same call.
Pitfalls
- A session only exposes tools loaded at session start; a newly added server's tools appear as
<name>__*only after a gateway reload. - Test with the same
HOME/PATHthe gateway uses, otherwise you validate the wrong environment. - Never print secret values; check presence only (
[ -n "${VAR}" ]).