Skip to main content
Glama
StarRocks

StarRocks MCP Server

Official

write_query

Execute SQL commands on StarRocks for data definition or modification, including DDL and DML statements that do not return a result set.

Instructions

Execute a DDL/DML or other StarRocks command that do not have a ResultSet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSQL to execute
dbNodatabase

Implementation Reference

  • The write_query tool is registered via the @mcp.tool decorator on line 205, making it an MCP tool named 'write_query'. The registration is implicit through FastMCP's decorator pattern.
    @mcp.tool(description="Execute a DDL/DML or other StarRocks command that do not have a ResultSet" + description_suffix)
    def write_query(query: Annotated[str, Field(description="SQL to execute")],
                    db: Annotated[str|None, Field(description="database")] = None) -> ToolResult:
  • The handler function for the 'write_query' tool. It executes a DDL/DML/command SQL via db_client.execute(), logs the result (success/error, rows affected, execution time), and returns a ToolResult with text content (limited to 2000 chars) and structured data.
    def write_query(query: Annotated[str, Field(description="SQL to execute")],
                    db: Annotated[str|None, Field(description="database")] = None) -> ToolResult:
        logger.info(f"Executing write query: {query[:100]}{'...' if len(query) > 100 else ''}")
        result = db_client.execute(query, db=db)
        if not result.success:
            logger.error(f"Write query failed: {result.error_message}")
        elif result.rows_affected is not None and result.rows_affected >= 0:
            logger.info(f"Write query executed successfully, {result.rows_affected} rows affected in {result.execution_time:.2f}s")
        else:
            logger.info(f"Write query executed successfully in {result.execution_time:.2f}s")
        return ToolResult(content=[TextContent(type='text', text=result.to_string(limit=2000))],
                          structured_content=result.to_dict())
  • Input schema for write_query: 'query' is a required string param (the SQL to execute), and 'db' is an optional string param (database name, defaults to None). Returns a ToolResult.
    def write_query(query: Annotated[str, Field(description="SQL to execute")],
                    db: Annotated[str|None, Field(description="database")] = None) -> ToolResult:
  • The DBClient.execute() method is the underlying database execution helper called by the write_query handler. It handles connection management, database switching, and returns a ResultSet with success status, affected rows, and timing info.
    def execute(
        self, 
        statement: str, 
        db: Optional[str] = None,
        return_format: Literal["raw", "pandas"] = "raw"
    ) -> ResultSet:
        """
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It states the tool executes commands without a ResultSet, but omits crucial details like side effects, error handling, permission requirements, and what the function returns on success/failure.

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?

The description is a single, front-loaded sentence with no unnecessary words. Every part contributes to understanding the tool's purpose.

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?

For a simple tool with two parameters and no output schema, the description covers the basic purpose. However, it lacks details about return values (likely nothing), error behavior, and whether the command is committed automatically. These gaps reduce completeness.

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?

The schema covers both parameters (query, db) with descriptions. The description adds value by specifying that commands are DDL/DML or those without a ResultSet, clarifying the intended use of the query parameter beyond the schema's generic 'SQL to execute'.

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 tool executes DDL/DML or other StarRocks commands without a ResultSet. It uses a specific verb (Execute) and resource (command), and distinguishes from siblings like read_query which return results.

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

Usage Guidelines4/5

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

The description explicitly limits use to commands that do not have a ResultSet, guiding when to use this tool versus read_query. While it does not name alternatives directly, the context from sibling tools makes the distinction clear.

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