Skip to main content
Glama

update_data

Modify records in MSSQL database tables by specifying column updates and WHERE clause conditions to target specific data rows for changes.

Instructions

Updates data in an MSSQL Database table using a WHERE clause. The WHERE clause must be provided for security.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableNameYesName of the table to update
updatesYesKey-value pairs of columns to update. Example: { 'status': 'active', 'last_updated': '2025-01-01' }
whereClauseYesWHERE clause to identify which records to update. Example: "genre = 'comedy' AND created_date <= '2025-07-05'"

Implementation Reference

  • The `run` method implements the core logic of the update_data tool: validates input, builds a parameterized UPDATE query, executes it on the MSSQL database, and returns success/error with rows affected.
    async run(params: any) {
      let query: string | undefined;
      try {
        const { tableName, updates, whereClause } = params;
        
        // Basic validation: ensure whereClause is not empty
        if (!whereClause || whereClause.trim() === '') {
          throw new Error("WHERE clause is required for security reasons");
        }
    
        const request = new sql.Request();
        
        // Build SET clause with parameterized queries for security
        const setClause = Object.keys(updates)
          .map((key, index) => {
            const paramName = `update_${index}`;
            request.input(paramName, updates[key]);
            return `[${key}] = @${paramName}`;
          })
          .join(", ");
    
        query = `UPDATE ${tableName} SET ${setClause} WHERE ${whereClause}`;
        const result = await request.query(query);
        
        return {
          success: true,
          message: `Update completed successfully. ${result.rowsAffected[0]} row(s) affected`,
          rowsAffected: result.rowsAffected[0],
        };
      } catch (error) {
        console.error("Error updating data:", error);
        return {
          success: false,
          message: `Failed to update data ${query ? ` with '${query}'` : ''}: ${error}`,
        };
      }
    }
  • Input schema defining the structure and requirements for the tool's arguments: tableName (string), updates (object), whereClause (string).
    inputSchema = {
      type: "object",
      properties: {
        tableName: { 
          type: "string", 
          description: "Name of the table to update" 
        },
        updates: {
          type: "object",
          description: "Key-value pairs of columns to update. Example: { 'status': 'active', 'last_updated': '2025-01-01' }",
        },
        whereClause: { 
          type: "string", 
          description: "WHERE clause to identify which records to update. Example: \"genre = 'comedy' AND created_date <= '2025-07-05'\"" 
        },
      },
      required: ["tableName", "updates", "whereClause"],
    } as any;
  • src/index.ts:132-134 (registration)
    Dispatches calls to the update_data tool in the CallToolRequestSchema handler via switch statement.
    case updateDataTool.name:
      result = await updateDataTool.run(args);
      break;
  • src/index.ts:116-118 (registration)
    Includes the updateDataTool instance in the list of available tools for ListToolsRequestSchema (non-readonly mode).
    tools: isReadOnly
      ? [listTableTool, readDataTool, describeTableTool] // todo: add searchDataTool to the list of tools available in readonly mode once implemented
      : [insertDataTool, readDataTool, describeTableTool, updateDataTool, createTableTool, createIndexTool, dropTableTool, listTableTool], // add all new tools here
  • src/index.ts:89-89 (registration)
    Instantiates the UpdateDataTool class for use in the MCP server.
    const updateDataTool = new UpdateDataTool();
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the WHERE clause requirement 'for security,' which hints at a safety constraint, but lacks details on permissions needed, whether updates are reversible, potential side effects, or error handling. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two sentences that are front-loaded and to the point, avoiding unnecessary verbosity. However, it could be slightly more structured by explicitly separating the purpose from the security note for better clarity.

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 the complexity of a database update tool with no annotations and no output schema, the description is incomplete. It lacks information on return values, error conditions, transactional behavior, or how updates interact with existing data, making it inadequate for safe and effective agent use.

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?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't explain parameter interactions or provide further examples), resulting in a baseline score of 3 where the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Updates data') and resource ('in an MSSQL Database table'), making the purpose understandable. However, it doesn't explicitly differentiate this from sibling tools like 'insert_data' or 'read_data' beyond the 'WHERE clause' mention, which is more of a technical requirement than a functional distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'using a WHERE clause' and noting it's 'for security,' which suggests this tool should be used for targeted updates rather than bulk operations. However, it doesn't explicitly state when to use this versus alternatives like 'insert_data' or provide exclusions, leaving some ambiguity for the agent.

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/Nirmal123K/mssql-mcp'

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