Files
codex/codex-rs/core-plugins/src/app_mcp_routing.rs
T
Adam Perry @ OpenAI 31372078d1 auth: move domain mode below app wire types (#29721)
## Why

Authentication mode is a domain concept used by login, model selection,
telemetry, and transports. Keeping the canonical type in app-server
protocol forces those lower-level crates to depend on an unrelated wire
API.

## What changed

- Added canonical `codex_protocol::auth::AuthMode` domain values.
- Kept the app-server wire DTO unchanged and added an explicit app-side
conversion.
- Removed production app-server-protocol dependencies from login,
model-provider-info, models-manager, and otel call paths.

## Stack

This is PR 2 of 6, stacked on [PR
#29714](https://github.com/openai/codex/pull/29714). Review only the
delta from `codex/split-json-rpc-protocols`. Next: [PR
#29722](https://github.com/openai/codex/pull/29722).

## Validation

- Auth and login coverage passed in the focused protocol/domain test
run.
- App-server account and auth conversion coverage passed.
2026-06-24 03:10:20 +00:00

33 lines
873 B
Rust

use codex_plugin::AppDeclaration;
use codex_protocol::auth::AuthMode;
use std::collections::HashMap;
use std::collections::HashSet;
pub fn apps_route_available(auth_mode: Option<AuthMode>) -> bool {
auth_mode.is_some_and(AuthMode::uses_codex_backend)
}
pub(crate) fn apply_app_mcp_routing_policy<M>(
apps: &mut Vec<AppDeclaration>,
mcp_servers: &mut HashMap<String, M>,
auth_mode: Option<AuthMode>,
plugin_active: bool,
) {
if !apps_route_available(auth_mode) {
apps.clear();
return;
}
if plugin_active && !apps.is_empty() {
let app_declaration_names = apps
.iter()
.map(|app| app.name.as_str())
.collect::<HashSet<_>>();
mcp_servers.retain(|name, _| !app_declaration_names.contains(name.as_str()));
}
}
#[cfg(test)]
#[path = "app_mcp_routing_tests.rs"]
mod tests;