couchdb_list_documents
Retrieve document IDs and revisions from a CouchDB database. Specify database name, limit results, and optionally include full document content.
Instructions
List all documents in a database with their IDs and revisions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | Name of the database | |
| limit | No | Maximum number of documents to return | |
| include_docs | No | Include full document content (default: false) |
Implementation Reference
- couchdb_mcp_server.py:481-514 (handler)The _list_documents method is the actual handler implementation that retrieves all documents from a CouchDB database. It accepts database name, optional limit, and include_docs parameters, queries the _all_docs view, and returns the results as JSON.async def _list_documents(self, database: str, limit: int | None = None, include_docs: bool = False) -> list[TextContent]: """List all documents in a database.""" try: db = self._get_server()[database] # Build view query parameters params: dict[str, Any] = {"include_docs": include_docs} if limit is not None: params["limit"] = limit # Get all documents all_docs = db.view('_all_docs', **params) docs = [] for row in all_docs: if include_docs: docs.append(row.doc) else: docs.append({ "id": row.id, "key": row.key, "value": row.value }) result = { "documents": docs, "count": len(docs) } 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 listing documents: {str(e)}")]
- couchdb_mcp_server.py:201-222 (schema)Tool schema definition for couchdb_list_documents in the list_tools() function. Defines the tool name, description, and inputSchema with 'database' (required), 'limit' (optional), and 'include_docs' (optional) parameters.Tool( name="couchdb_list_documents", description="List all documents in a database with their IDs and revisions", inputSchema={ "type": "object", "properties": { "database": { "type": "string", "description": "Name of the database", }, "limit": { "type": "integer", "description": "Maximum number of documents to return", }, "include_docs": { "type": "boolean", "description": "Include full document content (default: false)", }, }, "required": ["database"], }, ),
- couchdb_mcp_server.py:302-307 (registration)Registration of the couchdb_list_documents tool in the call_tool() handler. Routes the tool name to the _list_documents method with appropriate argument extraction.elif name == "couchdb_list_documents": return await self._list_documents( arguments["database"], arguments.get("limit"), arguments.get("include_docs", False) )