create_approval
Create an approval request for a content entry by providing the story's numeric ID and the approver's numeric ID.
Instructions
Creates an approval request for a story in a Storyblok space.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| story_id | Yes | Numeric ID of the content entry to be approved | |
| approver_id | Yes | Numeric ID of the user who will approve it |
Implementation Reference
- src/tools/approvals.ts:64-89 (handler)The create_approval tool handler. Uses Zod schema for input validation (story_id and approver_id), sends a POST request to Storyblok's /approvals/ endpoint with the approval payload, and returns the JSON response or an error.
// Tool: create_approval server.tool( 'create_approval', 'Creates an approval request for a story in a Storyblok space.', { story_id: z.number().describe('Numeric ID of the content entry to be approved'), approver_id: z.number().describe('Numeric ID of the user who will approve it'), }, async ({ story_id, approver_id }) => { try { const payload = { approval: { story_id, approver_id, }, }; const data = await apiPost('/approvals/', payload); return createJsonResponse(data); } catch (error) { if (error instanceof APIError) { return createErrorResponse(error); } throw error; } } ); - src/tools/approvals.ts:68-71 (schema)Zod input schema for create_approval, requiring story_id (number) and approver_id (number).
{ story_id: z.number().describe('Numeric ID of the content entry to be approved'), approver_id: z.number().describe('Numeric ID of the user who will approve it'), }, - src/tools/index.ts:58-58 (registration)Registration of the approvals module (including create_approval) in the central tool aggregator.
registerApprovals(server); - src/tools/approvals.ts:10-10 (registration)The registerApprovals function that registers all approval tools including create_approval with the MCP server.
export function registerApprovals(server: McpServer): void { - src/utils/api.ts:195-206 (helper)The apiPost helper utility used by create_approval to send POST requests 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); }