get_consumption_data
Retrieve hourly energy consumption data for the past 30 days, including time periods, total cost, base energy cost, and consumed kWh via the Tibber MCP server.
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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"title": "get_consumption_dataArguments",
"type": "object"
}
Implementation Reference
- server.py:49-72 (handler)The main handler function for the 'get_consumption_data' tool, decorated with @mcp.tool() which also serves as its registration. It connects to the Tibber API, fetches consumption data for the primary home, 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)}"