Skip to main content
Glama
tushar3006

Snowflake MCP Server

by tushar3006

list_databases

Retrieve all available databases in Snowflake to explore and manage database structures for efficient data operations and analysis.

Instructions

List all available databases in Snowflake

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_databases' tool. It queries Snowflake's INFORMATION_SCHEMA.DATABASES to list databases, applies exclusion filters if provided, formats the output as YAML and JSON, and returns text content and an embedded JSON resource.
    async def handle_list_databases(arguments, db, *_, exclusion_config=None):
        query = "SELECT DATABASE_NAME FROM INFORMATION_SCHEMA.DATABASES"
        data, data_id = await db.execute_query(query)
    
        # Filter out excluded databases
        if exclusion_config and "databases" in exclusion_config and exclusion_config["databases"]:
            filtered_data = []
            for item in data:
                db_name = item.get("DATABASE_NAME", "")
                exclude = False
                for pattern in exclusion_config["databases"]:
                    if pattern.lower() in db_name.lower():
                        exclude = True
                        break
                if not exclude:
                    filtered_data.append(item)
            data = filtered_data
    
        output = {
            "type": "data",
            "data_id": data_id,
            "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"),
            ),
        ]
  • Registration of the 'list_databases' tool in the all_tools list, including name, description, empty input schema (no arguments required), and reference to the handler function. This tool object is later filtered and exposed via handle_list_tools().
    Tool(
        name="list_databases",
        description="List all available databases in Snowflake",
        input_schema={
            "type": "object",
            "properties": {},
        },
        handler=handle_list_databases,
    ),
  • Input schema definition for the 'list_databases' tool, specifying an empty object (no required parameters).
    input_schema={
        "type": "object",
        "properties": {},
    },
  • The general call_tool handler includes special logic for 'list_databases' (and similar tools) to pass the exclusion_config parameter to enable filtering.
    @server.call_tool()
    @handle_tool_errors
    async def handle_call_tool(
        name: str, arguments: dict[str, Any] | None
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        if name in exclude_tools:
            return [types.TextContent(type="text", text=f"Tool {name} is excluded from this data connection")]
    
        handler = next((tool.handler for tool in allowed_tools if tool.name == name), None)
        if not handler:
            raise ValueError(f"Unknown tool: {name}")
    
        # Pass exclusion_config to the handler if it's a listing function
        if name in ["list_databases", "list_schemas", "list_tables"]:
            return await handler(
                arguments,
                db,
                write_detector,
                allow_write,
                server,
                exclusion_config=exclusion_config,
            )
        else:
            return await handler(arguments, db, write_detector, allow_write, server)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.5/5.0
Behavior2/5

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

No annotations provided. The description only states it lists databases, but does not disclose behavioral details such as permissions required, whether it returns names only, or any limitations. For a read-only tool, minimal disclosure.

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?

One sentence of 6 words, no redundancy, front-loaded. Every word is necessary.

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?

For a simple list tool with no parameters and no output schema, the description is minimally adequate. It could mention return format or whether it requires any permissions, but overall meets basic needs.

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?

No parameters in schema, so description doesn't need to add parameter semantics. Baseline for 0 parameters is 4.

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 lists all available databases in Snowflake, with a specific verb ('List') and resource ('databases'). It distinguishes itself from sibling tools like 'list_schemas' and 'describe_table'.

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 like 'list_schemas' or 'list_tables'. No when-not-to-use or explicit context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.