Skip to main content
Glama
cobanov

teslamate-mcp

get_longest_drives_by_distance

Retrieve the longest trips by distance for each vehicle, showing trip details including distance traveled and duration.

Instructions

Get the longest drives by distance for each car. Lists the longest trips taken with details about distance and duration.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • src/tools.py:72-76 (registration)
    Registers the tool 'get_longest_drives_by_distance' with its description and SQL file path.
    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",
    ),
  • Generic handler for executing predefined tools by retrieving the ToolDefinition and running its SQL query via DatabaseManager.
    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
        )
  • Registers the tool schema in the MCP list_tools() method, using the definition's name and description with 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": {}},
            )
        )
  • Core handler logic that loads SQL from file and executes the query asynchronously on the database pool.
        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)
    Dynamically creates and registers a specific handler function for each tool, including 'get_longest_drives_by_distance', in the STDIO transport 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)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool 'lists' trips with details, implying a read-only operation, but doesn't cover critical aspects like data freshness, pagination, error conditions, or performance characteristics. This is inadequate for a tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in two sentences: the first states the core purpose, and the second adds clarifying details about output content. Every sentence adds value without redundancy, making it appropriately concise and front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return values) and no parameters, the description's coverage of purpose and output details is minimally adequate. However, with no annotations and behavioral gaps, it doesn't fully address the tool's operational context, leaving room for improvement in guiding the agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, earning a baseline score of 4 for not adding unnecessary information beyond what the schema already provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get the longest drives by distance for each car' specifies the verb (get) and resource (longest drives by distance), with additional context about listing trips with distance and duration details. It distinguishes from siblings by focusing on longest trips rather than summaries, averages, or other metrics, though it doesn't explicitly name alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions 'for each car' but doesn't specify prerequisites, context, or exclusions compared to sibling tools like get_drive_summary_per_day or get_total_distance_and_efficiency, leaving the agent to infer usage based on purpose alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cobanov/teslamate-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server