core-agent-ide/codex-rs/rmcp-client/src
nicholasclark-openai 2bee37fe69
Plumb MCP turn metadata through _meta (#15190)
## Summary

Some background. We're looking to instrument GA turns end to end. Right
now a big gap is grouping mcp tool calls with their codex sessions. We
send session id and turn id headers to the responses call but not the
mcp/wham calls.

Ideally we could pass the args as headers like with responses, but given
the setup of the rmcp client, we can't send as headers without either
changing the rmcp package upstream to allow per request headers or
introducing a mutex which break concurrency. An earlier attempt made the
assumption that we had 1 client per thread, which allowed us to set
headers at the start of a turn. @pakrym mentioned that this assumption
might break in the near future.

So the solution now is to package the turn metadata/session id into the
_meta field in the post body and pull out in codex-backend.

- send turn metadata to MCP servers via `tools/call` `_meta` instead of
assuming per-thread request headers on shared clients
- preserve the existing `_codex_apps` metadata while adding
`x-codex-turn-metadata` for all MCP tool calls
- extend tests to cover both custom MCP servers and the codex apps
search flow

---------

Co-authored-by: Codex <noreply@openai.com>
2026-03-19 22:05:13 +00:00
..
bin Fix MCP tool calling (#14491) 2026-03-12 13:38:52 -07:00
auth_status.rs Apply argument comment lint across codex-rs (#14652) 2026-03-16 16:48:15 -07:00
lib.rs use scopes_supported for OAuth when present on MCP servers (#14419) 2026-03-12 11:57:06 -07:00
logging_client_handler.rs [elicitations] Switch to use MCP style elicitation payload for mcp tool approvals. (#13621) 2026-03-06 01:50:26 -08:00
oauth.rs Validate CODEX_HOME before resolving (#10249) 2026-01-30 15:46:33 -08:00
perform_oauth_login.rs Apply argument comment lint across codex-rs (#14652) 2026-03-16 16:48:15 -07:00
program_resolver.rs fix: resolve Windows MCP server execution for script-based tools (#3828) 2025-11-16 13:41:10 -08:00
rmcp_client.rs Plumb MCP turn metadata through _meta (#15190) 2026-03-19 22:05:13 +00:00
utils.rs [rmcp-client] Recover from streamable HTTP 404 sessions (#13514) 2026-03-06 10:02:42 -05:00