get_demand_summary
Retrieve electricity demand summary for specific dates including real demand, forecasts, and maximum/minimum values from Spain's grid operator data.
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 decorated with @mcp.tool() that implements the get_demand_summary tool. It fetches real demand data for the given date using the underlying get_indicator_data use case and formats a summary JSON response.@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")
- src/ree_mcp/interface/mcp_server.py:158-158 (registration)The @mcp.tool() decorator registers the get_demand_summary function as an MCP tool.@mcp.tool()