Skip to main content
Glama
kevinbin

MCP MySQL Server

by kevinbin

execute

Run INSERT, UPDATE, or DELETE queries on MySQL databases via the MCP server, enabling direct database modifications with optional parameters for precise command execution.

Instructions

Execute an INSERT, UPDATE, or DELETE query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsNoQuery parameters (optional)
sqlYesSQL query (INSERT, UPDATE, DELETE)

Implementation Reference

  • The primary handler for the 'execute' tool. Validates SQL type, executes the query via executeQuery helper, and formats the result as JSON text content.
    private async handleExecute(args: QueryArgs): Promise<QueryResult> {
      this.validateSqlInput(args.sql, ['INSERT', 'UPDATE', 'DELETE']);
      const result = await this.executeQuery(args.sql, args.params || []);
    
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(result, null, 2)
        }]
      };
  • src/index.ts:396-415 (registration)
    Tool registration entry in the ListTools handler, specifying name, description, and input schema for the 'execute' tool.
    {
      name: 'execute',
      description: 'Execute an INSERT, UPDATE, or DELETE query',
      inputSchema: {
        type: 'object',
        properties: {
          sql: {
            type: 'string',
            description: 'SQL query (INSERT, UPDATE, DELETE)',
          },
          params: {
            type: 'array',
            items: {
              type: ['string', 'number', 'boolean', 'null'],
            },
            description: 'Query parameters (optional)',
          },
        },
        required: ['sql'],
      },
  • TypeScript interface defining the input arguments for the 'execute' tool (shared with 'query' tool).
    interface QueryArgs {
      sql: string;
      params?: Array<string | number | boolean | null>;
    }
  • Core helper function that executes SQL queries using the MySQL connection pool and handles database errors.
    private async executeQuery<T>(sql: string, params: any[] = []): Promise<T> {
      const pool = await this.ensureConnection();
      try {
        const [result] = await pool.query(sql, params);
        return result as T;
      } catch (error) {
        this.handleDatabaseError(error);
      }
  • src/index.ts:523-524 (registration)
    Dispatch case in the CallTool request handler that routes 'execute' tool calls to the handleExecute method.
    case 'execute':
      return await this.handleExecute(request.params.arguments as unknown as QueryArgs);

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.3/5.0
Behavior2/5

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

No annotations are provided, so the description must bear the burden of behavioral disclosure. It confirms mutation but fails to detail side effects, permanence, or return behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single short sentence with no wasted words, but it could include more detail without sacrificing conciseness.

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 lack of output schema and annotations, the description does not explain return values or error behavior. It is too minimal for a mutation tool.

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 coverage is 100%, and the description does not add meaning beyond the schema. The schema already documents 'sql' and 'params' adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool executes INSERT, UPDATE, or DELETE queries, which specifies the action and resource. It distinguishes from sibling tools like 'query' which likely handles SELECT statements.

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 write operations but does not explicitly guide when to use this tool versus alternatives like 'query'. There is no mention of prerequisites or restrictions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools

Related Tools