Skip to main content
Glama
oceanbase

mcp-oceanbase

Official
by oceanbase

execute_sql

Run SQL queries directly on the OceanBase server to retrieve or manage data efficiently using the specified SQL command.

Instructions

Execute an SQL on the OceanBase server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes

Implementation Reference

  • The execute_sql tool handler. Executes arbitrary SQL queries on the OceanBase database, returns JSON with results or error.
    @app.tool()
    def execute_sql(sql: str) -> str:
        """Execute an SQL on the OceanBase server."""
        logger.info(f"Calling tool: execute_sql  with arguments: {sql}")
        result = {"sql": sql, "success": False, "rows": 0, "columns": None, "data": None, "error": None}
        try:
            with connect(**db_conn_info.model_dump()) as conn:
                with conn.cursor() as cursor:
                    cursor.execute(sql)
                    if cursor.description:
                        result["columns"] = [column[0] for column in cursor.description]
                        result["data"] = [[str(cell) for cell in row] for row in cursor.fetchall()]
                    else:
                        conn.commit()
                    result["rows"] = cursor.rowcount
                    result["success"] = True
        except Error as e:
            result["error"] = f"[Error]: {e}"
        except Exception as e:
            result["error"] = f"[Exception]: {e}"
        json_result = json.dumps(result)
        if result["error"]:
            logger.error(f"SQL executed failed, result: {json_result}")
        return json_result
  • Registration of the execute_sql tool using FastMCP @app.tool() decorator.
    @app.tool()
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It implies execution of arbitrary SQL, but doesn't disclose critical traits like whether it's read-only or mutating, authentication requirements, transaction handling, error behavior, or rate limits. This leaves significant gaps for an agent to understand risks and outcomes.

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 extremely concise—a single sentence with no wasted words. It's front-loaded with the core action, though this brevity contributes to gaps in other dimensions. For length alone, it earns full marks for efficiency.

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?

Given the complexity of SQL execution (potentially mutating, security-sensitive) with no annotations, 0% schema coverage, and no output schema, the description is highly incomplete. It lacks essential context on behavior, parameters, return values, and safety, making it inadequate for informed tool use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate but adds no parameter details. It mentions 'SQL' generically but doesn't explain the 'sql' parameter's format, supported SQL dialects, constraints (e.g., no multi-statement), or examples. This fails to address the undocumented parameter adequately.

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?

The description clearly states the action ('Execute') and target resource ('SQL on the OceanBase server'), making the purpose understandable. However, it doesn't differentiate this tool from potential sibling SQL execution tools (none are listed, but the generic nature doesn't address scope or limitations).

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?

No guidance is provided on when to use this tool versus alternatives. While sibling tools like 'configure_db_connection' or 'get_current_tenant' serve different purposes, the description doesn't clarify if this is for read-only queries, DML, DDL, or all SQL types, nor does it mention prerequisites like needing an established connection.

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/oceanbase/mcp-oceanbase'

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