Skip to content

[Bug] set_active_account tool not exposed - cannot use D1/KV/R2 tools with single accountΒ #260

@quotentiroler

Description

@quotentiroler

Bug Description

When using the cloudflare-bindings MCP server from VS Code (GitHub Copilot), all tools that require an account ID fail with the error:

No currently active accountId. Try listing your accounts (accounts_list) and then setting an active account (set_active_account)

However, the set_active_account tool is not exposed in the 25 tools discovered by VS Code.

Environment

  • MCP Client: VS Code 1.106.3 with GitHub Copilot
  • MCP Server: https://bindings.mcp.cloudflare.com/mcp
  • Transport: Tested both direct HTTP ("type": "http") and via mcp-remote 0.1.31
  • Account: Single Cloudflare account

Steps to Reproduce

  1. Configure VS Code MCP with cloudflare-bindings:

    {
      "servers": {
        "cloudflare-bindings": {
          "command": "npx",
          "args": ["mcp-remote", "https://bindings.mcp.cloudflare.com/mcp"]
        }
      }
    }
  2. Start the server - VS Code discovers 25 tools

  3. Call accounts_list - works, returns the account:

    {"accounts":[{"id":"xxx","name":"[email protected]'s Account"}],"count":1}
  4. Call d1_database_create (or any D1/KV/R2/Workers tool) - fails:

    No currently active accountId. Try listing your accounts (accounts_list) and then setting an active account (set_active_account)
    
  5. Try to call set_active_account - tool doesn't exist in the exposed tools

Expected Behavior

Either:

  1. Auto-select the account when there's only one account (most common case)
  2. Expose the set_active_account tool so users can set it manually

Code Reference

Looking at the source code in apps/workers-bindings/src/bindings.app.ts, the setActiveAccountId method exists:

async setActiveAccountId(accountId: string) {
    // ...
}

And registerAccountTools is called in init(), but the set_active_account tool appears to not be registered or is filtered out.

Impact

This bug makes the entire cloudflare-bindings MCP server unusable for managing D1 databases, KV namespaces, R2 buckets, and Workers - the core functionality of the server.

We spent ~30 minutes trying different configurations (direct HTTP, mcp-remote, re-authenticating OAuth multiple times) before realizing the tool simply isn't exposed.

Workaround

Use Wrangler CLI directly:

npx wrangler d1 create my-database

This works fine, but defeats the purpose of having an MCP server for AI-assisted Cloudflare management.

Suggested Fix

In packages/mcp-common/src/tools/account.tools.ts, ensure set_active_account is registered:

agent.server.tool(
  'set_active_account',
  'Set the active Cloudflare account for subsequent operations',
  { account_id: z.string().describe('The account ID to set as active') },
  async ({ account_id }) => {
    await agent.setActiveAccountId(account_id)
    return { content: [{ type: 'text', text: `Active account set to ${account_id}` }] }
  }
)

Or better, auto-select when accounts.length === 1.

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