get_task_checklist
Retrieve checklist items for any task to track subtasks and progress.
Instructions
Get checklist items for a task.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes |
Implementation Reference
- index.js:400-408 (handler)The handler function for get_task_checklist. Fetches the task by ID via the Habitica API, extracts the checklist, and returns formatted text with completion status for each item.
get_task_checklist: async ({ taskId }) => { const t = (await api("GET", `/tasks/${taskId}`)).data; const list = t?.checklist ?? []; if (list.length === 0) return ok(`Task "${t.text}" has no checklist items.`); return ok( `Task: ${t.text}\n` + list.map((i) => `${i.completed ? "✓" : "○"} ${i.text} (${i.id})`).join("\n"), ); }, - index.js:166-175 (schema)The tool definition including name, description, and inputSchema for get_task_checklist. Requires taskId as a string.
// Checklist { name: "get_task_checklist", description: "Get checklist items for a task.", inputSchema: { type: "object", properties: { taskId: { type: "string" } }, required: ["taskId"], }, }, - index.js:475-480 (registration)The MCP server setup and registration. Server is created, then ListToolsRequestSchema returns the tools array (which includes get_task_checklist), and CallToolRequestSchema dispatches to the handlers object.
const server = new Server( { name: "habitca-mcp", version: "1.0.0" }, { capabilities: { tools: {} } }, ); server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools })); - index.js:53-54 (helper)Helper function `ok` used to format the text response returned by get_task_checklist.
const ok = (text) => ({ content: [{ type: "text", text }] }); const json = (obj) => ok(JSON.stringify(obj, null, 2)); - index.js:23-51 (helper)Helper function `api` used by get_task_checklist to make the GET request to the Habitica API.
async function api(method, path, body) { const url = `${API_BASE}${path}`; const headers = { "x-api-user": USER_ID, "x-api-key": API_TOKEN, "x-client": `${USER_ID}-${APP_ID}`, "Content-Type": "application/json", }; const res = await fetch(url, { method, headers, body: body === undefined ? undefined : JSON.stringify(body), }); const text = await res.text(); let payload; try { payload = text ? JSON.parse(text) : {}; } catch { payload = { raw: text }; } if (!res.ok) { const msg = payload?.message || payload?.error || res.statusText; throw new McpError( ErrorCode.InternalError, `Habitica API ${res.status}: ${msg}`, ); } return payload; }