Skip to main content
Glama
ajkeast

My Coding Buddy MCP Server

by ajkeast

get_table_schema

Retrieve the schema information for a specific table, including column names and data types, to understand its structure.

Instructions

Get the schema information for a specific table.

Args: table_name (str): Name of the table to get schema for

Returns: str: A formatted string containing the table schema information Each column's information is on a new line

Raises: Error: If the table doesn't exist or schema retrieval fails

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The get_table_schema method on SQLTools class that connects to MySQL and executes DESCRIBE on the specified table, returning formatted schema information (Field, Type, Null, Key, Default, Extra) for each column.
    def get_table_schema(self, table_name: str) -> str:
        """Get the schema information for a specific table.
        
        Args:
            table_name (str): Name of the table to get schema for
            
        Returns:
            str: A formatted string containing the table schema information
                 Each column's information is on a new line
                 
        Raises:
            Error: If the table doesn't exist or schema retrieval fails
        """
        with self.get_connection() as conn:
            cursor = conn.cursor(dictionary=True, buffered=True)
            cursor.execute(f"DESCRIBE `{table_name}`")
            schema = cursor.fetchall()
            
            if not schema:
                return f"No schema found for table '{table_name}'"
                
            output = [f"Schema for table '{table_name}':"]
            for column in schema:
                output.append(f"Column: {column['Field']}")
                output.append(f"Type: {column['Type']}")
                output.append(f"Null: {column['Null']}")
                output.append(f"Key: {column['Key']}")
                output.append(f"Default: {column['Default']}")
                output.append(f"Extra: {column['Extra']}")
                output.append("")
            return "\n".join(output)
  • server.py:16-16 (registration)
    Registration of get_table_schema as an MCP tool via mcp.tool()(sql_tools.get_table_schema)
    mcp.tool()(sql_tools.get_table_schema)
  • Test case for get_table_schema that verifies it returns a string containing 'Schema for table'
    def test_table_get_schema(sql_tools: SQLTools, tables: List[str]):
        if not tables:
            pytest.skip("No tables available for table-specific tests.")
    
        result = sql_tools.get_table_schema(tables[0])
        assert isinstance(result, str)
        assert "Schema for table" in result
Behavior4/5

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

The description discloses the return format ('formatted string with each column on a new line') and error conditions ('if the table doesn't exist or schema retrieval fails'). It goes beyond the input schema, though it omits details like read-only nature or authentication requirements.

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 concise and well-structured with Args, Returns, and Raises sections. No redundant sentences; every statement adds value.

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

Completeness5/5

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

Given the simple tool (one parameter, no nested objects) and the presence of an output schema, the description covers purpose, parameter, return format, and error handling adequately. It is complete for its complexity.

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

Parameters5/5

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

The description fully explains the only parameter, table_name, as 'Name of the table to get schema for'. This adds meaning beyond the schema title 'Table Name' and is even more specific.

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's purpose: 'Get the schema information for a specific table.' It uses a specific verb ('Get') and resource ('schema information') and is distinct from sibling tools like execute_query, list_columns, or get_table_create.

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 explicit guidance on when to use this tool versus alternatives. No mentions of prerequisites, limitations, or comparisons with siblings like list_columns or get_table_create.

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/ajkeast/Coding-Buddy-MCP-Server'

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