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"]
    }

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