Skip to main content
Glama
andyfe76

CouchDB MCP Server

by andyfe76

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
NameRequiredDescriptionDefault
databaseYesName of the database
doc_idYesDocument ID

Implementation Reference

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

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