execute: account_id is accepted but accountId is undefined in the sandbox
- Dominant language
- TypeScript
- Stars
- 833
- Forks
- 116
- Avg merge
- 7h 19m
- Merged PRs (30d)
- 3
Description
## MCP Client
OpenAI Codex Desktop / `codex-cli 0.149.1` on macOS arm64.
## Authentication Type
OAuth, multi-account session.
## MCP Server Configuration
```json
{
"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:
```js
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 };
}
```
4. 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:
```text
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.
Contributor guide
Research direction
Start with src/tools/execute.ts and inspect how the selected account is injected into the sandbox, comparing that path with the deployed execute behavior. Add regression coverage for a hosted or multi-account execute call that supplies account_id and reads accountId, plus the intentional no-account error; done means the selected account is available and the documented error remains explicit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100