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

Implementation Reference

  • MCP tool handler for 'delete_row'. This is the function registered with @mcp.tool() that handles tool calls, including input schema via type annotations and docstring, and delegates execution to the CRUD helper.
    @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 helper function implementing the delete_row logic: validates inputs, constructs DELETE SQL query, executes it, and returns formatted 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)}

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