start-transaction
Initiate a new transaction in Microsoft SQL Server using the MCP server, enabling AI assistants to manage database operations through configurable connections.
Instructions
Start a new transaction
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/transactions.ts:36-42 (handler)The handler function for the 'start-transaction' tool. It generates a random UUID for the transaction ID, starts a database transaction using database.startTransaction(), stores the transaction in the class's transactions Map, and returns a success message with the ID.async startTransaction() { const transactionId = crypto.randomUUID(); const transaction = await database.startTransaction(); this.transactions.set(transactionId, transaction); return this.toResult(`Transaction started with ID: ${transactionId}. You can use this ID to commit or rollback the transaction later.`); }
- src/tools/transactions.ts:13-17 (registration)Registration of the 'start-transaction' tool in the static create method of TransactionTools class, using server.tool() with no input schema (empty args) and binding the startTransaction handler.server.tool( "start-transaction", "Start a new transaction", tools.startTransaction.bind(tools) );