gcp_list_storage_buckets
List all Cloud Storage buckets in a specified Google Cloud Platform project to manage and audit your object storage resources.
Instructions
List all Cloud Storage buckets in GCP
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | No | GCP project ID | |
| region | No | GCP region | us-central1 |
Implementation Reference
- src/adapters/gcp-adapter.ts:102-131 (handler)Core handler logic that lists GCP Cloud Storage buckets using the @google-cloud/storage client, fetches metadata, and maps to GCPStorageBucket type.async listStorageBuckets(): Promise<GCPStorageBucket[]> { await this.initializeClients(); if (!this.storage) throw new Error('Storage client not initialized'); try { const [buckets] = await this.storage.getBuckets(); const bucketList: GCPStorageBucket[] = []; for (const bucket of buckets) { const [metadata] = await bucket.getMetadata(); bucketList.push({ id: bucket.name, type: 'storage', name: bucket.name, projectId: this.projectId, location: metadata.location || this.region, status: 'running', bucketName: bucket.name, storageClass: metadata.storageClass, labels: metadata.labels ? Object.fromEntries( Object.entries(metadata.labels).map(([k, v]) => [k, v || '']) ) : undefined, }); } return bucketList; } catch (error) { throw new Error(`Failed to list storage buckets: ${error instanceof Error ? error.message : String(error)}`); } }
- src/tools/gcp-tools.ts:85-96 (handler)Tool handler case in handleGCPTool that invokes GCPAdapter.listStorageBuckets() and formats the response.case 'gcp_list_storage_buckets': { const buckets = await adapter.listStorageBuckets(); return { total: buckets.length, buckets: buckets.map((bucket) => ({ id: bucket.id, name: bucket.bucketName, location: bucket.location, storageClass: bucket.storageClass, })), }; }
- src/tools/gcp-tools.ts:23-40 (registration)Registers the gcp_list_storage_buckets tool in the gcpTools array, including name, description, and input schema.{ name: 'gcp_list_storage_buckets', description: 'List all Cloud Storage buckets in GCP', inputSchema: { type: 'object', properties: { projectId: { type: 'string', description: 'GCP project ID', }, region: { type: 'string', description: 'GCP region', default: 'us-central1', }, }, }, },
- src/tools/gcp-tools.ts:26-39 (schema)Input schema definition for the tool, specifying projectId and optional region parameters.inputSchema: { type: 'object', properties: { projectId: { type: 'string', description: 'GCP project ID', }, region: { type: 'string', description: 'GCP region', default: 'us-central1', }, }, },