get_me
Retrieve the authenticated user's profile information from HackMD, including account details and settings, to verify identity or access user-specific data.
Instructions
Get current user profile
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:9-15 (handler)Handler for 'get_me' tool — calls hackmdFetch('/me') to retrieve the current user's profile and wraps the result in a success/error response.
server.tool("get_me", "Get current user profile", {}, async () => { try { return success(await hackmdFetch("/me")); } catch (e) { return error((e as Error).message); } }); - src/tools.ts:6-15 (registration)Tool registration — registerTools() registers all tools including 'get_me' on the MCP server. The tool has no input parameters (empty schema) and returns the user profile.
export function registerTools(server: McpServer) { // ── User ────────────────────────────────────────────── server.tool("get_me", "Get current user profile", {}, async () => { try { return success(await hackmdFetch("/me")); } catch (e) { return error((e as Error).message); } }); - src/api.ts:13-38 (helper)hackmdFetch helper — generic API fetch function used by 'get_me' handler to make authenticated GET requests to the HackMD API.
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() helpers — format tool responses. 'get_me' uses both to wrap data or errors into MCP text content format.
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, }; } - src/tools.ts:9-9 (schema)Input schema for 'get_me' — an empty Zod object ({}) meaning the tool takes no parameters.
server.tool("get_me", "Get current user profile", {}, async () => {