Skip to main content
Glama
andyfe76

CouchDB MCP Server

by andyfe76

couchdb_create_document

Create new documents in CouchDB databases by specifying database name and JSON document data, with optional custom document ID.

Instructions

Create a new document in a database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYesName of the database
documentYesDocument data as JSON object
doc_idNoOptional document ID (if not provided, CouchDB generates one)

Implementation Reference

  • The actual handler implementation that creates a document in CouchDB. It accepts a database name, document data, and optional document ID. Uses db.save() to create the document, merging the doc_id if provided.
    async def _create_document(self, database: str, document: dict, doc_id: str | None = None) -> list[TextContent]:
        """Create a new document."""
        try:
            db = self._get_server()[database]
            if doc_id:
                doc_id, rev = db.save({"_id": doc_id, **document})
            else:
                doc_id, rev = db.save(document)
    
            result = {
                "id": doc_id,
                "rev": rev,
                "message": "Document created successfully"
            }
            return [TextContent(type="text", text=json.dumps(result, indent=2))]
        except KeyError:
            return [TextContent(type="text", text=f"Database '{database}' not found")]
        except Exception as e:
            return [TextContent(type="text", text=f"Error creating document: {str(e)}")]
  • Tool schema registration defining the input structure for couchdb_create_document. Requires 'database' and 'document' parameters, with optional 'doc_id'.
    Tool(
        name="couchdb_create_document",
        description="Create a new document in a database",
        inputSchema={
            "type": "object",
            "properties": {
                "database": {
                    "type": "string",
                    "description": "Name of the database",
                },
                "document": {
                    "type": "object",
                    "description": "Document data as JSON object",
                },
                "doc_id": {
                    "type": "string",
                    "description": "Optional document ID (if not provided, CouchDB generates one)",
                },
            },
            "required": ["database", "document"],
        },
    ),
  • Tool call routing that maps the 'couchdb_create_document' tool name to its handler method, extracting arguments from the request.
    elif name == "couchdb_create_document":
        return await self._create_document(
            arguments["database"],
            arguments["document"],
            arguments.get("doc_id")
        )
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states 'Create' which implies a write/mutation operation, but doesn't disclose permissions needed, whether it's idempotent, error conditions, or what happens on success (e.g., returns document ID). This leaves significant gaps for agent understanding.

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, clear sentence with zero wasted words. It's appropriately front-loaded with the core action and resource, making it efficient for quick comprehension without unnecessary elaboration.

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 mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after creation (e.g., returns document ID or confirmation), error handling, or how it differs from similar tools like couchdb_update_document. Given the complexity and lack of structured data, more context is needed.

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 parameters are well-documented in the schema itself. The description adds no additional parameter semantics beyond implying 'document' is JSON data, which is already clear from the schema. 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 action ('Create') and resource ('new document in a database'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like couchdb_update_document or couchdb_get_document, which would require mentioning this is specifically for initial creation rather than modification or retrieval.

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. It doesn't mention prerequisites (e.g., database must exist), when to choose this over couchdb_update_document for updates, or any context about sibling tools like couchdb_create_database for database-level operations.

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