Skip to main content
Glama
bpamiri

CockroachDB MCP Server

by bpamiri

begin_transaction

Start a database transaction to group multiple operations for atomic execution, ensuring data consistency and integrity in CockroachDB.

Instructions

Begin a database transaction.

Returns:
    Transaction status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'begin_transaction' MCP tool using @mcp.tool() decorator. Thin handler that delegates to connection_manager and handles exceptions.
    @mcp.tool()
    async def begin_transaction() -> dict[str, Any]:
        """Begin a database transaction.
    
        Returns:
            Transaction status.
        """
        try:
            return await connection_manager.begin_transaction()
        except Exception as e:
            return {"status": "error", "error": str(e)}
  • Core implementation of begin_transaction in ConnectionManager class: ensures connection, checks for existing transaction, disables autocommit, updates state.
    async def begin_transaction(self) -> dict[str, Any]:
        """Begin a database transaction.
    
        Returns:
            Transaction status.
        """
        conn = await self.ensure_connected()
    
        if self._state.in_transaction:
            return {"status": "error", "error": "Transaction already in progress"}
    
        try:
            # Disable autocommit for transaction
            await conn.set_autocommit(False)
            self._state.in_transaction = True
            return {"status": "started", "message": "Transaction started"}
        except Exception as e:
            return {"status": "error", "error": str(e)}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool 'returns transaction status', which hints at output but doesn't clarify critical behaviors like whether this requires specific permissions, if transactions are isolated, timeouts, or how errors are handled. For a mutation tool with zero annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief and front-loaded with the core purpose in the first sentence. The second sentence adds value by hinting at the return type. There's no wasted text, though it could be slightly more structured (e.g., separating purpose from returns more clearly).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (starting a database transaction) and the presence of an output schema, the description is minimally adequate. It states the purpose and hints at returns, but lacks details on behavioral traits, usage context, and error handling, which are important for a mutation tool with no annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so the schema fully documents the lack of inputs. The description doesn't need to add parameter details, but it correctly implies no inputs are required by not mentioning any. This meets the baseline for tools with no parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Begin') and resource ('a database transaction'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from its sibling 'commit_transaction' or 'rollback_transaction', which would require mentioning that this starts a new transaction rather than finalizing or aborting an existing one.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'commit_transaction' or 'rollback_transaction'. It doesn't mention prerequisites (e.g., needing a connection first) or typical workflows, leaving the agent to infer usage from context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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