update_manual_crypto
Update the balance of a manually-tracked cryptocurrency asset in your LunchMoney financial data to maintain accurate portfolio tracking.
Instructions
Update a manually-managed cryptocurrency asset balance
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes |
Implementation Reference
- src/tools/crypto.ts:59-98 (handler)Handler function that updates a manual cryptocurrency asset balance by making a PUT request to the LunchMoney API endpoint `/crypto/manual/{crypto_id}` with the provided balance.async ({ input }) => { const { baseUrl, lunchmoneyApiToken } = getConfig(); const body: any = {}; if (input.balance !== undefined) { body.balance = input.balance.toString(); } const response = await fetch(`${baseUrl}/crypto/manual/${input.crypto_id}`, { method: "PUT", headers: { Authorization: `Bearer ${lunchmoneyApiToken}`, "Content-Type": "application/json", }, body: JSON.stringify(body), }); if (!response.ok) { return { content: [ { type: "text", text: `Failed to update crypto asset: ${response.statusText}`, }, ], }; } const result = await response.json(); return { content: [ { type: "text", text: JSON.stringify(result), }, ], }; }
- src/tools/crypto.ts:49-57 (schema)Zod schema defining the input parameters: crypto_id (required number) and balance (optional number).input: z.object({ crypto_id: z .number() .describe("ID of the crypto asset to update"), balance: z .number() .optional() .describe("Updated balance of the crypto asset"), }),
- src/tools/crypto.ts:45-99 (registration)Registration of the 'update_manual_crypto' tool using server.tool(), including name, description, schema, and handler.server.tool( "update_manual_crypto", "Update a manually-managed cryptocurrency asset balance", { input: z.object({ crypto_id: z .number() .describe("ID of the crypto asset to update"), balance: z .number() .optional() .describe("Updated balance of the crypto asset"), }), }, async ({ input }) => { const { baseUrl, lunchmoneyApiToken } = getConfig(); const body: any = {}; if (input.balance !== undefined) { body.balance = input.balance.toString(); } const response = await fetch(`${baseUrl}/crypto/manual/${input.crypto_id}`, { method: "PUT", headers: { Authorization: `Bearer ${lunchmoneyApiToken}`, "Content-Type": "application/json", }, body: JSON.stringify(body), }); if (!response.ok) { return { content: [ { type: "text", text: `Failed to update crypto asset: ${response.statusText}`, }, ], }; } const result = await response.json(); return { content: [ { type: "text", text: JSON.stringify(result), }, ], }; } );