Writing a tiny MCP server — registries, dispatch, and the response shape — step 7 of 9
The dispatcher below calls the handler without checking whether
the required arguments are present. If a required key is missing,
the handler crashes with a KeyError deep in user code — instead
of returning a clean MCP error.
Fix it: before calling the handler, check each name in
tool["inputSchema"]["required"] against args. If any are
missing, return the MCP error envelope with text
missing required arg: <name> (the first missing one is fine).
Expected output:
True
missing required arg: city
The dispatcher below calls the handler without checking whether
the required arguments are present. If a required key is missing,
the handler crashes with a KeyError deep in user code — instead
of returning a clean MCP error.
Fix it: before calling the handler, check each name in
tool["inputSchema"]["required"] against args. If any are
missing, return the MCP error envelope with text
missing required arg: <name> (the first missing one is fine).
Expected output:
True
missing required arg: city
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.