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'],
    },
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 states the tool retrieves a document but lacks details on permissions required, error handling (e.g., if the document doesn't exist), response format, or any side effects. This is a significant gap for a read operation in a database context, where such information is crucial for safe usage.

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 any unnecessary words. It is front-loaded with the core action and resource, making it easy to parse. Every part of the sentence earns its place by conveying essential information, achieving optimal conciseness.

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 complexity of database operations and the lack of annotations and output schema, the description is incomplete. It doesn't address behavioral aspects like error cases, return values, or security requirements, which are critical for an agent to use the tool effectively. The description alone is insufficient for safe and informed tool invocation in this context.

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?

The input schema has 100% description coverage, with clear documentation for both parameters ('dbName' and 'docId'). The description adds no additional meaning beyond what the schema provides, such as examples or constraints. According to the rules, when schema coverage is high (>80%), the baseline score is 3, which applies here as the description doesn't compensate with extra param details.

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 action ('Get') and resource ('a document from a database'), making the purpose immediately understandable. It distinguishes from siblings like 'createDocument' and 'deleteDatabase' by specifying retrieval rather than creation or deletion. However, it doesn't explicitly differentiate from 'listDatabases' in terms of scope (single document vs. listing databases), which prevents a perfect score.

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. It doesn't mention prerequisites (e.g., needing an existing database and document), exclusions (e.g., not for creating or deleting), or comparisons to sibling tools like 'listDatabases' for broader queries. This leaves the agent with minimal context for tool selection.

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

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