Skip to main content
Glama
ry-ops

Cloudflare MCP Server

by ry-ops

list_zones

Retrieve all domains in your Cloudflare account with details like zone ID, name, status, and nameservers. Filter results by name or status and manage pagination for large zone lists.

Instructions

List all zones (domains) in the Cloudflare account. Returns zone details including ID, name, status, and nameservers.

Input Schema

NameRequiredDescriptionDefault
nameNoFilter zones by name (optional)
statusNoFilter by status: active, pending, initializing, moved, deleted, deactivated (optional)
pageNoPage number for pagination (default: 1)
per_pageNoNumber of zones per page (default: 20, max: 50)

Input Schema (JSON Schema)

{ "properties": { "name": { "description": "Filter zones by name (optional)", "type": "string" }, "page": { "description": "Page number for pagination (default: 1)", "type": "number" }, "per_page": { "description": "Number of zones per page (default: 20, max: 50)", "type": "number" }, "status": { "description": "Filter by status: active, pending, initializing, moved, deleted, deactivated (optional)", "type": "string" } }, "type": "object" }

Implementation Reference

  • The _list_zones handler function constructs query parameters from the input arguments and calls the Cloudflare API's /zones endpoint using the shared _make_request helper.
    async def _list_zones(self, args: dict) -> Any: """List zones.""" params = {} if args.get("name"): params["name"] = args["name"] if args.get("status"): params["status"] = args["status"] if args.get("page"): params["page"] = args["page"] if args.get("per_page"): params["per_page"] = args["per_page"] return await self._make_request("/zones", params=params)
  • Registers the list_zones tool in the MCP server's list_tools method, providing the tool name, description, and input schema.
    Tool( name="list_zones", description=( "List all zones (domains) in the Cloudflare account. " "Returns zone details including ID, name, status, and nameservers." ), inputSchema={ "type": "object", "properties": { "name": { "type": "string", "description": "Filter zones by name (optional)", }, "status": { "type": "string", "description": "Filter by status: active, pending, initializing, moved, deleted, deactivated (optional)", }, "page": { "type": "number", "description": "Page number for pagination (default: 1)", }, "per_page": { "type": "number", "description": "Number of zones per page (default: 20, max: 50)", }, }, }, ),
  • Defines the input schema for the list_zones tool, specifying optional parameters for filtering and pagination.
    inputSchema={ "type": "object", "properties": { "name": { "type": "string", "description": "Filter zones by name (optional)", }, "status": { "type": "string", "description": "Filter by status: active, pending, initializing, moved, deleted, deactivated (optional)", }, "page": { "type": "number", "description": "Page number for pagination (default: 1)", }, "per_page": { "type": "number", "description": "Number of zones per page (default: 20, max: 50)", }, }, }, ),
  • Shared helper method used by list_zones (and other tools) to make authenticated HTTP requests to the Cloudflare API.
    async def _make_request( self, endpoint: str, method: str = "GET", data: Optional[dict] = None, params: Optional[dict] = None, ) -> Any: """Make a request to the Cloudflare API.""" url = f"{CLOUDFLARE_API_BASE}{endpoint}" headers = { "Authorization": f"Bearer {self.api_token}", "Content-Type": "application/json", } try: response = await self.client.request( method=method, url=url, json=data, params=params, headers=headers, ) response.raise_for_status() result = response.json() if not result.get("success"): errors = result.get("errors", []) raise Exception(f"Cloudflare API error: {json.dumps(errors)}") return result.get("result") except httpx.HTTPError as e: raise Exception(f"HTTP error occurred: {str(e)}")

Latest Blog Posts

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/ry-ops/cloudflare-mcp-server'

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