Skip to main content
Glama
rickyb30

DataPilot MCP Server

by rickyb30

list_tables

Retrieve all tables in a specified database or schema to explore available data structures and plan queries.

Instructions

List all tables in a database/schema

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNo
schemaNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler implementation for 'list_tables'. Decorated with @mcp.tool(), calls Snowflake client, formats TableInfo objects to dicts, provides user feedback via ctx.
    @mcp.tool()
    async def list_tables(database: Optional[str] = None, schema: Optional[str] = None, ctx: Context = None) -> List[Dict[str, Any]]:
        """List all tables in a database/schema"""
        context_msg = f"Retrieving tables"
        if database:
            context_msg += f" from database: {database}"
        if schema:
            context_msg += f", schema: {schema}"
        
        await ctx.info(context_msg)
        
        try:
            client = await get_snowflake_client()
            tables = await client.list_tables(database, schema)
            
            # Convert to dict for JSON serialization
            result = []
            for table in tables:
                result.append({
                    "table_name": table.table_name,
                    "schema_name": table.schema_name,
                    "database_name": table.database_name,
                    "table_type": table.table_type,
                    "row_count": table.row_count,
                    "bytes": table.bytes,
                    "comment": table.comment
                })
            
            await ctx.info(f"Found {len(result)} tables")
            return result
            
        except Exception as e:
            logger.error(f"Error listing tables: {str(e)}")
            await ctx.error(f"Failed to list tables: {str(e)}")
            return []
  • Core SnowflakeClient method that executes SHOW TABLES query, parses results into TableInfo objects. Used by the MCP tool handler.
    async def list_tables(self, database: Optional[str] = None, schema: Optional[str] = None) -> List[TableInfo]:
        """List all tables in a database/schema"""
        query = "SHOW TABLES"
        if database and schema:
            query += f" IN SCHEMA {database}.{schema}"
        elif database:
            query += f" IN DATABASE {database}"
        
        result = await self.execute_query(query)
        
        tables = []
        for row in result.data:
            if result.success:
                tables.append(TableInfo(
                    table_name=row.get('name', ''),
                    schema_name=row.get('schema_name', ''),
                    database_name=row.get('database_name', ''),
                    table_type=row.get('kind', ''),
                    row_count=row.get('rows'),
                    bytes=row.get('bytes'),
                    comment=row.get('comment')
                ))
        
        return tables
  • Pydantic model defining the structure of table information returned by list_tables operations.
    class TableInfo(BaseModel):
        """Information about a Snowflake table"""
        table_name: str
        schema_name: str
        database_name: str
        table_type: str
        row_count: Optional[int] = None
        bytes: Optional[int] = None
        comment: Optional[str] = None
  • src/main.py:139-139 (registration)
    @mcp.tool() decorator registers the list_tables function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without disclosing behavioral traits such as permissions needed, rate limits, pagination, or what 'all tables' entails (e.g., includes system tables?). It lacks details on safety, performance, or response format.

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?

The description is a single, efficient sentence with zero waste, front-loaded with the core purpose. Every word earns its place, making it appropriately sized and structured for clarity.

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 low complexity (list operation), no annotations, and an output schema exists (reducing need to explain return values), the description is minimally adequate. However, it lacks context on parameter usage and behavioral aspects, leaving gaps for a tool with 2 parameters and sibling alternatives.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate but adds no parameter details beyond implying 'database/schema' scope. It doesn't explain what 'database' and 'schema' parameters do, their relationships, or default behaviors. Baseline is 3 due to 0 parameters being required, but value beyond schema is minimal.

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 action ('List all tables') and target resource ('in a database/schema'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'list_databases' or 'list_schemas' beyond the obvious resource difference, missing explicit sibling distinction.

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_databases' or 'list_schemas', nor does it mention prerequisites or exclusions. Usage is implied by the name alone, with no explicit context for selection.

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

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/rickyb30/datapilot-mcp-server'

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