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)
        )
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool lists documents with IDs and revisions, implying a read-only operation, but fails to detail critical aspects like pagination behavior, error handling, or performance considerations (e.g., impact of include_docs on response size). This leaves significant gaps for a tool with parameters.

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, efficient sentence that directly states the tool's purpose without unnecessary details. It is front-loaded and wastes no words, making it easy for an agent to parse quickly.

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?

Given the tool's complexity (3 parameters, no output schema, and no annotations), the description is insufficient. It lacks information on return values (e.g., format of listed documents), error cases, or how parameters interact, leaving the agent with incomplete guidance for proper invocation.

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 the input schema fully documents parameters like database, limit, and include_docs. The description adds no additional semantic context beyond what the schema provides, such as explaining default behaviors or constraints, resulting in a baseline score of 3.

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 verb ('List') and resource ('all documents in a database'), specifying the output includes IDs and revisions. However, it doesn't explicitly differentiate from sibling tools like couchdb_search_documents or couchdb_get_document, which could also retrieve documents but with different scopes or methods.

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 like couchdb_search_documents or couchdb_get_document. It lacks context about use cases, such as retrieving a comprehensive list versus filtered searches, leaving the agent to infer usage based on tool names alone.

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