Skip to main content
Glama
robertoamoreno

CouchDB MCP Server

createDocument

Create or update documents in CouchDB databases using specified document IDs and data to store or modify information.

Instructions

Create a new document or update an existing document in a database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dbNameYesDatabase name
docIdYesDocument ID
dataYesDocument data

Implementation Reference

  • The handler function that executes the createDocument tool. It validates input parameters, retrieves the CouchDB database instance, inserts or updates the document using the nano client's insert method, determines if it was created or updated based on _rev, and returns a success or error message in the MCP content format.
    private async handleCreateDocument(args: any) {
      if (!args.dbName || !args.docId || !args.data) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Missing required parameters: dbName, docId, data'
        );
      }
    
      try {
        const db = await getDatabase(args.dbName);
        const response = await db.insert(args.data, args.docId);
        const action = args.data._rev ? 'updated' : 'created';
        return {
          content: [
            {
              type: 'text',
              text: `Document ${action} with ID: ${response.id}, rev: ${response.rev}`,
            },
          ],
        };
      } catch (error: any) {
        const action = args.data._rev ? 'updating' : 'creating';
        return {
          content: [
            {
              type: 'text',
              text: `Error ${action} document: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • The input schema definition for the createDocument tool, specifying the required properties: dbName (string), docId (string), and data (object).
    inputSchema: {
      type: 'object',
      properties: {
        dbName: {
          type: 'string',
          description: 'Database name',
        },
        docId: {
          type: 'string',
          description: 'Document ID',
        },
        data: {
          type: 'object',
          description: 'Document data',
        },
      },
      required: ['dbName', 'docId', 'data'],
    },
  • src/index.ts:90-111 (registration)
    The registration of the createDocument tool in the ListToolsRequest handler, providing name, description, and input schema.
    {
      name: 'createDocument',
      description: 'Create a new document or update an existing document in a database',
      inputSchema: {
        type: 'object',
        properties: {
          dbName: {
            type: 'string',
            description: 'Database name',
          },
          docId: {
            type: 'string',
            description: 'Document ID',
          },
          data: {
            type: 'object',
            description: 'Document data',
          },
        },
        required: ['dbName', 'docId', 'data'],
      },
    },
  • src/index.ts:236-237 (registration)
    The dispatch case in the CallToolRequest handler that routes calls to the createDocument handler method.
    case 'createDocument':
      return this.handleCreateDocument(request.params.arguments);
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. While it mentions the tool can both create and update documents, it doesn't specify whether updates are partial or full replacements, what permissions are required, whether operations are idempotent, or what happens on conflicts. For a mutation tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that clearly states the tool's dual functionality. It's appropriately sized for the tool's purpose without unnecessary elaboration, though it could potentially be more front-loaded with critical behavioral information given the lack of annotations.

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?

For a document creation/update tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what happens when creating versus updating, what the response looks like, error conditions, or important behavioral constraints. Given the mutation nature and complexity of the operation, more contextual information is needed.

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, so all three parameters (dbName, docId, data) are documented in the schema. The description doesn't add any meaningful parameter semantics beyond what's already in the schema, such as format requirements for docId or constraints on data structure. This meets the baseline expectation when schema coverage is complete.

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 tool's purpose with specific verbs ('create' and 'update') and resource ('document in a database'), making it easy to understand what the tool does. However, it doesn't explicitly distinguish this from sibling tools like 'createDatabase' or 'getDocument', which would require more specific differentiation.

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 'createDatabase' for creating databases or 'getDocument' for retrieving documents. There's no mention of prerequisites, error conditions, or typical use cases, leaving the agent with insufficient context for appropriate 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