Skip to main content
Glama
yawlhead91

MariaDB MCP Server

by yawlhead91

get_table_schema

Retrieve the complete structure and schema details of a MariaDB database table to understand its columns, data types, and constraints for database analysis or query planning.

Instructions

Get the schema/structure of a specific table.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
databaseNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'get_table_schema' tool. It is registered via the @mcp.tool() decorator. Uses DESCRIBE query to fetch column details and SHOW TABLE STATUS for additional table metadata, formatting the output as a markdown table.
    @mcp.tool()
    async def get_table_schema(table_name: str, database: Optional[str] = None) -> str:
        """Get the schema/structure of a specific table."""
        try:
            if database:
                full_table_name = f"`{database}`.`{table_name}`"
            else:
                full_table_name = f"`{table_name}`"
            
            query = f"DESCRIBE {full_table_name}"
            results = await db_connection.execute_query(query)
            
            if not results:
                return f"Table '{table_name}' not found"
            
            schema_info = f"Schema for table '{table_name}':\n\n"
            schema_info += "| Field | Type | Null | Key | Default | Extra |\n"
            schema_info += "|-------|------|------|-----|---------|-------|\n"
            
            for row in results:
                field = row['Field']
                type_info = row['Type']
                null_info = row['Null']
                key_info = row['Key'] or ''
                default_info = row['Default'] or ''
                extra_info = row['Extra'] or ''
                
                schema_info += f"| {field} | {type_info} | {null_info} | {key_info} | {default_info} | {extra_info} |\n"
            
            # Also get table status for additional info
            status_query = f"SHOW TABLE STATUS LIKE '{table_name}'"
            if database:
                status_query = f"SHOW TABLE STATUS FROM `{database}` LIKE '{table_name}'"
            
            status_results = await db_connection.execute_query(status_query)
            if status_results:
                status = status_results[0]
                schema_info += f"\nTable Info:\n"
                schema_info += f"- Engine: {status.get('Engine', 'N/A')}\n"
                schema_info += f"- Rows: {status.get('Rows', 'N/A')}\n"
                schema_info += f"- Data Length: {status.get('Data_length', 'N/A')} bytes\n"
                schema_info += f"- Auto Increment: {status.get('Auto_increment', 'N/A')}\n"
                schema_info += f"- Create Time: {status.get('Create_time', 'N/A')}\n"
                schema_info += f"- Comment: {status.get('Comment', 'N/A')}\n"
            
            return schema_info
        
        except Exception as e:
            logger.error(f"Error getting table schema: {e}")
            return f"Error getting table schema: {str(e)}"
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Get') but doesn't describe traits like whether it's read-only, requires permissions, returns error handling for non-existent tables, or details about the output format. The description is minimal and misses key behavioral context needed for safe and effective use.

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 a single, efficient sentence with zero waste. It's front-loaded with the core purpose and appropriately sized for a simple tool, avoiding unnecessary elaboration. Every word earns its place, making it easy to parse quickly.

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

Completeness3/5

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

Given the tool's low complexity (2 parameters, 1 required) and the presence of an output schema (which handles return values), the description is somewhat complete but lacks depth. It covers the basic purpose but misses behavioral details and parameter guidance. With no annotations, it should do more to compensate, making it minimally adequate but with clear gaps.

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 schema provides no parameter details. The description mentions 'a specific table' which hints at the table_name parameter but doesn't explain the optional database parameter or provide any syntax, format, or constraints. It adds minimal value beyond the schema, compensating slightly but inadequately for the coverage gap.

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 verb ('Get') and resource ('schema/structure of a specific table'), making the purpose immediately understandable. It distinguishes from siblings like list_tables (which lists tables) and execute_sql (which runs queries), though it doesn't explicitly name these alternatives. The purpose is specific but could be slightly more precise about what 'schema/structure' entails.

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., needing to know the table name first), exclusions, or compare it to siblings like list_tables (for discovering tables) or execute_sql (for querying data). Usage is implied by the purpose but lacks explicit context.

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/yawlhead91/mariadb-mcp'

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