Skip to main content
Glama

update_data

Execute SQL UPDATE queries to modify records in MySQL databases. Designed for use with the MySQL MCP Server, enabling efficient data management and updates.

Instructions

Updates data in a table in the MySQL database.

Input Schema

NameRequiredDescriptionDefault
queryYesThe SQL UPDATE query to execute.

Input Schema (JSON Schema)

{ "properties": { "query": { "description": "The SQL UPDATE query to execute.", "type": "string" } }, "required": [ "query" ], "type": "object" }

Implementation Reference

  • Executes the UPDATE SQL query after validation, handles errors, and returns formatted response with transaction logging.
    private async handleUpdateData(request: any, transactionId: string) { if (!isValidSqlQueryArgs(request.params.arguments)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid SQL query arguments.' ); } const query = request.params.arguments.query; if (!isUpdateQuery(query)) { throw new McpError( ErrorCode.InvalidParams, 'Only UPDATE queries are allowed with update_data tool.' ); } console.error(`[${transactionId}] Executing UPDATE query: ${query}`); try { const [result] = await this.pool.query(query); console.error(`[${transactionId}] Data updated successfully`); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: 'Data updated successfully', result }, null, 2), }, ], }; } catch (error) { console.error(`[${transactionId}] Query error:`, error); if (error instanceof Error) { return { content: [ { type: 'text', text: `MySQL error: ${error.message}`, }, ], isError: true, }; } throw error; } }
  • Input schema definition for the update_data tool, specifying a required 'query' string parameter.
    inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'The SQL UPDATE query to execute.', }, }, required: ['query'], },
  • src/index.ts:136-149 (registration)
    Tool registration in the ListTools response, including name, description, and input schema.
    { name: 'update_data', description: 'Updates data in a table in the MySQL database.', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'The SQL UPDATE query to execute.', }, }, required: ['query'], }, },
  • src/index.ts:193-194 (registration)
    Routing in CallToolRequestHandler switch statement that calls the update_data handler.
    case 'update_data': return this.handleUpdateData(request, transactionId);
  • Helper function to validate if a query is an UPDATE statement, used in the handler.
    const isUpdateQuery = (query: string): boolean => query.trim().toLowerCase().startsWith('update');

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

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