get_history
Retrieve your HackMD reading history to see notes you have previously viewed. Access the list of recently read notes for quick reference.
Instructions
Get reading history
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_history"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:128-134 (handler)The handler function for the 'get_history' tool. It calls hackmdFetch('/history') to retrieve the user's reading history from the HackMD API.
server.tool("get_history", "Get reading history", {}, async () => { try { return success(await hackmdFetch("/history")); } catch (e) { return error((e as Error).message); } }); - src/api.ts:13-38 (helper)The hackmdFetch helper that performs the actual HTTP request to the HackMD API. Called by get_history's handler to fetch '/history'.
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)Utility helpers success() and error() used by get_history's handler to format the response (or error) returned by the tool.
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, }; }