Skip to main content
Glama
tushar3006

Snowflake MCP Server

by tushar3006

list_tables

Retrieve all tables within a specified database and schema to explore database structure and identify available data sources.

Instructions

List all tables in a specific database and schema

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYesDatabase name
schemaYesSchema name

Implementation Reference

  • The handler function that implements the list_tables tool logic: validates input, constructs SQL query to list tables from information_schema.tables in the given database.schema, applies table exclusion filters, formats output as YAML text and JSON embedded resource.
    async def handle_list_tables(arguments, db, *_, exclusion_config=None): if not arguments or "database" not in arguments or "schema" not in arguments: raise ValueError("Missing required 'database' and 'schema' parameters") database = arguments["database"] schema = arguments["schema"] query = f""" SELECT table_catalog, table_schema, table_name, comment FROM {database}.information_schema.tables WHERE table_schema = '{schema.upper()}' """ data, data_id = await db.execute_query(query) # Filter out excluded tables if exclusion_config and "tables" in exclusion_config and exclusion_config["tables"]: filtered_data = [] for item in data: table_name = item.get("TABLE_NAME", "") exclude = False for pattern in exclusion_config["tables"]: if pattern.lower() in table_name.lower(): exclude = True break if not exclude: filtered_data.append(item) data = filtered_data output = { "type": "data", "data_id": data_id, "database": database, "schema": schema, "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"), ), ]
  • Input schema definition for list_tables tool specifying required 'database' and 'schema' string parameters.
    "type": "object", "properties": { "database": {"type": "string", "description": "Database name"}, "schema": {"type": "string", "description": "Schema name"}, }, "required": ["database", "schema"], },
  • Tool registration object creation for list_tables, including name, description, input schema, and reference to the handler function. Added to the all_tools list used by list_tools and call_tool handlers.
    Tool( name="list_tables", description="List all tables in a specific database and schema", input_schema={ "type": "object", "properties": { "database": {"type": "string", "description": "Database name"}, "schema": {"type": "string", "description": "Schema name"}, }, "required": ["database", "schema"], }, handler=handle_list_tables, ),

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