Skip to main content
Glama
StarRocks

StarRocks MCP Server

Official

table_overview

Retrieve a table's column details, up to three sample rows, and total row count. Use refresh=true to bypass cached results.

Instructions

Get an overview of a specific table: columns, sample rows (up to 3), and total row count. Uses cache unless refresh=true

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYesTable name, optionally prefixed with database name (e.g., 'db_name.table_name'). If database is omitted, uses the default database.
refreshNoSet to true to force refresh, ignoring cache. Defaults to false.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Helper function _get_table_details that fetches table overview: row count, columns (DESCRIBE), and sample rows. Used by table_overview tool.
    def _get_table_details(db_name, table_name, limit=None):
        """
        Helper function to get description, sample rows, and count for a table.
        Returns a formatted string. Handles DB errors internally and returns error messages.
        """
        global global_table_overview_cache
        logger.debug(f"Fetching table details for {db_name}.{table_name}")
        output_lines = []
    
        full_table_name = f"`{table_name}`"
        if db_name:
            full_table_name = f"`{db_name}`.`{table_name}`"
        else:
            output_lines.append(
                f"Warning: Database name missing for table '{table_name}'. Using potentially incorrect context.")
            logger.warning(f"Database name missing for table '{table_name}'")
    
        count = 0
        output_lines.append(f"--- Overview for {full_table_name} ---")
    
        # 1. Get Row Count
        query = f"SELECT COUNT(*) FROM {full_table_name}"
        count_result = db_client.execute(query, db=db_name)
        if count_result.success and count_result.rows:
            count = count_result.rows[0][0]
            output_lines.append(f"\nTotal rows: {count}")
            logger.debug(f"Table {full_table_name} has {count} rows")
        else:
            output_lines.append(f"\nCould not determine total row count.")
            if not count_result.success:
                output_lines.append(f"Error: {count_result.error_message}")
                logger.error(f"Failed to get row count for {full_table_name}: {count_result.error_message}")
    
        # 2. Get Columns (DESCRIBE)
        if count > 0:
            query = f"DESCRIBE {full_table_name}"
            desc_result = db_client.execute(query, db=db_name)
            if desc_result.success and desc_result.column_names and desc_result.rows:
                output_lines.append(f"\nColumns:")
                output_lines.append(desc_result.to_string(limit=limit))
            else:
                output_lines.append("(Could not retrieve column information or table has no columns).")
                if not desc_result.success:
                    output_lines.append(f"Error getting columns for {full_table_name}: {desc_result.error_message}")
                    return "\n".join(output_lines)
    
            # 3. Get Sample Rows (LIMIT 3)
            query = f"SELECT * FROM {full_table_name} LIMIT 3"
            sample_result = db_client.execute(query, db=db_name)
            if sample_result.success and sample_result.column_names and sample_result.rows:
                output_lines.append(f"\nSample rows (limit 3):")
                output_lines.append(sample_result.to_string(limit=limit))
            else:
                output_lines.append(f"(No rows found in {full_table_name}).")
                if not sample_result.success:
                    output_lines.append(f"Error getting sample rows for {full_table_name}: {sample_result.error_message}")
    
        overview_string = "\n".join(output_lines)
        # Update cache even if there were partial errors, so we cache the error message too
        cache_key = (db_name, table_name)
        global_table_overview_cache[cache_key] = overview_string
        return overview_string
  • Main tool handler for 'table_overview' - accepts table name (optionally db-qualified) and refresh flag. Parses input, checks cache, calls _get_table_details.
    @mcp.tool(description="Get an overview of a specific table: columns, sample rows (up to 3), and total row count. Uses cache unless refresh=true" + description_suffix)
    def table_overview(
            table: Annotated[str, Field(
                description="Table name, optionally prefixed with database name (e.g., 'db_name.table_name'). If database is omitted, uses the default database.")],
            refresh: Annotated[
                bool, Field(description="Set to true to force refresh, ignoring cache. Defaults to false.")] = False
    ) -> str:
        try:
            logger.info(f"Getting table overview for: {table}, refresh={refresh}")
            if not table:
                logger.error("Table overview called without table name")
                return "Error: Missing 'table' argument."
    
            # Parse table argument: [db.]<table>
            parts = table.split('.', 1)
            db_name = None
            table_name = None
            if len(parts) == 2:
                db_name, table_name = parts[0], parts[1]
            elif len(parts) == 1:
                table_name = parts[0]
                db_name = db_client.default_database  # Use default if only table name is given
    
            if not table_name:  # Should not happen if table_arg exists, but check
                logger.error(f"Invalid table name format: {table}")
                return f"Error: Invalid table name format '{table}'."
            if not db_name:
                logger.error(f"No database specified for table {table_name}")
                return f"Error: Database name not specified for table '{table_name}' and no default database is set."
    
            cache_key = (db_name, table_name)
    
            # Check cache
            if not refresh and cache_key in global_table_overview_cache:
                logger.debug(f"Using cached overview for {db_name}.{table_name}")
                return global_table_overview_cache[cache_key]
    
            logger.debug(f"Fetching fresh overview for {db_name}.{table_name}")
            # Fetch details (will also update cache)
            overview_text = _get_table_details(db_name, table_name, limit=overview_length_limit)
            return overview_text
        except Exception as e:
            # Reset connections on unexpected errors
            logger.exception(f"Unexpected error in table_overview for {table}")
            reset_db_connections()
            stack_trace = traceback.format_exc()
            return f"Unexpected Error executing tool 'table_overview': {type(e).__name__}: {e}\nStack Trace:\n{stack_trace}"
  • Registration via @mcp.tool decorator on the table_overview function, with description about cache and refresh behavior.
    @mcp.tool(description="Get an overview of a specific table: columns, sample rows (up to 3), and total row count. Uses cache unless refresh=true" + description_suffix)
    def table_overview(
            table: Annotated[str, Field(
                description="Table name, optionally prefixed with database name (e.g., 'db_name.table_name'). If database is omitted, uses the default database.")],
            refresh: Annotated[
                bool, Field(description="Set to true to force refresh, ignoring cache. Defaults to false.")] = False
    ) -> str:
  • Input schema for table_overview: 'table' (string, optionally db.table format) and 'refresh' (bool, defaults to False).
    def table_overview(
            table: Annotated[str, Field(
                description="Table name, optionally prefixed with database name (e.g., 'db_name.table_name'). If database is omitted, uses the default database.")],
            refresh: Annotated[
                bool, Field(description="Set to true to force refresh, ignoring cache. Defaults to false.")] = False
    ) -> str:
  • Global cache dict for table overviews keyed by (db_name, table_name) tuple, and overview_length_limit configuration.
    overview_length_limit = int(os.getenv('STARROCKS_OVERVIEW_LIMIT', str(20000)))
    # Global cache for table overviews: {(db_name, table_name): overview_string}
    global_table_overview_cache = {}
Behavior4/5

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

With no annotations, the description carries full burden. It discloses caching behavior, refresh capability, and output scope. It does not mention permissions or impact, but the read-only nature is implied. Missing a statement about non-destructiveness, but overall adequate.

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?

Two sentences, front-loaded with purpose, then caching behavior. No wasted words. Every sentence contributes value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema, the description does not need to detail return values. It covers the key aspects: columns, sample rows, row count, caching. Could mention column types or order, but not essential.

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?

Schema coverage is 100% for both parameters. The description adds useful context: default database behavior for 'table' and the caching implication of 'refresh'. This adds meaning beyond the schema alone.

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 verb ('Get an overview'), the resource ('a specific table'), and the deliverables (columns, sample rows up to 3, total row count). It distinguishes from sibling tools like read_query or analyze_query by focusing on structural overview.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description does not explicitly state when to use this tool over siblings like db_summary or read_query. The caching behavior is mentioned but no guidance on when caching is acceptable or when refresh is needed.

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/StarRocks/mcp-server-starrocks'

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