Skip to main content
Glama
nolleh
by nolleh

get_table_structure

Retrieve the structure of a Vertica table, including columns, data types, and constraints. Specify table name and optional schema to inspect database schema.

Instructions

Get the structure of a table including columns, data types, and constraints.

Args:
    ctx: FastMCP context for progress reporting and logging
    table_name: Name of the table to inspect
    schema: Schema name (default: public)

Returns:
    Table structure information as a string

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
schemaNopublic

Implementation Reference

  • The tool handler function for 'get_table_structure'. It queries Vertica's v_catalog.columns and v_catalog.constraint_columns to fetch column info (name, type, length, precision, nullable, default) and constraints, then formats the result as a string.
    @mcp.tool()
    async def get_table_structure(
        ctx: Context,
        table_name: str,
        schema: str = "public"
    ) -> str:
        """Get the structure of a table including columns, data types, and constraints.
    
        Args:
            ctx: FastMCP context for progress reporting and logging
            table_name: Name of the table to inspect
            schema: Schema name (default: public)
    
        Returns:
            Table structure information as a string
        """
        await ctx.info(f"Getting structure for table: {schema}.{table_name}")
    
        # Get or create connection manager
        manager = await get_or_create_manager(ctx)
        if not manager:
            return "Error: Failed to initialize database connection. Check configuration."
    
        query = """
        SELECT
            column_name,
            data_type,
            character_maximum_length,
            numeric_precision,
            numeric_scale,
            is_nullable,
            column_default
        FROM v_catalog.columns
        WHERE table_schema = %s
        AND table_name = %s
        ORDER BY ordinal_position;
        """
    
        conn = None
        cursor = None
        try:
            conn = manager.get_connection()
            cursor = conn.cursor()
            cursor.execute(query, (schema, table_name))
            columns = cursor.fetchall()
    
            if not columns:
                return f"No table found: {schema}.{table_name}"
    
            # Get constraints
            cursor.execute("""
                SELECT
                    constraint_name,
                    constraint_type,
                    column_name
                FROM v_catalog.constraint_columns
                WHERE table_schema = %s
                AND table_name = %s;
            """, (schema, table_name))
            constraints = cursor.fetchall()
    
            # Format the output
            result = f"Table Structure for {schema}.{table_name}:\n\n"
            result += "Columns:\n"
            for col in columns:
                result += f"- {col[0]}: {col[1]}"
                if col[2]:  # character_maximum_length
                    result += f"({col[2]})"
                elif col[3]:  # numeric_precision
                    result += f"({col[3]},{col[4]})"
                result += f" {'NULL' if col[5] == 'YES' else 'NOT NULL'}"
                if col[6]:  # column_default
                    result += f" DEFAULT {col[6]}"
                result += "\n"
    
            if constraints:
                result += "\nConstraints:\n"
                for const in constraints:
                    result += f"- {const[0]} ({const[1]}): {const[2]}\n"
    
            return result
    
        except Exception as e:
            error_msg = f"Error getting table structure: {str(e)}"
            await ctx.error(error_msg)
            return error_msg
        finally:
            if cursor:
                cursor.close()
            if conn:
                manager.release_connection(conn)
  • Tool registration via the @mcp.tool() decorator on line 367, which registers the async function 'get_table_structure' as an MCP tool.
    @mcp.tool()
    async def get_table_structure(
  • Input schema: takes 'table_name' (str, required) and 'schema' (str, default 'public'). Return type is str.
    async def get_table_structure(
        ctx: Context,
        table_name: str,
        schema: str = "public"
    ) -> str:
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavior. It mentions returning 'Table structure information as a string' but does not describe the format, side effects (e.g., read-only), error behavior, or performance characteristics.

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 relatively concise, with the purpose stated in the first line. However, the Args/Returns block adds some verbosity without significant extra value, and could be streamlined.

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 no output schema and a potentially complex return value, the description should elaborate on the format of the returned string (e.g., JSON, plain text). It also lacks error handling details and examples.

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?

Schema description coverage is 0%, so the description adds value beyond the schema. It defines table_name and schema with a default, but does not provide examples, constraints (e.g., required format for table_name), or clarification of schema parameter semantics.

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

Purpose5/5

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

The description clearly states the tool retrieves table structure including columns, data types, and constraints. It uses a specific verb (Get) and resource (table structure), and is distinct from sibling tools like execute_query or list_views.

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 does not provide any guidance on when to use this tool versus alternatives. No mention of prerequisites, cases where other tools are preferred, or scope limitations.

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/nolleh/mcp-vertica'

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