For tools/call, the tool name appears twice in the request: in the Mcp-Name header and in the body. Gateways decide based on the header; the server runs what is in the body. So that both see the same thing, the server rejects any mismatch with -32020.
Symptom
curl -s -w " -> HTTP %{http_code}\n" http://leitwarte.labor/mcp "${KOPF[@]}" -H "Mcp-Method: tools/call" -H "Mcp-Name: wo_bin_ich" --data @neustart.json
curl -s -w " -> HTTP %{http_code}\n" http://leitwarte.labor/mcp "${KOPF[@]}" -H "Mcp-Method: tools/call" --data @neustart.json
{"jsonrpc":"2.0","id":1,"error":{"code":-32020,"message":"mcp-name header does not match the request body's 'name' parameter"}} -> HTTP 400
{"jsonrpc":"2.0","id":1,"error":{"code":-32020,"message":"mcp-name header does not match the request body's 'name' parameter"}} -> HTTP 400
In the course, an attacker writes a harmless name into the header to get around a block rule in the gateway – or leaves the header out. The body calls dienst_neustarten (“restart service”).
Diagnosis
Compare the Mcp-Name header with params.name in the body. Without an error, both hold the same value, and for tools/call both headers are set. Cross-check with the matching name: the gateway blocks the tool before any pod is reached.
curl -s -w " -> HTTP %{http_code}\n" http://leitwarte.labor/mcp "${KOPF[@]}" -H "Mcp-Method: tools/call" -H "Mcp-Name: dienst_neustarten" --data @neustart.json
Forbidden -> HTTP 403
Causes
header contradictsMcp-Name names a different tool
The header claims something other than the body. That is exactly the trick that could fool a gateway that only looks at the header.
header missingMcp-Name or Mcp-Method not set
For tools/call the request needs both headers. If one is missing, the server treats it as a mismatch.
versionVersion header does not match _meta
The server reports the same error class when MCP-Protocol-Version does not match the version in _meta.
Fix
-H "Mcp-Method: tools/call" -H "Mcp-Name: dienst_neustarten"
Don't: Switch off the check in the server so that “it works again”. It makes sure gateway and server decide on the same basis.
MCPA hands-on, Day 14: audit log, OpenTelemetry and a gateway with block rules in front of the MCP server on k3s.
Go to day 14 →
FAQ
May Mcp-Name be encoded?
Yes, as =?base64?…?=, for example for names with special characters. Server and gateway must decode the value before comparing.
Why is the rejected request missing from the audit log?
A request the gateway already blocks (403) never reaches a pod. -32020, by contrast, comes from the server itself.