Skip to main content
Glama

execute

Execute INSERT, UPDATE, or DELETE queries to modify data in MySQL databases through the MCP MySQL Server.

Instructions

Execute an INSERT, UPDATE, or DELETE query

Input Schema

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

Implementation Reference

  • Implements the core logic for the 'execute' tool: validates input, ensures DB connection, executes non-SELECT SQL queries (INSERT/UPDATE/DELETE), and returns JSON-stringified results.
    private async handleExecute(args: any) { await this.ensureConnection(); if (!args.sql) { throw new McpError(ErrorCode.InvalidParams, 'SQL query is required'); } const sql = args.sql.trim().toUpperCase(); if (sql.startsWith('SELECT')) { throw new McpError( ErrorCode.InvalidParams, 'Use query tool for SELECT statements' ); } try { const [result] = await this.connection!.query(args.sql, args.params || []); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Query execution failed: ${getErrorMessage(error)}` ); } }
  • Schema definition for the 'execute' tool, including name, description, and input schema specifying required 'sql' string and optional 'params' array.
    { 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'], }, },
  • src/index.ts:199-200 (registration)
    Registers the 'execute' tool handler in the CallToolRequestSchema switch statement, routing calls to handleExecute.
    case 'execute': return await this.handleExecute(request.params.arguments);

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

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