commit-transaction
Commit a specified transaction in Microsoft SQL Server databases using the transaction ID for secure and controlled database operations.
Instructions
Commit a transaction
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| transactionId | Yes | The ID of the transaction to commit. |
Implementation Reference
- src/tools/transactions.ts:44-53 (handler)The main handler function for the 'commit-transaction' tool. It retrieves the transaction from the local map, commits it using the database transaction object, removes it from the map, and returns a success message.async commitTransaction({ transactionId }: { transactionId: string }) { const transaction = this.transactions.get(transactionId); if (!transaction) { throw new Error(`Transaction with ID ${transactionId} not found.`); } await transaction.commit(); this.transactions.delete(transactionId); return this.toResult(`Transaction with ID ${transactionId} committed successfully.`);
- src/tools/transactions.ts:22-22 (schema)Zod schema defining the input parameter 'transactionId' as a string for the 'commit-transaction' tool.{ transactionId: z.string().describe("The ID of the transaction to commit.") },
- src/tools/transactions.ts:19-24 (registration)Registers the 'commit-transaction' tool on the MCP server, specifying name, description, schema, and handler.server.tool( "commit-transaction", "Commit a transaction", { transactionId: z.string().describe("The ID of the transaction to commit.") }, tools.commitTransaction.bind(tools), );
- src/server.ts:19-19 (registration)Top-level call to create and register TransactionTools, which includes the 'commit-transaction' tool.TransactionTools.create(server);