mirror of
https://github.com/openai/codex.git
synced 2026-11-17 14:58:36 +00:00
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
This commit is contained in:
1 parent
136f75e7b7
commit
51c9ed6d4f
41 files changed
+981
-20
No files matched your search
@@ -46,7 +46,7 @@ fn function_payloads_remain_function_outputs() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mcp_code_mode_result_serializes_full_call_tool_result() {
|
||||
fn mcp_code_mode_result_omits_private_metadata() {
|
||||
let output = CallToolResult {
|
||||
content: vec![serde_json::json!({
|
||||
"type": "text",
|
||||
@@ -78,11 +78,9 @@ fn mcp_code_mode_result_serializes_full_call_tool_result() {
|
||||
"content": "done",
|
||||
},
|
||||
"isError": false,
|
||||
"_meta": {
|
||||
"source": "mcp",
|
||||
},
|
||||
})
|
||||
);
|
||||
assert_eq!(output.meta, Some(serde_json::json!({ "source": "mcp" })));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -232,7 +230,7 @@ fn mcp_tool_output_response_item_preserves_content_items() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mcp_tool_output_code_mode_result_stays_raw_call_tool_result() {
|
||||
fn mcp_tool_output_code_mode_result_preserves_content_without_private_metadata() {
|
||||
let large_content = "large structured value ".repeat(1_000);
|
||||
let output = McpToolOutput {
|
||||
result: CallToolResult {
|
||||
@@ -244,7 +242,9 @@ fn mcp_tool_output_code_mode_result_stays_raw_call_tool_result() {
|
||||
"content": large_content,
|
||||
})),
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
meta: Some(serde_json::json!({
|
||||
"hive_dispatch_id": "private-dispatch-id",
|
||||
})),
|
||||
},
|
||||
tool_input: json!({}),
|
||||
wall_time: std::time::Duration::from_millis(1250),
|
||||
@@ -269,6 +269,10 @@ fn mcp_tool_output_code_mode_result_stays_raw_call_tool_result() {
|
||||
"isError": false,
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
output.result.meta,
|
||||
Some(serde_json::json!({ "hive_dispatch_id": "private-dispatch-id" }))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user