hatch_pet
Hatch a pet by combining an egg with a hatching potion using the Habitica API to add a new pet to your inventory.
Instructions
Hatch a pet from an egg + hatching potion.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| egg | Yes | ||
| hatchingPotion | Yes |
Implementation Reference
- index.js:271-282 (schema)Tool definition and input schema for 'hatch_pet'. Defines the tool name, description, and required parameters (egg, hatchingPotion).
{ name: "hatch_pet", description: "Hatch a pet from an egg + hatching potion.", inputSchema: { type: "object", properties: { egg: { type: "string" }, hatchingPotion: { type: "string" }, }, required: ["egg", "hatchingPotion"], }, }, - index.js:437-440 (handler)Handler function for 'hatch_pet'. Calls the Habitica API POST /user/hatch/{egg}/{hatchingPotion} to hatch a pet from an egg and hatching potion.
hatch_pet: async ({ egg, hatchingPotion }) => { await api("POST", `/user/hatch/${encodeURIComponent(egg)}/${encodeURIComponent(hatchingPotion)}`); return ok(`Hatched ${egg}-${hatchingPotion}.`); }, - index.js:480-492 (registration)Server registration: tools are listed via ListToolsRequestSchema and dispatched to handlers via CallToolRequestSchema which looks up the handler by name.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools })); 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)); } });