get_drive_summary_per_day
Retrieve daily driving summaries for each vehicle from the TeslaMate database, enabling detailed analysis of travel patterns and efficiency.
Instructions
Get the drive summary per day for each car.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.py:62-66 (schema)ToolDefinition schema for the 'get_drive_summary_per_day' tool, specifying its name, description, and the associated SQL query file.ToolDefinition( name="get_drive_summary_per_day", description="Get the drive summary per day for each car. Provides daily driving statistics including distance, duration, and efficiency.", sql_file="drive_summary_per_day.sql", ),
- src/database.py:27-34 (handler)Core handler logic in DatabaseManager.execute_query_sync: reads the SQL file specific to the tool and executes it synchronously on the database, returning results as list of dicts. Used by local main.py.def execute_query_sync(self, sql_file_path: str) -> List[Dict[str, Any]]: """Execute SQL query synchronously""" sql_query = self.read_sql_file(sql_file_path) with psycopg.connect(self.connection_string, row_factory=dict_row) as conn: with conn.cursor() as cur: cur.execute(sql_query) return cur.fetchall()
- src/database.py:36-44 (handler)Async version of the query execution handler in DatabaseManager.execute_query_async, reads tool-specific SQL and executes asynchronously. Used by remote main_remote.py.self, sql_file_path: str, pool: AsyncConnectionPool ) -> List[Dict[str, Any]]: """Execute SQL query asynchronously""" sql_query = self.read_sql_file(sql_file_path) async with pool.connection() as conn: async with conn.cursor() as cur: await cur.execute(sql_query) return await cur.fetchall()
- main.py:32-39 (registration)Registration loop in local main.py: for each ToolDefinition (including get_drive_summary_per_day), creates a specific handler function and registers it with the MCP server using mcp.tool().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)Registration in remote main_remote.py's list_tools(): includes 'get_drive_summary_per_day' from TOOL_DEFINITIONS in the list of available tools returned to MCP client.for tool_def in TOOL_DEFINITIONS: tools.append( types.Tool( name=tool_def.name, description=tool_def.description, inputSchema={"type": "object", "properties": {}}, ) )