get_battery_degradation_over_time
Track and analyze battery degradation trends over time for Tesla vehicles using TeslaMate data. Monitor health and performance to optimize battery longevity and usage.
Instructions
Get the battery degradation over time for each car.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:22-28 (handler)Generic handler factory used to create the execution function for get_battery_degradation_over_time and other tools. The handler reads and executes the SQL file 'battery_degradation_over_time.sql' synchronously.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)Handler function for executing predefined tools like get_battery_degradation_over_time asynchronously by looking up the tool definition and running its SQL query.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:32-36 (schema)Tool schema definition including name, description, and reference to the SQL query file implementing the battery degradation analysis.ToolDefinition( name="get_battery_degradation_over_time", description="Get the battery degradation over time for each car. Tracks battery health metrics and capacity changes.", sql_file="battery_degradation_over_time.sql", ),
- main.py:31-39 (registration)Dynamically registers the get_battery_degradation_over_time handler (and all others) with the FastMCP server instance.# Register all tools from definitions 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_battery_degradation_over_time (and all predefined tools) in the list_tools() response with empty input schema, enabling MCP clients to discover and call it.for tool_def in TOOL_DEFINITIONS: tools.append( types.Tool( name=tool_def.name, description=tool_def.description, inputSchema={"type": "object", "properties": {}}, ) )