Skip to main content
Glama
robertoamoreno

CouchDB MCP Server

getDocument

Retrieve specific documents from a CouchDB database by providing the database name and document ID using this MCP server tool.

Instructions

Get a document from a database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dbNameYesDatabase name
docIdYesDocument ID

Implementation Reference

  • The handler function that validates input parameters, retrieves the database instance using getDatabase, fetches the document using the CouchDB client's get method, and returns the document as JSON or an error message.
    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, }; } }
  • Defines the tool's metadata including name, description, and input schema specifying required dbName and docId parameters.
    { 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)
    Registers the tool handler in the switch statement for CallToolRequestSchema, dispatching getDocument calls to handleGetDocument.
    case 'getDocument': return this.handleGetDocument(request.params.arguments);

Other Tools

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

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