update_team_note
Update a team note's content and permissions on HackMD by specifying the team path, note ID, optional new markdown content, read/write permissions, and custom permalink.
Instructions
Update a team note
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| team_path | Yes | Team path | |
| 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:197-229 (handler)Handler implementation for 'update_team_note'. Registers the tool with Zod schema validation (team_path, note_id, content, read_permission, write_permission, permalink) and sends a PATCH request to /teams/:team_path/notes/:note_id via hackmdFetch.
server.tool( "update_team_note", "Update a team note", { team_path: z.string().min(1).describe("Team path"), 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 ({ team_path, 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(`/teams/${team_path}/notes/${note_id}`, { method: "PATCH", body }) ); } catch (e) { return error((e as Error).message); } } ); - src/tools.ts:197-213 (schema)Zod schema for 'update_team_note' input parameters: team_path (required), note_id (required), and optional content, read_permission, write_permission, permalink.
server.tool( "update_team_note", "Update a team note", { team_path: z.string().min(1).describe("Team path"), 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"), }, - src/tools.ts:6-6 (registration)The function registerTools is called in server.ts to register all tools including 'update_team_note'.
export function registerTools(server: McpServer) { - src/api.ts:13-38 (helper)hackmdFetch helper: makes authenticated HTTP requests to HackMD API, used by the handler to send the PATCH request.
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) } : {}), }); if (!res.ok) { const text = await res.text().catch(() => ""); throw new Error(`HackMD API ${method} ${path} → ${res.status}: ${text}`); } if (res.status === 204) return { success: true }; if (res.status === 202) return { success: true, status: "accepted" }; return res.json(); } - src/helpers.ts:1-12 (helper)success and error response formatters used by the handler to return MCP-compatible results.
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, }; }