Skip to main content
Glama

gcp_storage_list

Read-onlyIdempotent

List Google Cloud Storage buckets and objects to manage cloud storage resources. Specify a bucket to view its contents or list all buckets in your project.

Instructions

GCS 목록|버킷 목록|스토리지|storage list - Cloud Storage 버킷/객체 목록을 조회합니다

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketNo버킷 이름 (없으면 버킷 목록, 있으면 해당 버킷의 객체 목록)
prefixNo객체 필터링 prefix (예: "logs/")
project_idNoGCP 프로젝트 ID (기본: 현재 설정된 프로젝트)
limitNo최대 항목 수 (기본: 50)
formatNo출력 형식 (기본: text)text

Implementation Reference

  • The asynchronous handler function that implements the core logic for listing GCS buckets or objects using gcloud storage commands, parsing output, and formatting results.
    export async function gcpStorageList(args: GcpStorageListArgs) {
      try {
        const projectId = await getProjectId(args.project_id);
        const limit = args.limit || 50;
    
        if (args.bucket) {
          // List objects in bucket
          let path = `gs://${args.bucket}`;
          if (args.prefix) {
            path += `/${args.prefix}`;
          }
    
          const command = `storage ls -l "${path}" --project=${projectId}`;
          const result = await executeGcloud(command, 30000);
    
          // Parse ls output
          const lines = result.stdout.trim().split('\n').filter(Boolean);
          const objects: any[] = [];
    
          for (const line of lines.slice(0, limit)) {
            // Format: "    SIZE  CREATED  gs://bucket/path"
            const match = line.match(/^\s*(\d+)\s+(\S+)\s+gs:\/\/(.+)$/);
            if (match) {
              objects.push({
                name: match[3].replace(`${args.bucket}/`, ''),
                size: parseInt(match[1], 10),
                created: match[2],
              });
            } else if (line.includes('gs://')) {
              // Directory-like entry
              const pathMatch = line.match(/gs:\/\/(.+)/);
              if (pathMatch) {
                objects.push({
                  name: pathMatch[1].replace(`${args.bucket}/`, ''),
                  size: 0,
                  isDirectory: true,
                });
              }
            }
          }
    
          if (args.format === 'json') {
            return {
              content: [
                {
                  type: 'text',
                  text: JSON.stringify({
                    project: projectId,
                    bucket: args.bucket,
                    prefix: args.prefix,
                    totalObjects: objects.length,
                    objects,
                  }, null, 2),
                },
              ],
            };
          }
    
          return {
            content: [
              {
                type: 'text',
                text: `📦 버킷: ${args.bucket}\n${args.prefix ? `📂 Prefix: ${args.prefix}\n` : ''}\n${formatStorageList(objects, false)}`,
              },
            ],
          };
        } else {
          // List buckets
          const command = `storage buckets list --project=${projectId} --format=json`;
          const result = await executeGcloud(command, 30000);
    
          let buckets: any[] = [];
          try {
            buckets = JSON.parse(result.stdout || '[]');
          } catch {
            buckets = [];
          }
    
          const bucketList = buckets.slice(0, limit).map((b: any) => ({
            name: b.name || b.id,
            location: b.location,
            storageClass: b.storageClass,
            created: b.timeCreated,
          }));
    
          if (args.format === 'json') {
            return {
              content: [
                {
                  type: 'text',
                  text: JSON.stringify({
                    project: projectId,
                    totalBuckets: bucketList.length,
                    buckets: bucketList,
                  }, null, 2),
                },
              ],
            };
          }
    
          return {
            content: [
              {
                type: 'text',
                text: `프로젝트: ${projectId}\n\n${formatStorageList(bucketList, true)}`,
              },
            ],
          };
        }
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: formatError(error),
            },
          ],
          isError: true,
        };
      }
    }
  • The tool definition object including name, description, annotations, and detailed inputSchema for parameters like bucket, prefix, project_id, limit, and format.
    export const gcpStorageListDefinition = {
      name: 'gcp_storage_list',
      description: 'GCS 목록|버킷 목록|스토리지|storage list - Cloud Storage 버킷/객체 목록을 조회합니다',
      annotations: {
        title: 'Cloud Storage 목록 조회',
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: true,
      },
      inputSchema: {
        type: 'object' as const,
        properties: {
          bucket: {
            type: 'string',
            description: '버킷 이름 (없으면 버킷 목록, 있으면 해당 버킷의 객체 목록)',
          },
          prefix: {
            type: 'string',
            description: '객체 필터링 prefix (예: "logs/")',
          },
          project_id: {
            type: 'string',
            description: 'GCP 프로젝트 ID (기본: 현재 설정된 프로젝트)',
          },
          limit: {
            type: 'number',
            description: '최대 항목 수 (기본: 50)',
            default: 50,
          },
          format: {
            type: 'string',
            enum: ['text', 'json'],
            description: '출력 형식 (기본: text)',
            default: 'text',
          },
        },
        required: [],
      },
    };
  • src/index.ts:77-89 (registration)
    Collection of all tool definitions into a 'tools' array, including gcpStorageListDefinition, used by the MCP ListTools handler.
    const tools = [
      gcpSetupDefinition,
      gcpLogsReadDefinition,
      gcpRunStatusDefinition,
      gcpRunLogsDefinition,
      gcpSqlQueryDefinition,
      gcpSqlProxyDefinition,
      gcpStorageListDefinition,
      gcpSecretListDefinition,
      gcpAuthStatusDefinition,
      gcpServicesListDefinition,
      gcpBillingInfoDefinition,
    ];
  • src/index.ts:223-224 (registration)
    Dispatch case in the main CallToolRequest handler that routes calls to the gcpStorageList function.
    case 'gcp_storage_list':
      return await gcpStorageList(args as any) as CallToolResult;
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds valuable context beyond annotations by specifying the dual behavior (list buckets when no bucket parameter, list objects within bucket when bucket provided). Annotations already cover read-only, open-world, idempotent, and non-destructive traits, but the description usefully clarifies the conditional logic that isn't captured in structured fields.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with a single sentence that efficiently communicates the core functionality. The pipe-separated keywords at the beginning ('GCS 목록|버킷 목록|스토리지|storage list') provide helpful search aliases without unnecessary verbosity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the comprehensive annotations (read-only, idempotent, etc.) and full parameter documentation in the schema, the description provides adequate context for this listing tool. The main gap is the lack of output schema, but the description mentions the listing action which aligns with the tool's purpose, making it reasonably complete for the agent's needs.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the input schema thoroughly documents all 5 parameters. The description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline of 3 where the schema does the heavy lifting for parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as listing Cloud Storage buckets/objects in Korean, with specific verbs ('조회합니다' - to retrieve/list) and resources ('버킷/객체 목록' - bucket/object list). It distinguishes from siblings by focusing on storage listing, though it doesn't explicitly differentiate from similar listing tools like gcp_secret_list or gcp_services_list beyond the storage domain.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context for Cloud Storage operations but doesn't provide explicit guidance on when to use this tool versus alternatives. It lacks statements about when-not-to-use or comparisons with sibling tools, leaving the agent to infer based on the storage-specific focus.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/su-record/hi-gcloud'

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