Skip to main content
Glama
apache

Doris MCP Server

Official
by apache

get_table_schema

Retrieve comprehensive schema details of a specified table, including column names, data types, and comments, using the Doris MCP Server. Specify the table name and optionally the database name for targeted metadata extraction.

Instructions

[Function Description]: Get detailed structure information of the specified table (columns, types, comments, etc.).

[Parameter Content]:

  • table_name (string) [Required] - Name of the table to query

  • db_name (string) [Optional] - Target database name, defaults to the current database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
db_nameNo
table_nameYes

Implementation Reference

  • Registers the 'get_table_schema' tool with the MCP server using the @mcp.tool decorator. Defines input parameters: table_name (required), db_name and catalog_name (optional). The function proxies to self.call_tool for execution.
            @mcp.tool(
                "get_table_schema",
                description="""[Function Description]: Get detailed structure information of the specified table (columns, types, comments, etc.).
    
    [Parameter Content]:
    
    - table_name (string) [Required] - Name of the table to query
    
    - db_name (string) [Optional] - Target database name, defaults to the current database
    
    - catalog_name (string) [Optional] - Target catalog name for federation queries, defaults to current catalog
    """,
            )
            async def get_table_schema_tool(
                table_name: str, db_name: str = None, catalog_name: str = None
            ) -> str:
                """Get table schema information"""
                return await self.call_tool("get_table_schema", {
                    "table_name": table_name,
                    "db_name": db_name,
                    "catalog_name": catalog_name
                })
  • Defines the input schema validation for the 'get_table_schema' tool in the list_tools method, specifying JSON schema with table_name as required string property.
                    name="get_table_schema",
                    description="""[Function Description]: Get detailed structure information of the specified table (columns, types, comments, etc.).
    
    [Parameter Content]:
    
    - table_name (string) [Required] - Name of the table to query
    
    - db_name (string) [Optional] - Target database name, defaults to the current database
    
    - catalog_name (string) [Optional] - Target catalog name for federation queries, defaults to current catalog
    """,
                    inputSchema={
                        "type": "object",
                        "properties": {
                            "table_name": {"type": "string", "description": "Table name"},
                            "db_name": {"type": "string", "description": "Database name"},
                            "catalog_name": {"type": "string", "description": "Catalog name"},
                        },
                        "required": ["table_name"],
                    },
  • Dispatcher handler in ToolsManager.call_tool that routes 'get_table_schema' tool invocations by extracting arguments and delegating to MetadataExtractor.get_table_schema_for_mcp.
    async def _get_table_schema_tool(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
        """Get table schema tool routing"""
        table_name = arguments.get("table_name")
        db_name = arguments.get("db_name")
        catalog_name = arguments.get("catalog_name")
        
        # Delegate to metadata extractor for processing
        return await self.metadata_extractor.get_table_schema_for_mcp(
            table_name, db_name, catalog_name
        )
  • Core handler implementation for 'get_table_schema' tool in MetadataExtractor. Validates input, calls get_table_schema_async to fetch schema via DESCRIBE query, formats MCP response with success/error handling.
    async def get_table_schema_for_mcp(
        self, 
        table_name: str, 
        db_name: str = None, 
        catalog_name: str = None
    ) -> Dict[str, Any]:
        """Get detailed schema information for specified table (columns, types, comments, etc.) - MCP interface"""
        logger.info(f"Getting table schema: Table: {table_name}, DB: {db_name}, Catalog: {catalog_name}")
        
        if not table_name:
            return self._format_response(success=False, error="Missing table_name parameter")
        
        try:
            schema = await self.get_table_schema_async(table_name=table_name, db_name=db_name, catalog_name=catalog_name)
            
            if not schema:
                return self._format_response(
                    success=False, 
                    error="Table does not exist or has no columns", 
                    message=f"Unable to get schema for table {catalog_name or 'default'}.{db_name or self.db_name}.{table_name}"
                )
            
            return self._format_response(success=True, result=schema)
        except Exception as e:
            logger.error(f"Failed to get table schema: {str(e)}", exc_info=True)
            return self._format_response(success=False, error=str(e), message="Error occurred while getting table schema")
  • Helper function that executes DESCRIBE query (with catalog.db.table support) to retrieve raw table schema and formats it into structured column information list.
    async def get_table_schema_async(self, table_name: str, db_name: str = None, catalog_name: str = None) -> List[Dict[str, Any]]:
        """Asynchronously get table schema information"""
        try:
            # Use async query method
            effective_catalog = catalog_name or self.catalog_name
            
            # Build query statement
            if effective_catalog and effective_catalog != "internal":
                query = f"DESCRIBE `{effective_catalog}`.`{db_name or self.db_name}`.`{table_name}`"
            else:
                query = f"DESCRIBE `{db_name or self.db_name}`.`{table_name}`"
            
            # Execute async query
            result = await self._execute_query_async(query, db_name)
            
            if not result:
                return []
            
            # Process results
            schema = []
            for row in result:
                if isinstance(row, dict):
                    schema.append({
                        'column_name': row.get('Field', ''),
                        'data_type': row.get('Type', ''),
                        'is_nullable': row.get('Null', 'NO') == 'YES',
                        'default_value': row.get('Default', None),
                        'comment': row.get('Comment', ''),
                        'key': row.get('Key', ''),
                        'extra': row.get('Extra', '')
                    })
            
            return schema
            
        except Exception as e:
            logger.error(f"Failed to get table schema: {e}")
            return []
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 it 'gets' information, implying a read-only operation, but doesn't specify whether this requires permissions, has rate limits, returns paginated results, or what format the output takes (e.g., JSON, structured data). For a tool with no annotation coverage, this leaves significant gaps in understanding how it behaves beyond basic functionality.

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 appropriately sized and structured with clear sections for function and parameters. Each sentence adds value: the first defines the purpose with examples, and the parameter section explains semantics. There's minimal waste, though the formatting with brackets and bullet points is slightly verbose but still efficient.

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 moderate complexity (2 parameters, no output schema, no annotations), the description is somewhat complete but has gaps. It covers purpose and parameter semantics adequately, but lacks behavioral details like output format, error handling, or usage guidelines relative to siblings. Without annotations or output schema, more context on what 'detailed structure information' entails would improve completeness.

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?

The description adds meaningful context beyond the input schema, which has 0% description coverage. It explains that table_name is required and specifies what it queries, and clarifies that db_name is optional with a default to the current database. This compensates well for the lack of schema descriptions, though it doesn't detail constraints like valid table name formats or database name syntax.

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 the resource 'detailed structure information of the specified table', with specific examples like 'columns, types, comments, etc.' This distinguishes it from siblings like get_db_list or get_table_indexes by focusing on comprehensive schema details rather than lists or specific components. However, it doesn't explicitly differentiate from get_table_column_comments or get_table_comment, which are more specialized siblings.

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 siblings like get_table_column_comments (for only comments) or get_table_indexes (for indexes), nor does it specify prerequisites such as needing database access or when this is preferred over exec_query for schema inspection. Usage is implied by the purpose but lacks explicit context or exclusions.

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

Related 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/apache/doris-mcp-server'

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