Remove template IDs from MCP tool call metadata (#33467)

## What changed

- Remove `template_id` from MCP tool call items and lifecycle events.
- Remove `templateId` from app-server `McpToolCallAppContext` responses and generated schemas.
- Update protocol conversions, documentation, and existing test expectations for the revised metadata shape.

GitOrigin-RevId: f2b1304eadff661eec3966673ea71206b1542b98
This commit is contained in:
Martin Au-Yeung
2026-07-16 01:23:52 +00:00
committed by copyberry
parent be39aab9f4
commit 800715d201
33 changed files with 2 additions and 173 deletions
-11
View File
@@ -344,7 +344,6 @@ struct McpToolCallItemMetadata {
link_id: Option<String>,
mcp_app_resource_uri: Option<String>,
app_name: Option<String>,
template_id: Option<String>,
action_name: Option<String>,
plugin_id: Option<String>,
}
@@ -363,7 +362,6 @@ impl McpToolCallItemMetadata {
mcp_app_resource_uri: metadata
.and_then(|metadata| metadata.mcp_app_resource_uri.clone()),
app_name: trusted_mcp_app_metadata.and_then(|metadata| metadata.connector_name.clone()),
template_id: trusted_mcp_app_metadata.and_then(|metadata| metadata.template_id.clone()),
action_name: trusted_mcp_app_metadata
.and_then(|metadata| metadata.codex_apps_meta.as_ref())
.and_then(|meta| meta.get(MCP_TOOL_RESOURCE_URI_META_KEY))
@@ -911,7 +909,6 @@ async fn notify_mcp_tool_call_started(
mcp_app_resource_uri: item_metadata.mcp_app_resource_uri,
link_id: item_metadata.link_id,
app_name: item_metadata.app_name,
template_id: item_metadata.template_id,
action_name: item_metadata.action_name,
plugin_id: item_metadata.plugin_id,
status: McpToolCallStatus::InProgress,
@@ -956,7 +953,6 @@ async fn notify_mcp_tool_call_completed(
mcp_app_resource_uri: item_metadata.mcp_app_resource_uri,
link_id: item_metadata.link_id,
app_name: item_metadata.app_name,
template_id: item_metadata.template_id,
action_name: item_metadata.action_name,
plugin_id: item_metadata.plugin_id,
status,
@@ -1034,7 +1030,6 @@ pub(crate) struct McpToolApprovalMetadata {
tool_title: Option<String>,
tool_description: Option<String>,
mcp_app_resource_uri: Option<String>,
template_id: Option<String>,
codex_apps_meta: Option<serde_json::Map<String, serde_json::Value>>,
openai_file_input_optional_fields: Option<HashMap<String, Vec<String>>>,
}
@@ -1045,7 +1040,6 @@ const MCP_TOOL_LINK_ID_META_KEY: &str = "link_id";
const MCP_TOOL_PLUGIN_ID_META_KEY: &str = "plugin_id";
const MCP_TOOL_THREAD_ID_META_KEY: &str = "threadId";
const MCP_TOOL_CONNECTED_ACCOUNT_EMAIL_META_KEY: &str = "connected_account_email";
const MCP_TOOL_TEMPLATE_ID_META_KEY: &str = "template_id";
const MCP_TOOL_RESOURCE_URI_META_KEY: &str = "resource_uri";
async fn custom_mcp_tool_approval_mode(
@@ -1568,11 +1562,6 @@ pub(crate) async fn lookup_mcp_tool_metadata(
tool_title: tool_info.tool.title,
tool_description: tool_info.tool.description.map(std::borrow::Cow::into_owned),
mcp_app_resource_uri: get_mcp_app_resource_uri(tool_info.tool.meta.as_deref()),
template_id: codex_apps_meta
.as_ref()
.and_then(|meta| meta.get(MCP_TOOL_TEMPLATE_ID_META_KEY))
.and_then(serde_json::Value::as_str)
.map(str::to_string),
codex_apps_meta,
// Disallow custom MCPs from uploading files via fileParams.
openai_file_input_optional_fields: openai_file_input_optional_fields_for_server(
-16
View File
@@ -87,7 +87,6 @@ fn approval_metadata(
tool_title: tool_title.map(str::to_string),
tool_description: tool_description.map(str::to_string),
mcp_app_resource_uri: None,
template_id: None,
codex_apps_meta: None,
openai_file_input_optional_fields: None,
}
@@ -1224,11 +1223,9 @@ fn mcp_tool_call_item_metadata_only_trusts_codex_apps_identity() {
/*tool_description*/ None,
);
metadata.link_id = Some("link_fedcba9876543210fedcba9876543210".to_string());
metadata.template_id = Some("calendar_template".to_string());
metadata.codex_apps_meta = Some(
serde_json::json!({
"resource_uri": "/asdk_app_0123456789abcdef0123456789abcdef/link_fedcba9876543210fedcba9876543210/create_event",
"template_id": "calendar_template",
})
.as_object()
.cloned()
@@ -1242,7 +1239,6 @@ fn mcp_tool_call_item_metadata_only_trusts_codex_apps_identity() {
link_id: Some("link_fedcba9876543210fedcba9876543210".to_string()),
mcp_app_resource_uri: None,
app_name: Some("Calendar".to_string()),
template_id: Some("calendar_template".to_string()),
action_name: Some("create_event".to_string()),
plugin_id: None,
}
@@ -1254,7 +1250,6 @@ fn mcp_tool_call_item_metadata_only_trusts_codex_apps_identity() {
link_id: None,
mcp_app_resource_uri: None,
app_name: None,
template_id: None,
action_name: None,
plugin_id: None,
}
@@ -1279,7 +1274,6 @@ async fn mcp_tool_call_item_includes_app_identity() {
link_id: Some("link_fedcba9876543210fedcba9876543210".to_string()),
mcp_app_resource_uri: None,
app_name: Some("Calendar".to_string()),
template_id: Some("calendar_template".to_string()),
action_name: Some("create_event".to_string()),
plugin_id: Some("sample@test".to_string()),
},
@@ -1328,7 +1322,6 @@ async fn codex_apps_tool_call_request_meta_includes_turn_metadata_and_codex_apps
tool_title: Some("Create Event".to_string()),
tool_description: Some("Create a calendar event.".to_string()),
mcp_app_resource_uri: None,
template_id: None,
codex_apps_meta: Some(
serde_json::json!({
"resource_uri": "connector://calendar/tools/calendar_create_event",
@@ -1817,7 +1810,6 @@ fn guardian_mcp_review_request_includes_annotations_when_present() {
tool_title: None,
tool_description: None,
mcp_app_resource_uri: None,
template_id: None,
codex_apps_meta: None,
openai_file_input_optional_fields: None,
};
@@ -2520,7 +2512,6 @@ async fn approve_mode_skips_when_annotations_do_not_require_approval() {
tool_title: Some("Read Only Tool".to_string()),
tool_description: None,
mcp_app_resource_uri: None,
template_id: None,
codex_apps_meta: None,
openai_file_input_optional_fields: None,
};
@@ -2597,7 +2588,6 @@ async fn guardian_mode_skips_auto_when_annotations_do_not_require_approval() {
tool_title: Some("Read Only Tool".to_string()),
tool_description: None,
mcp_app_resource_uri: None,
template_id: None,
codex_apps_meta: None,
openai_file_input_optional_fields: None,
};
@@ -2657,7 +2647,6 @@ async fn permission_request_hook_allows_mcp_tool_call() {
tool_title: Some("Create entities".to_string()),
tool_description: None,
mcp_app_resource_uri: None,
template_id: None,
codex_apps_meta: None,
openai_file_input_optional_fields: None,
};
@@ -2796,7 +2785,6 @@ async fn permission_request_hook_runs_after_remembered_mcp_approval() {
tool_title: Some("Create entities".to_string()),
tool_description: None,
mcp_app_resource_uri: None,
template_id: None,
codex_apps_meta: None,
openai_file_input_optional_fields: None,
};
@@ -2886,7 +2874,6 @@ async fn guardian_mode_mcp_denial_returns_rationale_message() {
tool_title: Some("Dangerous Tool".to_string()),
tool_description: Some("Reads calendar data.".to_string()),
mcp_app_resource_uri: None,
template_id: None,
codex_apps_meta: None,
openai_file_input_optional_fields: None,
};
@@ -2943,7 +2930,6 @@ async fn prompt_mode_waits_for_approval_when_annotations_do_not_require_approval
tool_title: Some("Read Only Tool".to_string()),
tool_description: None,
mcp_app_resource_uri: None,
template_id: None,
codex_apps_meta: None,
openai_file_input_optional_fields: None,
};
@@ -3001,7 +2987,6 @@ async fn full_access_mode_skips_mcp_tool_approval_for_all_approval_modes() {
tool_title: Some("Dangerous Tool".to_string()),
tool_description: Some("Performs a risky action.".to_string()),
mcp_app_resource_uri: None,
template_id: None,
codex_apps_meta: None,
openai_file_input_optional_fields: None,
};
@@ -3057,7 +3042,6 @@ async fn approve_mode_skips_guardian_in_every_permission_mode() {
tool_title: Some("Dangerous Tool".to_string()),
tool_description: Some("Performs a risky action.".to_string()),
mcp_app_resource_uri: None,
template_id: None,
codex_apps_meta: None,
openai_file_input_optional_fields: None,
};
@@ -225,7 +225,6 @@ async fn emit_tool_call_begin(
mcp_app_resource_uri: None,
link_id: None,
app_name: None,
template_id: None,
action_name: None,
plugin_id: None,
status: McpToolCallStatus::InProgress,
@@ -269,7 +268,6 @@ async fn emit_tool_call_end(
mcp_app_resource_uri: None,
link_id: None,
app_name: None,
template_id: None,
action_name: None,
plugin_id: None,
status,