Skip to main content
Glama
stinkgen

Trino MCP Server

by stinkgen

inspect_table

Retrieve comprehensive metadata for Trino database tables, including column definitions and statistics, to analyze data structure and optimize queries.

Instructions

    Get detailed metadata about a table.
    
    Args:
        catalog: Catalog name.
        schema: Schema name.
        table: Table name.
        
    Returns:
        Dict[str, Any]: Table metadata including columns, statistics, etc.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
catalogYes
schemaYes
tableYes

Implementation Reference

  • The inspect_table tool handler: decorated with @mcp.tool(), fetches table metadata via TrinoClient.get_table_details, computes row count with a COUNT(*) query, enhances columns with data types, nullability, and defaults from information_schema.columns.
    @mcp.tool()
    def inspect_table(
        catalog: str, 
        schema: str, 
        table: str
    ) -> Dict[str, Any]:
        """
        Get detailed metadata about a table.
        
        Args:
            catalog: Catalog name.
            schema: Schema name.
            table: Table name.
            
        Returns:
            Dict[str, Any]: Table metadata including columns, statistics, etc.
        """
        logger.info(f"Inspecting table: {catalog}.{schema}.{table}")
        
        try:
            table_details = client.get_table_details(catalog, schema, table)
            
            # Try to get a row count (this might not work on all connectors)
            try:
                count_result = client.execute_query(
                    f"SELECT count(*) AS row_count FROM {catalog}.{schema}.{table}"
                )
                if count_result.rows and count_result.rows[0]:
                    table_details["row_count"] = count_result.rows[0][0]
            except Exception as e:
                logger.warning(f"Failed to get row count: {e}")
                
            # Get additional info from the information_schema if available
            try:
                info_schema_query = f"""
                SELECT column_name, data_type, is_nullable, column_default
                FROM {catalog}.information_schema.columns
                WHERE table_catalog = '{catalog}'
                AND table_schema = '{schema}'
                AND table_name = '{table}'
                """
                info_schema_result = client.execute_query(info_schema_query)
                
                enhanced_columns = []
                for col in table_details["columns"]:
                    enhanced_col = col.copy()
                    
                    # Find matching info_schema row
                    for row in info_schema_result.rows:
                        if row[0] == col["name"]:
                            enhanced_col["data_type"] = row[1]
                            enhanced_col["is_nullable"] = row[2]
                            enhanced_col["default"] = row[3]
                            break
                            
                    enhanced_columns.append(enhanced_col)
                    
                table_details["columns"] = enhanced_columns
            except Exception as e:
                logger.warning(f"Failed to get column details from information_schema: {e}")
                
            return table_details
        
        except Exception as e:
            error_msg = str(e)
            logger.error(f"Table inspection failed: {error_msg}")
            return {
                "error": error_msg,
                "catalog": catalog,
                "schema": schema,
                "table": table
            }
  • The register_trino_tools function where inspect_table is registered via @mcp.tool() decorator among other Trino tools.
    def register_trino_tools(mcp: FastMCP, client: TrinoClient) -> None:
        """
        Register Trino tools with the MCP server.
        
        Args:
            mcp: The MCP server instance.
            client: The Trino client instance.
        """
        
        @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves metadata, implying a read-only operation, but doesn't specify permissions required, rate limits, error handling, or what 'detailed metadata' includes beyond a vague mention of 'columns, statistics, etc.' 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.

Conciseness5/5

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

The description is well-structured and concise, using a clear purpose statement followed by Args and Returns sections. Every sentence serves a purpose without unnecessary elaboration, making it easy to parse quickly.

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 metadata inspection tool with no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on return format specifics, error cases, or behavioral traits, which are crucial for an agent to use the tool effectively in a database context.

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 lists the parameters (catalog, schema, table) and their roles, but with 0% schema description coverage, it only provides basic names without deeper context like format examples or constraints. It adds some value by clarifying what each parameter represents, but doesn't fully compensate for the lack of schema details.

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 with a specific verb ('Get') and resource ('detailed metadata about a table'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'cancel_query' or 'execute_query', which might also interact with tables in different ways.

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 any prerequisites, context for usage, or comparisons with sibling tools like 'cancel_query' or 'execute_query', leaving the agent to infer usage scenarios.

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