update_comment
Update a comment by its ID, optionally modifying its content.
Instructions
Update a comment.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the comment to update | |
| content | No | A string representing the content of a comment. |
Implementation Reference
- src/tools/comments.ts:51-59 (handler)The handler function for the update_comment tool. It destructures `id` from the input, sends a PATCH request to `/comments/{id}` via apiPatch, logs the response, and returns a formatted success/error result using formatUpdate/formatError.
async ({ id, ...body }) => { try { const record = await apiPatch<EduframeRecord>(`/comments/${id}`, body); void logResponse("update_comment", { id, ...body }, record); return formatUpdate(record, "comment"); } catch (error) { return formatError(error); } }, - src/tools/comments.ts:43-50 (schema)The schema/metadata for the update_comment tool. Defines the input schema requiring `id` (positive integer) and optional `content` (string).
{ description: "Update a comment.", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the comment to update"), content: z.string().optional().describe("A string representing the content of a comment."), }, }, - src/tools/comments.ts:41-60 (registration)Registration of the update_comment tool via server.registerTool within the registerCommentTools function.
server.registerTool( "update_comment", { description: "Update a comment.", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the comment to update"), content: z.string().optional().describe("A string representing the content of a comment."), }, }, async ({ id, ...body }) => { try { const record = await apiPatch<EduframeRecord>(`/comments/${id}`, body); void logResponse("update_comment", { id, ...body }, record); return formatUpdate(record, "comment"); } catch (error) { return formatError(error); } }, ); - src/api.ts:201-212 (helper)The apiPatch helper function used by the update_comment handler to make a PATCH request to the Eduframe API.
export async function apiPatch<T>(path: string, body: unknown): Promise<T> { const { token } = getConfig(); const url = buildUrl(path); const response = await fetch(url.toString(), { method: "PATCH", headers: buildHeaders(token), body: JSON.stringify(body), }); return handleResponse<T>(response); } - src/formatters.ts:102-111 (helper)The formatUpdate helper used to format the response after successfully updating a comment.
export function formatUpdate(record: EduframeRecord, resourceName: string): CallToolResult { return { content: [ { type: "text", text: `Successfully updated ${resourceName}:\n\n${formatJSON(record)}${RESPONSE_LOG_HINT}`, }, ], }; }