Skip to main content
Glama

test_execute

Test SQL queries for execution feasibility in MySQL databases with automatic rollback to verify query validity without data changes.

Instructions

Checks if an SQL query can be executed and rolls back afterward.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes

Implementation Reference

  • The switch case that implements the test_execute tool logic: starts a transaction, attempts to execute the SQL query, rolls back in finally, returns error if failed or success message if successful.
    case "test_execute": { const sql = request.params.arguments?.sql as string; await connection.query('START TRANSACTION'); try { await connection.query(sql); } catch (error) { return { content: [{ type: "text", text: `Failed to execute SQL. error: ${error}` }], isError: true, }; } finally { await connection.query('ROLLBACK'); } return { content: [{ type: "text", text: "The update SQL query can be executed." }], isError: false, }; }
  • Input schema definition for the test_execute tool, requiring a 'sql' string.
    inputSchema: { type: "object", properties: { sql: { type: "string" }, }, required: ["sql"], },
  • src/index.ts:50-60 (registration)
    Registration of the test_execute tool in the ListTools handler response, including name, description, and input schema.
    { name: "test_execute", description: "Checks if an SQL query can be executed and rolls back afterward.", inputSchema: { type: "object", properties: { sql: { type: "string" }, }, required: ["sql"], }, },

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

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