update_note
Modify an existing note on HackMD by updating its content, permalink, read, or write permissions using the note ID and new payload.
Instructions
Update an existing note
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| noteId | Yes | Note ID | |
| payload | Yes | Update note options |
Implementation Reference
- tools/userNotes.ts:121-137 (handler)The handler function that implements the core logic of the 'update_note' tool by calling the HackMD API's updateNote method and formatting the response.
async ({ noteId, payload }) => { try { const result = await client.updateNote(noteId, payload); return { content: [ { type: "text", text: `Note ${noteId} updated successfully:\n${JSON.stringify(result, null, 2)}`, }, ], }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } - utils/schemas.ts:61-80 (schema)Zod schema defining the payload options for updating a note, including content, permissions, and permalink.
export const UpdateNoteOptionsSchema = z.object({ content: z.string().optional().describe("New note content"), readPermission: z .enum([ NotePermissionRole.OWNER, NotePermissionRole.SIGNED_IN, NotePermissionRole.GUEST, ]) .optional() .describe("Read permission"), writePermission: z .enum([ NotePermissionRole.OWNER, NotePermissionRole.SIGNED_IN, NotePermissionRole.GUEST, ]) .optional() .describe("Write permission"), permalink: z.string().optional().describe("Custom permalink"), }); - tools/userNotes.ts:107-120 (registration)MCP server tool registration for 'update_note', including tool name, description, input schema, and metadata hints.
server.tool( "update_note", "Update an existing note", { noteId: z.string().describe("Note ID"), payload: UpdateNoteOptionsSchema.describe("Update note options"), }, { title: "Update a note", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true, },