# Your MCP gateway reads a header. Your tool reads the body.

- Canonical: https://ansezz.com/blog/laravel-mcp-param-headers-match-body/
- Markdown: https://ansezz.com/blog/laravel-mcp-param-headers-match-body/index.md
- Published: 2026-11-30
- Description: MCP 2026-07-28 lets a tool argument travel in a header and in the body. Laravel MCP 1.2.1 rejects a mismatch, but only for tools that declare it.
- Category: [laravel](https://ansezz.com/blog/category/laravel/)
- Tags: [laravel](https://ansezz.com/blog/tag/laravel/), [mcp](https://ansezz.com/blog/tag/mcp/), [security](https://ansezz.com/blog/tag/security/), [api-design](https://ansezz.com/blog/tag/api-design/)

An MCP tool call can now carry one argument twice, once in the body and once in a header. If the two disagree, your gateway and your tool act on different values.

**TL;DR**

- The [MCP 2026-07-28 spec](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http) lets a server mark a tool argument with `x-mcp-header`. Clients then copy that value into an `Mcp-Param-{Name}` header, so a gateway can route on it without parsing the JSON body.
- A server must reject a header that disagrees with the body, with HTTP `400` and error `-32020`. [Laravel MCP 1.2.1](https://github.com/laravel/mcp/pull/406), released on 17 November, added that check. 1.2.0 and older accept the mismatch.
- The check only runs for tools that declare `x-mcp-header`, and it runs when the tool is called. Code you put in front of it sees the header first.

This is a different problem from the [Origin check](/blog/laravel-mcp-origin-validation/) and from the [stateless request headers](/blog/stateless-mcp-servers-laravel/). Those cover who is calling and which protocol version they speak. This one is about a value that appears in two places.

## A tool argument can now travel twice

Say a tool takes a `region` argument. In the 2026-07-28 spec, the server may add an `x-mcp-header` property to that argument in the tool's `inputSchema`:

```json
"region": { "type": "string", "x-mcp-header": "Region" }
```

When a tool declares this, the [spec](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http) says conforming clients must also send the value as `Mcp-Param-Region: us-west1`. The point is to let a load balancer, rate limiter, or WAF decide something without reading the body.

The annotation is optional for servers. The spec limits it to string, integer, and boolean arguments. A value that is not plain ASCII gets a Base64 form, `=?base64?...?=`.

Now you have the same fact in two places. The spec says why that is a problem. Servers must reject a mismatch because components can rely on different sources of truth, for example "a load balancer routing on the header value while the MCP server executes based on the body value."

That sentence is the whole risk. The gateway sees `staging`. The tool receives `production`.

**Try this**

List your tools and look for `x-mcp-header` in the `inputSchema`. If a tool has it, a header now mirrors an argument, and something in front of your app may be trusting the header.

## Laravel MCP 1.2.1 compares the two

The server side of the rule landed in [PR #406](https://github.com/laravel/mcp/pull/406), merged on 17 November and shipped in [v1.2.1](https://github.com/laravel/mcp/releases/tag/v1.2.1). For an annotated tool over HTTP, a mirrored header that is missing, unexpected, or different from the body now fails with `400` and `-32020`. Over stdio there are no headers, so the check is skipped.

The check runs when the tool is called. It does not run in the `ValidateMcpHeaders` middleware, because only the tool schema says which arguments carry the annotation.

One more thing: I could not find a fluent way to declare the annotation. A search of the [Laravel 13.x MCP docs](https://laravel.com/docs/13.x/mcp) for `x-mcp-header` finds nothing. The package's own test fixture adds it by overriding `toArray()`, so I did the same:

```php
public function toArray(): array
{
    $tool = parent::toArray();

    $tool['inputSchema']['properties']['region']['x-mcp-header'] = 'Region';

    return $tool;
}
```

**Note**

If you never add this annotation, nothing here changes for you. The check only protects tools that opt in.

## Same request, three versions

I built a small Laravel 13.44.1 app with one annotated tool, `drain-region-tool`, and ran the same requests against `laravel/mcp` 1.2.0, 1.2.1, and 1.3.0. The run was on 30 November 2026, at 17:52 Asia/Kuala_Lumpur, against a local server. The tool does nothing but echo the body value.

| Request | 1.2.0 | 1.2.1 and 1.3.0 |
| -- | -- | -- |
| Header `us-west1`, body `us-west1` | 200, `draining us-west1` | 200, `draining us-west1` |
| Header `staging`, body `production` | 200, `draining production` | 400, `-32020` |
| Header missing | 200, `draining production` | 400, `-32020` |
| Base64 header for `staging`, body `production` | 200, `draining production` | 400, `-32020` |
| Old-style client with no protocol headers, same mismatch | 200, `draining production` | 400, `-32020` |

On 1.2.0, a gateway that routes on `staging` forwards a request that runs on `production`. From 1.2.1 on, the same request is rejected before the tool runs. The message names the header and the body path, for example `The [Mcp-Param-Region] header value does not match the request body value at [/region]`.

![Comic pop-art scene of a blue robot with a magnifying glass comparing a blue tag with a note that has a red stripe, a red 400 stamp on the box, under the words COMPARE BOTH](/blog/laravel-mcp-param-headers-match-body/inline-1.webp)

*Same box, two labels. The server compares both and stamps 400 when they differ.*

**Note**

This is a local check with a synthetic tool. It is not a gateway test. I only checked how the server answers.

## Where the header is still only a hint

Two things in the same run are easy to miss.

First, the check only covers tools that declare the annotation. I added a second tool with the same `region` argument and no `x-mcp-header`. A request with a lying `Mcp-Param-Region` header returned `200` on every version, and the tool used the body. Nothing was wrong with the tool. But if your own code reads `Mcp-Param-Region` for every call, it is reading a value nobody validated for that tool.

Second, order. I added a middleware to the MCP route that records the header it sees. On the rejected request, it logged `Mcp-Param-Region='staging'` before the `400` came back. So a rate limit keyed on that header counts the request under `staging`, even though the call was refused.

That is mostly harmless for a counter. It is not harmless for a decision. An allow list or a tenant lookup in front of the tool should not treat the header as settled.

**Trusting the copy:** Middleware reads `Mcp-Param-Region`, picks a tenant or a rate bucket, and the tool trusts that choice later.

**Trusting the body:** The tool reads `region` from the arguments and authorizes that value. The header is used for routing and metering only.

> A header is a second opinion about an argument. The tool runs on the body.

The spec adds a note for intermediaries that enforce policy on these headers, such as routing or rate-limiting by tenant. They should check that `MCP-Protocol-Version` names a version that requires the validation. If it is older or missing, they should reject the request instead of trusting the header.

**Try this**

Grep your app for `Mcp-Param`. For each hit, ask whether the tool declares that header, and whether the code makes a decision with it before the tool call runs.

## What I would check this week

Run `composer show laravel/mcp`. If you are below 1.2.1 and any tool declares `x-mcp-header`, update first. From 1.2.1 on, a mismatch gets a `400`. Below it, the lie goes through.

If you never declared the annotation, you do not need it. Add it only when a gateway really needs a value to route or meter on, and keep it to the arguments that need it.

Keep authorization on the body. Put the check inside the tool, or in a policy it calls, and use the header for routing. Then a header that slips past a layer cannot change what the tool is allowed to do.

**Key takeaways**

- With `x-mcp-header`, one tool argument travels in the body and in an `Mcp-Param-{Name}` header. The spec says the server must reject a mismatch with `400` and `-32020`.
- Laravel MCP 1.2.1 and later do that for annotated tools over HTTP. 1.2.0 and older ran the body value while the header said something else.
- The header is only a hint for unannotated tools and for any code that runs before the tool call. Authorize on the body.

Which part of your stack reads an MCP header before your tool does?
