Skip to main content
Glama
stinkgen

Trino MCP Server

by stinkgen

cancel_query

Stop a running query in Trino by providing its query ID to manage query execution and optimize resource usage.

Instructions

    Cancel a running query.
    
    Args:
        query_id: ID of the query to cancel.
        
    Returns:
        Dict[str, Any]: Result of the cancellation operation.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
query_idYes

Implementation Reference

  • MCP tool handler for cancel_query: calls TrinoClient.cancel_query and formats response.
    def cancel_query(query_id: str) -> Dict[str, Any]:
        """
        Cancel a running query.
        
        Args:
            query_id: ID of the query to cancel.
            
        Returns:
            Dict[str, Any]: Result of the cancellation operation.
        """
        logger.info(f"Cancelling query: {query_id}")
        
        try:
            success = client.cancel_query(query_id)
            
            if success:
                return {
                    "success": True,
                    "message": f"Query {query_id} cancelled successfully"
                }
            else:
                return {
                    "success": False,
                    "message": f"Failed to cancel query {query_id}"
                }
        
        except Exception as e:
            error_msg = str(e)
            logger.error(f"Query cancellation failed: {error_msg}")
            return {
                "success": False,
                "error": error_msg,
                "query_id": query_id
            }
  • Registration of Trino tools (including cancel_query) via register_trino_tools call during app lifespan.
    register_trino_resources(mcp, trino_client)
    register_trino_tools(mcp, trino_client)
  • TrinoClient helper method implementing query cancellation via Trino system procedure.
    def cancel_query(self, query_id: str) -> bool:
        """
        Cancel a running query.
        
        Args:
            query_id: The ID of the query to cancel.
            
        Returns:
            bool: True if the query was successfully canceled, False otherwise.
        """
        self.ensure_connection()
        
        try:
            # Use system procedures to cancel the query
            self.execute_query(f"CALL system.runtime.kill_query(query_id => '{query_id}')")
            return True
        except Exception as e:
            logger.error(f"Failed to cancel query {query_id}: {e}")
            return False
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 action ('Cancel') but doesn't explain what cancellation entails (e.g., whether it's reversible, if it requires specific permissions, potential side effects, or rate limits). This leaves significant gaps in understanding the tool's behavior.

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

Conciseness4/5

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

The description is appropriately brief and front-loaded with the core purpose. The Args/Returns sections are structured but slightly verbose for a single parameter; every sentence earns its place, though minor trimming could improve efficiency.

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

Completeness2/5

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

Given the complexity of a cancellation operation (a mutation with potential side effects), no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on behavioral traits, return value specifics, error conditions, and usage context, making it inadequate for safe and effective tool invocation.

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

Parameters3/5

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

The description adds minimal semantic context for the single parameter ('ID of the query to cancel'), but with 0% schema description coverage, it doesn't fully compensate. It clarifies that 'query_id' refers to a query ID, which is helpful, but doesn't provide format examples or validation rules beyond what the basic schema indicates.

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 action ('Cancel') and target ('a running query'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'execute_query' or 'inspect_table', which would require explicit comparison to achieve a score of 5.

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 doesn't mention prerequisites (e.g., that the query must be running), exclusions, or comparisons to sibling tools, leaving the agent without contextual usage instructions.

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/stinkgen/trino_mcp'

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