Skip to main content
Glama
ESJavadex

REE MCP Server

by ESJavadex

get_daily_demand_statistics

Analyze daily electricity demand statistics for Spain's grid, providing maximum, minimum, and sum values for generation during specified date ranges.

Instructions

Get daily demand statistics for a period.

Provides comprehensive daily demand analysis including maximum, minimum, and sum of generation values for each day in the specified period.

Args: start_date: Start date in YYYY-MM-DD format end_date: End date in YYYY-MM-DD format

Returns: JSON string with daily statistics and overall summary.

Examples: Get statistics for a week: >>> await get_daily_demand_statistics("2025-10-01", "2025-10-07")

Get statistics for a month:
>>> await get_daily_demand_statistics("2025-10-01", "2025-10-31")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYes
end_dateYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'get_daily_demand_statistics', decorated with @mcp.tool() which registers it. Orchestrates execution by setting up data fetcher and DemandAnalysisService, calls the service method, and formats the response.
    @mcp.tool()
    async def get_daily_demand_statistics(start_date: str, end_date: str) -> str:
        """Get daily demand statistics for a period.
    
        Provides comprehensive daily demand analysis including maximum, minimum,
        and sum of generation values for each day in the specified period.
    
        Args:
            start_date: Start date in YYYY-MM-DD format
            end_date: End date in YYYY-MM-DD format
    
        Returns:
            JSON string with daily statistics and overall summary.
    
        Examples:
            Get statistics for a week:
            >>> await get_daily_demand_statistics("2025-10-01", "2025-10-07")
    
            Get statistics for a month:
            >>> await get_daily_demand_statistics("2025-10-01", "2025-10-31")
        """
        try:
            async with ToolExecutor() as executor:
                use_case = executor.create_get_indicator_data_use_case()
                data_fetcher = DataFetcher(use_case)
                service = DemandAnalysisService(data_fetcher)
    
                result = await service.get_daily_demand_statistics(start_date, end_date)
    
            return ResponseFormatter.success(result)
    
        except DomainException as e:
            return ResponseFormatter.domain_exception(e)
        except Exception as e:
            return ResponseFormatter.unexpected_error(e, context="Error getting demand statistics")
  • Core helper method implementing the daily demand statistics logic within DemandAnalysisService. Fetches max daily demand, min daily demand, and sum generation data, computes per-day stats (max, min, load factor, swing), and overall summary statistics.
    async def get_daily_demand_statistics(self, start_date: str, end_date: str) -> dict[str, Any]:
        """Get daily demand statistics.
    
        Args:
            start_date: Start date in YYYY-MM-DD format
            end_date: End date in YYYY-MM-DD format
    
        Returns:
            Daily demand statistics with max, min, and sum of generation
        """
        # Fetch all three demand indicators
        indicators = {
            "max_daily": IndicatorIDs.MAX_DAILY_DEMAND,
            "min_daily": IndicatorIDs.MIN_DAILY_DEMAND,
            "sum_generation": IndicatorIDs.REAL_DEMAND_SUM_GENERATION,
        }
    
        raw_data = await self.data_fetcher.fetch_multiple_indicators(
            indicators, start_date, end_date, "day"
        )
    
        result: dict[str, Any] = {
            "period": {"start": start_date, "end": end_date},
            "daily_statistics": [],
        }
    
        # Extract values by date
        max_values = raw_data.get("max_daily", {}).get("values", [])
        min_values = raw_data.get("min_daily", {}).get("values", [])
        sum_values = raw_data.get("sum_generation", {}).get("values", [])
    
        # Combine data by date
        for i, max_point in enumerate(max_values):
            date = max_point["datetime"][:10]  # Extract YYYY-MM-DD
            max_mw = max_point["value"]
    
            min_mw = min_values[i]["value"] if i < len(min_values) else None
            sum_mw = sum_values[i]["value"] if i < len(sum_values) else None
    
            daily_stat: dict[str, Any] = {
                "date": date,
                "max_demand_mw": max_mw,
                "min_demand_mw": min_mw,
                "sum_generation_mw": sum_mw,
            }
    
            # Calculate load factor if we have both max and min
            if min_mw is not None and max_mw > 0:
                daily_stat["load_factor"] = round((min_mw / max_mw) * 100, 2)
                daily_stat["daily_swing_mw"] = round(max_mw - min_mw, 2)
            else:
                daily_stat["load_factor"] = None
                daily_stat["daily_swing_mw"] = None
    
            result["daily_statistics"].append(daily_stat)
    
        # Calculate overall statistics
        if result["daily_statistics"]:
            max_values_list = [s["max_demand_mw"] for s in result["daily_statistics"]]
            min_values_list = [
                s["min_demand_mw"]
                for s in result["daily_statistics"]
                if s["min_demand_mw"] is not None
            ]
            load_factors = [
                s["load_factor"] for s in result["daily_statistics"] if s["load_factor"] is not None
            ]
    
            result["summary"] = {
                "peak_demand_mw": round(max(max_values_list), 2),
                "lowest_demand_mw": round(min(min_values_list), 2) if min_values_list else None,
                "average_max_demand_mw": round(sum(max_values_list) / len(max_values_list), 2),
                "average_load_factor_pct": (
                    round(sum(load_factors) / len(load_factors), 2) if load_factors else None
                ),
                "days_analyzed": len(result["daily_statistics"]),
            }
    
        return result
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that the tool provides 'comprehensive daily demand analysis' and returns JSON with statistics and summary, which is helpful. However, it doesn't mention behavioral aspects like rate limits, authentication requirements, data freshness, or error conditions that would be important for an agent to know.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, args, returns, examples). It's appropriately sized at 10 sentences, with the core purpose stated upfront. The examples are helpful but could be slightly more concise.

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?

Given the tool has an output schema (which handles return values) and only 2 parameters, the description provides adequate context. It explains what statistics are computed, parameter formats, and includes usage examples. For a relatively simple query tool, this is reasonably complete, though it could benefit from more behavioral context.

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

Parameters4/5

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

The schema description coverage is 0%, so the description must compensate. It successfully adds meaning by specifying date format (YYYY-MM-DD) and clarifying that these define the period for analysis. The description provides concrete examples showing how to use the parameters, which adds significant value beyond the bare schema.

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

Purpose4/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: 'Get daily demand statistics for a period' with specific details about what statistics are included (maximum, minimum, sum of generation values). It distinguishes from siblings by focusing on daily statistics rather than volatility, summary, or other analyses. However, it doesn't explicitly contrast with all siblings like 'get_demand_summary'.

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?

The description provides no guidance on when to use this tool versus alternatives like 'get_demand_summary' or 'analyze_demand_volatility'. It includes examples but doesn't explain the appropriate context or prerequisites for using this specific statistical analysis tool.

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/ESJavadex/ree-mcp'

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