Expose MCP app identity in app context (#29934)

## Why

MCP tool-call events need to expose trusted app identity and action
metadata directly so v2 clients do not have to infer it from tool names
or resource URIs.

## What changed

- Add optional `appName`, `templateId`, and `actionName` fields to MCP
tool-call `appContext`.
- Populate `appName` and `templateId` from trusted Codex Apps metadata,
and derive `actionName` from the trusted app resource metadata.
- Preserve all three fields through core events, legacy protocol events,
persisted thread history, resume redaction, and app-server v2 responses.
- Document the public `appContext` fields in
`codex-rs/app-server/README.md`.
- Regenerate app-server JSON and TypeScript schemas and add coverage for
serialization, persistence, redaction, and metadata propagation.

## Validation

- `just test -p codex-app-server-protocol mcp_tool_call`
- `just test -p codex-core
mcp_tool_call_item_metadata_only_trusts_codex_apps_identity
mcp_tool_call_item_includes_app_identity`
- `just write-app-server-schema`

---------

Co-authored-by: Martin Au-Yeung <280153141+martinauyeung-oai@users.noreply.github.com>
This commit is contained in:
Martin Au-Yeung
2026-06-25 18:31:10 -07:00
committed by GitHub
co-authored by Martin Au-Yeung
parent fb8598df3f
commit ec300bc7bd
32 changed files with 516 additions and 4 deletions
@@ -834,6 +834,9 @@ async fn thread_resume_redacts_payloads_for_chatgpt_remote_clients() -> Result<(
connector_id: "calendar".to_string(),
link_id: Some("link_calendar".to_string()),
resource_uri: Some("ui://widget/lookup.html".to_string()),
app_name: Some("Calendar".to_string()),
template_id: Some("calendar_template".to_string()),
action_name: Some("lookup".to_string()),
})
);
let result = result.as_ref().expect("redacted MCP result");
@@ -884,6 +887,9 @@ async fn thread_resume_redacts_payloads_for_chatgpt_remote_clients() -> Result<(
connector_id: "calendar".to_string(),
link_id: Some("link_calendar".to_string()),
resource_uri: Some("ui://widget/lookup.html".to_string()),
app_name: Some("Calendar".to_string()),
template_id: Some("calendar_template".to_string()),
action_name: Some("lookup".to_string()),
})
);
let result = result.as_ref().expect("normal MCP result");
@@ -990,6 +996,9 @@ fn append_resume_redaction_history(
connector_id: Some("calendar".to_string()),
mcp_app_resource_uri: Some("ui://widget/lookup.html".to_string()),
link_id: Some("link_calendar".to_string()),
app_name: Some("Calendar".to_string()),
template_id: Some("calendar_template".to_string()),
action_name: Some("lookup".to_string()),
plugin_id: None,
duration: Duration::from_millis(8),
result: Ok(CallToolResult {