delete_component
Delete a component from your Storyblok space by providing its unique ID. Remove unused or outdated components to keep your content model organized.
Instructions
Deletes a component by ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the component to delete |
Implementation Reference
- src/tools/components.ts:295-306 (handler)Main handler for delete_component tool - deletes a component by ID via DELETE /components/{id} API call
async ({ id }) => { try { await apiDelete(`/components/${id}`); return createJsonResponse({ message: `Component ${id} has been successfully deleted.` }); } catch (error) { if (error instanceof APIError) { return createErrorResponse(error); } throw error; } } ); - src/tools/components.ts:289-306 (registration)Registration of delete_component tool with the MCP server, including name, description, and input schema
server.tool( 'delete_component', 'Deletes a component by ID.', { id: z.string().describe('ID of the component to delete'), }, async ({ id }) => { try { await apiDelete(`/components/${id}`); return createJsonResponse({ message: `Component ${id} has been successfully deleted.` }); } catch (error) { if (error instanceof APIError) { return createErrorResponse(error); } throw error; } } ); - src/tools/components.ts:292-294 (schema)Input schema for delete_component - requires a single string 'id' parameter
{ id: z.string().describe('ID of the component to delete'), }, - src/utils/api.ts:227-234 (helper)The apiDelete helper function used to perform the DELETE HTTP request to the Storyblok Management API
export async function apiDelete<T = unknown>(path: string): Promise<T> { const url = buildManagementUrl(path); const response = await fetch(url, { method: 'DELETE', headers: getManagementHeaders(), }); return handleResponse<T>(response, url); } - src/utils/response.ts:37-53 (helper)The createErrorResponse helper used to format error responses
export function createErrorResponse( error: unknown, errorCode?: string ): McpErrorResponse { const message = error instanceof Error ? error.message : String(error); const response: McpErrorResponse = { isError: true, content: [{ type: 'text', text: message }], }; if (errorCode) { response.errorCode = errorCode; response.errorMessage = message; } return response; } - src/utils/response.ts:26-30 (helper)The createJsonResponse helper used to format successful JSON responses
export function createJsonResponse(data: unknown): McpSuccessResponse { return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }], }; }