delete_note
Permanently delete a HackMD note by specifying its unique note ID.
Instructions
Delete a note
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note_id | Yes | Note ID |
Implementation Reference
- src/tools.ts:111-124 (handler)The tool 'delete_note' is registered and its handler function deletes a note by ID via a DELETE HTTP request to the HackMD API.
server.tool( "delete_note", "Delete a note", { note_id: z.string().min(1).describe("Note ID"), }, async ({ note_id }) => { try { return success(await hackmdFetch(`/notes/${note_id}`, { method: "DELETE" })); } catch (e) { return error((e as Error).message); } } ); - src/tools.ts:111-116 (schema)Input schema: the tool accepts a single required parameter 'note_id' (string, min length 1).
server.tool( "delete_note", "Delete a note", { note_id: z.string().min(1).describe("Note ID"), }, - src/tools.ts:111-124 (registration)Registration of 'delete_note' on the MCP server via server.tool().
server.tool( "delete_note", "Delete a note", { note_id: z.string().min(1).describe("Note ID"), }, async ({ note_id }) => { try { return success(await hackmdFetch(`/notes/${note_id}`, { method: "DELETE" })); } catch (e) { return error((e as Error).message); } } ); - src/api.ts:13-27 (helper)hackmdFetch helper: performs authenticated HTTP requests to the HackMD API, used by delete_note to issue the DELETE.
export async function hackmdFetch( path: string, options: { method?: string; body?: unknown } = {} ): Promise<unknown> { const { method = "GET", body } = options; const token = getToken(); const res = await fetch(`${API_BASE}${path}`, { method, headers: { Authorization: `Bearer ${token}`, ...(body ? { "Content-Type": "application/json" } : {}), }, ...(body ? { body: JSON.stringify(body) } : {}), }); - src/helpers.ts:1-12 (helper)success and error helper functions: format the MCP tool response, used by delete_note's handler.
export function success(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; } export function error(message: string) { return { content: [{ type: "text" as const, text: JSON.stringify({ error: message }) }], isError: true as const, }; }