Skip to main content
Glama
t2hnd

Bakery Data MCP Server

by t2hnd

execute_sql

Execute custom SQL queries to analyze bakery sales data, retrieve transaction records, and access product catalog information from the database.

Instructions

Execute a custom SQL query on the database. Use with caution. Read-only queries recommended.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSQL query to execute.
paramsNoParameters for the SQL query (for parameterized queries). Optional.

Implementation Reference

  • The handler function for the 'execute_sql' tool. It takes a SQL query and optional parameters from the arguments, executes it on the database cursor, and returns results for SELECT queries or a success message with row count for modifications.
    elif name == "execute_sql":
        query = arguments["query"]
        params = arguments.get("params", [])
    
        cursor.execute(query, params)
    
        # Check if this is a SELECT query
        if query.strip().upper().startswith("SELECT"):
            results = cursor.fetchall()
            return [TextContent(
                type="text",
                text=json.dumps(results, ensure_ascii=False, indent=2)
            )]
        else:
            conn.commit()
            return [TextContent(
                type="text",
                text=f"Query executed successfully. Rows affected: {cursor.rowcount}"
            )]
  • The registration of the 'execute_sql' tool in the list_tools() function, including its name, description, and input schema definition for the query and optional parameters.
    Tool(
        name="execute_sql",
        description="Execute a custom SQL query on the database. Use with caution. Read-only queries recommended.",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "SQL query to execute."
                },
                "params": {
                    "type": "array",
                    "description": "Parameters for the SQL query (for parameterized queries). Optional.",
                    "items": {
                        "type": ["string", "number", "null"]
                    }
                }
            },
            "required": ["query"]
        }
    ),
  • The input schema for the 'execute_sql' tool, defining the expected arguments: a required 'query' string and optional 'params' array.
    inputSchema={
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "SQL query to execute."
            },
            "params": {
                "type": "array",
                "description": "Parameters for the SQL query (for parameterized queries). Optional.",
                "items": {
                    "type": ["string", "number", "null"]
                }
            }
        },
        "required": ["query"]
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds value by warning 'Use with caution' and recommending read-only queries, which hints at potential risks like data modification or performance issues. However, it doesn't detail specific behaviors such as permissions required, rate limits, or what happens with non-read-only queries, leaving gaps in transparency.

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 highly concise and front-loaded, consisting of two clear sentences that directly address the tool's function and a key caution. Every sentence earns its place without redundancy, making it efficient and easy to parse.

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?

Given the tool's complexity (executing arbitrary SQL queries) and the absence of both annotations and an output schema, the description is somewhat incomplete. It covers the basic purpose and a caution but lacks details on return values, error handling, or security implications, which are crucial for such a powerful tool. It's adequate but has clear gaps.

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?

The input schema has 100% description coverage, so the schema already documents both parameters ('query' and 'params') thoroughly. The description doesn't add any meaningful semantic details beyond what the schema provides, such as examples or constraints on query syntax. Thus, it meets the baseline but doesn't enhance parameter understanding.

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 tool's purpose with a specific verb ('execute') and resource ('custom SQL query on the database'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_schema' or 'query_transactions', which might also involve database queries, so it falls short of a perfect score.

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

Usage Guidelines3/5

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

The description provides some guidance with 'Use with caution' and 'Read-only queries recommended', which implies cautionary context but doesn't specify when to use this tool versus alternatives like 'query_departments' or 'sales_summary'. It lacks explicit when/when-not rules or named alternatives, leaving usage somewhat ambiguous.

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/t2hnd/bakery_data_mcp'

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