create_asset_folder
Organize assets by creating a new folder in a Storyblok space; specify a parent folder ID to nest it under an existing folder.
Instructions
Create a new asset folder in the current Storyblok space.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the new asset folder | |
| parent_id | No | ID of the parent folder (if nested) |
Implementation Reference
- src/tools/assets-folder.ts:68-94 (handler)Handler function for the 'create_asset_folder' tool. Accepts 'name' (required) and 'parent_id' (optional) parameters. Constructs a payload and POSTs to '/asset_folders/' via apiPost. Returns the API response as JSON.
// Tool: create_asset_folder server.tool( 'create_asset_folder', 'Create a new asset folder in the current Storyblok space.', { name: z.string().describe('Name of the new asset folder'), parent_id: z.number().optional().describe('ID of the parent folder (if nested)'), }, async ({ name, parent_id }) => { try { const payload: { asset_folder: { name: string; parent_id?: number } } = { asset_folder: { name }, }; if (parent_id !== undefined) { payload.asset_folder.parent_id = parent_id; } const data = await apiPost('/asset_folders/', payload); return createJsonResponse(data); } catch (error) { if (error instanceof APIError) { return createErrorResponse(error); } throw error; } } ); - src/tools/assets-folder.ts:72-75 (schema)Input schema for 'create_asset_folder': name (z.string, required) and parent_id (z.number, optional). Defined inline in the server.tool() call using Zod.
{ name: z.string().describe('Name of the new asset folder'), parent_id: z.number().optional().describe('ID of the parent folder (if nested)'), }, - src/tools/index.ts:93-93 (registration)Registration call: registerAssetsFolders(server) is invoked in the registerAllTools function, which wires up all tools including 'create_asset_folder' to the MCP server.
registerAssetsFolders(server); - src/tools/index.ts:33-33 (registration)Import of the registerAssetsFolders function from './assets-folder.js' in the tool aggregator index.
import { registerAssetsFolders } from './assets-folder.js'; - src/utils/api.ts:195-206 (helper)The apiPost helper function used by the handler to make the POST request to the Storyblok Management API.
export async function apiPost<T = unknown>( path: string, body: unknown ): Promise<T> { const url = buildManagementUrl(path); const response = await fetch(url, { method: 'POST', headers: getManagementHeaders(), body: JSON.stringify(body), }); return handleResponse<T>(response, url); }