get_longest_drives_by_distance
Identify the longest drives by distance for each car in your TeslaMate database. Extract detailed trip analytics to monitor and analyze driving patterns.
Instructions
Get the longest drives by distance for each car.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main_remote.py:117-127 (handler)Handler function that retrieves the tool definition by name and executes the corresponding SQL query asynchronously for the remote MCP server.# Tool handler functions 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 )
- main.py:22-28 (handler)Factory function that creates the specific tool handler for a given SQL file by returning a closure that executes the query synchronously for the local STDIO MCP server.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.py:31-39 (registration)Dynamically creates and registers handler functions for all predefined tools, including get_longest_drives_by_distance, in the local MCP server.# 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:178-186 (registration)Registers all predefined tools, including get_longest_drives_by_distance with empty input schema, in the list_tools method for the remote MCP server.# Add all predefined tools for tool_def in TOOL_DEFINITIONS: tools.append( types.Tool( name=tool_def.name, description=tool_def.description, inputSchema={"type": "object", "properties": {}}, ) )
- src/tools.py:72-76 (registration)Defines the tool metadata: name, description, and SQL file path used for tool registration and execution across both local and remote servers.ToolDefinition( name="get_longest_drives_by_distance", description="Get the longest drives by distance for each car. Lists the longest trips taken with details about distance and duration.", sql_file="longest_drives_by_distance.sql", ),