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

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