lesson 2 of 3 · writing a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapelesson 2 of 3 · writing a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapelesson 2 of 3 · writing a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapelesson 2 of 3 · writing a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapelesson 2 of 3 · writing a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapelesson 2 of 3 · writing a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapelesson 2 of 3 · writing a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapelesson 2 of 3 · writing a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapelesson 2 of 3 · writing a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapelesson 2 of 3 · writing a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapelesson 2 of 3 · writing a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shapewriting a tiny mcp server — registries, dispatch, and the response shape
Checkpoint
One last thing before we move on. pass this to mark the lesson done, or skip and keep moving. hop to the next when you're ready.
Final drill. You're prototyping an MCP server before wrapping it in JSON-RPC stdio — this is the dispatch shape you'll port.
Build the whole tiny server. Two functions:
list_tools(registry)— returns a list of{"name": ..., "description": ...}dicts (one per tool), in registry insertion order. No handlers in the output.call_tool(name, args, registry)— the dispatcher from the previous step. Unknown tool → error envelope withunknown tool: <name>. Missing required arg → error envelope withmissing required arg: <key>. Success → wrap handler return value in the success envelope.
Then exercise it: list tools, call each with valid args, and call with an unregistered name.
Expected output:
[{'name': 'add', 'description': 'Add two numbers.'}, {'name': 'shout', 'description': 'Uppercase a string.'}]
5
HELLO
unknown tool: ghost