score_task
Score tasks in Habitica by using direction 'up' to complete a to-do, daily, or positive habit, and 'down' to record a negative habit.
Instructions
Score a task. direction='up' completes a todo/daily or marks a + habit; 'down' is for negative habits.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | ||
| direction | No | up |
Implementation Reference
- index.js:144-155 (schema)Input schema definition for score_task tool: requires taskId (string) and optional direction ('up' or 'down', default 'up').
{ name: "score_task", description: "Score a task. direction='up' completes a todo/daily or marks a + habit; 'down' is for negative habits.", inputSchema: { type: "object", properties: { taskId: { type: "string" }, direction: { type: "string", enum: ["up", "down"], default: "up" }, }, required: ["taskId"], }, }, - index.js:388-395 (handler)Handler implementation: calls Habitica API POST /tasks/{taskId}/score/{direction}, then formats response with exp delta, gp, and level if present.
score_task: async ({ taskId, direction = "up" }) => { const r = (await api("POST", `/tasks/${taskId}/score/${direction}`)).data; const parts = [`Scored task ${direction}.`]; if (r?.exp != null) parts.push(`exp Δ ${r.delta?.toFixed?.(2) ?? ""} → ${r.exp}`); if (r?.gp != null) parts.push(`gp ${r.gp.toFixed(2)}`); if (r?.lvl != null) parts.push(`level ${r.lvl}`); return ok(parts.join(" · ")); }, - index.js:482-492 (registration)Generic tool call dispatcher that looks up handlers[name]; score_task is registered via this mechanism (handlers object includes score_task key).
server.setRequestHandler(CallToolRequestSchema, async (req) => { const { name, arguments: args = {} } = req.params; const fn = handlers[name]; if (!fn) throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`); try { return await fn(args); } catch (err) { if (err instanceof McpError) throw err; throw new McpError(ErrorCode.InternalError, err?.message ?? String(err)); } }); - index.js:53-53 (helper)Helper function 'ok' used by score_task handler to wrap the result text in MCP content response format.
const ok = (text) => ({ content: [{ type: "text", text }] }); - index.js:23-30 (helper)Helper function 'api' used by score_task handler to make HTTP requests 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", };