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)

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