get_bucket_details
Retrieve detailed information about a specific Cloud Storage bucket in Google Cloud Platform by providing the project ID and bucket name.
Instructions
Get detailed information about a specific Cloud Storage bucket.
Args:
project_id: The ID of the GCP project
bucket_name: The name of the bucket to get details for
Returns:
Detailed information about the specified Cloud Storage bucket
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket_name | Yes | ||
| project_id | Yes |
Implementation Reference
- The handler function for the 'get_bucket_details' tool. It uses the Google Cloud Storage client to retrieve bucket details including name, location, storage class, creation time, versioning, labels, and more, then formats them into a string response.@mcp.tool() def get_bucket_details(project_id: str, bucket_name: str) -> str: """ Get detailed information about a specific Cloud Storage bucket. Args: project_id: The ID of the GCP project bucket_name: The name of the bucket to get details for Returns: Detailed information about the specified Cloud Storage bucket """ try: from google.cloud import storage # Initialize the Storage client client = storage.Client(project=project_id) # Get the bucket bucket = client.get_bucket(bucket_name) # Format the response details = [] details.append(f"Name: {bucket.name}") details.append(f"Project: {project_id}") details.append(f"Location: {bucket.location or 'Unknown'}") details.append(f"Storage Class: {bucket.storage_class or 'Unknown'}") details.append(f"Created: {bucket.time_created.strftime('%Y-%m-%d %H:%M:%S UTC') if bucket.time_created else 'Unknown'}") details.append(f"Versioning Enabled: {bucket.versioning_enabled}") details.append(f"Requester Pays: {bucket.requester_pays}") details.append(f"Lifecycle Rules: {len(bucket.lifecycle_rules) if bucket.lifecycle_rules else 0} rules defined") details.append(f"Labels: {bucket.labels or 'None'}") details.append(f"CORS: {bucket.cors or 'None'}") details_str = "\n".join(details) return f""" Cloud Storage Bucket Details: {details_str} """ except Exception as e: return f"Error getting bucket details: {str(e)}"
- src/gcp_mcp/server.py:42-42 (registration)Top-level registration call for all storage tools, including 'get_bucket_details', by invoking the register_tools function from the storage module.storage_tools.register_tools(mcp)
- src/gcp_mcp/gcp_modules/storage/tools.py:6-7 (registration)The register_tools function in the storage module that defines and registers the 'get_bucket_details' tool using @mcp.tool() decorator.def register_tools(mcp): """Register all storage tools with the MCP server."""