get_scopes_and_collections_in_bucket
Retrieve scope and collection names within a Couchbase bucket, returning a structured dictionary with scope keys and associated collection lists for data organization.
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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/server.py:84-102 (handler)The handler function that executes the tool logic: connects to the Couchbase cluster and bucket, retrieves all scopes using bucket.collections().get_all_scopes(), and lists collections within each scope.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
- src/mcp_server.py:175-177 (registration)Registers the tool by adding it to the FastMCP server instance via the loop over ALL_TOOLS list, which includes get_scopes_and_collections_in_bucket.# Register all tools for tool in ALL_TOOLS: mcp.add_tool(tool)
- src/tools/__init__.py:35-50 (registration)Defines the ALL_TOOLS list that includes get_scopes_and_collections_in_bucket, used for batch registration of all tools.ALL_TOOLS = [ get_buckets_in_cluster, get_server_configuration_status, test_cluster_connection, get_scopes_and_collections_in_bucket, get_collections_in_scope, get_scopes_in_bucket, get_document_by_id, upsert_document_by_id, delete_document_by_id, get_schema_for_collection, run_sql_plus_plus_query, get_index_advisor_recommendations, list_indexes, get_cluster_health_and_services, ]
- src/tools/__init__.py:24-32 (registration)Imports the get_scopes_and_collections_in_bucket handler from server.py into the tools package for inclusion in ALL_TOOLS.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, )