buy_reward
Purchase a custom reward using its unique key.
Instructions
Buy a custom reward by key.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes |
Implementation Reference
- index.js:297-305 (registration)Tool definition for 'buy_reward' registered in the tools array with name, description, and inputSchema requiring 'key'.
{ name: "buy_reward", description: "Buy a custom reward by key.", inputSchema: { type: "object", properties: { key: { type: "string" } }, required: ["key"], }, }, - index.js:445-448 (handler)Handler function for 'buy_reward' that sends a POST request to /user/buy/{key} and returns the resulting gold balance.
buy_reward: async ({ key }) => { const r = (await api("POST", `/user/buy/${encodeURIComponent(key)}`)).data; return ok(`Bought reward "${key}". gp: ${r?.gp ?? "?"}`); }, - index.js:482-492 (registration)The CallToolRequestSchema handler that dispatches tool calls (including 'buy_reward') to the handlers map.
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)); } });