get_daily_battery_usage_patterns
Retrieve daily battery consumption trends for Tesla vehicles stored in the TeslaMate database, enabling analysis of energy usage patterns over time.
Instructions
Get the daily battery usage patterns for each car.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:22-28 (handler)Factory that creates the specific handler function for the tool, which executes db_manager.execute_query_sync(sql_file) where sql_file is 'daily_battery_usage.sql' for this tool.def create_tool_handler(sql_file: str): """Factory function to create tool handlers""" def handler() -> List[Dict[str, Any]]: return db_manager.execute_query_sync(sql_file) return handler
- main_remote.py:118-127 (handler)Executes the tool logic for get_daily_battery_usage_patterns by retrieving its definition and running the SQL query asynchronously.async def execute_predefined_tool(tool_name: str) -> List[Dict[str, Any]]: """Execute a predefined tool by name""" if not app_context: raise RuntimeError("Application context not initialized") tool = get_tool_by_name(tool_name) return await app_context.db_manager.execute_query_async( tool.sql_file, app_context.db_pool )
- src/tools.py:52-56 (registration)ToolDefinition registering the name, description, and SQL file for the get_daily_battery_usage_patterns tool.ToolDefinition( name="get_daily_battery_usage_patterns", description="Get the daily battery usage patterns for each car. Analyzes battery consumption patterns throughout the day.", sql_file="daily_battery_usage.sql", ),
- main.py:32-39 (registration)Dynamically creates and registers the handler for get_daily_battery_usage_patterns (and others) with the MCP server.for tool_def in TOOL_DEFINITIONS: tool_func = create_tool_handler(tool_def.sql_file) tool_func.__doc__ = tool_def.description tool_func.__name__ = tool_def.name # Register the tool with the MCP server mcp.tool()(tool_func)
- main_remote.py:179-186 (registration)Registers get_daily_battery_usage_patterns in the list_tools response with its description and empty input schema.for tool_def in TOOL_DEFINITIONS: tools.append( types.Tool( name=tool_def.name, description=tool_def.description, inputSchema={"type": "object", "properties": {}}, ) )
- main_remote.py:184-185 (schema)Defines the input schema for the tool as an empty object (no parameters).inputSchema={"type": "object", "properties": {}}, )