openai/codex · error
originating MCP tool link does not match its app context
Error message
originating MCP tool link does not match its app context
What it means
Guard in ResourceOrigin::read: the link_id recorded on the originating tool call does not match the tool's current link_id metadata, meaning the account link changed since the tool call and the read is refused.
Solutions
- Use the account link associated with the app context of the originating tool call.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at codex-rs/codex-mcp/src/resource_origin.rs:273 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/a0d0be30dedf112a.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/codex-mcp/src/resource_origin.rs:273
anyhow::bail!("originating MCP tool call does not match the requested resource");
}
if self.ambiguous_account {
anyhow::bail!("originating MCP tool call has ambiguous account selection");
}
let tool_info = binding
.tool_info(CODEX_APPS_MCP_SERVER_NAME, &self.tool)
.context("originating MCP tool is unavailable")?;
if tool_info.connector_id.as_deref() != Some(self.connector_id.as_str()) {
anyhow::bail!("originating MCP tool connector does not match its app context");
}
let tool_meta = tool_info.tool.meta.as_ref().map(|meta| &meta.0);
let current_link_id = tool_meta
.and_then(|meta| meta.get("link_id"))
.and_then(serde_json::Value::as_str)
.filter(|value| !value.trim().is_empty());
if current_link_id != self.link_id.as_deref() {
anyhow::bail!("originating MCP tool link does not match its app context");
}
if self.link_id.is_none()
&& tool_meta
.and_then(|meta| meta.get("_codex_apps"))
.and_then(|meta| meta.get("requires_explicit_link_id"))
.and_then(serde_json::Value::as_bool)
== Some(true)
{
anyhow::bail!("originating MCP tool requires an explicit account link");
}
let annotations = tool_info.tool.annotations.as_ref();
if !AppToolPolicyEvaluator::new(&binding.config().config_layer_stack)
.policy(AppToolPolicyInput {
connector_id: Some(&self.connector_id),
tool_name: tool_info.tool.name.as_ref(),
tool_title: tool_info.tool.title.as_deref(),
destructive_hint: annotations.and_then(|value| value.destructive_hint),View on GitHub (pinned to 339751715c)