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
| Name | Required | Description | Default |
|---|---|---|---|
| apiKey | No | API key for authentication (optional if provided via --api_key) | |
| bucketName | Yes | ||
| isPublic | No |
Implementation Reference
- src/shared/tools.ts:688-722 (handler)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, }; } })
- src/shared/tools.ts:682-687 (schema)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, },
- src/shared/tools.ts:678-723 (registration)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, }; } }) );
- src/shared/tools.ts:174-188 (helper)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; } }; }