get_zone_analytics
Retrieve analytics data for a Cloudflare zone including requests, bandwidth, threats, and pageviews within specified time ranges to monitor performance and security metrics.
Instructions
Get analytics data for a zone including requests, bandwidth, threats, and pageviews.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| zone_id | Yes | The zone ID | |
| since | No | Start time (ISO 8601 format or relative like '-1440' for last 24h) | |
| until | No | End time (ISO 8601 format or relative like '-0') |
Input Schema (JSON Schema)
{
"properties": {
"since": {
"description": "Start time (ISO 8601 format or relative like '-1440' for last 24h)",
"type": "string"
},
"until": {
"description": "End time (ISO 8601 format or relative like '-0')",
"type": "string"
},
"zone_id": {
"description": "The zone ID",
"type": "string"
}
},
"required": [
"zone_id"
],
"type": "object"
}
Implementation Reference
- The handler function that implements get_zone_analytics by preparing parameters and calling the Cloudflare API endpoint for zone 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 tool, specifying zone_id as required and optional since/until date parameters.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"], },
- src/cloudflare_mcp_server/__init__.py:430-431 (registration)Registration/dispatch in the call_tool method that handles invocation of get_zone_analytics by calling its handler.elif name == "get_zone_analytics": result = await self._get_zone_analytics(arguments)
- src/cloudflare_mcp_server/__init__.py:381-399 (registration)Tool registration in list_tools() method, defining the tool's metadata and schema for MCP server discovery.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"], }, ),