Skip to main content
Glama
ESJavadex

REE MCP Server

by ESJavadex

analyze_demand_volatility

Analyze electricity demand volatility patterns to identify high-variability days and assess stability by calculating daily demand swings and load factors over specified periods.

Instructions

Analyze demand volatility patterns over a period.

Calculates daily demand swings, load factors, and volatility levels to identify high-variability days and overall stability patterns.

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

Returns: JSON string with volatility analysis and stability assessment.

Examples: Analyze volatility for a week: >>> await analyze_demand_volatility("2025-10-01", "2025-10-07")

Analyze volatility for a month:
>>> await analyze_demand_volatility("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 decorated with @mcp.tool(). Instantiates DemandAnalysisService and calls its analyze_demand_volatility method. Handles exceptions and formats response as JSON string.
    @mcp.tool()
    async def analyze_demand_volatility(start_date: str, end_date: str) -> str:
        """Analyze demand volatility patterns over a period.
    
        Calculates daily demand swings, load factors, and volatility levels
        to identify high-variability days and overall stability patterns.
    
        Args:
            start_date: Start date in YYYY-MM-DD format
            end_date: End date in YYYY-MM-DD format
    
        Returns:
            JSON string with volatility analysis and stability assessment.
    
        Examples:
            Analyze volatility for a week:
            >>> await analyze_demand_volatility("2025-10-01", "2025-10-07")
    
            Analyze volatility for a month:
            >>> await analyze_demand_volatility("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.analyze_demand_volatility(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 analyzing demand volatility")
  • Main business logic for analyzing demand volatility within DemandAnalysisService class. Fetches daily max and min demand data, computes daily swings, percentages, classifies volatility levels, and provides overall analysis including stability assessment.
    async def analyze_demand_volatility(self, start_date: str, end_date: str) -> dict[str, Any]:
        """Analyze demand volatility patterns.
    
        Args:
            start_date: Start date in YYYY-MM-DD format
            end_date: End date in YYYY-MM-DD format
    
        Returns:
            Volatility analysis with swings and stability metrics
        """
        # Fetch max and min daily demand
        indicators = {
            "max_daily": IndicatorIDs.MAX_DAILY_DEMAND,
            "min_daily": IndicatorIDs.MIN_DAILY_DEMAND,
        }
    
        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_volatility": [],
            "analysis": {},
        }
    
        max_values = raw_data.get("max_daily", {}).get("values", [])
        min_values = raw_data.get("min_daily", {}).get("values", [])
    
        daily_swings = []
        load_factors = []
    
        # Calculate daily volatility
        for i, max_point in enumerate(max_values):
            if i >= len(min_values):
                break
    
            date = max_point["datetime"][:10]
            max_mw = max_point["value"]
            min_mw = min_values[i]["value"]
    
            swing_mw = max_mw - min_mw
            swing_pct = (swing_mw / max_mw) * 100 if max_mw > 0 else 0
            load_factor = (min_mw / max_mw) * 100 if max_mw > 0 else 0
    
            volatility_data = {
                "date": date,
                "max_demand_mw": round(max_mw, 2),
                "min_demand_mw": round(min_mw, 2),
                "daily_swing_mw": round(swing_mw, 2),
                "swing_percentage": round(swing_pct, 2),
                "load_factor_pct": round(load_factor, 2),
            }
    
            # Volatility classification
            if swing_pct < 20:
                volatility_data["volatility_level"] = "low"
            elif swing_pct < 40:
                volatility_data["volatility_level"] = "moderate"
            elif swing_pct < 60:
                volatility_data["volatility_level"] = "high"
            else:
                volatility_data["volatility_level"] = "very_high"
    
            result["daily_volatility"].append(volatility_data)
            daily_swings.append(swing_mw)
            load_factors.append(load_factor)
    
        # Overall analysis
        if daily_swings:
            avg_swing = sum(daily_swings) / len(daily_swings)
            max_swing = max(daily_swings)
            min_swing = min(daily_swings)
            avg_load_factor = sum(load_factors) / len(load_factors)
    
            # Count days by volatility level
            volatility_counts = {"low": 0, "moderate": 0, "high": 0, "very_high": 0}
            for day_data in result["daily_volatility"]:
                level = day_data["volatility_level"]
                volatility_counts[level] += 1
    
            result["analysis"] = {
                "average_daily_swing_mw": round(avg_swing, 2),
                "max_daily_swing_mw": round(max_swing, 2),
                "min_daily_swing_mw": round(min_swing, 2),
                "average_load_factor_pct": round(avg_load_factor, 2),
                "volatility_distribution": volatility_counts,
                "stability_assessment": (
                    "excellent"
                    if avg_load_factor >= 80
                    else "good"
                    if avg_load_factor >= 70
                    else "moderate"
                    if avg_load_factor >= 60
                    else "concerning"
                ),
                "interpretation": {
                    "load_factor": "Higher load factor (closer to 100%) indicates more stable demand",
                    "volatility_levels": {
                        "low": "<20% swing",
                        "moderate": "20-40% swing",
                        "high": "40-60% swing",
                        "very_high": ">60% swing",
                    },
                },
            }
    
        return result
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions what the tool calculates but doesn't cover important behavioral aspects like whether this is a read-only operation, computational requirements, rate limits, authentication needs, or error handling. The description is functional but lacks operational context.

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) and front-loaded the core functionality. While slightly longer than minimal, every sentence adds value: the first explains what it calculates, the second explains the purpose, and the examples demonstrate usage patterns.

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?

Given the tool has an output schema (returns JSON string) and only 2 parameters with good description coverage, the description is adequate but could be more complete. It explains what the tool does and how to use it, but lacks context about when to use it versus siblings, and doesn't describe the structure of the returned volatility analysis beyond 'JSON string with volatility analysis and stability assessment.'

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?

With 0% schema description coverage, the description compensates well by documenting both parameters in the Args section, specifying their purpose (start and end dates) and format (YYYY-MM-DD). It provides clear examples showing how to use the parameters, adding meaningful context 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 analyzes demand volatility patterns over a period, calculating daily demand swings, load factors, and volatility levels. It specifies the resource (demand volatility patterns) and verb (analyze), but doesn't explicitly differentiate from sibling tools like 'get_daily_demand_statistics' or 'get_peak_analysis' which might overlap in analyzing demand data.

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. While it mentions analyzing volatility patterns, it doesn't specify use cases, prerequisites, or when other tools like 'get_daily_demand_statistics' or 'get_peak_analysis' might be more appropriate for related analyses.

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