Skip to main content
Glama

mcp-server-cloudflare

Official
by cloudflare
account.api.ts1.49 kB
import { getProps } from '../get-props' import type { Cloudflare } from 'cloudflare' import type { Account } from 'cloudflare/resources/accounts/accounts.mjs' import type { CloudflareMcpAgent } from '../types/cloudflare-mcp-agent.types' import type { ToolHandler } from '../types/tools.types' export async function handleAccountsList({ client }: { client: Cloudflare }): Promise<Account[]> { // Currently limited to 50 accounts const response = await client.accounts.list({ query: { per_page: 50 } }) return response.result } export const withAccountCheck = <T extends Record<string, any>>( agent: CloudflareMcpAgent, handler: ToolHandler<T> ) => { return async (params: T) => { const accountId = await agent.getActiveAccountId() if (!accountId) { return { content: [ { type: 'text' as const, text: 'No currently active accountId. Try listing your accounts (accounts_list) and then setting an active account (set_active_account)', }, ], } } try { const props = getProps(agent) const result = await handler({ ...params, accountId, apiToken: props.accessToken || '', }) return { content: [{ type: 'text' as const, text: JSON.stringify(result) }], } } catch (error) { return { content: [ { type: 'text' as const, text: JSON.stringify({ error: `Error processing request: ${error instanceof Error ? error.message : 'Unknown error'}`, }), }, ], } } } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cloudflare/mcp-server-cloudflare'

If you have feedback or need assistance with the MCP directory API, please join our Discord server