Skip to main content
Glama

create-bucket

Create new storage buckets with configurable public access settings for organizing and managing cloud storage resources through the Insforge backend platform.

Instructions

Create new storage bucket

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyNoAPI key for authentication (optional if provided via --api_key)
bucketNameYes
isPublicNo

Implementation Reference

  • Handler function that creates a new storage bucket by sending a POST request to the backend API with bucketName and isPublic parameters. Includes error handling, response formatting, and background context addition.
    withUsageTracking('create-bucket', async ({ apiKey, bucketName, isPublic }) => { try { const actualApiKey = getApiKey(apiKey); const response = await fetch(`${API_BASE_URL}/api/storage/buckets`, { method: 'POST', headers: { 'x-api-key': actualApiKey, 'Content-Type': 'application/json', }, body: JSON.stringify({ bucketName, isPublic } as CreateBucketRequest), }); const result = await handleApiResponse(response); return await addBackgroundContext({ content: [ { type: 'text', text: formatSuccessMessage('Bucket created', result), }, ], }); } catch (error) { const errMsg = error instanceof Error ? error.message : 'Unknown error occurred'; return { content: [ { type: 'text', text: `Error creating bucket: ${errMsg}`, }, ], isError: true, }; } })
  • Zod input schema for the create-bucket tool: optional apiKey parameter and spreads fields from imported createBucketRequestSchema (bucketName, isPublic).
    apiKey: z .string() .optional() .describe('API key for authentication (optional if provided via --api_key)'), ...createBucketRequestSchema.shape, },
  • Registration of the 'create-bucket' MCP tool on the server using server.tool(), including description, input schema, and handler function.
    server.tool( 'create-bucket', 'Create new storage bucket', { apiKey: z .string() .optional() .describe('API key for authentication (optional if provided via --api_key)'), ...createBucketRequestSchema.shape, }, withUsageTracking('create-bucket', async ({ apiKey, bucketName, isPublic }) => { try { const actualApiKey = getApiKey(apiKey); const response = await fetch(`${API_BASE_URL}/api/storage/buckets`, { method: 'POST', headers: { 'x-api-key': actualApiKey, 'Content-Type': 'application/json', }, body: JSON.stringify({ bucketName, isPublic } as CreateBucketRequest), }); const result = await handleApiResponse(response); return await addBackgroundContext({ content: [ { type: 'text', text: formatSuccessMessage('Bucket created', result), }, ], }); } catch (error) { const errMsg = error instanceof Error ? error.message : 'Unknown error occurred'; return { content: [ { type: 'text', text: `Error creating bucket: ${errMsg}`, }, ], isError: true, }; } }) );
  • Helper wrapper function that adds usage tracking to tool handlers, logging success or failure.
    function withUsageTracking<T extends unknown[], R>( toolName: string, handler: (...args: T) => Promise<R> ): (...args: T) => Promise<R> { return async (...args: T): Promise<R> => { try { const result = await handler(...args); await trackToolUsage(toolName, true); return result; } catch (error) { await trackToolUsage(toolName, false); throw error; } }; }

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/InsForge/insforge-mcp'

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