Skip to main content
Glama
robertoamoreno

CouchDB MCP Server

createDatabase

Create a new CouchDB database by specifying a database name. This tool enables AI assistants to set up databases for storing and managing documents.

Instructions

Create a new CouchDB database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dbNameYesDatabase name

Implementation Reference

  • The handler function for the 'createDatabase' tool. Validates the input dbName and calls the getDatabase helper to create the database if it does not exist, returning a formatted success or error response.
    private async handleCreateDatabase(args: any) { if (!args.dbName || typeof args.dbName !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Invalid database name'); } try { await getDatabase(args.dbName); return { content: [ { type: 'text', text: `Database ${args.dbName} created successfully`, }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error creating database: ${error.message}`, }, ], isError: true, }; } }
  • Input schema definition for the 'createDatabase' tool, requiring a 'dbName' string parameter.
    inputSchema: { type: 'object', properties: { dbName: { type: 'string', description: 'Database name', }, }, required: ['dbName'], },
  • src/index.ts:54-67 (registration)
    Registration of the 'createDatabase' tool in the ListToolsRequestSchema handler, providing name, description, and schema.
    { name: 'createDatabase', description: 'Create a new CouchDB database', inputSchema: { type: 'object', properties: { dbName: { type: 'string', description: 'Database name', }, }, required: ['dbName'], }, },
  • src/index.ts:230-231 (registration)
    Dispatch registration in the CallToolRequestSchema switch statement, routing 'createDatabase' calls to the handler.
    case 'createDatabase': return this.handleCreateDatabase(request.params.arguments);
  • Helper function that gets an existing CouchDB database or creates it if not found (404), then returns the DocumentScope. This performs the core logic for database creation.
    export async function getDatabase(dbName: string): Promise<DocumentScope<any>> { try { await couch.db.get(dbName); } catch (error: any) { if (error.statusCode === 404) { await couch.db.create(dbName); } else { throw error; } } return couch.use(dbName); }

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