Skip to main content
Glama
santosh07401

Redshift MCP Server

by santosh07401

redshift_list_tables

Retrieve all table names from a specified schema in Amazon Redshift to explore database structure and identify available data tables.

Instructions

List all tables in a specific schema.

Args:
    schema: The schema name (default: "public")

Returns:
    JSON list of table names

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaNopublic

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler implementation for the 'redshift_list_tables' MCP tool. Decorated with @mcp.tool() for registration, defines input schema via type hints and docstring, constructs SQL to list tables in the given schema, and executes via 'redshift_query' helper.
    @mcp.tool()
    def redshift_list_tables(schema: str = "public") -> str:
        """
        List all tables in a specific schema.
        
        Args:
            schema: The schema name (default: "public")
        
        Returns:
            JSON list of table names
        """
        sql = f"""
        SELECT table_name 
        FROM information_schema.tables 
        WHERE table_schema = '{schema}'
        AND table_type = 'BASE TABLE'
        """
        return redshift_query(sql)
  • Input/output schema definition for the tool via function signature (schema: str = 'public') and docstring.
    def redshift_list_tables(schema: str = "public") -> str:
        """
        List all tables in a specific schema.
        
        Args:
            schema: The schema name (default: "public")
        
        Returns:
            JSON list of table names
        """
  • Helper tool 'redshift_query' used by 'redshift_list_tables' to execute the generated SQL and return JSON results.
    @mcp.tool()
    def redshift_query(sql: str) -> str:
        """
        Execute a SQL query on Redshift and return results as JSON.
        
        Args:
            sql: The SQL query to execute
        
        Returns:
            JSON string of the query results or error message
        """
        try:
            with get_connection() as conn:
                df = pd.read_sql(sql, conn)
                return df.to_json(orient="records", indent=2)
        except Exception as e:
            return f"Error executing query: {str(e)}"
  • Supporting get_connection function used indirectly via redshift_query for database connectivity.
    def get_connection():
        """Create a connection to Redshift or local Postgres."""
        try:
            # If host is localhost and port is 5432, assume local Postgres for testing
            if REDSHIFT_HOST == "localhost" and REDSHIFT_PORT == 5432:
                import psycopg2
                return psycopg2.connect(
                    host=REDSHIFT_HOST,
                    port=REDSHIFT_PORT,
                    database=REDSHIFT_DATABASE,
                    user=REDSHIFT_USER,
                    password=REDSHIFT_PASSWORD
                )
            else:
                return redshift_connector.connect(
                    host=REDSHIFT_HOST,
                    port=REDSHIFT_PORT,
                    database=REDSHIFT_DATABASE,
                    user=REDSHIFT_USER,
                    password=REDSHIFT_PASSWORD
                )
        except Exception as e:
            logger.error(f"Connection error: {e}")
            raise

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool lists tables but doesn't cover important aspects like whether it requires specific permissions, has rate limits, handles errors, or provides pagination for large result sets. This leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with the core purpose stated first. The 'Args' and 'Returns' sections are structured but slightly redundant given the schema. It could be more concise by removing the explicit parameter listing since it adds little beyond the schema.

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 the tool's low complexity (one parameter) and the presence of an output schema (which handles return values), the description is somewhat complete. However, it lacks behavioral details and usage guidelines, which are important even for simple tools, making it only minimally adequate.

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?

The description adds minimal value beyond the input schema. It explains that 'schema' is the schema name with a default of 'public', which is already clear from the schema's 'default' and 'title' fields. With 0% schema description coverage, this doesn't fully compensate, but the single parameter is straightforward, keeping it at baseline.

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 tool's purpose with a specific verb ('List') and resource ('tables in a specific schema'), making it easy to understand what it does. However, it doesn't explicitly differentiate from sibling tools like 'redshift_describe_table' or 'redshift_query', which prevents a perfect score.

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. It doesn't mention sibling tools like 'redshift_describe_table' (for detailed table info) or 'redshift_query' (for custom queries), leaving the agent without context for tool selection.

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