openai/codex · error

originating MCP tool requires an explicit account link

Error message

originating MCP tool requires an explicit account link

What it means

Bailed in resource_origin while reading through an app-context-bound resource: the calling tool's metadata carries no usable link_id (missing, empty, or whitespace), but this app context requires an explicitly linked account to authorize the read. Sibling guards check connector and link-id match.

Solutions

  1. Provide an explicit account link when invoking the originating MCP tool.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/codex-mcp/src/resource_origin.rs:282 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/494197d087157ace. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/codex-mcp/src/resource_origin.rs:282

        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),
                open_world_hint: annotations.and_then(|value| value.open_world_hint),
            })
            .enabled
        {
            anyhow::bail!("originating MCP tool is disabled by app configuration");
        }

        let meta = serde_json::from_value(serde_json::json!({
            "threadId": thread_id,

View on GitHub (pinned to 339751715c)