Skip to main content
Glama

Couchbase MCP Server for LLMs

by Aniket310101
collection.ts1.89 kB
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { Cluster, Bucket } from 'couchbase'; import { z } from 'zod'; export function registerCollectionTools(server: McpServer, cluster: Cluster, bucket: Bucket) { server.tool( 'createCollection', 'Create a new collection in a scope', { collectionName: z.string().describe('The name of the collection to create'), scopeName: z.string().describe('The name of the scope to create the collection in'), }, async ({ collectionName, scopeName }) => { try { const collectionManager = bucket.collections(); await collectionManager.createCollection(collectionName, scopeName); return { content: [{ type: 'text', text: `Collection ${collectionName} created successfully in scope ${scopeName}` }], isError: false }; } catch (error: any) { return { content: [{ type: 'text', text: `Failed to create collection: ${error.message}` }], isError: true }; } } ); server.tool( 'dropCollection', 'Delete a collection from a scope', { collectionName: z.string().describe('The name of the collection to drop'), scopeName: z.string().describe('The name of the scope to drop the collection from'), }, async ({ collectionName, scopeName }) => { try { const collectionManager = bucket.collections(); await collectionManager.dropCollection(collectionName, scopeName); return { content: [{ type: 'text', text: `Collection ${collectionName} dropped successfully from scope ${scopeName}` }], isError: false }; } catch (error: any) { return { content: [{ type: 'text', text: `Failed to drop collection: ${error.message}` }], isError: true }; } } ); }

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/Aniket310101/MCP-Server-Couchbase'

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