-
Notifications
You must be signed in to change notification settings - Fork 16
Support multiple buckets #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Introduced `connect_to_bucket` utility to establish bucket connections using the cluster context. - Updated relevant functions to accept `bucket_name` as an argument where necessary, improving flexibility in handling Couchbase operations. - Enhanced documentation and logging for better clarity on connection status and error handling.
…able usage - Added new features for retrieving bucket, scope, and collection lists in the MCP server. - Removed references to `CB_BUCKET_NAME` from environment variable sections
…the utils module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the codebase to support multiple buckets instead of being limited to a single bucket. The changes remove bucket-specific configuration requirements and enable dynamic bucket access through function parameters.
Key changes:
- Removes bucket-specific configuration and validation logic
- Updates all bucket-dependent functions to accept bucket_name as a parameter
- Adds new helper functions for bucket, scope, and collection discovery
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/utils/context.py | Removes bucket context management and validation, simplifies cluster connection logic |
src/utils/connection.py | Removes logging statement from bucket connection function |
src/utils/config.py | Removes validation functions for required parameters |
src/utils/init.py | Updates exports to reflect removed validation functions and context changes |
src/tools/server.py | Adds bucket discovery functions and updates existing functions to accept bucket parameters |
src/tools/query.py | Updates query functions to accept bucket_name parameter |
src/tools/kv.py | Updates key-value operations to accept bucket_name parameter |
src/tools/init.py | Adds new bucket discovery functions to exports |
src/mcp_server.py | Removes bucket-name CLI option and configuration |
README.md | Updates documentation to reflect removal of bucket configuration requirement |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
# Test basic connectivity by getting bucket name | ||
bucket_name = bucket.name | ||
cluster = get_cluster_connection(ctx) | ||
bucket = connect_to_bucket(cluster, bucket_name) if bucket_name else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function attempts to connect to a bucket when bucket_name is provided, but there's no validation that bucket_name is not an empty string. An empty string would pass the truthiness check but would likely cause connection issues.
bucket = connect_to_bucket(cluster, bucket_name) if bucket_name else None | |
bucket = connect_to_bucket(cluster, bucket_name) if bucket_name and bucket_name.strip() else None |
Copilot uses AI. Check for mistakes.
if scope_name not in scopes_and_collections: | ||
logger.error(f"Scope {scope_name} not found in bucket {bucket_name}") | ||
raise ValueError(f"Scope {scope_name} not found in bucket {bucket_name}") | ||
return scopes_and_collections[scope_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function calls get_scopes_and_collections_in_bucket which retrieves all scopes and collections, but only returns collections for a specific scope. This is inefficient as it fetches unnecessary data.
return scopes_and_collections[scope_name] | |
cluster = get_cluster_connection(ctx) | |
bucket = connect_to_bucket(cluster, bucket_name) | |
try: | |
scopes = bucket.collections().get_all_scopes() | |
for scope in scopes: | |
if scope.name == scope_name: | |
return [c.name for c in scope.collections] | |
logger.error(f"Scope {scope_name} not found in bucket {bucket_name}") | |
raise ValueError(f"Scope {scope_name} not found in bucket {bucket_name}") | |
except Exception as e: | |
logger.error(f"Error getting collections in scope: {e}") | |
raise |
Copilot uses AI. Check for mistakes.
No description provided.