t2000_withdraw
Transfer funds from savings to checking accounts. Specify dollar amount or use "all" for full balance, with optional preview mode before executing.
Instructions
Withdraw from savings back to checking. Amount is in dollars. Use "all" to withdraw everything. Set dryRun: true to preview.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Dollar amount to withdraw, or "all" | |
| dryRun | No | Preview without signing (default: false) |
Implementation Reference
- packages/mcp/src/tools/write.ts:113-149 (handler)The implementation of the 't2000_withdraw' tool, which handles withdrawals from savings, including a dry-run preview mode and mutex-locked execution.
server.tool( 't2000_withdraw', 'Withdraw from savings back to checking. Amount is in dollars. Use "all" to withdraw everything. Set dryRun: true to preview.', { amount: z.union([z.number(), z.literal('all')]).describe('Dollar amount to withdraw, or "all"'), dryRun: z.boolean().optional().describe('Preview without signing (default: false)'), }, async ({ amount, dryRun }) => { try { if (dryRun) { agent.enforcer.assertNotLocked(); const positions = await agent.positions(); const health = await agent.healthFactor(); const savings = positions.positions .filter(p => p.type === 'save') .reduce((sum, p) => sum + p.amount, 0); return { content: [{ type: 'text', text: JSON.stringify({ preview: true, amount: amount === 'all' ? savings : amount, currentSavings: savings, currentHealthFactor: health.healthFactor, }), }], }; } const result = await mutex.run(() => agent.withdraw({ amount })); return { content: [{ type: 'text', text: JSON.stringify(result) }] }; } catch (err) { return errorResult(err); } }, );