Skip to main content
Glama
bpamiri

CockroachDB MCP Server

by bpamiri

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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)}

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