get_consumption_data
Retrieve hourly energy consumption data for the past 30 days, including time periods, total costs, base energy costs, and consumed kWh from Tibber power supplier.
Instructions
Get the hourly consumption data for the last 30 days, such as time period, total cost, base energy cost, and consumpted kwh.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.py:49-72 (handler)The main handler function for the 'get_consumption_data' tool. It is decorated with @mcp.tool() which registers it in the FastMCP server. The function connects to the Tibber API, fetches homes, retrieves hourly consumption data, and returns it as a string.@mcp.tool() async def get_consumption_data() -> str: """Get the hourly consumption data for the last 30 days, such as time period, total cost, base energy cost, and consumpted kwh. """ try: tibber_connection = tibber.Tibber(tibber_api_token, user_agent="tibber-mcp") await tibber_connection.update_info() homes = tibber_connection.get_homes() if not homes: logger.error("No homes found for this Tibber account") return "No homes found" home = homes[0] await home.fetch_consumption_data() await tibber_connection.close_connection() result = home.hourly_consumption_data return str(result) except Exception as e: logger.error(f"Error retrieving price info: {e}") return f"Error: {str(e)}"
- server.py:49-49 (registration)The @mcp.tool() decorator registers the get_consumption_data function as a tool in the MCP server.@mcp.tool()