Skip to content

Commit 44ae7e6

Browse files
committed
Fix UpdateTable tool
1 parent 91bd53d commit 44ae7e6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

MssqlMcp/NodejsMcpServer/src/tools/UpdateDataTool.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class UpdateDataTool implements Tool {
2525
} as any;
2626

2727
async run(params: any) {
28+
let query: string | undefined;
2829
try {
2930
const { tableName, updates, whereClause } = params;
3031

@@ -44,7 +45,7 @@ export class UpdateDataTool implements Tool {
4445
})
4546
.join(", ");
4647

47-
const query = `UPDATE [${tableName}] SET ${setClause} WHERE ${whereClause}`;
48+
query = `UPDATE ${tableName} SET ${setClause} WHERE ${whereClause}`;
4849
const result = await request.query(query);
4950

5051
return {
@@ -56,7 +57,7 @@ export class UpdateDataTool implements Tool {
5657
console.error("Error updating data:", error);
5758
return {
5859
success: false,
59-
message: `Failed to update data: ${error}`,
60+
message: `Failed to update data ${query ? ` with '${query}'` : ''}: ${error}`,
6061
};
6162
}
6263
}

0 commit comments

Comments
 (0)