Skip to main content
Glama
StarRocks

StarRocks MCP Server

Official

analyze_query

Analyzes SQL query performance using profiles by processing query ID and SQL. Part of the StarRocks MCP Server, enabling efficient query optimization and database exploration.

Instructions

Analyze query via profile

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesQuery SQL
uuidYesQuery ID, a string composed of 32 hexadecimal digits formatted as 8-4-4-4-12

Implementation Reference

  • The handler function for the analyze_query tool, including registration via @mcp.tool decorator and input schema via Annotated parameters. It executes ANALYZE PROFILE for a given query UUID or EXPLAIN ANALYZE for SQL, returning the result as a string.
    @mcp.tool(description="Analyze a query and get analyze result using query profile" + description_suffix)
    def analyze_query(
            uuid: Annotated[
                str|None, Field(description="Query ID, a string composed of 32 hexadecimal digits formatted as 8-4-4-4-12")]=None,
            sql: Annotated[str|None, Field(description="Query SQL")]=None,
            db: Annotated[str|None, Field(description="database")] = None
    ) -> str:
        if uuid:
            logger.info(f"Analyzing query profile for UUID: {uuid}")
            return db_client.execute(f"ANALYZE PROFILE FROM '{uuid}'", db=db).to_string()
        elif sql:
            logger.info(f"Analyzing query: {sql[:100]}{'...' if len(sql) > 100 else ''}")
            return db_client.execute(f"EXPLAIN ANALYZE {sql}", db=db).to_string()
        else:
            logger.warning("Analyze query called without valid UUID or SQL")
            return f"Failed to analyze query, the reasons maybe: 1.query id is not standard uuid format; 2.the SQL statement have spelling error."
  • Registration of the analyze_query tool using the @mcp.tool decorator.
    @mcp.tool(description="Analyze a query and get analyze result using query profile" + description_suffix)
  • Input schema definition for the analyze_query tool using Pydantic Annotated fields for uuid, sql, and db parameters.
    uuid: Annotated[
        str|None, Field(description="Query ID, a string composed of 32 hexadecimal digits formatted as 8-4-4-4-12")]=None,
    sql: Annotated[str|None, Field(description="Query SQL")]=None,
    db: Annotated[str|None, Field(description="database")] = None
Behavior1/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. The description reveals nothing about what the tool actually does - whether it's a read or write operation, what 'analysis' entails, what 'profile' refers to, what permissions might be required, or what the expected output format is. For a tool with no annotation coverage, this is completely inadequate.

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

Conciseness2/5

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

While technically concise with just three words, this is under-specification rather than effective conciseness. The description fails to communicate essential information about the tool's purpose and behavior. Every word should earn its place, but here the words don't provide meaningful guidance to the agent about tool selection or usage.

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

Completeness1/5

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

Given the complexity implied by the name 'analyze_query' and the complete lack of annotations and output schema, the description is woefully incomplete. The agent cannot determine what type of analysis is performed, what 'profile' means, what the tool returns, or how it differs from sibling query tools. For a tool with no structured behavioral information, the description fails to provide the necessary context.

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?

With 100% schema description coverage, both parameters (sql and uuid) are well-documented in the schema itself. The description adds no additional semantic context about these parameters - it doesn't explain how they relate to the 'analysis' or 'profile' mentioned, nor does it provide usage examples or constraints beyond what's in the schema. The baseline score of 3 reflects adequate parameter documentation solely through the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Analyze query via profile' is vague and tautological - it essentially restates the tool name 'analyze_query' without specifying what analysis is performed or what 'via profile' means. It doesn't clearly distinguish this from sibling tools like 'read_query' or 'query_and_plotly_chart', leaving the agent uncertain about when to choose this specific tool.

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

Usage Guidelines1/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. With multiple query-related sibling tools (read_query, query_and_plotly_chart, write_query), the agent receives no indication of what makes 'analyze_query' distinct or when it should be preferred over other options. There are no explicit or implied usage scenarios provided.

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

Related 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