delete_document_by_id
Remove a specific document from a Couchbase database by providing its unique identifier, bucket, scope, and collection details.
Instructions
Delete a document by its ID. Returns True on success, False on failure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket_name | Yes | ||
| scope_name | Yes | ||
| collection_name | Yes | ||
| document_id | Yes |
Implementation Reference
- src/tools/kv.py:62-80 (handler)Core implementation of the delete_document_by_id tool. Deletes the document from Couchbase using the provided bucket, scope, collection, and ID. Returns True on success, False otherwise.def delete_document_by_id( ctx: Context, bucket_name: str, scope_name: str, collection_name: str, document_id: str, ) -> bool: """Delete a document by its ID. Returns True on success, False on failure.""" cluster = get_cluster_connection(ctx) bucket = connect_to_bucket(cluster, bucket_name) try: collection = bucket.scope(scope_name).collection(collection_name) collection.remove(document_id) logger.info(f"Successfully deleted document {document_id}") return True except Exception as e: logger.error(f"Error deleting document {document_id}: {e}") return False
- src/tools/__init__.py:11-15 (registration)Imports delete_document_by_id from kv.py into the tools package, making it available for registration.from .kv import ( delete_document_by_id, get_document_by_id, upsert_document_by_id, )
- src/tools/__init__.py:42-64 (registration)Includes delete_document_by_id in ALL_TOOLS list, which is used to batch-register all tools with the MCP server.ALL_TOOLS = [ get_buckets_in_cluster, get_server_configuration_status, test_cluster_connection, get_scopes_and_collections_in_bucket, get_collections_in_scope, get_scopes_in_bucket, get_document_by_id, upsert_document_by_id, delete_document_by_id, get_schema_for_collection, run_sql_plus_plus_query, get_index_advisor_recommendations, list_indexes, get_cluster_health_and_services, get_queries_not_selective, get_queries_not_using_covering_index, get_queries_using_primary_index, get_queries_with_large_result_count, get_queries_with_largest_response_sizes, get_longest_running_queries, get_most_frequent_queries, ]
- src/mcp_server.py:175-178 (registration)Loop that registers every tool in ALL_TOOLS (including delete_document_by_id) to the FastMCP server instance.# Register all tools for tool in ALL_TOOLS: mcp.add_tool(tool)