Skip to main content
Glama
robertoamoreno

CouchDB MCP Server

getDocument

Retrieve documents from CouchDB databases by specifying database name and document ID to access stored data.

Instructions

Get a document from a database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dbNameYesDatabase name
docIdYesDocument ID

Implementation Reference

  • The core handler function that implements the getDocument tool logic: validates dbName and docId, fetches the database, retrieves the document using the CouchDB client's get method, and formats the response as JSON text or handles errors.
    private async handleGetDocument(args: any) { if (!args.dbName || !args.docId) { throw new McpError( ErrorCode.InvalidParams, 'Missing required parameters: dbName, docId' ); } try { const db = await getDatabase(args.dbName); const doc = await db.get(args.docId); return { content: [ { type: 'text', text: JSON.stringify(doc, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error retrieving document: ${error.message}`, }, ], isError: true, }; } }
  • src/index.ts:112-129 (registration)
    Registers the getDocument tool in the ListToolsRequest handler's tool list, providing its name, description, and input schema.
    { name: 'getDocument', description: 'Get a document from a database', inputSchema: { type: 'object', properties: { dbName: { type: 'string', description: 'Database name', }, docId: { type: 'string', description: 'Document ID', }, }, required: ['dbName', 'docId'], }, }
  • src/index.ts:238-239 (registration)
    In the CallToolRequest handler, routes calls to the 'getDocument' tool to its specific handler method.
    case 'getDocument': return this.handleGetDocument(request.params.arguments);
  • Defines the input schema for the getDocument tool, specifying required dbName and docId as strings.
    inputSchema: { type: 'object', properties: { dbName: { type: 'string', description: 'Database name', }, docId: { type: 'string', description: 'Document ID', }, }, required: ['dbName', 'docId'], },

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/robertoamoreno/couchdb-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server