Commit Graph

200 Commits

Author SHA1 Message Date
Eric Traut
343074d420 Report runtime MCP connection status (#40068)
## Why

MCP inventory can be cached or collected separately from a thread's live
connections, so tool availability alone does not describe the current runtime
state.

## What changed

- Add a nullable `runtimeStatus` to `mcpServerStatus/list` for thread-scoped
  requests, covering not-started, starting, connected, authentication-required,
  failed, cancelled, and disabled connections.
- Observe published connection state without starting or reconnecting servers,
  and return an unknown status when no thread is supplied or the active
  configuration no longer matches the published registration.
- Show connection state and tool counts in the compact `/mcp` view while
  retaining the detailed inventory in `/mcp verbose` and compatibility with
  servers that omit `runtimeStatus`.

## Testing

- Cover runtime status transitions, deferred and disabled servers, closed
  transports, configuration changes, protocol compatibility, and TUI rendering.

GitOrigin-RevId: e3bb6efe652f0fa8b3c97d5c53e4729b3a87cd91
2026-08-22 05:54:43 +00:00
Ankush Gupta
970b7f2ff4 Preserve strict MCP auto-review outcomes (#40031)
## What changed

Propagate canonical denial, timeout, and abort responses from strict MCP
auto-review instead of replacing them with a generic decline. This preserves
the reviewer's action and metadata, including denial rationale, while still
failing closed when no canonical decision is available.

Update the fallback message to direct the agent to request explicit user
approval before proceeding.

## Testing

Add unit and app-server integration coverage for strict auto-review denials
and cancellations.

GitOrigin-RevId: d8126ab223ab546b95e2d984f6e4dd540a324a59
2026-08-21 23:14:28 +00:00
Krish Chainani
ab8768306f Preserve executor context for MCP stop hooks (#40012)
## What changed

- Scope executor-provided stop-hook calls to the MCP server environment that registered the hook, and reject calls when that environment does not match.
- Forward turn metadata with executor stop-hook requests while retaining the hook call's `threadId` metadata.

## Testing

- Cover environment matching for MCP tool calls and verify executor stop hooks receive their environment ID and request metadata.

GitOrigin-RevId: b544ea3a6ca1f61389fb4597978ed7aac27d529a
2026-08-21 21:17:42 +00:00
jif
8edb95f274 Preserve MCP compatibility with older executors (#39979)
## Why

Older executors do not support resolving HTTP header values from their own
environment. Sending environment-backed bearer tokens to them can prevent MCP
servers from starting.

## What changed

- Advertise executor support for environment-backed HTTP headers with the
  `httpHeaderEnvVars` capability.
- Delegate bearer-token resolution only when the selected executor advertises
  that capability; otherwise, resolve tokens available in the host environment.
- Exclude executor-owned MCP servers that require environment-backed bearer
  tokens when the executor cannot resolve them, while retaining compatible
  host-owned and executor-owned servers.

## Testing

Added protocol and environment-variable coverage plus an end-to-end test that
simulates an older executor and verifies compatible MCP servers remain usable.

GitOrigin-RevId: 43545926f6f7e0f3b1091eb29d34647f6372bc4a
2026-08-21 17:21:30 +00:00
jif
00a7b888b2 Discover HTTP MCP servers from selected executors (#39941)
## What changed

- Read `mcp_servers` configuration and requirements from each selected remote
  executor and add eligible HTTP servers to the thread's MCP runtime.
- Bind discovered servers to the thread's concrete executor snapshot and apply
  environment MCP policy and requirements. Discovery is best effort, and
  executor-local servers are not treated as required at startup.
- Ignore unsupported stdio servers and HTTP configurations that depend on
  environment-provided headers or header helpers.

## Testing

- Added an app-server integration test covering discovery, authenticated HTTP
  tool invocation, requirements enforcement, and exclusion of stdio servers.

GitOrigin-RevId: 6e1cdcebdbb1cc21a5a2285fbc5617d8d5997182
2026-08-21 14:23:33 +00:00
jif
9c3da20b3f Track remote MCP header environment variables (#39930)
## Why

Remote HTTP MCP connections can source header values from the host environment,
so those variables must remain part of the connection identity even when the MCP
server runs in an executor environment.

## What changed

- Track `env_http_headers` variables for remote HTTP MCP connections.
- Continue tracking `bearer_token_env_var` only for local environments, where the
  host resolves the token.

## Testing

Add coverage that verifies remote connections track host header variables without
tracking executor bearer-token variables, while local connections track both.

GitOrigin-RevId: 8fe175c54a101721a27b76495dcd298f0c2bc6a3
2026-08-21 13:22:25 +00:00
jif
93c54bca38 Resolve HTTP MCP bearer tokens in executor environments (#39926)
## Why

Executor-owned HTTP MCP servers need to read their bearer credentials from the
selected executor environment instead of the host process.

## What changed

- Preserve `bearer_token_env_var` for executor-owned HTTP MCP configurations and
  resolve it when the executor sends each request.
- Extend delegated HTTP headers with executor-local environment references while
  rejecting missing, empty, or protected credential variables.
- Keep transport-provided bearer authentication compatible with MCP redirect and
  OAuth handling without sending a placeholder authorization value.

## Testing

- Cover authenticated executor-owned MCP requests end to end.
- Cover delegated header resolution and rejection of protected variables.
- Cover parsing executor-owned bearer configuration and transport-provided bearer
  behavior.

GitOrigin-RevId: 442bf7382198ffb69eba797eb36d4c74faabda88
2026-08-21 12:50:15 +00:00
victor-openai
097825f75a Add app-server MCP event streaming (#39761)
## What changed

- Add experimental `mcpServer/event/stream/start` and `mcpServer/event/stream/stop` requests for hosted apps, plus `mcpServer/event/stream/notification` forwarding.
- Scope subscriptions to the owning app-server connection and subscribed thread, enforce unique IDs and a per-connection limit, and clean them up when the thread is unsubscribed or the connection closes.
- Wait for the MCP active notification before completing startup, retry streams that close immediately, and terminate them when authentication or hosted runtime ownership changes.

## Testing

- Add an app-server integration test covering activation, event forwarding, duplicate subscription rejection, and explicit cancellation.

GitOrigin-RevId: 8a6fc1615adfc5af7e67def3b824fa5909ab3e7b
2026-08-20 17:49:35 +00:00
Angad Singh
1bfabb21fe Raise the MCP tool name limit to 128 bytes (#39594)
## Why

The Responses API accepts tool names up to 128 bytes, but MCP tool name
normalization limited model-visible names to 64 bytes.

## What changed

- Preserve MCP tool names up to the 128-byte Responses API limit.
- Continue shortening and hashing names that exceed the limit so generated
  names remain bounded and unique.

## Testing

- Cover names at the 128-byte boundary and immediately above it.
- Verify distinct long names remain 128 bytes and code-mode compatible.

GitOrigin-RevId: 75544d00e75dd0e9328b3e2ac763d26f9cc99a48
2026-08-20 05:21:09 +00:00
sayan-oai
fde2156057 Enforce environment MCP policies (#39335)
## What changed

- Add environment-provided MCP restrictions for configured and plugin-provided servers.
- Disable attachment-scoped servers while their environment configuration is pending, failed, or unselected, while preserving selected-plugin access and the controller-owned Apps server.
- Apply the resolved policy to runtime startup, model tool exposure, telemetry, OAuth flows, and skill dependency installation.

## Testing

- Cover policy filtering for configured and plugin servers, environment state transitions, Apps ownership, and managed OAuth rejection.

GitOrigin-RevId: 7ca5d4dda14068e758497f88835d5cba685e159e
2026-08-19 01:26:16 +00:00
Abhinav
d35e5495f9 Route hook MCP calls through current connections (#39331)
## What changed

- Execute hook-triggered MCP calls through the runtime's latest connection set instead of preparing a separate catalog-bound call.
- Keep hook calls from waiting for server startup or reconnecting, and reject disconnected servers immediately.
- Apply the shorter of the hook-requested timeout and the server's configured tool timeout.

## Testing

- Update connection manager tests to cover non-waiting calls and disabled tool filters.

GitOrigin-RevId: 3166b2d1e26d9ae2b8b3a648b4d0897cc260eb93
2026-08-19 01:15:10 +00:00
Abhinav
87070a7792 Enable MCP tool hooks in Codex sessions (#39296)
## What changed

- Execute `mcp_tool` hook handlers through the session's shared MCP runtime, including managed hook configurations.
- Restrict hook calls to already-connected, cataloged, and policy-allowed tools. Unavailable servers fail immediately without starting or reconnecting them.
- Pass session metadata to hook tools, cap hook timeouts by the server timeout, and invoke hooks without model-tool approval or recursive hook dispatch.
- Record handler type and execution mode in hook telemetry, and mark memory as externally influenced after successful or blocking MCP hooks when configured.

## Testing

- Added end-to-end coverage for prompt interpolation, hidden tools, blocking decisions, unavailable servers, thread metadata, approval bypass, and memory-mode handling.
- Added MCP runtime coverage for startup readiness, tool filters, catalog revisions, and managed connector policy.

GitOrigin-RevId: 1647cb801ebc5fa385c7bda9d9c266a389c611b8
2026-08-18 22:10:43 +00:00
victor-openai
a1dc95d5af Scope MCP resource reads by connector (#39244)
## What changed

- Add an optional `connectorId` to `mcpServer/resource/read`.
- Forward the selected connector through `x-codex-turn-metadata` for threaded and threadless resource reads, restricting hosted app resources to that connector.
- Update the generated protocol schemas and app-server documentation.

GitOrigin-RevId: 5cc94d703abbbb6086665910c1c9ed5dc7075210
2026-08-18 18:01:39 +00:00
jif
a397079287 Preserve MCP resource origins across compaction (#39192)
## Why

Compaction can remove the tool-call events that associate an MCP app widget with
the tool, account, and URI needed to authorize later resource reads.

## What changed

- Store a bounded MCP resource-origin checkpoint with each compacted rollout.
- Restore the checkpoint when resuming a session so existing widgets remain
  readable after compaction and restart.
- Discard saved origins when rollback rewrites history across the compaction
  boundary, and reject oversized or invalid checkpoints during restoration.

## Testing

- Extend the app-server MCP resource-origin test to compact a paginated thread,
  continue the conversation, and read the original widgets before and after a
  restart.
- Verify rollback clears provenance that no longer matches retained history.

GitOrigin-RevId: 7f91c6202fe8d9be21c78dda42fa205937c44263
2026-08-18 12:37:41 +00:00
jif
880f1135ea Scope MCP app resource reads to their originating call (#39187)
## Why

App widgets need to read resources using the app and account context of the
tool call that produced them, including after a thread is restored.

## What changed

- Add an optional `originCallId` to `mcpServer/resource/read` requests and
  return it on successful scoped reads.
- Track bounded provenance for successful app tool calls in thread history and
  use the current tool binding, account link, and app policy when reading the
  associated widget resource.
- Reject missing, mismatched, failed, or ambiguous origins, while keeping
  app-only tools available for widget reads without exposing them to the model.

## Testing

Add app-server coverage for scoped widget reads across both history modes,
ephemeral and persistent threads, server restarts, app-only visibility, and
invalid origin cases.

GitOrigin-RevId: 11eaefc066b2a3b639599e4cbdef680233d150a2
2026-08-18 11:51:21 +00:00
thomas
14973840e0 Tag Codex Apps protocol discovery metrics (#39058)
## What changed

Add `server_kind=openai_codex_apps` to the
`codex.mcp.protocol_discovery` counter and its duration metric when protocol
discovery runs for the Codex Apps MCP server. Other MCP servers retain the
existing `mode` and `outcome` tags.

GitOrigin-RevId: aadbdc54642f2c103a9f1bab39308e962c115f75
2026-08-17 19:38:18 +00:00
thomas
6bed213411 Add MCP protocol discovery metrics (#38634)
## What changed

- Record a counter and duration for MCP client protocol discovery.
- Tag observations with the configured `legacy` or `auto` mode and classify
  outcomes as `modern`, `legacy`, or `failure`.

GitOrigin-RevId: f348e0d900b437d5a9fef1c33cdb1314f2421785
2026-08-14 19:57:04 +00:00
jif
42b5f05cef Preserve MCP namespace descriptions in the tool catalog cache (#38623)
## What changed

Keep MCP namespace descriptions when publishing tool definitions to the
process-scoped catalog cache. Cached definitions now expose the server
instructions to the model before a lazily started MCP connection finishes
initializing.

## Testing

Update the cached MCP startup integration test to verify that cached namespace
descriptions retain the originating server instructions.

GitOrigin-RevId: d1b73381852fd43c6b54a7c22a599474c774dc20
2026-08-14 18:35:13 +00:00
Matthew Zeng
45c9c74e29 Reuse pending MCP startups during reconciliation (#38493)
## Why

MCP runtime reconciliation can occur while an unchanged server is still
starting, such as when capability roots become available. Reconciliation
should neither wait for that startup nor initialize the same server again.

## What changed

- Reuse an active, uncancelled pending MCP connection when its identity,
  catalog limit, and protocol mode still match.
- Publish the shared startup result through the reconciled server view while
  applying its updated tool filter.
- Preserve cancellation when a reused pending server is subsequently removed.

## Testing

Added coverage for filtered-tool publication, disabling a reused pending
server, and capability-root reconciliation during Codex Apps startup.

GitOrigin-RevId: 690cf8695e75b341d097d7d22b5da6993b24e787
2026-08-14 04:49:14 +00:00
willwang-openai
1da59ad257 Support per-server MCP OAuth callback ports (#38448)
## What changed

- Add `oauth.callback_port` to MCP server configuration and preserve it when
  serializing configuration edits.
- Accept `oauth.callbackPort` from plugin MCP declarations and skill dependency
  metadata.
- Prefer the server-specific callback port over `mcp_oauth_callback_port` for
  CLI login, app-server, plugin installation, executor, and skill dependency
  OAuth flows.

## Testing

- Cover configuration parsing, serialization, and fallback behavior.
- Verify plugin, executor, and skill OAuth registrations use their configured
  callback ports instead of the global port.

GitOrigin-RevId: 7f65e5e7869358307e49779f1b75e8672b607736
2026-08-13 22:42:12 +00:00
Celia Chen
b87327f4e5 Add rustls fallback for local MCP HTTP requests (#38436)
## Why

Local MCP requests can fail when the platform TLS backend cannot negotiate a
protocol version with an HTTPS endpoint.

## What changed

- Retry replayable local MCP requests once with rustls after a recognized TLS
  protocol-version negotiation failure. Keep certificate, timeout, and unrelated
  connection failures on the existing error path.
- Remember successful fallback per HTTPS origin and outbound route, while keeping
  the platform TLS backend as the default for other destinations.
- Share the fallback-enabled client across local MCP resolution, CLI login, and
  OAuth discovery while preserving remote environment HTTP clients.

## Testing

Added coverage for platform-specific error detection, request replay, cached
fallback reuse and isolation, non-replayable requests, redirects, and remote MCP
client selection.

GitOrigin-RevId: 39a2d96fdb2ea0e51df14f652ba2a953d24e69a1
2026-08-13 21:13:07 +00:00
Eric Traut
f8a3db0b99 Clarify MCP OAuth reauthentication errors (#38418)
## Why

When an MCP server rejects existing OAuth credentials, reporting that the server
is merely not logged in obscures that the user needs to authenticate again.

## What changed

Pass the MCP startup failure reason into error formatting and report that the
server requires OAuth reauthentication when appropriate. Preserve the existing
recovery hint for either `codex mcp login` or the client's OAuth sign-in flow.

## Testing

Cover the reauthentication message for both login flows and verify it in the
streamable HTTP OAuth round-trip test.

GitOrigin-RevId: 6f6d5fe7519b1a476f8b70d976223b2ea1ec938e
2026-08-13 18:45:13 +00:00
xl-openai
379cb68444 Add dynamic HTTP header helpers for MCP servers (#38245)
## What changed

- Add `http_headers_helper` configuration for local streamable HTTP MCP servers. The configured shell command runs once per connection and returns a JSON object of headers that is cached across requests.
- Apply helper headers to MCP startup and OAuth flows while restricting them to the server origin, stopping redirects, rejecting reserved or duplicate headers, and enforcing output and execution limits.
- Reject helpers for remote or managed-disabled servers, use the local environment working directory, and redact helper commands from `codex mcp list` and `codex mcp get` output.

## Testing

- Cover configuration validation, helper lifecycle and output parsing, origin isolation, OAuth discovery and token refresh, managed requirements, environment selection, and CLI redaction.

GitOrigin-RevId: 84e0e26ce75520b0869d37c72b1678e033bd6818
2026-08-12 20:36:32 +00:00
jif
7093e8c480 Start required cached MCP servers lazily for subagents (#38217)
## Why

Subagents can reuse cached MCP tool definitions without opening another server
connection immediately, but marking a server as required previously forced eager
startup even when its cached tools were available.

## What changed

- Allow required MCP servers with usable cached tools to remain dormant under
  the lazy startup policy.
- Treat those cached tools as satisfying required-server validation and tool
  catalog capture until the server is needed.
- Preserve eager startup for required servers without cached tools and start a
  dormant server when one of its tools is called.

## Testing

Extend the cached HTTP MCP subagent test to cover both optional and required
servers, verifying that the required server stays dormant until its cached tool
is called.

GitOrigin-RevId: 48ea20b9ae447eef27461caee2320ea78465bb6a
2026-08-12 16:50:23 +00:00
Tamir Duberstein
e20616d265 Propagate MCP elicitation event delivery failures (#38035)
## Why

When the event receiver is closed, an MCP elicitation request cannot reach its
consumer. Ignoring that delivery failure leaves the request and its lifecycle
registration pending while waiting for a response that cannot arrive.

## What changed

Return a contextual error when an MCP elicitation event cannot be delivered.
This drops the pending-request guard immediately, removing the responder from
the router and releasing its lifecycle registration.

## Testing

Add a regression test that closes the event channel and verifies the request
fails immediately, the router is empty, and the lifecycle registration is
released.

GitOrigin-RevId: 1067f35a5775d61c5bcd07b4b190d3907d8f219a
2026-08-11 16:31:30 +00:00
jif
0ca439900e Cache tool catalogs for streamable HTTP MCP servers (#37970)
## Why

Subagents should be able to use known HTTP MCP tool definitions without opening a connection until a tool is actually called.

## What changed

- Add streamable HTTP configurations to the process-scoped MCP tool catalog cache when their authentication identity can be derived safely.
- Fingerprint transport settings, relevant environment variables, protocol mode, plugin status, and client capabilities so catalogs are reused only across equivalent connections.
- Keep OAuth and other dynamically resolved credential configurations out of the shared cache.

## Testing

- Add an integration test proving that a subagent receives cached HTTP tools without reinitializing the server, then starts its own connection when it calls one.

GitOrigin-RevId: bb2787e29e9b71993def31aafd1f0d8f1b728d26
2026-08-11 09:22:50 +00:00
jif
dd22460869 Add MCP OAuth credential contention regression tests (#37866)
## What changed

- Cover non-blocking credential probes when the file or secrets store is locked, including retaining only a matching prior credential snapshot and recovering after the lock is released.
- Extend the streamable HTTP OAuth round trip to verify that user turns continue during store contention, newly discovered servers recover after contention, and logged-out servers do not reuse authenticated connections.
- Cover reconciliation of authentication failures and effective `Authorization` headers.

GitOrigin-RevId: 8e377644001bd0be04dc9f79841080094d09d199
2026-08-10 18:40:02 +00:00
mchen-oai
4b0e2a0bff Support MCP form input in full-access user threads (#37864)
## Why

Standard MCP forms can require user-entered values even when tool permissions are
otherwise auto-approved in full-access sessions.

## What changed

- Recognize the `openai/standard-form-input` client extension and surface
  non-approval forms in full-access, user-initiated root threads.
- Keep approval forms, automation and subagent threads, headless sessions, and
  clients without the capability on their existing decline or review paths.
- Treat the capability as client-only so it is not advertised to MCP servers,
  and enable it after session startup so required servers cannot block startup
  waiting for form input.

## Testing

Add unit and app-server coverage for accepted form round trips, declined cases,
approval metadata safeguards, resumed threads, and extension filtering.

GitOrigin-RevId: 053bfe397a5c79eceef90a81d13e2aca6353af43
2026-08-10 18:20:12 +00:00
jif
afcc95b431 Speed up MCP OAuth credential reads (#37860)
## Why

Refreshing MCP connection identities should not stall the async executor while another process holds the OAuth credential-store lock.

## What changed

- Probe file and secrets credential stores without waiting during runtime refreshes, retaining the last known credentials when the store is contended.
- Reuse unchanged authentication failures while credentials are temporarily unavailable instead of restarting the connection.
- Run blocking credential loads on a blocking worker during MCP client construction.
- Allow OAuth fallback when a configured authorization header is missing, empty, or invalid.

GitOrigin-RevId: 38dad5606da9a1ceb30fe945000ec9151a5058fa
2026-08-10 17:58:15 +00:00
Evan Fannin
41014b11bd Add MCP event discovery and subscriptions (#37494)
## What changed

- Expose hosted Plugin Runtime event definitions through `McpResourceClient::list_events`.
- Add cancellable `events/stream` subscriptions that route lifecycle notifications to the matching request and cancel when the stream is dropped.
- Bound event notification and queue sizes, time out stalled response headers, and close streamable HTTP responses locally on cancellation.

## Testing

- Add streamable HTTP integration coverage for isolated concurrent subscriptions, local cancellation, and stalled response-header timeouts.

GitOrigin-RevId: 98c6fffa8f004eb2638c1b0705f659222cbbdfdb
2026-08-07 19:36:52 +00:00
jif
27e4a05cd3 Expose runtime activity in server diagnostics (#37486)
## What changed

- Add lifecycle-backed gauges for in-flight and queued app requests, pending server requests and mailbox messages, active turns, and live MCP connections.
- Register each gauge on first use and decrement it when the tracked work or resource is dropped.
- Document the new `server/diagnostics` gauge names and account for the diagnostics request itself in the response example and test.

GitOrigin-RevId: 4bb82a3918af0b502d149b5d761ad669b2083f39
2026-08-07 18:38:24 +00:00
jif
b3ffe3d001 Recover MCP servers after OAuth reauthentication (#37337)
## Why

An OAuth-backed Streamable HTTP MCP server can fail startup when its stored credentials are rejected. If a client then completes OAuth sign-in and replaces those credentials, the failed server needs to become available without restarting the Codex session.

## What changed

- Track the credential store and OAuth tokens used for each MCP connection, and detect replacements after authentication failures.
- Refresh affected MCP servers before the next turn and include their recovered tools in the model request.
- Classify HTTP authentication challenges and rejected refresh tokens as requiring reauthentication, with sign-in guidance appropriate to local and client-managed environments.

## Testing

- Cover recovery from expired credentials through an externally written replacement token.
- Cover authentication-error classification, startup messaging, and `Auto` store migration from file credentials to the keyring.

GitOrigin-RevId: 9b090089d4e7a44ffc182f4e25da20a18e97b70f
2026-08-07 00:17:46 +00:00
jif
1151b23f01 Start cached MCP servers lazily for subagents (#37261)
## Why

Subagents can reuse cached MCP tool definitions without starting every optional
server before any of its tools are used.

## What changed

- Defer startup for subagent-owned, optional MCP servers when their cache has at
  least one visible, allowed tool, and trigger startup on the first operation
  that needs the live client.
- Keep root sessions, required servers, selected plugin servers, and explicit
  reconnects eager.
- Exclude empty catalogs from cache eligibility and keep dormant servers out of
  the initial startup summary.

## Testing

- Extend MCP tool-cache coverage for eager root startup, unused and filtered
  subagent servers, deferred startup status events, and startup that survives an
  interrupted first tool call.

GitOrigin-RevId: e7528ff08312583a6747cbc6550ea5b6eabda9a6
2026-08-06 11:18:24 +00:00
jif
952e87d3f2 Reuse stable MCP bindings across sampling steps (#37101)
## What changed

- Cache an `McpBinding` on each published MCP runtime once server startup has
  settled and the tool catalog revision is stable.
- Reuse the cached binding while the catalog revision remains unchanged, and
  rebuild it after a runtime publish or catalog change.
- Treat terminal failures from optional servers as stable, while continuing to
  wait for required servers and reconnecting Codex Apps servers.

## Testing

- Cover binding reuse within one published runtime and invalidation after a
  republish.
- Cover stability checks for pending, failed optional, required, and
  reconnected servers.

GitOrigin-RevId: 783a6b04897f6c484a6d56fd9cee542814041759
2026-08-05 14:04:39 +00:00
jacobzhou-oai
56b82e676c Enforce Agent Plugin runtime boundaries (#37027)
## What changed

- Track Agent Plugin manifests through plugin, skill, and MCP loading so their capabilities use format-specific behavior without changing legacy plugins.
- Discover only direct-child skills, exclude app and hook capabilities, isolate MCP data, and reject MCP configuration files that are non-regular or resolve outside the plugin root.
- Bound model-visible skill instructions, plugin instructions, MCP descriptions, schemas, individual tools, and the aggregate Agent Plugin MCP tool set.
- Stop MCP and OAuth redirects when Agent Plugins send configured or authorization headers, while retaining existing redirect behavior for legacy MCP servers.

## Testing

- Add coverage for capability filtering, skill discovery, isolated MCP data and reserved-path expansion, unsafe MCP configuration files, context limits, and redirect handling.

GitOrigin-RevId: c9af66b051269f3226628ca280a58d32c808c38f
2026-08-05 04:54:33 +00:00
yijiang12
bf05737da4 Preserve ChatGPT auth for trusted staging MCP servers (#36983)
## What changed

- Treat an MCP server as trusted for ChatGPT authentication when its origin
  matches the configured HTTPS `chatgpt-staging.com` host or one of its
  subdomains.
- Continue trusting the production ChatGPT origin and falling back to OAuth for
  other transports and origins.

## Testing

- Cover both the staging apex domain and a staging subdomain.

GitOrigin-RevId: 1b1d06ab214141d39eb38d46de9dfb74e6fedb3e
2026-08-04 22:13:50 +00:00
Martin Au-Yeung
ee46c5ba0e Negotiate MCP extensions per app-server session (#36910)
## Why

App-server clients need to advertise structured MCP extension settings, including supported MCP App UI MIME types, rather than only opting into OpenAI form elicitation with a boolean.

## What changed

- Add an `extensions` map to initialize capabilities and preserve `mcpServerOpenaiFormElicitation` as a legacy alias for `openai/form`.
- Capture the declared extension profile when a thread is started, resumed, or forked, propagate it to subagents, and advertise it to downstream MCP servers during initialization.
- Keep the profile stable for the lifetime of the loaded session instead of changing it on later turns or direct tool calls.

## Testing

- Cover extension conversion, downstream MCP initialization, session isolation, legacy form support, and subagent inheritance.

GitOrigin-RevId: fbcedbb74ce788e574b0f884a4c45c4cedb9de54
2026-08-04 15:23:43 +00:00
jacobzhou-oai
bd12b3a9ec Add Agent Plugins MCP config parsing (#36796)
## What changed

- Add `parse_agent_plugin_mcp_config` to translate Agent Plugins v1 `mcp.json` files into Codex MCP server configuration.
- Normalize `stdio` and streamable HTTP transports, including `PLUGIN_ROOT` and `PLUGIN_DATA` expansion, contained plugin paths, secure endpoint validation, and filtering of client-owned HTTP headers.
- Keep valid sibling servers when another server is invalid, while returning per-server parse errors.
- Preserve UTF-8 HTTP header values when forwarding streamable HTTP protocol headers.

## Testing

- Cover transport mapping, placeholder expansion, path containment, schema and field validation, per-server errors, platform-specific environment handling, and UTF-8 headers.

GitOrigin-RevId: ed4ab0fcf495afbb381ce48beb93989629444c56
2026-08-03 20:36:59 +00:00
tongzhou wang
51c9ed6d4f Add per-surface MCP tool exposure controls (#36781)
## Why

MCP tools can be exposed directly, discovered through tool search, or called
from Code Mode. Servers need to be able to opt out of any of these surfaces
without disabling their tools everywhere.

## What changed

- Add `omit_tools_from` to MCP server configuration, accepting any combination
  of `direct`, `deferred`, and `code_mode`.
- Apply the exclusions independently when building direct, deferred, and Code
  Mode tool surfaces while keeping omitted tools registered for permitted uses.
- Remove client-private `_meta` fields from MCP results returned to Code Mode.
- Include the new setting in the configuration schema and MCP config
  serialization.

## Testing

- Cover every exposure combination across Code Mode, Code-Mode-only sessions,
  tool search, direct-only namespaces, and prefixed and unprefixed MCP names.
- Verify direct and nested execution paths, parallel-call support, config
  round-tripping, and `_meta` filtering.

GitOrigin-RevId: 12dfcb78bb5c5ecf4d70f38a8b5022792463a27f
2026-08-03 18:51:46 +00:00
jif
e4e040881a Raise the host-owned Codex Apps catalog limit (#36772)
## Why

Codex Apps tool catalogs can exceed the standard MCP limit of 2,048 items and
still need to remain available through tool search.

## What changed

- Allow up to 8,192 catalog items for host-owned `codex_apps` registrations.
- Keep the 2,048-item limit for other MCP servers, including extensions that
  register the `codex_apps` name.
- Restrict the shared Codex Apps tool cache to host-owned registrations.

## Testing

- Cover large catalogs for built-in and hosted-plugin registrations while
  verifying that another extension retains the standard limit.
- Verify that a same-named extension cannot read the host-owned Apps cache.

GitOrigin-RevId: 2265693a460e9be63c4c849169cba7324def4f49
2026-08-03 17:06:46 +00:00
Rasmus Rygaard
5825699981 Raise the MCP catalog item limit to 2,048 (#36534)
## What changed

Increase the maximum number of items collected across paginated MCP tool,
resource, and resource-template discovery requests from 1,024 to 2,048.

GitOrigin-RevId: b6ce0691d6a217e92faaf141cbf09978b296eeda
2026-08-01 23:39:55 +00:00
Ankush Gupta
287e1020ae Add strict automatic review for MCP elicitations (#36365)
## What changed

- Recognize the `codex_strict_auto_review` MCP elicitation marker and route
  marked approval requests through the configured automatic reviewer.
- Accept only canonical automatic-review approvals and fail closed without a
  user prompt when review is unavailable, denied, malformed, disallowed by
  policy, or requests persistence.
- Validate Codex Apps approval metadata against the active MCP invocation and
  build the review request from the trusted invocation details.

## Testing

- Add unit coverage for strict review decisions, malformed markers, reviewer
  failures, explicit policy denials, and lifecycle cleanup.
- Add app-server round-trip coverage for approvals, denials, configuration
  constraints, spoofed metadata, persistent requests, and subsequent turns.

GitOrigin-RevId: af73b45a9b63118f25f6429d95b3222c5dbb59fb
2026-07-31 17:18:08 +00:00
jif
164b3bfeab Isolate MCP OAuth credentials by environment (#36310)
## Why

MCP servers running in an executor must not reuse host-owned OAuth credentials,
even when they have the same configured server name and URL.

## What changed

- Derive environment-scoped credential names for executor-owned MCP servers and
  use them consistently for login, logout, authentication, and connection setup.
- Mark executor-owned entries in the file credential store and fail closed when
  loading or saving an entry could cross the host/executor boundary.
- Preserve compatibility with existing local OAuth credentials, including local
  server names that overlap the new reserved prefixes.

## Testing

- Extend the executor MCP integration test to verify that executor requests use
  the executor token, never send the host token, and persist both credentials
  separately.

GitOrigin-RevId: 4fc92d0533b0fe2e0df34f6d47b81e3d20d07807
2026-07-31 11:23:46 +00:00
jif
bf4d3f51ea Restrict hosted MCP credentials to local environments (#36306)
## Why

Executor-owned MCP servers must not receive hosted ChatGPT actor credentials or credentials from the host's OAuth store.

## What changed

- Provide the ChatGPT auth provider and consult stored OAuth credentials only for MCP servers in the local environment.
- Require non-local servers configured with `auth = "chatgpt"` to supply a non-empty, valid static `Authorization` header. Reject environment-backed authorization so host secrets are not resolved for an executor-owned server.
- Report unsupported authentication and fail startup before connecting when an executor-owned server has no acceptable explicit authorization.

## Testing

Add coverage for local credential forwarding, non-local credential isolation, static header validation, auth status, OAuth lookup avoidance, and startup rejection.

GitOrigin-RevId: e18f1878f260c93d9babd390a5a7eac86172299b
2026-07-31 10:42:02 +00:00
Alexi Christakis
410c22b30e Extract MCP environment headers into a local variable (#36047)
GitOrigin-RevId: 1372756e47133f49e64c5308624dc8685c282efb
2026-07-29 23:46:54 +00:00
jif
7ec480dda5 Distinguish unknown MCP authentication status (#36045)
## Why

OAuth discovery failures do not establish that an MCP server lacks OAuth
support. Reporting those failures as `unsupported` conflates an inconclusive
check with a confirmed result.

## What changed

- Add an `unknown` MCP authentication status across the protocol, app server,
  CLI, and TUI.
- Preserve OAuth discovery errors so callers can report `unknown`, while
  retaining `unsupported` for servers known not to support OAuth.
- Document the distinction in the app server API.

## Testing

- Verify transient HTTP discovery errors are preserved.
- Verify `codex mcp list --json` reports `unknown` when discovery is rate
  limited.

GitOrigin-RevId: e4562985971606740538e542ec7eeee502111964
2026-07-29 23:24:43 +00:00
jif
3e3ae08839 Limit MCP catalog pagination (#36039)
## Why

MCP catalog discovery must not allow a server to keep pagination running or
growing without bounds.

## What changed

- Apply the shared pagination collector to tool, resource, and resource-template
  discovery.
- Limit each catalog to 100 pages and 1,024 items, and reject pagination cursors
  larger than 64 KiB or any repeated cursor.
- Bound the entire pagination operation by the configured tool timeout, falling
  back to 30 seconds when no timeout is configured.

## Testing

Add unit coverage for every limit and an end-to-end MCP test that preserves
valid multi-page tools while excluding a server that returns an oversized
cursor.

GitOrigin-RevId: 961a1bfa5fe8a265daf56e342a919c980cd720fa
2026-07-29 22:37:09 +00:00
jif
85c082cccc Share optional MCP startup grace across connection sets (#36011)
## Why

Each connection set could restart the one-second startup grace for the same
cacheable optional MCP server, repeatedly delaying catalog capture while that
server was still pending.

## What changed

- Store the optional startup deadline in the shared tool catalog cache entry.
- Reuse that deadline until a catalog is published, and allow a fresh grace
  period after the cached catalog expires.
- Preserve per-connection-set startup grace for servers that disable catalog
  caching.

## Testing

Added a paused-time test covering shared deadlines, immediate cached-tool reuse,
cache expiration, and disabled caching.

GitOrigin-RevId: 3494969ee7002c70ce9e4ffd370e46a22d38cc11
2026-07-29 18:53:15 +00:00
thomas
a05bcda3db Upgrade rmcp to 3.0.0 (#36001)
## What changed

- Update the Rust MCP SDK from `3.0.0-beta.3` to `3.0.0` and adapt to its renamed metadata and server discovery types.
- Accept discovery responses without server identity metadata, using the configured server name as a fallback, and rely on the SDK's native support for namespaced server identity metadata.
- Preserve typed OAuth HTTP errors so transport failures, cross-origin redirects, and transient HTTP responses are reported instead of being treated as anonymous access.

## Testing

- Cover modern discovery with namespaced or missing server identity over HTTP, SSE, and stdio.
- Cover OAuth discovery error propagation for transport failures, redirects, and transient status codes.

GitOrigin-RevId: 12c1e45136cca89ce4fb15986c2b5df14608682a
2026-07-29 17:38:20 +00:00
jif
fbf666fa98 Let unrelated tools run while MCP servers start (#35937)
## Why

Cached MCP definitions can make a tool callable before its server has finished
starting. Waiting for that server while holding the tool execution gate blocks
unrelated calls in the same response.

## What changed

- Expose the owning MCP server through tool runtime metadata, including tools
  with exposure overrides.
- Refresh MCP state and wait for that specific server before entering the
  parallel execution gate.

## Testing

Extend the cached MCP tool regression test to verify that an unrelated plan
update completes while MCP startup remains pending.

GitOrigin-RevId: 884d154bc403dfc1d347d265da3d6a887948e7b6
2026-07-29 11:14:16 +00:00