Skip to main content
Glama

MySQL MCP Server

mysql_update

Update MySQL table data using specific conditions and values. Simplifies modifying database records through structured input for efficient data management in MySQL MCP Server.

Instructions

更新表数据

Input Schema

NameRequiredDescriptionDefault
dataYes要更新的数据
tableNameYes表名称
whereYes更新条件

Input Schema (JSON Schema)

{ "properties": { "data": { "description": "要更新的数据", "type": "object" }, "tableName": { "description": "表名称", "type": "string" }, "where": { "description": "更新条件", "type": "object" } }, "required": [ "tableName", "data", "where" ], "type": "object" }

Implementation Reference

  • The handler function that implements the mysql_update tool. It constructs an UPDATE SQL statement from the provided data and where conditions, executes it using the DatabaseManager, and returns the number of affected rows.
    private async handleUpdate(args: { tableName: string; data: any; where: any }): Promise<any> { const setClause = Object.keys(args.data).map(key => `\`${key}\` = ?`).join(', '); const whereClause = Object.keys(args.where).map(key => `\`${key}\` = ?`).join(' AND '); const sql = `UPDATE \`${args.tableName}\` SET ${setClause} WHERE ${whereClause}`; const params = [...Object.values(args.data), ...Object.values(args.where)]; const result = await this.dbManager.query(sql, params); return { content: [ { type: 'text', text: `成功更新 ${result.affectedRows} 行数据`, }, ], }; }
  • Input schema for the mysql_update tool, defining parameters: tableName (string), data (object), where (object).
    inputSchema: { type: 'object', properties: { tableName: { type: 'string', description: '表名称' }, data: { type: 'object', description: '要更新的数据' }, where: { type: 'object', description: '更新条件' }, }, required: ['tableName', 'data', 'where'], },
  • src/server.ts:171-183 (registration)
    Registration of the mysql_update tool in the ListTools response, including name, description, and input schema.
    { name: 'mysql_update', description: '更新表数据', inputSchema: { type: 'object', properties: { tableName: { type: 'string', description: '表名称' }, data: { type: 'object', description: '要更新的数据' }, where: { type: 'object', description: '更新条件' }, }, required: ['tableName', 'data', 'where'], }, },
  • src/server.ts:255-256 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes mysql_update calls to the handleUpdate method.
    case 'mysql_update': return await this.handleUpdate(args as any);

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/pickstar-2002/mysql-mcp'

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