Skip to main content
Glama

get_geographic_breakdown

Analyze viewer locations and regional performance to understand global reach, plan strategies, check market penetration, optimize CDN, and verify compliance. Returns views by country, region, or city with percentages and map-ready data.

Instructions

Analyze viewer LOCATIONS and regional performance. USE WHEN: Understanding global reach, planning regional strategies, checking market penetration, optimizing CDN, compliance checks. RETURNS: Views/viewers by country/region/city with percentages. EXAMPLES: 'Which countries watch our content?', 'Show US state breakdown', 'Find top 10 cities for viewership'. Includes map-ready data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_dateYesStart date in YYYY-MM-DD format (e.g., '2024-01-01')
to_dateYesEnd date in YYYY-MM-DD format (e.g., '2024-01-31')
granularityNoLocation detail level (default: 'country'): 'world' = continents, 'country' = nations, 'region' = states/provinces, 'city' = cities. Higher detail requires region_filter.
region_filterNoZoom into specific area: For region view use country code (e.g., 'US' for US states), for city view use 'US-CA' for California cities. Required for region/city granularity.
metricsNoMetrics to include

Implementation Reference

  • The primary handler function for the 'get_geographic_breakdown' tool. It fetches raw geographic data from the core analytics module, enhances it with percentage calculations, top locations sorting, and adds insights like coverage statistics. Returns formatted JSON suitable for geographic visualizations and analysis.
    async def get_geographic_breakdown(
        manager: KalturaClientManager,
        from_date: str,
        to_date: str,
        granularity: str = "country",
        region_filter: Optional[str] = None,
        metrics: Optional[List[str]] = None,
    ) -> str:
        """
        Get analytics broken down by geographic location.
    
        This function provides location-based analytics at various levels of
        granularity, from global overview to city-level detail.
    
        USE WHEN:
        - Understanding global content reach
        - Planning regional content strategies
        - Analyzing market penetration
        - Optimizing CDN configuration
        - Compliance with regional requirements
    
        Args:
            manager: Kaltura client manager
            from_date: Start date (YYYY-MM-DD)
            to_date: End date (YYYY-MM-DD)
            granularity: Level of geographic detail:
                - "world": Global overview
                - "country": Country-level breakdown (default)
                - "region": State/province level
                - "city": City-level detail
            region_filter: Optional filter for specific region:
                - Country code (e.g., "US") for region/city views
                - Continent name for country views
            metrics: Optional list of metrics to include
    
        Returns:
            JSON with geographic distribution data:
            {
                "granularity": "country",
                "top_locations": [
                    {
                        "location": "United States",
                        "code": "US",
                        "metrics": {
                            "views": 45678,
                            "unique_viewers": 12345,
                            "avg_watch_time": 234.5,
                            "percentage": 35.2
                        }
                    },
                    ...
                ],
                "map_data": {...},  // GeoJSON format for visualization
                "insights": {
                    "fastest_growing": ["India", "Brazil"],
                    "highest_engagement": ["Canada", "UK"],
                    "coverage": "127 countries"
                }
            }
    
        Examples:
            # Global country breakdown
            get_geographic_breakdown(manager, from_date, to_date)
    
            # US state-level analysis
            get_geographic_breakdown(manager, from_date, to_date,
                                   granularity="region", region_filter="US")
    
            # City-level for California
            get_geographic_breakdown(manager, from_date, to_date,
                                   granularity="city", region_filter="US-CA")
        """
        from .analytics_core import get_geographic_analytics
    
        result = await get_geographic_analytics(
            manager=manager,
            from_date=from_date,
            to_date=to_date,
            level=granularity,
            country_filter=region_filter,
        )
    
        # Enhance with insights
        data = json.loads(result)
        if "data" in data and len(data.get("data", [])) > 0:
            # Add percentage calculations
            total = sum(float(item.get("count_plays", 0)) for item in data["data"])
            for item in data["data"]:
                plays = float(item.get("count_plays", 0))
                item["percentage"] = round((plays / total * 100) if total > 0 else 0, 2)
    
            # Sort by plays and add top locations
            data["top_locations"] = sorted(
                data["data"], key=lambda x: float(x.get("count_plays", 0)), reverse=True
            )[:10]
    
            # Add insights
            data["insights"] = {
                "total_countries": len(data["data"]),
                "coverage": f"{len(data['data'])} locations",
            }
    
        return json.dumps(data, indent=2)
  • MCP tool schema definition including input parameters validation (from_date, to_date required; granularity enum; etc.) and detailed usage description for the get_geographic_breakdown tool.
    name="get_geographic_breakdown",
    description="Analyze viewer LOCATIONS and regional performance. USE WHEN: Understanding global reach, planning regional strategies, checking market penetration, optimizing CDN, compliance checks. RETURNS: Views/viewers by country/region/city with percentages. EXAMPLES: 'Which countries watch our content?', 'Show US state breakdown', 'Find top 10 cities for viewership'. Includes map-ready data.",
    inputSchema={
        "type": "object",
        "properties": {
            "from_date": {
                "type": "string",
                "description": "Start date in YYYY-MM-DD format (e.g., '2024-01-01')",
            },
            "to_date": {
                "type": "string",
                "description": "End date in YYYY-MM-DD format (e.g., '2024-01-31')",
            },
            "granularity": {
                "type": "string",
                "enum": ["world", "country", "region", "city"],
                "description": "Location detail level (default: 'country'): 'world' = continents, 'country' = nations, 'region' = states/provinces, 'city' = cities. Higher detail requires region_filter.",
            },
            "region_filter": {
                "type": "string",
                "description": "Zoom into specific area: For region view use country code (e.g., 'US' for US states), for city view use 'US-CA' for California cities. Required for region/city granularity.",
            },
            "metrics": {
                "type": "array",
                "items": {"type": "string"},
                "description": "Metrics to include",
            },
        },
        "required": ["from_date", "to_date"],
    },
  • Tool dispatch registration in the MCP server's call_tool handler, mapping the tool name to its execution with the Kaltura manager.
    elif name == "get_geographic_breakdown":
        result = await get_geographic_breakdown(kaltura_manager, **arguments)
  • Tool export and registration in the tools module __all__ list, making it available for import in the server.
    "get_geographic_breakdown",
  • Helper documentation in list_analytics_capabilities function, providing purpose, use cases, and example for the tool.
        "function": "get_geographic_breakdown",
        "purpose": "Location-based analytics",
        "use_cases": [
            "Global reach analysis",
            "Regional content strategy",
            "Market penetration",
            "CDN optimization",
        ],
        "example": "get_geographic_breakdown(manager, from_date, to_date, granularity='country')",
    },
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes what the tool returns (views/viewers by geographic units with percentages), mentions 'map-ready data' as a behavioral trait, and provides example queries. However, it doesn't mention potential limitations like data latency, access permissions, or rate limits.

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 well-structured and front-loaded with purpose, usage guidelines, returns, and examples in distinct sections. Every sentence earns its place by providing essential information without redundancy. The formatting with clear sections enhances readability.

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

Completeness4/5

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

For a tool with 5 parameters, 100% schema coverage, but no annotations or output schema, the description provides good contextual completeness. It covers purpose, usage scenarios, return format, and examples. The main gap is the lack of output schema, but the description compensates by describing what's returned.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description doesn't add significant parameter semantics beyond what's in the schema, though it reinforces the geographic focus. The baseline of 3 is appropriate when the schema does the heavy lifting.

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's purpose with specific verbs ('analyze viewer locations and regional performance') and distinguishes it from siblings by focusing on geographic breakdown rather than general analytics, time-series, or other media-specific operations. It explicitly mentions the resource being analyzed (viewer locations).

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

Usage Guidelines5/5

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

The description provides explicit usage guidance with a 'USE WHEN:' section listing five specific scenarios (understanding global reach, planning regional strategies, checking market penetration, optimizing CDN, compliance checks). This gives clear context for when to select this tool over alternatives like general analytics tools.

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/zoharbabin/kaltura-mcp'

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