Skip to main content
Glama

Couchbase MCP Server for LLMs

by Aniket310101
scope.ts2.38 kB
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { Cluster, Bucket } from 'couchbase'; import { z } from 'zod'; export function registerScopeTools(server: McpServer, cluster: Cluster, bucket: Bucket) { server.tool( 'createScope', 'Create a new scope in the bucket', { scopeName: z.string().describe('Name of the scope to create'), }, async ({ scopeName }) => { try { await bucket.collections().createScope(scopeName); return { content: [{ type: 'text', text: `Successfully created scope: ${scopeName}` }], isError: false, }; } catch (error: any) { return { content: [{ type: 'text', text: `Failed to create scope: ${error.message}` }], isError: true, }; } } ); server.tool( 'deleteScope', 'Delete an existing scope from the bucket', { scopeName: z.string().describe('Name of the scope to delete'), }, async ({ scopeName }) => { try { await bucket.collections().dropScope(scopeName); return { content: [{ type: 'text', text: `Successfully deleted scope: ${scopeName}` }], isError: false, }; } catch (error: any) { return { content: [{ type: 'text', text: `Failed to delete scope: ${error.message}` }], isError: true, }; } } ); server.tool( 'listScopes', 'List all scopes in the bucket', {}, async () => { try { const scopes = await bucket.collections().getAllScopes(); const scopeNames = scopes.map(scope => scope.name); return { content: [{ type: 'text', text: JSON.stringify(scopeNames, null, 2) }], isError: false, }; } catch (error: any) { return { content: [{ type: 'text', text: `Failed to list scopes: ${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