Skip to content

Discover stdio MCP servers from selected executor plugins#27870

Merged
jif-oai merged 5 commits into
mainfrom
jif/selected-executor-plugin-mcp-registration
Jun 15, 2026
Merged

Discover stdio MCP servers from selected executor plugins#27870
jif-oai merged 5 commits into
mainfrom
jif/selected-executor-plugin-mcp-registration

Conversation

@jif-oai

@jif-oai jif-oai commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Why

In short: this PR discovers MCP registrations by reading a selected plugin's .mcp.json on its executor. #27884 then resolves those registrations in the shared catalog.

thread/start.selectedCapabilityRoots can select a plugin root owned by an executor, and Codex can resolve that package through the executor filesystem. MCP declarations inside the selected plugin are still ignored.

This PR adds the source-specific discovery layer on top of the selected-plugin catalog boundary in #27884:

selected capability root
        |
        v
resolve the plugin through its executor filesystem
        |
        v
read and normalize its MCP config through the same filesystem
        |
        v
contribute stdio registrations bound to that environment ID

The existing MCP launcher and connection manager remain unchanged. MCP config parsing is shared with local plugins through #27863.

What changed

  • Added an executor plugin MCP provider in the MCP extension.
  • Retained only the exact filesystem capability used for package resolution and reused it for the selected plugin's MCP config, with no host-filesystem fallback or unrelated process/HTTP authority.
  • Read either the manifest-declared MCP config or the default .mcp.json; a missing default file means the plugin has no MCP servers.
  • Accepted stdio servers only for this first vertical. Executor-owned HTTP declarations are skipped with a warning until their placement semantics are defined.
  • Normalized stdio registrations with the owning environment's stable logical ID and plugin-root working directory.
  • Resolved environment-variable names on the owning executor and rejected explicit local forwarding for non-local plugins.
  • Froze discovered declarations once per active thread runtime, then applied current managed plugin and MCP requirements when contributing them.
  • Carried the selected root ID, display name, and selection order into the catalog contribution defined by Add selected-plugin precedence and attribution to the MCP catalog #27884.

Behavior and scope

There is intentionally no production behavior change yet. This PR provides the executor provider and contribution boundary, but app-server does not install it in this change. Existing local plugin MCP loading is unchanged, and no MCP process is launched by this PR alone.

Assumptions

  • The selected root ID is the plugin policy identity; the manifest display name is presentation metadata.
  • An environment ID is a stable logical authority. Reconnection or replacement under the same ID does not change ownership.
  • Selected plugin packages and their manifests are trusted inputs.
  • The selected package and MCP discovery snapshot remain frozen for the active thread runtime.

Follow-up

The next PR installs this contributor in app-server and adds an end-to-end test proving that a selected plugin MCP tool launches on its owning executor, can be called by the model, survives an explicit MCP refresh, and is invisible when its root was not selected.

Resume, fork, environment removal or ID changes, dynamic catalog reload, and executor-owned HTTP MCP placement remain separate lifecycle decisions.

Verification

Focused tests cover executor-only filesystem reads, missing and malformed config, stdio filtering and normalization, managed requirements, package attribution, and selection order. CI owns execution of the test suite.

@jif-oai jif-oai requested a review from a team as a code owner June 12, 2026 13:15
@jif-oai

jif-oai commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf55b02be2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/ext/mcp/src/lib.rs
Comment thread codex-rs/ext/mcp/Cargo.toml
@jif-oai

jif-oai commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 642d0f27e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/ext/mcp/src/lib.rs
Comment thread codex-rs/ext/mcp/Cargo.toml
Comment thread codex-rs/ext/mcp/src/executor_plugin/provider.rs
@jif-oai jif-oai force-pushed the jif/selected-executor-plugin-mcp-registration branch from 642d0f2 to f6fbab9 Compare June 12, 2026 14:24
@jif-oai jif-oai changed the base branch from main to jif/selected-plugin-mcp-catalog June 12, 2026 14:25
@jif-oai jif-oai changed the title Register MCP servers from selected executor plugins Discover stdio MCP servers from selected executor plugins Jun 12, 2026
@jif-oai

