update_comment
Update a comment's content by providing discussion and comment IDs along with a JSON message array. Modify existing comments in Storyblok discussions.
Instructions
Updates a comment in a discussion via the Storyblok Management API.
Required:
discussion_id: Numeric ID of the discussion.
comment_id: Numeric ID of the comment.
Payload:
message_json: Required. Array of message objects, each with keys "type", "text", "attrs".
message: Optional string or null.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| discussion_id | Yes | Numeric ID of the discussion | |
| comment_id | Yes | Numeric ID of the comment | |
| message_json | Yes | Required. Array of message objects, each with keys "type", "text", "attrs" | |
| message | No | Optional string or null |
Implementation Reference
- src/tools/discussions.ts:267-306 (handler)The handler function for the update_comment tool. Calls apiPut to the Storyblok Management API endpoint /discussions/{discussion_id}/comments/{comment_id} with a payload containing message_json (array of message objects) and optional message string. Returns JSON response or error.
// Tool: update_comment server.tool( 'update_comment', `Updates a comment in a discussion via the Storyblok Management API. Required: - discussion_id: Numeric ID of the discussion. - comment_id: Numeric ID of the comment. Payload: - message_json: Required. Array of message objects, each with keys "type", "text", "attrs". - message: Optional string or null.`, { discussion_id: z.number().describe('Numeric ID of the discussion'), comment_id: z.number().describe('Numeric ID of the comment'), message_json: z .array(z.record(z.unknown())) .describe('Required. Array of message objects, each with keys "type", "text", "attrs"'), message: z.string().optional().describe('Optional string or null'), }, async ({ discussion_id, comment_id, message_json, message }) => { try { const payload: { comment: { message_json: Record<string, unknown>[]; message?: string } } = { comment: { message_json, }, }; if (message !== undefined) { payload.comment.message = message; } const data = await apiPut(`/discussions/${discussion_id}/comments/${comment_id}`, payload); return createJsonResponse(data); } catch (error) { if (error instanceof APIError) { return createErrorResponse(error); } throw error; } } ); - src/tools/discussions.ts:267-306 (schema)Input schema for update_comment tool: discussion_id (number), comment_id (number), message_json (array of record objects), and optional message (string). Defined using Zod.
// Tool: update_comment server.tool( 'update_comment', `Updates a comment in a discussion via the Storyblok Management API. Required: - discussion_id: Numeric ID of the discussion. - comment_id: Numeric ID of the comment. Payload: - message_json: Required. Array of message objects, each with keys "type", "text", "attrs". - message: Optional string or null.`, { discussion_id: z.number().describe('Numeric ID of the discussion'), comment_id: z.number().describe('Numeric ID of the comment'), message_json: z .array(z.record(z.unknown())) .describe('Required. Array of message objects, each with keys "type", "text", "attrs"'), message: z.string().optional().describe('Optional string or null'), }, async ({ discussion_id, comment_id, message_json, message }) => { try { const payload: { comment: { message_json: Record<string, unknown>[]; message?: string } } = { comment: { message_json, }, }; if (message !== undefined) { payload.comment.message = message; } const data = await apiPut(`/discussions/${discussion_id}/comments/${comment_id}`, payload); return createJsonResponse(data); } catch (error) { if (error instanceof APIError) { return createErrorResponse(error); } throw error; } } ); - src/tools/discussions.ts:267-306 (registration)Registration of the update_comment tool via server.tool('update_comment', ...) inside the registerDiscussions function.
// Tool: update_comment server.tool( 'update_comment', `Updates a comment in a discussion via the Storyblok Management API. Required: - discussion_id: Numeric ID of the discussion. - comment_id: Numeric ID of the comment. Payload: - message_json: Required. Array of message objects, each with keys "type", "text", "attrs". - message: Optional string or null.`, { discussion_id: z.number().describe('Numeric ID of the discussion'), comment_id: z.number().describe('Numeric ID of the comment'), message_json: z .array(z.record(z.unknown())) .describe('Required. Array of message objects, each with keys "type", "text", "attrs"'), message: z.string().optional().describe('Optional string or null'), }, async ({ discussion_id, comment_id, message_json, message }) => { try { const payload: { comment: { message_json: Record<string, unknown>[]; message?: string } } = { comment: { message_json, }, }; if (message !== undefined) { payload.comment.message = message; } const data = await apiPut(`/discussions/${discussion_id}/comments/${comment_id}`, payload); return createJsonResponse(data); } catch (error) { if (error instanceof APIError) { return createErrorResponse(error); } throw error; } } ); - src/tools/discussions.ts:18-18 (registration)The registerDiscussions function that registers all discussion tools including update_comment.
export function registerDiscussions(server: McpServer): void { - src/tools/index.ts:35-35 (registration)Import of registerDiscussions from './discussions.js' in the tool aggregator.
import { registerDiscussions } from './discussions.js';