couchdb_get_document
Retrieve a specific document from a CouchDB database using its document ID. This tool fetches stored data for viewing or processing within the CouchDB MCP Server environment.
Instructions
Retrieve a document from a database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | Name of the database | |
| doc_id | Yes | Document ID |
Implementation Reference
- couchdb_mcp_server.py:367-376 (handler)The _get_document handler method that implements the core logic for retrieving a document from CouchDB. It gets the database, retrieves the document by ID, and returns it as JSON with proper error handling for missing databases or documents.async def _get_document(self, database: str, doc_id: str) -> list[TextContent]: """Retrieve a document.""" try: db = self._get_server()[database] doc = db[doc_id] return [TextContent(type="text", text=json.dumps(doc, indent=2))] except KeyError: return [TextContent(type="text", text=f"Database '{database}' or document '{doc_id}' not found")] except couchdb.http.ResourceNotFound: return [TextContent(type="text", text=f"Document '{doc_id}' not found")]
- couchdb_mcp_server.py:278-282 (registration)Registration mapping in the call_tool handler that routes the 'couchdb_get_document' tool name to its handler method, extracting the database and doc_id arguments.elif name == "couchdb_get_document": return await self._get_document( arguments["database"], arguments["doc_id"] )
- couchdb_mcp_server.py:113-130 (schema)Tool schema definition for couchdb_get_document, specifying it requires 'database' and 'doc_id' parameters, both as strings, with descriptions for each.Tool( name="couchdb_get_document", description="Retrieve a document from a database", inputSchema={ "type": "object", "properties": { "database": { "type": "string", "description": "Name of the database", }, "doc_id": { "type": "string", "description": "Document ID", }, }, "required": ["database", "doc_id"], }, ),