Skip to content

execute: account_id is accepted but accountId is undefined in the sandbox #204

Description

@sumitake

MCP Client

OpenAI Codex Desktop / codex-cli 0.149.1 on macOS arm64.

Authentication Type

OAuth, multi-account session.

MCP Server Configuration

{
  "type": "http",
  "url": "https://mcp.cloudflare.com/mcp"
}

No token or account identifier is included in this report.

Failing Endpoint / Tool

execute, before a GET /accounts/{account_id}/subscriptions request could be made.

Bug Description

The hosted execute tool accepted a valid account_id argument, and its dynamic tool description explicitly said that accountId is set from the optional account_id tool argument. Inside the sandbox, however, reading accountId immediately raised ReferenceError: accountId is not defined.

This appears to be a deployed-server/runtime regression or mismatch with the current tool contract. The current cloudflare/mcp source in src/tools/execute.ts also appears to inject const accountId = ... when an account is selected. Related issue #65 described this exact desired one-place account-selection behavior and is closed.

Steps to Reproduce

  1. Connect to https://mcp.cloudflare.com/mcp with OAuth for a user that can access multiple accounts.
  2. Call execute with a valid account_id tool argument.
  3. Use the documented binding in the async code, for example:
async () => {
  const r = await cloudflare.request({
    method: "GET",
    path: `/accounts/${accountId}/subscriptions`,
    query: { page: 1, per_page: 100 }
  });
  return { success: r.success, status: r.status };
}
  1. Observe that execution fails before the API request.

Expected Behavior

When account_id is supplied, the sandbox should define accountId to that exact selected account for the duration of the call. If account selection is absent or invalid, the tool should return the documented explicit account-selection error rather than an undefined-variable error.

Actual Behavior

The call failed immediately with:

ReferenceError: accountId is not defined
    at exec_main.mjs:2:71

A subsequent call that hardcoded the same account identifier into the path reached the Cloudflare API layer, confirming that the sandbox and request helper otherwise executed. Hardcoding is a brittle workaround and contradicts the tool description.

Additional Context

  • Observed: 2026-08-27 UTC.
  • Codex Cloudflare plugin metadata: cloudflare 0.1.2, which points to the official hosted MCP server.
  • Current cloudflare/mcp main observed at 75c4dbc005e2ee14b937b18089a7880062264351.
  • Suggested regression coverage: hosted/multi-account execute with an explicit account_id, an expression that reads accountId, and a read-only API path; separately verify the intentional no-account error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions