Skip to content

app-server: add turn-scoped MCP metadata by server#24166

Draft
mzeng-openai wants to merge 1 commit into
mainfrom
dev/mzeng/mcp-meta-by-server
Draft

app-server: add turn-scoped MCP metadata by server#24166
mzeng-openai wants to merge 1 commit into
mainfrom
dev/mzeng/mcp-meta-by-server

Conversation

@mzeng-openai
Copy link
Copy Markdown
Collaborator

Why

App-server clients need a way to pass turn-scoped metadata to model-initiated tool calls for a particular MCP server, such as request location metadata for search, without exposing the broader responsesapiClientMetadata bag to every MCP server used during the turn.

What changed

  • Add experimental turn/start.mcpMetaByServer, keyed by configured MCP server name, and carry it through turn startup and active-turn steering.
  • Merge each configured metadata object into outbound _meta only for model-initiated calls routed through the matching server. An entry for an aggregate server such as codex_apps therefore applies to connector tools routed through that server.
  • Keep responsesapiClientMetadata scoped to Responses API requests rather than forwarding it to MCP requests.
  • Protect Codex-owned MCP request metadata keys, including turn metadata, app/plugin/thread/sandbox fields, and rollout trace correlation ids, from client override.
  • Document the experimental API and add protocol, core unit, and model-triggered MCP integration coverage.

Verification

  • cargo test -p codex-protocol
  • cargo test -p codex-app-server-protocol
  • cargo test -p codex-rollout-trace
  • cargo test -p codex-core --lib mcp_tool_call_request_meta
  • cargo test -p codex-core --lib turn_metadata_state_merges_client_metadata_without_replacing_reserved_fields
  • cargo test -p codex-core --lib steer_input_returns_active_turn_id
  • cargo test -p codex-core mcp_tool_call_receives_turn_metadata_for_selected_server
  • cargo test -p codex-app-server --test all turn_start_updates_sandbox_and_cwd_between_turns_v2
  • cargo check -p codex-mcp-server -p codex-thread-manager-sample
  • Generated stable and experimental app-server schema fixtures with just write-app-server-schema and just write-app-server-schema --experimental; stable fixtures remain unchanged because the new field is experimental.

Known issue

  • cargo test -p codex-core aborts in thread_manager::tests::resume_and_fork_do_not_restore_thread_environments_from_rollout with a stack overflow; the same test reproduces when run in isolation, while the feature-specific core tests above pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant