Skip to main content
Glama
andyfe76

CouchDB MCP Server

by andyfe76

couchdb_update_document

Update an existing document in a CouchDB database by specifying the database name, document ID, and revised document data including the _rev field.

Instructions

Update an existing document in a database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYesName of the database
doc_idYesDocument ID
documentYesUpdated document data (must include _rev)

Implementation Reference

  • The _update_document method implements the actual logic for updating a CouchDB document. It retrieves the database, ensures the document has _id, saves it using db.save(), and handles various error cases (KeyError for missing database, ResourceConflict for revision conflicts, and general exceptions). Returns the updated document id and revision.
    async def _update_document(self, database: str, doc_id: str, document: dict) -> list[TextContent]:
        """Update an existing document."""
        try:
            db = self._get_server()[database]
    
            # Ensure document has _id
            if "_id" not in document:
                document["_id"] = doc_id
    
            # Save the document
            saved_id, rev = db.save(document)
    
            result = {
                "id": saved_id,
                "rev": rev,
                "message": "Document updated successfully"
            }
            return [TextContent(type="text", text=json.dumps(result, indent=2))]
        except KeyError:
            return [TextContent(type="text", text=f"Database '{database}' not found")]
        except couchdb.http.ResourceConflict:
            return [TextContent(type="text", text="Document update conflict - document was modified, please get the latest revision")]
        except Exception as e:
            return [TextContent(type="text", text=f"Error updating document: {str(e)}")]
  • Tool schema definition for couchdb_update_document, registered in the list_tools() handler. Defines the input schema with database (string), doc_id (string), and document (object) as required fields. The document parameter note specifies it must include _rev for optimistic concurrency control.
    Tool(
        name="couchdb_update_document",
        description="Update an existing document in a database",
        inputSchema={
            "type": "object",
            "properties": {
                "database": {
                    "type": "string",
                    "description": "Name of the database",
                },
                "doc_id": {
                    "type": "string",
                    "description": "Document ID",
                },
                "document": {
                    "type": "object",
                    "description": "Updated document data (must include _rev)",
                },
            },
            "required": ["database", "doc_id", "document"],
        },
    ),
  • Tool routing registration in the call_tool() handler that routes the 'couchdb_update_document' tool name to its handler method _update_document(), extracting the database, doc_id, and document arguments.
    elif name == "couchdb_update_document":
        return await self._update_document(
            arguments["database"],
            arguments["doc_id"],
            arguments["document"]
        )
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool updates documents but doesn't mention critical behaviors like whether it's idempotent, what happens on conflicts, if it requires specific permissions, or what the response format is. This is inadequate for a mutation tool with zero annotation coverage.

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 a single, efficient sentence that directly states the tool's function without any unnecessary words. It's appropriately sized and front-loaded with the core action.

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

Completeness2/5

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

For a document update tool with no annotations and no output schema, the description is insufficient. It doesn't cover behavioral aspects like error conditions, response format, or idempotency, leaving significant gaps in understanding how to use the tool effectively.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema fully documents all three parameters. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain the '_rev' requirement in more detail). This meets the baseline for high schema coverage.

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 verb 'Update' and the resource 'an existing document in a database', making the purpose unambiguous. However, it doesn't distinguish this tool from its sibling 'couchdb_delete_document' or 'couchdb_get_document' in terms of operation type, which prevents a perfect score.

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 'couchdb_create_document' or 'couchdb_delete_document'. It lacks context about prerequisites (e.g., document must exist) or typical use cases, offering only basic functional information.

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/andyfe76/couchdb_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server