Skip to main content
Glama
ahmedselimmansor-ctrl

IBM Cloud MCP Server

cos_list_buckets

Retrieves all Cloud Object Storage buckets for a given instance CRN, enabling efficient bucket inventory management.

Instructions

List all Cloud Object Storage buckets

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instance_crnYesCOS instance CRN

Implementation Reference

  • The 'cos_list_buckets' tool handler: uses IBMCloudAPIClient.request() to GET https://config.cloud-object-storage.cloud.ibm.com/v1/b with the instance CRN as the ibm-service-instance-id header. The handler is an inline async function passed to server.tool().
    server.tool("cos_list_buckets", "List all Cloud Object Storage buckets", {
      instance_crn: z.string().describe("COS instance CRN"),
    }, async (p) => safeTool(() =>
      client.request(`${cfgBase}/b`, {headers:{"ibm-service-instance-id":p.instance_crn}})
    ));
  • The input schema for 'cos_list_buckets': requires a single parameter 'instance_crn' of type string (Zod schema), described as 'COS instance CRN'.
    server.tool("cos_list_buckets", "List all Cloud Object Storage buckets", {
      instance_crn: z.string().describe("COS instance CRN"),
  • The tool is registered via server.tool('cos_list_buckets', ...) inside the registerCOSTools() function in src/tools/cos/index.ts.
    server.tool("cos_list_buckets", "List all Cloud Object Storage buckets", {
      instance_crn: z.string().describe("COS instance CRN"),
    }, async (p) => safeTool(() =>
      client.request(`${cfgBase}/b`, {headers:{"ibm-service-instance-id":p.instance_crn}})
    ));
  • src/server.ts:59-60 (registration)
    The registerCOSTools function is called from src/server.ts to register all COS tools, including cos_list_buckets.
    registerCOSTools(server, client, config);
    console.error(`  ✓ Cloud Object Storage (12 tools)`);
  • The IBMCloudAPIClient.request() method is the underlying helper that executes the HTTP request for the tool handler. It handles authentication, retries, and error parsing.
    async request<T = unknown>(
      url: string,
      options: RequestOptions = {}
    ): Promise<T> {
      const {
        method = "GET",
        headers = {},
        body,
        queryParams,
        skipAuth = false,
        retries = 3,
      } = options;
    
      // Build URL with query params
      const fullUrl = this.buildUrl(url, queryParams);
    
      // Build headers
      const requestHeaders: Record<string, string> = {
        "Accept": "application/json",
        ...headers,
      };
    
      if (!skipAuth) {
        const token = await this.auth.getToken();
        requestHeaders["Authorization"] = `Bearer ${token}`;
      }
    
      if (body && !requestHeaders["Content-Type"]) {
        requestHeaders["Content-Type"] = "application/json";
      }
    
      const requestBody =
        body && typeof body === "object" ? JSON.stringify(body) : (body as string | undefined);
    
      // Execute with retry logic
      let lastError: Error | null = null;
    
      for (let attempt = 0; attempt < retries; attempt++) {
        try {
          const response = await fetch(fullUrl, {
            method,
            headers: requestHeaders,
            body: requestBody,
          });
    
          if (!response.ok) {
            const error = await parseAPIError(response);
    
            // Retry on rate limit with exponential backoff
            if (error instanceof RateLimitError && attempt < retries - 1) {
              const retryAfter = response.headers.get("Retry-After");
              const waitMs = retryAfter
                ? parseInt(retryAfter, 10) * 1000
                : Math.pow(2, attempt + 1) * 1000;
              await this.sleep(waitMs);
              lastError = error;
              continue;
            }
    
            // Retry on 5xx errors
            if (response.status >= 500 && attempt < retries - 1) {
              await this.sleep(Math.pow(2, attempt + 1) * 1000);
              lastError = error;
              continue;
            }
    
            throw error;
          }
    
          // Handle 204 No Content
          if (response.status === 204) {
            return undefined as T;
          }
    
          // Check if response has body
          const contentType = response.headers.get("content-type") || "";
          if (contentType.includes("application/json")) {
            return (await response.json()) as T;
          }
    
          return (await response.text()) as T;
        } catch (error) {
          if (error instanceof TypeError && attempt < retries - 1) {
            // Network error — retry
            await this.sleep(Math.pow(2, attempt + 1) * 1000);
            lastError = error;
            continue;
          }
          throw error;
        }
      }
    
      throw lastError || new Error("Request failed after retries");
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It does not mention that listing is scoped to the instance specified by 'instance_crn', nor does it discuss pagination, rate limits, or authorization beyond the CRN. The description is too brief for a tool with no annotations.

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 a single, clear sentence with no waste. For a simple list tool with one parameter, this level of conciseness is appropriate, though it could benefit from slight expansion.

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

Completeness3/5

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

Given the simplicity of the tool (1 param, no output schema, no annotations), the description provides the basic purpose. However, it lacks details about the return format (e.g., list of bucket names or full details) and any limitations, making it moderately complete for an agent.

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?

The schema provides 100% coverage for the single parameter 'instance_crn' with its own description. The tool description adds no additional meaning to this parameter, hence baseline score of 3.

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

Purpose5/5

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

The description clearly states the verb 'List' and resource 'Cloud Object Storage buckets'. It is specific and distinct from sibling tools like 'cos_list_objects' which lists objects within a bucket.

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?

No explicit guidance on when to use this tool versus alternatives like 'cos_get_bucket_config'. Usage is implied from the name and description, but no when-not-to-use or context provided.

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/ahmedselimmansor-ctrl/IBM_cloud_MCP_SERVER'

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