Skip to main content
Glama
ESJavadex

REE MCP Server

by ESJavadex

get_peak_analysis

Analyze daily maximum and minimum electricity demand to identify patterns and calculate load factors for Spain's electrical grid over a specified period.

Instructions

Get peak demand analysis over a period.

Analyzes daily maximum and minimum demand to identify patterns and calculate load factors.

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

Returns: JSON string with peak demand analysis.

Examples: Get peak analysis for a week: >>> await get_peak_analysis("2025-10-01", "2025-10-07")

Get peak analysis for a month:
>>> await get_peak_analysis("2025-10-01", "2025-10-31")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYes
end_dateYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function implementing the get_peak_analysis MCP tool. Decorated with @mcp.tool() for automatic registration in FastMCP. Fetches daily max and min demand data from REE API using specific indicator IDs, processes it to compute daily peak-to-valley differences, load factors, and period-wide statistics. Returns formatted JSON with analysis results and interpretations.
    @mcp.tool()
    async def get_peak_analysis(start_date: str, end_date: str) -> str:
        """Get peak demand analysis over a period.
    
        Analyzes daily maximum and minimum demand to identify patterns and
        calculate load factors.
    
        Args:
            start_date: Start date in YYYY-MM-DD format
            end_date: End date in YYYY-MM-DD format
    
        Returns:
            JSON string with peak demand analysis.
    
        Examples:
            Get peak analysis for a week:
            >>> await get_peak_analysis("2025-10-01", "2025-10-07")
    
            Get peak analysis for a month:
            >>> await get_peak_analysis("2025-10-01", "2025-10-31")
        """
        try:
            async with ToolExecutor() as executor:
                use_case = executor.create_get_indicator_data_use_case()
    
                # Get max demand
                max_request = GetIndicatorDataRequest(
                    indicator_id=IndicatorIDs.MAX_DAILY_DEMAND.id,
                    start_date=start_date,
                    end_date=end_date,
                    time_granularity="day",
                )
                max_response = await use_case.execute(max_request)
                max_data = max_response.model_dump()
    
                # Get min demand
                min_request = GetIndicatorDataRequest(
                    indicator_id=IndicatorIDs.MIN_DAILY_DEMAND.id,
                    start_date=start_date,
                    end_date=end_date,
                    time_granularity="day",
                )
                min_response = await use_case.execute(min_request)
                min_data = min_response.model_dump()
    
            # Combine data
            max_values = max_data.get("values", [])
            min_values = min_data.get("values", [])
    
            daily_analysis = []
            peak_demands = []
            load_factors = []
    
            for max_val, min_val in zip(max_values, min_values, strict=False):
                max_mw = max_val["value"]
                min_mw = min_val["value"]
                avg_mw = (max_mw + min_mw) / 2
                peak_to_valley = max_mw - min_mw
                load_factor = (avg_mw / max_mw * 100) if max_mw > 0 else 0
    
                daily_analysis.append(
                    {
                        "date": max_val["datetime"][:10],
                        "peak_demand_mw": max_mw,
                        "minimum_demand_mw": min_mw,
                        "average_demand_mw": round(avg_mw, 2),
                        "peak_to_valley_mw": round(peak_to_valley, 2),
                        "load_factor_percentage": round(load_factor, 2),
                    }
                )
    
                peak_demands.append(max_mw)
                load_factors.append(load_factor)
    
            # Calculate period statistics
            period_stats = {}
            if peak_demands:
                period_stats = {
                    "highest_peak_mw": max(peak_demands),
                    "lowest_peak_mw": min(peak_demands),
                    "average_peak_mw": round(sum(peak_demands) / len(peak_demands), 2),
                    "average_load_factor_percentage": round(sum(load_factors) / len(load_factors), 2),
                    "interpretation": {
                        "high_load_factor": "> 70% (efficient, stable demand)",
                        "medium_load_factor": "50-70% (moderate variability)",
                        "low_load_factor": "< 50% (high variability, inefficient)",
                    },
                }
    
            result = {
                "period": {"start": start_date, "end": end_date},
                "daily_analysis": daily_analysis,
                "period_statistics": period_stats,
            }
    
            return ResponseFormatter.success(result)
    
        except Exception as e:
            return ResponseFormatter.unexpected_error(e, context="Error analyzing peaks")
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool 'analyzes' and 'calculates,' implying a read-only operation, but doesn't disclose behavioral traits such as authentication requirements, rate limits, data freshness, or error handling. The description adds minimal behavioral context beyond the basic operation.

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 the core purpose, followed by clear sections for Args, Returns, and Examples. Every sentence adds value without redundancy, making it efficient and easy to parse.

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 2 parameters with 0% schema coverage and an output schema present, the description compensates well by detailing parameter formats and providing usage examples. It doesn't need to explain return values due to the output schema. However, for a tool with no annotations and multiple siblings, more behavioral and usage context would enhance completeness.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaning by specifying the parameter formats ('YYYY-MM-DD') and providing examples of usage for a week and a month, which clarifies the semantics beyond the bare schema. However, it doesn't explain constraints like date ranges or time zones.

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 peak demand analysis over a period' and elaborates with 'Analyzes daily maximum and minimum demand to identify patterns and calculate load factors.' This specifies the verb ('Get/analyzes'), resource ('peak demand analysis'), and scope ('daily maximum and minimum demand'), though it doesn't explicitly differentiate from siblings like 'get_daily_demand_statistics' or '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. With siblings like 'get_daily_demand_statistics' and 'get_demand_summary', there's no indication of how this tool differs in context or use case, leaving the agent without direction on tool selection.

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