Skip to main content
Glama
pickstar-2002

MySQL MCP Server

mysql_update

Modify existing records in MySQL database tables by specifying update conditions and new data values to maintain accurate information.

Instructions

更新表数据

Input Schema

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

Implementation Reference

  • The main handler function for the 'mysql_update' tool. It constructs an UPDATE SQL statement from the provided 'data' (SET clause) and 'where' (condition), parameterizes it, executes the query via dbManager, 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} 行数据`,
          },
        ],
      };
    }
  • The input schema definition for the 'mysql_update' tool, specifying tableName, data (fields to update), and where (update condition) as required object properties.
    {
      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)
    The switch case registration that dispatches 'mysql_update' tool calls to the handleUpdate method.
    case 'mysql_update':
      return await this.handleUpdate(args as any);
  • src/server.ts:226-228 (registration)
    The overall CallToolRequestHandler where 'mysql_update' is handled via switch on tool name.
    });
    
    this.server.setRequestHandler(CallToolRequestSchema, async (request: any) => {
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. '更新表数据' indicates a write/mutation operation but provides no information about permissions needed, whether changes are reversible, transaction behavior, error conditions, or what happens when the WHERE clause matches multiple rows. For a database mutation tool with zero annotation coverage, this is a significant gap in behavioral transparency.

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 at just four Chinese characters ('更新表数据'). While it may be too brief for completeness, it's perfectly front-loaded with the core purpose and contains zero wasted words or redundant information.

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 this is a database mutation tool with no annotations, no output schema, and three required parameters (including nested objects), the description is inadequate. It doesn't explain what the tool returns, error conditions, transactional behavior, or how it differs from similar tools. The minimal description fails to provide the context needed for safe and effective use of a potentially destructive database operation.

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%, with all three parameters ('tableName', 'data', 'where') having descriptions in Chinese. The tool description adds no additional parameter information beyond what's already in the schema. According to scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '更新表数据' (Update table data) states a clear verb ('update') and resource ('table data'), which is better than a tautology. However, it doesn't distinguish this tool from its sibling 'mysql_insert' (which adds data) or 'mysql_delete' (which removes data) - it only generically describes updating without specifying how it differs from other data modification tools.

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. With siblings like 'mysql_insert' (for adding new records), 'mysql_delete' (for removing records), and 'mysql_query' (for general SQL operations), there's no indication of when this specific UPDATE operation is appropriate versus using a more general query or other modification tools.

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

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