mirror of
https://github.com/openai/codex.git
synced 2026-11-13 22:47:20 +00:00
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
This commit is contained in:
1 parent
bab7c2dcc1
commit
ee46c5ba0e
61 files changed
+729
-284
No files matched your search
@@ -15,6 +15,7 @@ use std::time::Duration;
|
||||
use codex_config::McpServerConfig;
|
||||
use codex_config::McpServerTransportConfig;
|
||||
use codex_exec_server::Environment;
|
||||
use codex_protocol::mcp::ClientMcpExtensions;
|
||||
use lru::LruCache;
|
||||
use rmcp::model::ElicitationCapability;
|
||||
use sha1::Digest;
|
||||
@@ -78,7 +79,7 @@ impl McpToolCatalogCache {
|
||||
runtime_context: &McpRuntimeContext,
|
||||
resolved_environment: Option<&Arc<Environment>>,
|
||||
client_elicitation_capability: &ElicitationCapability,
|
||||
supports_openai_form_elicitation: bool,
|
||||
client_mcp_extensions: &ClientMcpExtensions,
|
||||
) -> Option<McpToolCatalogCacheContext> {
|
||||
let identity = ToolCatalogIdentity::new(
|
||||
server_name,
|
||||
@@ -86,7 +87,7 @@ impl McpToolCatalogCache {
|
||||
runtime_context,
|
||||
resolved_environment,
|
||||
client_elicitation_capability,
|
||||
supports_openai_form_elicitation,
|
||||
client_mcp_extensions,
|
||||
)?;
|
||||
let entry = lock_unpoisoned(&self.entries)
|
||||
.get_or_insert(identity, || Arc::new(ToolCatalogCacheEntry::default()))
|
||||
@@ -218,12 +219,12 @@ impl ToolCatalogIdentity {
|
||||
runtime_context: &McpRuntimeContext,
|
||||
environment: Option<&Arc<Environment>>,
|
||||
client_elicitation_capability: &ElicitationCapability,
|
||||
supports_openai_form_elicitation: bool,
|
||||
client_mcp_extensions: &ClientMcpExtensions,
|
||||
) -> Option<Self> {
|
||||
let transport = ToolCatalogTransportIdentity::new(
|
||||
config,
|
||||
client_elicitation_capability,
|
||||
supports_openai_form_elicitation,
|
||||
client_mcp_extensions,
|
||||
)?;
|
||||
Some(Self {
|
||||
server_name: server_name.to_string(),
|
||||
@@ -247,7 +248,7 @@ impl ToolCatalogTransportIdentity {
|
||||
fn new(
|
||||
config: &McpServerConfig,
|
||||
client_elicitation_capability: &ElicitationCapability,
|
||||
supports_openai_form_elicitation: bool,
|
||||
client_mcp_extensions: &ClientMcpExtensions,
|
||||
) -> Option<Self> {
|
||||
let McpServerTransportConfig::Stdio {
|
||||
command,
|
||||
@@ -282,7 +283,7 @@ impl ToolCatalogTransportIdentity {
|
||||
cwd,
|
||||
&config.environment_id,
|
||||
client_elicitation_capability,
|
||||
supports_openai_form_elicitation,
|
||||
client_mcp_extensions.iter().collect::<BTreeMap<_, _>>(),
|
||||
))
|
||||
.ok()?,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user