Skip to main content
Glama
YeomYuJun

Tibero MCP Server

by YeomYuJun

execute_sql

Execute SQL queries on Tibero databases to retrieve data, modify records, or inspect schemas through secure database connections.

Instructions

Execute an SQL query on the Tibero server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL query to execute

Implementation Reference

  • Handler function for executing SQL queries. Supports SELECT (returns CSV results), DML (INSERT/UPDATE/DELETE with commit and rowcount), and other DDL queries.
    if name == "execute_sql":
        query = arguments.get("query")
        if not query:
            raise ValueError("Query is required")
        
        # Execute the query
        cursor.execute(query)
        
        # Handle different query types
        query_upper = query.strip().upper()
        
        # Data retrieval queries
        if (query_upper.startswith("SELECT") or 
            query_upper.startswith("SHOW") or 
            query_upper.startswith("DESC")):
            
            # Get column names
            columns = [desc[0] for desc in cursor.description] if cursor.description else []
            rows = cursor.fetchall()
            
            if not columns:
                return [TextContent(type="text", text="Query executed successfully, but returned no columns.")]
            
            # Format as CSV
            result = [",".join(map(str, columns))]
            result.extend([",".join(map(lambda x: str(x) if x is not None else "NULL", row)) for row in rows])
            
            return [TextContent(
                type="text", 
                text=f"Results ({len(rows)} rows):\n" + "\n".join(result)
            )]
        
        # Non-SELECT queries (DML/DDL)
        else:
            # For DML, commit the transaction
            if (query_upper.startswith("INSERT") or 
                query_upper.startswith("UPDATE") or 
                query_upper.startswith("DELETE")):
                conn.commit()
                return [TextContent(
                    type="text", 
                    text=f"Query executed successfully. Rows affected: {cursor.rowcount}"
                )]
            # For DDL, no commit needed (auto-commit)
            else:
                return [TextContent(
                    type="text", 
                    text="Query executed successfully."
                )]
  • JSON schema defining the input for the execute_sql tool: an object with a required 'query' string.
    inputSchema={
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "The SQL query to execute"
            }
        },
        "required": ["query"]
    }
  • Registration of the execute_sql tool in the list_tools() function, including name, description, and input schema.
    Tool(
        name="execute_sql",
        description="Execute an SQL query on the Tibero server",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "The SQL query to execute"
                }
            },
            "required": ["query"]
        }
    ),
  • Helper function to establish JDBC connection to Tibero database, used by the execute_sql handler.
    def get_connection():
        """Create a JDBC connection to Tibero database."""
        config = get_db_config()
        connection_string = f"jdbc:tibero:thin:@{config['host']}:{config['port']}:{config['sid']}"
        
        try:
            # Make sure the JDBC driver is in the classpath or provide path
            driver_path = os.getenv("CLASSPATH", "drivers/tibero6-jdbc.jar")
            
            conn = jaydebeapi.connect(
                "com.tmax.tibero.jdbc.TbDriver",
                connection_string,
                [config["user"], config["password"]],
                driver_path
            )
            conn.jconn.setAutoCommit(False)  # Set to manual commit mode for safety
            return conn
        except Exception as e:
            logger.error(f"Failed to connect to Tibero: {str(e)}")
            raise
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action but doesn't mention critical traits like whether this is read-only or destructive, what permissions are needed, error handling, or result formatting. For a database execution tool, this leaves significant gaps in understanding its behavior.

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, efficient sentence with zero wasted words. It's appropriately sized for a simple tool and front-loads the essential information without unnecessary elaboration.

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?

For a database execution tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after execution (e.g., returns results, affects data), error conditions, or security implications, leaving the agent with incomplete context for safe and effective use.

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 description coverage is 100%, with the single parameter 'query' fully documented in the schema. The description adds no additional meaning about parameter syntax, valid SQL types, or constraints beyond what the schema provides, meeting the baseline for high schema coverage.

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 ('SQL query on the Tibero server'), providing specific verb+resource information. However, it doesn't differentiate from the sibling tool 'get_table_info', which might also involve SQL queries or database operations, so it doesn't fully distinguish from alternatives.

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?

The description provides no guidance on when to use this tool versus alternatives like 'get_table_info'. There's no mention of appropriate contexts, exclusions, or prerequisites for executing SQL queries, leaving the agent without usage direction.

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/YeomYuJun/tibero-mcp-server'

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