Skip to main content
Glama
bpamiri

CockroachDB MCP Server

by bpamiri

rollback_transaction

Cancel pending database changes in CockroachDB by aborting the current transaction, useful for error recovery or when modifications are no longer needed.

Instructions

Rollback the current transaction.

Returns: Rollback status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler logic for rolling back the current database transaction. Ensures connection, checks if in transaction, performs rollback, resets autocommit and transaction state.
    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)}
  • MCP tool registration using @mcp.tool() decorator. Thin wrapper that delegates to connection_manager.rollback_transaction() with error handling.
    @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)}
  • The registered MCP tool handler function that invokes the core rollback logic.
    @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)}
  • Global instance of ConnectionManager used by the server tools.
    connection_manager = ConnectionManager()

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/bpamiri/cockroachdb-mcp'

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