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);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool executes INSERT, UPDATE, or DELETE queries, implying mutation operations, but fails to disclose critical traits such as required permissions, whether changes are reversible, potential side effects, or any rate limits. This leaves significant gaps in understanding the tool's 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 extremely concise and front-loaded, consisting of a single sentence that directly states the tool's purpose without any unnecessary words. Every part of the sentence earns its place by clearly conveying the core functionality.

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 complexity of a mutation tool (executing INSERT, UPDATE, DELETE queries) with no annotations and no output schema, the description is incomplete. It lacks information on permissions, error handling, return values, or how it differs from sibling tools, making it inadequate for safe and effective use by an AI agent.

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 schema description coverage is 100%, so the input schema already documents both parameters ('sql' and 'params') adequately. The description adds minimal value by implying the 'sql' parameter should be for INSERT, UPDATE, or DELETE queries, but doesn't provide additional syntax, format details, or examples beyond what the schema specifies, 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 tool's purpose with a specific verb ('Execute') and resource type ('INSERT, UPDATE, or DELETE query'), making it easy to understand what the tool does. However, it doesn't explicitly distinguish it from sibling tools like 'query' or 'add_column', which might also involve database operations, so it misses full sibling differentiation.

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. It doesn't mention when to choose 'execute' over sibling tools like 'query' (which might handle SELECT queries) or 'add_column' (which might be for schema modifications), leaving the agent without context for tool selection.

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

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

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