Skip to main content
Glama
EvilPhatBoi

MSSQL MCP Server

by EvilPhatBoi

update_data

Modify specific records in Microsoft SQL Server tables by applying column updates to rows matching a WHERE clause condition for targeted data management.

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 main handler function that performs the SQL UPDATE operation using parameterized queries for security, validates the WHERE clause, and returns success/failure 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 required parameters: tableName (string), updates (object of column-value pairs), whereClause (string for security).
    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:109-113 (registration)
    Registers the updateDataTool instance in the list of available tools returned by ListToolsRequest (in non-readonly mode).
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      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:126-127 (registration)
    Dispatches calls to the update_data tool by invoking its run method in the CallToolRequest handler switch statement.
    case updateDataTool.name:
      result = await updateDataTool.run(args);
  • src/index.ts:83-83 (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 is useful context, but fails to cover critical aspects: it doesn't specify whether this is a destructive operation, what permissions are needed, how errors are handled, or what the response looks like. For a mutation tool with zero annotation coverage, this leaves significant gaps.

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 with just two sentences, front-loading the core purpose and following with a critical constraint. Every word earns its place, with no redundant or vague language, making it efficient and easy to parse.

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 tool's complexity as a database mutation operation with no annotations and no output schema, the description is insufficient. It lacks details on behavioral traits like destructiveness, error handling, or return values, and while the schema covers parameters well, the overall context for safe and effective use is incomplete.

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 minimal value beyond the schema by emphasizing the WHERE clause's security importance, but it doesn't provide additional syntax, format details, or examples that aren't already in the schema descriptions. This meets the baseline for high schema coverage.

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 immediately understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'insert_data' or 'read_data' beyond the basic verb difference.

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 provides some guidance by specifying that 'The WHERE clause must be provided for security,' which implies a usage constraint. However, it doesn't offer explicit guidance on when to use this tool versus alternatives like 'insert_data' or 'read_data,' nor does it mention prerequisites or exclusions beyond the WHERE clause requirement.

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/EvilPhatBoi/McpSqlServer'

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