couchdb_delete_document
Delete a document from a CouchDB database by specifying the database name, document ID, and revision number to remove data.
Instructions
Delete a document from a database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | Name of the database | |
| doc_id | Yes | Document ID | |
| rev | Yes | Document revision (_rev) |
Implementation Reference
- couchdb_mcp_server.py:403-414 (handler)The actual handler implementation for deleting a document from CouchDB. Takes database name, document ID, and revision, then uses the CouchDB Python library's delete() method to remove the document. Handles various exceptions including database not found, document not found, and revision conflicts.async def _delete_document(self, database: str, doc_id: str, rev: str) -> list[TextContent]: """Delete a document.""" try: db = self._get_server()[database] db.delete({"_id": doc_id, "_rev": rev}) return [TextContent(type="text", text=f"Document '{doc_id}' deleted successfully")] except KeyError: return [TextContent(type="text", text=f"Database '{database}' not found")] except couchdb.http.ResourceNotFound: return [TextContent(type="text", text=f"Document '{doc_id}' not found")] except couchdb.http.ResourceConflict: return [TextContent(type="text", text="Document delete conflict - revision mismatch")]
- couchdb_mcp_server.py:153-174 (schema)Tool schema definition for couchdb_delete_document. Defines the tool's name, description, and input schema with required parameters: database (string), doc_id (string), and rev (string for document revision).Tool( name="couchdb_delete_document", description="Delete a document from a database", inputSchema={ "type": "object", "properties": { "database": { "type": "string", "description": "Name of the database", }, "doc_id": { "type": "string", "description": "Document ID", }, "rev": { "type": "string", "description": "Document revision (_rev)", }, }, "required": ["database", "doc_id", "rev"], }, ),
- couchdb_mcp_server.py:289-294 (registration)Registration point where the couchdb_delete_document tool name is routed to its handler method. Extracts the three required arguments (database, doc_id, rev) and calls the _delete_document async method.elif name == "couchdb_delete_document": return await self._delete_document( arguments["database"], arguments["doc_id"], arguments["rev"] )