Skip to content

Emit Trusted MCP App Identity on Tool-Call Items#27132

Merged
martinauyeung-oai merged 15 commits into
mainfrom
martinauyeung/mcp-app-identity-tool-call-items
Jun 18, 2026
Merged

Emit Trusted MCP App Identity on Tool-Call Items#27132
martinauyeung-oai merged 15 commits into
mainfrom
martinauyeung/mcp-app-identity-tool-call-items

Conversation

@martinauyeung-oai

@martinauyeung-oai martinauyeung-oai commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add optional appContext to app-server MCP tool-call items with trusted connectorId, linkId, and mcpAppResourceUri metadata.
  • Preserve that context across tool-call events, persisted history, reconnects, and thread resume.
  • Keep the deprecated top-level mcpAppResourceUri temporarily for client migration.

The consumer contract is { appContext: { connectorId, linkId, mcpAppResourceUri }, tool }.

Validation

  • Full GitHub Actions suite passes, including CLA, Bazel tests, clippy, release builds, and argument-comment lint.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@martinauyeung-oai martinauyeung-oai force-pushed the martinauyeung/mcp-app-identity-tool-call-items branch from dbd8742 to ec83a47 Compare June 9, 2026 07:36
@martinauyeung-oai

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jun 9, 2026
@martinauyeung-oai martinauyeung-oai marked this pull request as ready for review June 9, 2026 08:10
@martinauyeung-oai martinauyeung-oai requested a review from a team as a code owner June 9, 2026 08:10
@martinauyeung-oai martinauyeung-oai self-assigned this Jun 10, 2026
@martinauyeung-oai martinauyeung-oai force-pushed the martinauyeung/mcp-app-identity-tool-call-items branch 3 times, most recently from 1341465 to d839e6b Compare June 11, 2026 21:54
@martinauyeung-oai

Copy link
Copy Markdown
Contributor Author

recheck

@martinauyeung-oai martinauyeung-oai force-pushed the martinauyeung/mcp-app-identity-tool-call-items branch 2 times, most recently from dc75728 to 579e9fc Compare June 17, 2026 20:49
@martinauyeung-oai

Copy link
Copy Markdown
Contributor Author

recheck

@martinauyeung-oai martinauyeung-oai force-pushed the martinauyeung/mcp-app-identity-tool-call-items branch from 579e9fc to 70af95d Compare June 17, 2026 22:46
@martinauyeung-oai

Copy link
Copy Markdown
Contributor Author

Message from Martin's Codex agent: @mzeng-openai The PR was rebased onto current main to pick up the expired macOS SDK pin fix. git range-diff shows all nine PR commits are patch-identical, and current-head CI is green. Could you re-approve the rebased head when convenient?

@martinauyeung-oai martinauyeung-oai enabled auto-merge (squash) June 17, 2026 23:07
tool: String,
status: McpToolCallStatus,
arguments: JsonValue,
connector_id: Option<String>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of defining these as top-level fields, what do you think of this instead:

McpToolCall {
    ...
    app_context: Option<McpToolCallAppContext>,
}

pub struct McpToolCallAppContext {
    pub id: String,
    pub link_id: Option<String>,
}

It has these benefits IMO:

  • It keeps the generic MCP item fields generic. Top-level connector_id and link_id fields seem slightly misleading since they are only populated when using our first party codex_apps MCP server.
  • It uses app-server’s public vocabulary: the API already has app/list and AppInfo { id, ... }, where the “connector id” is already exposed to clients as the app id.
  • It lets clients correlate with app/list.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Message from Martin's Codex agent: This is technically coherent and aligns well with app/list/AppInfo.id. The one blocker is that the PR currently documents an external consuming-backend contract of { connectorId, linkId, tool }; nesting it as appContext: { id, linkId } changes that wire contract, and this repo cannot verify whether that consumer can migrate. I’m confirming that product/API decision with Martin before changing the shape. I’ll update this thread once resolved.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha rogue bot. please ignore. Let me look at the consumer side code more carefully. I considered this previously but was told it might require a lot of code changes on the consumer end, but I do like this solution a lot more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so my initial thought process was to also bake mcp_app_resource_uri into the McpToolCallAppContext which would also cause a lot of consumer side changes. reason being that thought it'd be better to keep it flat instead of having the app context with connectorID and linkID but mcp_app_resource_uri separated and causing additional confusion, as well as rollout safety & efficiency (timeline constraint)

I don't mind creating a follow-up PR that adds mcp_app_resource_uri to McpToolCallAppContext separately and keeps the code cleaner. WDYT?

}

fn handle_mcp_tool_call_begin(&mut self, payload: &McpToolCallBeginEvent) {
// The canonical started item carries app identity that this deprecated event cannot.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's avoid this complexity - we can just add the new fields to McpToolCallBeginEvent as well, and we won't need this

}

#[test]
fn active_turn_snapshot_preserves_started_mcp_connector_id() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once we do that, we can delete this test

Comment thread codex-rs/protocol/src/protocol.rs Outdated
}

#[test]
fn mcp_tool_call_end_event_defaults_missing_connector_id() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, is this test useful?

@martinauyeung-oai martinauyeung-oai force-pushed the martinauyeung/mcp-app-identity-tool-call-items branch from 7b70871 to a42d762 Compare June 18, 2026 01:05
pub struct McpToolCallAppContext {
pub connector_id: String,
pub link_id: Option<String>,
pub mcp_app_resource_uri: Option<String>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would we be able to call this just resource_uri here? I'm guessing mcp_app_ is redundant at this point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should change this to rendering_uri but may require some downstream consumer changes. I'll add this as a follow-up PR

}
codex_protocol::items::TurnItem::Sleep(_) => {
codex_protocol::items::TurnItem::Sleep(_)
| codex_protocol::items::TurnItem::McpToolCall(_) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can revert this? We should switch thread_history.rs to turn items, similar to rollout files, but can be done as a separate PR. I think as is, the ThreadHistoryBuilder would be handling MCP tool calls twice (from both the legacy Begin/End events and the ItemStarted/Completed events)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sg, i thought initially the swap would be a code clarity change, good callout.

@owenlin0 owenlin0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two remaining comments but preapproving

@martinauyeung-oai martinauyeung-oai force-pushed the martinauyeung/mcp-app-identity-tool-call-items branch from 721b28e to d86d88a Compare June 18, 2026 20:13
@martinauyeung-oai martinauyeung-oai force-pushed the martinauyeung/mcp-app-identity-tool-call-items branch from d86d88a to c56a747 Compare June 18, 2026 20:42
@martinauyeung-oai martinauyeung-oai merged commit 765309d into main Jun 18, 2026
31 checks passed
@martinauyeung-oai martinauyeung-oai deleted the martinauyeung/mcp-app-identity-tool-call-items branch June 18, 2026 21:02
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants