Skip to main content
Glama
bpamiri

CockroachDB MCP Server

by bpamiri

delete_row

Remove a specific row from a CockroachDB table by specifying its primary key value and table name.

Instructions

Delete a row by primary key.

Args:
    table: Table name (schema.table or just table).
    id_value: Primary key value.
    id_column: Name of the ID column (default: 'id').

Returns:
    Delete result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYes
id_valueYes
id_columnNoid

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration and handler for the 'delete_row' MCP tool. Decorated with @mcp.tool() and delegates to crud.delete_row.
    @mcp.tool()
    async def delete_row(
        table: str,
        id_value: str | int,
        id_column: str = "id",
    ) -> dict[str, Any]:
        """Delete a row by primary key.
    
        Args:
            table: Table name (schema.table or just table).
            id_value: Primary key value.
            id_column: Name of the ID column (default: 'id').
    
        Returns:
            Delete result.
        """
        try:
            return await crud.delete_row(table, id_value, id_column)
        except Exception as e:
            return {"status": "error", "error": str(e)}
  • Core implementation of delete_row: constructs DELETE SQL query, executes it using connection_manager, handles read-only mode, validation, and returns detailed result.
    async def delete_row(
        table: str,
        id_value: str | int,
        id_column: str = "id",
    ) -> dict[str, Any]:
        """Delete a row by primary key.
    
        Args:
            table: Table name (schema.table or just table).
            id_value: Primary key value.
            id_column: Name of the ID column (default: 'id').
    
        Returns:
            Delete result.
        """
        # Check read-only mode
        if settings.read_only:
            return {"status": "error", "error": "Server is in read-only mode"}
    
        # Validate table name
        valid, error = _validate_table_name(table)
        if not valid:
            return {"status": "error", "error": error}
    
        schema, table_name = _parse_table_name(table)
    
        query = f"DELETE FROM {schema}.{table_name} WHERE {id_column} = %s"
    
        conn = await connection_manager.ensure_connected()
    
        try:
            async with conn.cursor() as cur:
                await cur.execute(query, (id_value,))
    
                if cur.rowcount == 0:
                    return {
                        "status": "warning",
                        "table": f"{schema}.{table_name}",
                        "action": "delete",
                        "id": id_value,
                        "message": "No row found with specified ID",
                        "rows_affected": 0,
                    }
    
                return {
                    "status": "success",
                    "table": f"{schema}.{table_name}",
                    "action": "deleted",
                    "id": id_value,
                    "rows_affected": cur.rowcount,
                }
        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 states the tool deletes a row, implying a destructive mutation, but fails to mention critical aspects like required permissions, whether deletions are permanent or reversible, error handling, or transactional behavior. This leaves significant gaps for a destructive operation.

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

Conciseness5/5

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

The description is front-loaded with the core purpose, followed by well-structured sections for Args and Returns. Each sentence earns its place by providing essential information without redundancy, making it efficient and easy to parse.

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 as a destructive mutation with no annotations, the description is moderately complete: it covers parameters and mentions a return value, but lacks behavioral context like safety warnings or transactional dependencies. The output schema exists, so return values need not be detailed, but other gaps remain.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaningful context for all three parameters: 'table' specifies naming conventions, 'id_value' clarifies it's the primary key value, and 'id_column' notes the default. This goes beyond the bare schema, though it could detail data types or constraints more explicitly.

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

Purpose5/5

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

The description clearly states the specific action ('Delete a row') and resource ('by primary key'), distinguishing it from siblings like 'update_row' or 'insert_row' which perform different operations on rows. It precisely communicates the tool's function without being vague or tautological.

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 'update_row' or 'upsert_row', nor does it mention prerequisites such as needing an active connection or transaction. It lacks context about appropriate scenarios or exclusions, offering only basic operational details.

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