cast_spell
Cast a class spell on a target task or party member to gain buffs or healing in Habitica.
Instructions
Cast a class spell, optionally on a target task or party member.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spellId | Yes | ||
| targetId | No |
Implementation Reference
- index.js:332-343 (schema)Tool definition/schema for 'cast_spell' with inputSchema requiring spellId and optional targetId.
{ name: "cast_spell", description: "Cast a class spell, optionally on a target task or party member.", inputSchema: { type: "object", properties: { spellId: { type: "string" }, targetId: { type: "string" }, }, required: ["spellId"], }, }, - index.js:455-461 (handler)Handler for cast_spell: calls the Habitica API with spellId (and optional targetId) and returns a success message.
cast_spell: async ({ spellId, targetId }) => { const path = targetId ? `/user/class/cast/${spellId}?targetId=${encodeURIComponent(targetId)}` : `/user/class/cast/${spellId}`; await api("POST", path); return ok(`Cast ${spellId}${targetId ? ` on ${targetId}` : ""}.`); }, - index.js:482-492 (registration)Registration via CallToolRequestSchema on the MCP Server, routing tool name 'cast_spell' to the handler.
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)); } });