Skip to main content
Glama
ESJavadex

REE MCP Server

by ESJavadex

compare_forecast_actual

Analyze electricity demand forecast accuracy by comparing predicted vs actual values and calculating error metrics like MAE and RMSE for specific dates.

Instructions

Compare forecasted vs actual electricity demand.

Calculates forecast accuracy metrics (error, MAE, RMSE) for demand predictions.

Args: date: Date in YYYY-MM-DD format

Returns: JSON string with forecast comparison and accuracy metrics.

Examples: Compare forecast accuracy for Oct 8: >>> await compare_forecast_actual("2025-10-08")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function implementing the 'compare_forecast_actual' MCP tool. It retrieves hourly demand forecast (IndicatorIDs.DEMAND_FORECAST) and actual demand (IndicatorIDs.REAL_DEMAND_PENINSULAR) data for the specified date, performs pairwise comparisons to compute absolute/percentage errors, and aggregates accuracy metrics including MAE, RMSE, MAPE, and forecast bias direction. The function is decorated with @mcp.tool() for automatic registration and schema generation via FastMCP.
    @mcp.tool()
    async def compare_forecast_actual(date: str) -> str:
        """Compare forecasted vs actual electricity demand.
    
        Calculates forecast accuracy metrics (error, MAE, RMSE) for demand predictions.
    
        Args:
            date: Date in YYYY-MM-DD format
    
        Returns:
            JSON string with forecast comparison and accuracy metrics.
    
        Examples:
            Compare forecast accuracy for Oct 8:
            >>> await compare_forecast_actual("2025-10-08")
        """
        try:
            start_date, end_date = DateTimeHelper.build_day_range(date)
    
            async with ToolExecutor() as executor:
                use_case = executor.create_get_indicator_data_use_case()
    
                # Get forecast data
                forecast_request = GetIndicatorDataRequest(
                    indicator_id=IndicatorIDs.DEMAND_FORECAST.id,
                    start_date=start_date,
                    end_date=end_date,
                    time_granularity="hour",
                )
                forecast_response = await use_case.execute(forecast_request)
                forecast_data = forecast_response.model_dump()
    
                # Get actual data
                actual_request = GetIndicatorDataRequest(
                    indicator_id=IndicatorIDs.REAL_DEMAND_PENINSULAR.id,
                    start_date=start_date,
                    end_date=end_date,
                    time_granularity="hour",
                )
                actual_response = await use_case.execute(actual_request)
                actual_data = actual_response.model_dump()
    
            # Compare values
            forecast_values = forecast_data.get("values", [])
            actual_values = actual_data.get("values", [])
    
            comparisons = []
            errors = []
            absolute_errors = []
            squared_errors = []
    
            for forecast, actual in zip(forecast_values, actual_values, strict=False):
                forecast_mw = forecast["value"]
                actual_mw = actual["value"]
                error_mw = forecast_mw - actual_mw
                error_pct = (error_mw / actual_mw * 100) if actual_mw > 0 else 0
    
                comparisons.append(
                    {
                        "datetime": forecast["datetime"],
                        "forecast_mw": forecast_mw,
                        "actual_mw": actual_mw,
                        "error_mw": round(error_mw, 2),
                        "error_percentage": round(error_pct, 2),
                    }
                )
    
                errors.append(error_mw)
                absolute_errors.append(abs(error_mw))
                squared_errors.append(error_mw**2)
    
            # Calculate accuracy metrics
            accuracy_metrics = {}
            if errors:
                mae = sum(absolute_errors) / len(absolute_errors)
                rmse = (sum(squared_errors) / len(squared_errors)) ** 0.5
                mean_error = sum(errors) / len(errors)
                mape = sum(
                    abs(e / a["value"]) * 100 for e, a in zip(errors, actual_values, strict=False)
                ) / len(errors)
    
                accuracy_metrics = {
                    "mean_absolute_error_mw": round(mae, 2),
                    "root_mean_squared_error_mw": round(rmse, 2),
                    "mean_error_mw": round(mean_error, 2),
                    "mean_absolute_percentage_error": round(mape, 2),
                    "bias": (
                        "overforecast"
                        if mean_error > 0
                        else "underforecast"
                        if mean_error < 0
                        else "unbiased"
                    ),
                }
    
            result = {
                "date": date,
                "comparisons": comparisons,
                "accuracy_metrics": accuracy_metrics,
            }
    
            return ResponseFormatter.success(result)
    
        except Exception as e:
            return ResponseFormatter.unexpected_error(e, context="Error comparing forecast")
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 of behavioral disclosure. It mentions the tool calculates metrics (error, MAE, RMSE) but does not specify computational details, data sources, or potential limitations like rate limits or authentication needs. For a tool with no annotations, this leaves significant behavioral aspects unclear.

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 uses bullet points effectively. It is appropriately sized for the tool's complexity, though the example could be slightly more concise. Overall, it avoids unnecessary verbosity.

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, the description does not need to detail return values, which it handles adequately. However, with no annotations and a single parameter, it could benefit from more behavioral context (e.g., data freshness, error handling). The description is minimally complete but lacks depth for a tool performing calculations.

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 description adds meaningful context beyond the input schema, which has 0% description coverage. It specifies the 'date' parameter format (YYYY-MM-DD) and provides an example usage, clarifying its purpose and expected input. With only one parameter, this is sufficient to compensate for the schema's lack of descriptions.

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 specific action ('compare forecasted vs actual electricity demand') and resource ('electricity demand'), distinguishing it from siblings like 'analyze_demand_volatility' or 'get_daily_demand_statistics' which focus on different aspects of demand data. The purpose is precise and unambiguous.

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. It mentions calculating forecast accuracy metrics but does not specify scenarios where this is preferred over other tools like 'get_demand_summary' or 'analyze_demand_volatility', nor does it mention prerequisites or exclusions.

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