Skip to main content
Glama
jason-ung

starrocks-mcp

by jason-ung

execute_query

Run SQL queries on StarRocks databases to retrieve data and analyze information through Claude AI assistants.

Instructions

Execute a SQL query against StarRocks and return results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL query to execute

Implementation Reference

  • The actual implementation of execute_query which interacts with the StarRocks database using pymysql.
    def execute_query(self, query: str) -> List[Dict[str, Any]]:
        """
        Execute SQL query and return results.
    
        Args:
            query: SQL query string
    
        Returns:
            List of dictionaries representing rows
        """
        if not self._connection:
            self.connect()
    
        try:
            with self._connection.cursor(pymysql.cursors.DictCursor) as cursor:
                cursor.execute(query)
                results = cursor.fetchall()
                logger.info(f"Query executed successfully, returned {len(results)} rows")
                return results
        except Exception as e:
            logger.error(f"Query execution failed: {e}")
            raise
  • The MCP tool handler logic that calls StarRocksClient.execute_query.
    if name == "execute_query":
        sql = arguments.get("sql")
        if not sql:
            raise ValueError("SQL query is required")
    
        validate_sql(sql)
    
        results = client.execute_query(sql)
        truncated_results, was_truncated = truncate_results(results)
    
        result_text = f"Query executed successfully. Returned {len(results)} rows"
        if was_truncated:
            result_text += f" (showing first {len(truncated_results)} rows)"
    
        result_text += f":\n\n{format_json(truncated_results)}"
    
        return [TextContent(type="text", text=result_text)]
  • The tool registration and schema definition for execute_query.
    Tool(
        name="execute_query",
        description="Execute a SQL query against StarRocks and return results.",
        inputSchema={
            "type": "object",
            "properties": {
                "sql": {
                    "type": "string",
                    "description": "SQL query to execute",
                },
            },
            "required": ["sql"],
        },
    ),
Behavior2/5

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

No annotations provided, so description carries full burden, yet it fails to disclose critical behavioral traits: whether the tool supports write operations (INSERT/UPDATE/DELETE), read-only safety, result format/size limits, or execution timeouts. 'Return results' is vague given the high-stakes nature of arbitrary SQL execution.

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?

Single sentence, front-loaded with action verb, no redundancy. However, given the tool's high complexity and lack of annotations/output schema, the brevity crosses from concise to under-specified.

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

Completeness2/5

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

Arbitrary SQL execution is high-complexity with significant safety implications. With no annotations, no output schema, and minimal description, the definition lacks essential context about data modification risks, result structure, and operational scope required for safe agent invocation.

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 has 100% coverage with clear parameter description. The description adds context by specifying 'StarRocks' as the target system (not in schema), but adds no detail on SQL syntax requirements, supported dialect features, or parameter binding beyond the schema's basic declaration.

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?

Clear specific verb ('Execute') and resource ('SQL query') against StarRocks. However, it does not distinguish from sibling metadata tools (describe_table, list_tables), which also retrieve data but via specific patterns rather than arbitrary SQL.

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?

Provides no guidance on when to use this versus the specific metadata tools (list_tables, describe_table) or when to prefer built-in tools over raw SQL. No mention of prerequisites or query complexity considerations.

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/jason-ung/starrocks-mcp'

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