get_demand_summary
Retrieve electricity demand data for a specific date, including real demand, forecast, and maximum/minimum values from Spain's electrical grid.
Instructions
Get a summary of electricity demand for a specific date.
Convenience tool that fetches key demand indicators (real demand, forecast, max/min) for a given date.
Args: date: Date in YYYY-MM-DD format (default: 2025-10-08)
Returns: JSON string with demand summary.
Examples: Get today's demand summary: >>> await get_demand_summary("2025-10-11")
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | 2025-10-08 |
Implementation Reference
- The handler function for the get_demand_summary MCP tool. It is decorated with @mcp.tool() which registers it automatically with the FastMCP server. The function fetches real demand data for the specified date using the REE indicator API and returns a JSON summary including statistics and unit information.@mcp.tool() async def get_demand_summary(date: str = "2025-10-08") -> str: """Get a summary of electricity demand for a specific date. Convenience tool that fetches key demand indicators (real demand, forecast, max/min) for a given date. Args: date: Date in YYYY-MM-DD format (default: 2025-10-08) Returns: JSON string with demand summary. Examples: Get today's demand summary: >>> await get_demand_summary("2025-10-11") """ try: start_date, end_date = DateTimeHelper.build_day_range(date) # Fetch demand data directly async with ToolExecutor() as executor: use_case = executor.create_get_indicator_data_use_case() request = GetIndicatorDataRequest( indicator_id=IndicatorIDs.REAL_DEMAND_PENINSULAR.id, start_date=start_date, end_date=end_date, time_granularity="hour", ) response = await use_case.execute(request) demand_data = response.model_dump() result = { "date": date, "real_demand": { "statistics": demand_data.get("statistics"), "unit": demand_data["indicator"]["unit"], "values_count": len(demand_data.get("values", [])), }, } return ResponseFormatter.success(result) except Exception as e: return ResponseFormatter.unexpected_error(e, context="Error getting demand summary")