Skip to main content
Glama
tushar3006

Snowflake MCP Server

by tushar3006

describe_table

Retrieve schema information for a specific Snowflake table, including column details and data types, to understand table structure and support database operations.

Instructions

Get the schema information for a specific table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYesFully qualified table name in the format 'database.schema.table'

Implementation Reference

  • The main handler function that parses the fully qualified table name, executes a query against INFORMATION_SCHEMA.COLUMNS to retrieve column metadata (name, default, nullable, data_type, comment), formats the output as YAML text and JSON embedded resource.
    async def handle_describe_table(arguments, db, *_):
        if not arguments or "table_name" not in arguments:
            raise ValueError("Missing table_name argument")
    
        table_spec = arguments["table_name"]
        split_identifier = table_spec.split(".")
    
        # Parse the fully qualified table name
        if len(split_identifier) < 3:
            raise ValueError("Table name must be fully qualified as 'database.schema.table'")
    
        database_name = split_identifier[0].upper()
        schema_name = split_identifier[1].upper()
        table_name = split_identifier[2].upper()
    
        query = f"""
            SELECT column_name, column_default, is_nullable, data_type, comment 
            FROM {database_name}.information_schema.columns 
            WHERE table_schema = '{schema_name}' AND table_name = '{table_name}'
        """
        data, data_id = await db.execute_query(query)
    
        output = {
            "type": "data",
            "data_id": data_id,
            "database": database_name,
            "schema": schema_name,
            "table": table_name,
            "data": data,
        }
        yaml_output = data_to_yaml(output)
        json_output = json.dumps(output)
        return [
            types.TextContent(type="text", text=yaml_output),
            types.EmbeddedResource(
                type="resource",
                resource=types.TextResourceContents(uri=f"data://{data_id}", text=json_output, mimeType="application/json"),
            ),
        ]
  • Registers the describe_table tool in the all_tools list, specifying name, description, input schema (requiring fully qualified table_name), and linking to the handle_describe_table handler. This tool object is then filtered and exposed via list_tools and call_tool.
    Tool(
        name="describe_table",
        description="Get the schema information for a specific table",
        input_schema={
            "type": "object",
            "properties": {
                "table_name": {
                    "type": "string",
                    "description": "Fully qualified table name in the format 'database.schema.table'",
                },
            },
            "required": ["table_name"],
        },
        handler=handle_describe_table,
    ),
  • Defines the input schema for the describe_table tool: an object with a required 'table_name' string property expecting 'database.schema.table' format.
    input_schema={
        "type": "object",
        "properties": {
            "table_name": {
                "type": "string",
                "description": "Fully qualified table name in the format 'database.schema.table'",
            },
        },
        "required": ["table_name"],
    },

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/tushar3006/MCP'

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