Skip to main content
Glama
ry-ops

Cloudflare MCP Server

by ry-ops

get_zone_analytics

Retrieve analytics data for a Cloudflare zone including requests, bandwidth, threats, and pageviews over a specified time period.

Instructions

Get analytics data for a zone including requests, bandwidth, threats, and pageviews.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
zone_idYesThe zone ID
sinceNoStart time (ISO 8601 format or relative like '-1440' for last 24h)
untilNoEnd time (ISO 8601 format or relative like '-0')

Implementation Reference

  • Tool registration: 'get_zone_analytics' is registered as an MCP Tool with name, description, and inputSchema (zone_id required, optional since/until timestamps).
    Tool(
        name="get_zone_analytics",
        description="Get analytics data for a zone including requests, bandwidth, threats, and pageviews.",
        inputSchema={
            "type": "object",
            "properties": {
                "zone_id": {"type": "string", "description": "The zone ID"},
                "since": {
                    "type": "string",
                    "description": "Start time (ISO 8601 format or relative like '-1440' for last 24h)",
                },
                "until": {
                    "type": "string",
                    "description": "End time (ISO 8601 format or relative like '-0')",
                },
            },
            "required": ["zone_id"],
        },
    ),
  • Handler implementation: _get_zone_analytics builds query params (since, until) from args and calls the Cloudflare API endpoint /zones/{zone_id}/analytics/dashboard.
    async def _get_zone_analytics(self, args: dict) -> Any:
        """Get zone analytics."""
        params = {}
        if args.get("since"):
            params["since"] = args["since"]
        if args.get("until"):
            params["until"] = args["until"]
    
        return await self._make_request(
            f"/zones/{args['zone_id']}/analytics/dashboard", params=params
        )
  • Input schema for get_zone_analytics: accepts zone_id (required), since (optional ISO/relative), until (optional ISO/relative).
    inputSchema={
        "type": "object",
        "properties": {
            "zone_id": {"type": "string", "description": "The zone ID"},
            "since": {
                "type": "string",
                "description": "Start time (ISO 8601 format or relative like '-1440' for last 24h)",
            },
            "until": {
                "type": "string",
                "description": "End time (ISO 8601 format or relative like '-0')",
            },
        },
        "required": ["zone_id"],
    },
  • Helper: _make_request is the underlying HTTP helper used by _get_zone_analytics to make authenticated 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)}")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description should disclose behavioral traits like read-only nature, data freshness, or rate limits. It only states it 'gets' data, which implies a read operation but lacks explicit safety or side-effect information.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with 13 words, directly stating the tool's purpose with no redundancy or unnecessary detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description provides some output context (requests, bandwidth, threats, pageviews) but lacks details on output format, time range semantics, and behavioral aspects. Given no output schema, more completeness would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the description adds no new meaning beyond the schema. It does not explain how 'since' and 'until' affect the analytics data or provide context beyond field names.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves analytics data for a zone, listing specific data types (requests, bandwidth, threats, pageviews). This distinguishes it from sibling tools like get_zone (zone details) and list_zones (listing zones).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No usage guidance is provided. The description does not specify when to use this tool, prerequisites, or alternatives among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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