promptdojo_

Writing a tiny MCP server — registries, dispatch, and the response shape — step 6 of 9

Cursor wrote a call_tool dispatcher. When the handler raises an exception, the dispatcher returns just the exception's string — not an MCP error envelope. The client has no way to tell this was an error vs. a normal result.

Fix line 11 so that on exception, the dispatcher returns the proper MCP error shape:

{"isError": True, "content": [{"type": "text", "text": str(e)}]}

Expected output:

True
boom
The break is on line 7 — but read the whole snippet first.

full-screen editor opens — close anytime to keep reading.