Skip to main content
Glama
nilsir

MCP Server MySQL

by nilsir

execute

Execute INSERT, UPDATE, DELETE or other modifying SQL queries in MySQL databases and return affected rows count for data manipulation operations.

Instructions

Execute an INSERT, UPDATE, DELETE or other modifying query. Returns affected rows count.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL query to execute
paramsNoQuery parameters for prepared statement

Implementation Reference

  • The main handler logic for the 'execute' tool. It retrieves the database pool, checks SQL permissions, executes the modifying SQL query (INSERT/UPDATE/DELETE), and returns structured output with affected rows, insert ID, and changed rows.
    async ({ sql, params }) => {
      const p = await getPool();
    
      // Check if the operation is allowed
      checkSqlPermission(sql);
    
      const [result] = await p.execute<ResultSetHeader>(sql, params || []);
    
      const output = {
        affectedRows: result.affectedRows,
        insertId: result.insertId,
        changedRows: result.changedRows,
      };
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify(output, null, 2),
          },
        ],
        structuredContent: output,
      };
    }
  • Zod schema defining the input parameters for the 'execute' tool: sql (required string) and optional params array.
    {
      sql: z.string().describe("SQL query to execute"),
      params: z.array(z.unknown()).optional().describe("Query parameters for prepared statement"),
    },
  • src/index.ts:175-206 (registration)
    Registration of the 'execute' tool using server.tool(), including name, description, input schema, and handler function.
    server.tool(
      "execute",
      "Execute an INSERT, UPDATE, DELETE or other modifying query. Returns affected rows count.",
      {
        sql: z.string().describe("SQL query to execute"),
        params: z.array(z.unknown()).optional().describe("Query parameters for prepared statement"),
      },
      async ({ sql, params }) => {
        const p = await getPool();
    
        // Check if the operation is allowed
        checkSqlPermission(sql);
    
        const [result] = await p.execute<ResultSetHeader>(sql, params || []);
    
        const output = {
          affectedRows: result.affectedRows,
          insertId: result.insertId,
          changedRows: result.changedRows,
        };
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(output, null, 2),
            },
          ],
          structuredContent: output,
        };
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries full burden. It discloses that the tool performs modifications and returns affected rows count, which is basic behavioral information. However, it doesn't mention critical aspects like authentication requirements, transaction behavior, error handling, or potential destructive effects (though 'modifying query' implies mutation). For a tool with no annotations and significant mutation capability, this is insufficient disclosure.

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 (one sentence) and front-loaded with the core purpose. Every word earns its place: 'Execute' (action), 'INSERT, UPDATE, DELETE or other modifying query' (scope), 'Returns affected rows count' (outcome). No wasted words or redundant information.

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 tool's complexity (executing arbitrary SQL modifications), lack of annotations, and no output schema, the description is incomplete. It doesn't cover security implications, error cases, transaction boundaries, or what 'affected rows count' entails. For a high-risk mutation tool with zero structured safety signals, the description should provide more contextual guidance.

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 both parameters ('sql' and 'params') well-documented in the schema. The description adds no additional parameter semantics beyond what the schema provides (e.g., no examples of SQL syntax or param usage). With high schema coverage, the baseline is 3, and the description doesn't compensate with extra value.

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 executes modifying SQL queries (INSERT, UPDATE, DELETE) and returns affected rows count. It specifies the action ('Execute') and resource ('modifying query'), distinguishing it from read-only siblings like 'query' or 'describe_table'. However, it doesn't explicitly differentiate from other modifying tools like 'alter_table' or 'drop_table' beyond the SQL statement scope.

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 implies usage for SQL modification operations, suggesting when to use it (for INSERT/UPDATE/DELETE queries). However, it doesn't provide explicit guidance on when NOT to use it (e.g., for read-only queries where 'query' would be appropriate) or mention alternatives like 'alter_table' for schema changes. The context is clear but lacks sibling differentiation and exclusion criteria.

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/nilsir/mcp-server-mysql'

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