Skip to main content
Glama

get_scopes_and_collections_in_bucket

Retrieve all scopes and collections within a Couchbase bucket to understand data organization and structure.

Instructions

Get the names of all scopes and collections in the bucket. Returns a dictionary with scope names as keys and lists of collection names as values.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes

Implementation Reference

  • The main handler function that connects to the Couchbase cluster and bucket, retrieves all scopes using bucket.collections().get_all_scopes(), and maps each scope to its collections, returning a dictionary of scopes to lists of collection names.
    def get_scopes_and_collections_in_bucket(
        ctx: Context, bucket_name: str
    ) -> dict[str, list[str]]:
        """Get the names of all scopes and collections in the bucket.
        Returns a dictionary with scope names as keys and lists of collection names as values.
        """
        cluster = get_cluster_connection(ctx)
        bucket = connect_to_bucket(cluster, bucket_name)
        try:
            scopes_collections = {}
            collection_manager = bucket.collections()
            scopes = collection_manager.get_all_scopes()
            for scope in scopes:
                collection_names = [c.name for c in scope.collections]
                scopes_collections[scope.name] = collection_names
            return scopes_collections
        except Exception as e:
            logger.error(f"Error getting scopes and collections: {e}")
            raise
  • Imports the get_scopes_and_collections_in_bucket handler from src/tools/server.py into the tools namespace.
    from .server import (
        get_buckets_in_cluster,
        get_cluster_health_and_services,
        get_collections_in_scope,
        get_scopes_and_collections_in_bucket,
        get_scopes_in_bucket,
        get_server_configuration_status,
        test_cluster_connection,
    )
  • Includes the tool function in the ALL_TOOLS list, which is later used to register all tools with the MCP server.
    ALL_TOOLS = [
        get_buckets_in_cluster,
        get_server_configuration_status,
        test_cluster_connection,
        get_scopes_and_collections_in_bucket,
  • Registers all tools from ALL_TOOLS, including get_scopes_and_collections_in_bucket, with the FastMCP server instance.
    for tool in ALL_TOOLS:
        mcp.add_tool(tool)

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/Couchbase-Ecosystem/mcp-server-couchbase'

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