mirror of
https://github.com/openai/codex.git
synced 2026-11-17 14:58:36 +00:00
Adjust MCP tool approval handling for custom servers (#11787)
Summary This PR expands MCP client-side approval behavior beyond codex_apps and tightens elicitation capability signaling. - Removed the codex_apps-only gate in MCP tool approval checks, so local/custom MCP servers are now eligible for the same client-side approval prompt flow when tool annotations indicate side effects. - Updated approval memory keying to support tools without a connector ID (connector_id: Option<String>), allowing “Approve this Session” to be remembered even when connector metadata is missing. - Updated prompt text for non-codex_apps tools to identify origin as The <server> MCP server instead of This app. - Added MCP initialization capability policy so only codex_apps advertises MCP elicitation capability; other servers advertise no elicitation support. - Added regression tests for: server-specific prompt copy behavior codex-apps-only elicitation capability advertisement Testing - Not run (not requested)
This commit is contained in:
1 parent
547f462385
commit
f6fd4cb3f5
2 files changed
+99
-29
No files matched your search
@@ -1006,6 +1006,21 @@ impl From<anyhow::Error> for StartupOutcomeError {
|
||||
}
|
||||
}
|
||||
|
||||
fn elicitation_capability_for_server(server_name: &str) -> Option<ElicitationCapability> {
|
||||
if server_name == CODEX_APPS_MCP_SERVER_NAME {
|
||||
// https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation#capabilities
|
||||
// indicates this should be an empty object.
|
||||
Some(ElicitationCapability {
|
||||
form: Some(FormElicitationCapability {
|
||||
schema_validation: None,
|
||||
}),
|
||||
url: None,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
async fn start_server_task(
|
||||
server_name: String,
|
||||
client: Arc<RmcpClient>,
|
||||
@@ -1015,6 +1030,8 @@ async fn start_server_task(
|
||||
tx_event: Sender<Event>,
|
||||
elicitation_requests: ElicitationRequestManager,
|
||||
) -> Result<ManagedClient, StartupOutcomeError> {
|
||||
let elicitation = elicitation_capability_for_server(&server_name);
|
||||
|
||||
let params = InitializeRequestParams {
|
||||
meta: None,
|
||||
capabilities: ClientCapabilities {
|
||||
@@ -1022,14 +1039,7 @@ async fn start_server_task(
|
||||
extensions: None,
|
||||
roots: None,
|
||||
sampling: None,
|
||||
// https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation#capabilities
|
||||
// indicates this should be an empty object.
|
||||
elicitation: Some(ElicitationCapability {
|
||||
form: Some(FormElicitationCapability {
|
||||
schema_validation: None,
|
||||
}),
|
||||
url: None,
|
||||
}),
|
||||
elicitation,
|
||||
tasks: None,
|
||||
},
|
||||
client_info: Implementation {
|
||||
@@ -1541,6 +1551,22 @@ mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn elicitation_capability_enabled_only_for_codex_apps() {
|
||||
let codex_apps_capability = elicitation_capability_for_server(CODEX_APPS_MCP_SERVER_NAME);
|
||||
assert!(matches!(
|
||||
codex_apps_capability,
|
||||
Some(ElicitationCapability {
|
||||
form: Some(FormElicitationCapability {
|
||||
schema_validation: None
|
||||
}),
|
||||
url: None,
|
||||
})
|
||||
));
|
||||
|
||||
assert!(elicitation_capability_for_server("custom_mcp").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mcp_init_error_display_prompts_for_github_pat() {
|
||||
let server_name = "github";
|
||||
|
||||
Reference in new issue
Block a user