clicks_withdraw_yield
Withdraw earned yield and principal from an AI agent's DeFi position on Base. Authorized users can specify amounts or withdraw all available funds in USDC.
Instructions
Withdraw yield + principal for an agent. Only the agent, their operator, or contract owner can withdraw.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_address | Yes | Ethereum address of the AI agent | |
| amount | No | Amount to withdraw in USDC. Omit to withdraw everything. |
Implementation Reference
- mcp-server/src/index.ts:340-360 (handler)The handler implementation for the `clicks_withdraw_yield` tool in the MCP server, which interacts with a contract to withdraw funds.
async ({ agent_address, amount }) => { const signer = getSigner(); const splitter = new Contract(ADDRESSES.splitter, SPLITTER_ABI, signer); const amountWei = amount ? parseUnits(amount, 6) : 0n; const tx = await splitter.withdrawYield(agent_address, amountWei); await tx.wait(); return { content: [{ type: 'text' as const, text: JSON.stringify({ success: true, txHash: tx.hash, agent: agent_address, amount_usdc: amount || 'all', message: `Withdrawal complete. USDC returned to agent wallet (2% fee on yield only).`, }, null, 2), }], }; }, ); - mcp-server/src/index.ts:333-339 (registration)The registration of the `clicks_withdraw_yield` tool in the MCP server, including the input schema.
server.tool( 'clicks_withdraw_yield', 'Withdraw yield + principal for an agent. Only the agent, their operator, or contract owner can withdraw.', { agent_address: z.string().describe('Ethereum address of the AI agent'), amount: z.string().optional().describe('Amount to withdraw in USDC. Omit to withdraw everything.'), },