update_note
Update an existing note on HackMD by changing its content, read or write permissions, or permalink to control access and sharing.
Instructions
Update a note's content or permissions
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note_id | Yes | Note ID | |
| content | No | New markdown content | |
| read_permission | No | Read permission | |
| write_permission | No | Write permission | |
| permalink | No | Custom permalink |
Implementation Reference
- src/tools.ts:80-109 (handler)Handler for the 'update_note' tool. Defines input schema (note_id, content, read_permission, write_permission, permalink) and executes a PATCH request to /notes/:note_id via hackmdFetch to update a note's content or permissions.
server.tool( "update_note", "Update a note's content or permissions", { note_id: z.string().min(1).describe("Note ID"), content: z.string().optional().describe("New markdown content"), read_permission: z .enum(["owner", "signed_in", "guest"]) .optional() .describe("Read permission"), write_permission: z .enum(["owner", "signed_in", "guest"]) .optional() .describe("Write permission"), permalink: z.string().optional().describe("Custom permalink"), }, async ({ note_id, content, read_permission, write_permission, permalink }) => { try { const body: Record<string, unknown> = {}; if (content !== undefined) body.content = content; if (read_permission !== undefined) body.readPermission = read_permission; if (write_permission !== undefined) body.writePermission = write_permission; if (permalink !== undefined) body.permalink = permalink; return success(await hackmdFetch(`/notes/${note_id}`, { method: "PATCH", body })); } catch (e) { return error((e as Error).message); } } ); - src/tools.ts:80-109 (registration)The 'update_note' tool is registered via server.tool() with its name, description, Zod schema, and async handler function, all in one call.
server.tool( "update_note", "Update a note's content or permissions", { note_id: z.string().min(1).describe("Note ID"), content: z.string().optional().describe("New markdown content"), read_permission: z .enum(["owner", "signed_in", "guest"]) .optional() .describe("Read permission"), write_permission: z .enum(["owner", "signed_in", "guest"]) .optional() .describe("Write permission"), permalink: z.string().optional().describe("Custom permalink"), }, async ({ note_id, content, read_permission, write_permission, permalink }) => { try { const body: Record<string, unknown> = {}; if (content !== undefined) body.content = content; if (read_permission !== undefined) body.readPermission = read_permission; if (write_permission !== undefined) body.writePermission = write_permission; if (permalink !== undefined) body.permalink = permalink; return success(await hackmdFetch(`/notes/${note_id}`, { method: "PATCH", body })); } catch (e) { return error((e as Error).message); } } );