Skip to main content
Glama
ajkeast

My Coding Buddy MCP Server

by ajkeast

list_columns

Retrieve column names and data types for a specified database table. Input a table name to get its columns and types.

Instructions

List columns for a given table.

Args: table_name (str): Table name to inspect

Returns: str: Column names and types for the table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The actual implementation of the list_columns method in the SQLTools class. It takes a table_name parameter, connects to MySQL, runs 'SHOW COLUMNS FROM `table_name`', and returns a formatted string listing each column's Field, Type, Null, Key, Default, and Extra attributes.
    def list_columns(self, table_name: str) -> str:
        """List columns for a given table.
        
        Args:
            table_name (str): Table name to inspect
        
        Returns:
            str: Column names and types for the table
        """
        with self.get_connection() as conn:
            cursor = conn.cursor(dictionary=True, buffered=True)
            cursor.execute(f"SHOW COLUMNS FROM `{table_name}`")
            columns = cursor.fetchall()
    
            if not columns:
                return f"No columns found for table '{table_name}'"
    
            output = [f"Columns for table '{table_name}':"]
            for column in columns:
                output.append(
                    f"{column['Field']} {column['Type']} NULL={column['Null']} KEY={column['Key']} DEFAULT={column['Default']} EXTRA={column['Extra']}"
                )
            return "\n".join(output)
  • server.py:15-15 (registration)
    Registration of list_columns as an MCP tool via the FastMCP decorator pattern.
    mcp.tool()(sql_tools.list_columns)
  • The function signature serves as the schema: it accepts a single 'table_name: str' parameter and returns a 'str'.
    def list_columns(self, table_name: str) -> str:
        """List columns for a given table.
        
        Args:
            table_name (str): Table name to inspect
        
        Returns:
            str: Column names and types for the table
        """
  • The get_connection context manager is a helper used by list_columns to obtain a MySQL database connection.
    @contextmanager
    def get_connection(self):
        """Context manager for database connections.
        
        Yields:
            mysql.connector.connection: Database connection object
            
        Raises:
            Error: If connection to the database fails
        """
        connection = None
        try:
            connection = mysql.connector.connect(
                host=self.host,
                user=self.user,
                password=self.password,
                database=self.database
            )
            yield connection
        except Error as e:
            print(f"Error connecting to MySQL database: {e}")
            raise
        finally:
            if connection and connection.is_connected():
                connection.close()
Behavior2/5

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

No annotations are present, so the description carries full burden. It only mentions return value but does not disclose side effects, auth needs, or any safety considerations.

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 concise and front-loaded. However, the Args/Returns section partially repeats the schema. Still, it is efficient.

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

Completeness4/5

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

Given the tool's simplicity and presence of an output schema, the description is sufficient. It explains input and output clearly.

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?

Schema description coverage is 0%, so description compensates by documenting the parameter 'table_name' with its type and meaning. It adds value beyond the schema.

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 'List columns for a given table', using a specific verb and resource. It distinguishes from siblings like list_tables and list_databases.

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

Usage Guidelines3/5

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

No explicit when-to-use or when-not-to-use guidance is provided. Usage is implied but not differentiated from alternative tools like execute_query or get_table_schema.

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