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") )

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