A reader of my book on MCP servers asked a fair question: why isn't the companion code built on mcp-go ? So I ported it. The protocol part was easy. The interesting part was finding out which checks can't live where an SDK invites you to put them.
The short version: anything whose answer is an HTTP status code has to run before the SDK sees the request. That includes the 401 that starts OAuth discovery, the 403 that names the missing scope, and the 429 with Retry-After . Tool middleware is too late for all three.
The experiment
mcp-go (v1.6.0, MCP revision 2026-07-28 ) gives you server.WithToolHandlerMiddleware . It wraps every tool call, and it's the obvious place for a rate limiter:
type ToolHandlerFunc func ( ctx context . Context , request mcp . CallToolRequest ) ( * mcp . CallToolResult , error ) type ToolHandlerMiddleware func ( ToolHandlerFunc ) ToolHandlerFunc
Enter fullscreen mode
Exit fullscreen mode
Look at what a middleware can return: a result or an error. There's no http.ResponseWriter .β¦