Skip to main content
Glama
andyfe76

CouchDB MCP Server

by andyfe76

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
NameRequiredDescriptionDefault
databaseYesName of the database
limitNoMaximum number of documents to return
include_docsNoInclude full document content (default: false)

Implementation Reference

  • 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)}")]
  • 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"], }, ),
  • 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) )

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