jif-oai commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6fbab93e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -39,3 +41,20 @@ impl McpServerContributor<Config> for HostedPluginRuntimeExtension {
pub fn install(builder: &mut ExtensionRegistryBuilder<Config>) {
builder.mcp_server_contributor(std::sync::Arc::new(HostedPluginRuntimeExtension));
}

/// Installs discovery for MCP servers declared by thread-selected executor plugins.
pub fn install_executor_plugins(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Wire executor plugin MCP discovery into startup

When executor plugins declare MCP servers, this installer is never wired into production startup: repo-wide rg shows the app-server production registry still only calls codex_mcp_extension::install, while install_executor_plugins and initialize_executor_plugin_thread_data are only referenced by tests. That means selected plugin MCP declarations won't be discovered for real threads.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the next PR, calm down

Comment thread codex-rs/ext/mcp/Cargo.toml
@jif-oai jif-oai force-pushed the jif/selected-executor-plugin-mcp-registration branch from f6fbab9 to b718083 Compare June 12, 2026 15:19
Comment thread codex-rs/ext/mcp/src/executor_plugin/provider.rs
Comment thread codex-rs/ext/mcp/src/executor_plugin/provider.rs
jif-oai added a commit that referenced this pull request Jun 15, 2026
…7884)

## Why

**In short:** this PR resolves already-discovered MCP registrations. It
does not read selected plugins or discover their MCP servers.

The resolved MCP catalog currently builds config and auto-discovered
plugin registrations before runtime contributors are applied. A
thread-selected plugin needs a distinct precedence tier in that same
initial resolution pass: otherwise a disabled lower-precedence winner
can leave stale name-level state behind, and the winning MCP tools
cannot be attributed to the selected package reliably.

This PR adds that catalog boundary before executor discovery is
connected.

## What changed

- Added an explicit selected-plugin registration tier between
auto-discovered plugins and explicit config.
- Collected selected-plugin contributions before the initial catalog
build, while leaving compatibility and generic extension overlays in
their existing runtime phase.
- Retained the winning plugin ID and display name directly on
plugin-owned catalog registrations.
- Derived MCP tool provenance from the winning catalog entry instead of
joining against local-only plugin summaries.
- Retained the winning selected server's tool approval policy in the
running connection manager, so a selected registration cannot inherit
approval behavior from a losing local plugin.
- Kept remembered approval session-scoped for selected plugins until
there is an authority-aware persistence contract; Codex will not write
approval back to an unrelated local plugin.
- Preserved existing name-level disabled vetoes for discovered plugins
and config, while keeping a selected package's own disabled registration
scoped to that registration.
- Preserved deterministic selection order and existing config,
compatibility, and extension precedence.

The resulting order is:

```text
auto-discovered plugin
  < selected plugin
  < explicit config
  < compatibility registration
  < extension overlay
```

## Behavior and scope

This is a catalog and provenance change only. No production host
contributes selected-plugin MCP registrations yet, so existing local MCP
behavior remains unchanged.

The stacked follow-up, #27870, installs the executor plugin provider
that produces these registrations. App-server activation remains a
separate final step.

## Verification

Focused tests cover precedence, deterministic selected-plugin conflicts,
disabled-veto behavior across catalog phases, managed requirements
before selected-plugin resolution, winning-server approval policy, and
attribution when local and selected packages share an ID or server name.
CI owns execution of the test suite.
Base automatically changed from jif/selected-plugin-mcp-catalog to main June 15, 2026 09:10
@jif-oai

jif-oai commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5453ca8f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/ext/mcp/Cargo.toml
@jif-oai jif-oai merged commit b3c423e into main Jun 15, 2026
31 checks passed
@jif-oai jif-oai deleted the jif/selected-executor-plugin-mcp-registration branch June 15, 2026 09:52
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants