rollback_transaction
Cancel pending database changes by aborting the current transaction, restoring data to its previous state.
Instructions
Rollback the current transaction.
Returns:
Rollback status.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "rollback_transaction"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/cockroachdb_mcp/server.py:404-414 (handler)MCP tool handler and registration for 'rollback_transaction'. This is the entry point for the tool, decorated with @mcp.tool() and delegates to the connection manager.
@mcp.tool() async def rollback_transaction() -> dict[str, Any]: """Rollback the current transaction. Returns: Rollback status. """ try: return await connection_manager.rollback_transaction() except Exception as e: return {"status": "error", "error": str(e)} - Core implementation of rollback_transaction in the ConnectionManager class. Performs the actual database rollback and state management.
async def rollback_transaction(self) -> dict[str, Any]: """Rollback the current transaction. Returns: Rollback status. """ conn = await self.ensure_connected() if not self._state.in_transaction: return {"status": "error", "error": "No transaction in progress"} try: await conn.rollback() await conn.set_autocommit(True) self._state.in_transaction = False return {"status": "rolled_back", "message": "Transaction rolled back"} except Exception as e: return {"status": "error", "error": str(e)}