modelcontextprotocol / modelcontextprotocol/python-sdk
[Bug] Client sends empty _meta:{} on every request; strict servers (Meta Ads MCP) reject with HTTP 400
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.3k
- Forks
- 4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 31
Description
Description
JSONRPCDispatcher.send_raw_request attaches _meta to params unconditionally:
out_params = dict(params) if params is not None else {}
out_meta = dict(out_params.get("_meta") or {})
on_progress = opts.get("on_progress")
if on_progress is not None:
out_meta["progressToken"] = request_id
out_params["_meta"] = out_meta # <- empty dict goes on the wire
When no progress callback is set and the otel tracer is a no-op (default), out_meta stays {} and every request ships _meta: {}.
Strict JSON-RPC servers reject this: Meta's hosted Ads MCP server (https://mcp.facebook.com/ads) returns HTTP 400 with -32602 "_meta for Request must be a dict or null" on initialize, making it unreachable from any client built on this SDK. _meta: null is rejected identically — the field must be absent.
Other MCP clients Meta documents (Claude Code, ChatGPT) don't emit an empty _meta and connect fine.
Reproduction
Reported downstream from Hermes Agent (NousResearch/hermes-agent#105637), with a minimal curl repro against the real server (400 with _meta:{}}, 200 without). Happy to attach a self-contained repro against a local strict server if preferred.
Proposed fix
if out_meta:
out_params["_meta"] = out_meta
elif "_meta" in out_params:
del out_params["_meta"]
after inject_trace_context(out_meta) so a real trace context is still sent.
Environment
- mcp SDK: current main (
src/mcp/shared/jsonrpc_dispatcher.py) - Python 3.12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/mcp/shared/jsonrpc_dispatcher.py at JSONRPCDispatcher.send_raw_request and trace how out_meta is populated, including inject_trace_context. Run the initialize request against a strict server or the described minimal repro; done means requests without progress or trace metadata omit _meta entirely while retaining real metadata when present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100