referrals
Manage referral programs to earn USDC commissions by referring agents and providers on the402.ai marketplace. Track referrals, view earnings breakdowns, and withdraw commissions using API actions.
Instructions
Manage your referral program on the402.ai. Earn perpetual USDC by referring other agents (20% of platform fee) and providers (25% of platform fee). Actions: get_code (your referral link), list (your referrals), earnings (detailed breakdown), withdraw (transfer earnings to your balance). Requires API key.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | get_code = get your referral code/link, list = see who you referred, earnings = detailed breakdown, withdraw = transfer to balance |
Implementation Reference
- src/tools/referrals.ts:16-51 (handler)The handler function for the 'referrals' tool, which dispatches based on the 'action' argument.
async ({ action }) => { switch (action) { case "get_code": { const result = await client.authGet("/v1/referrals/code"); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } case "list": { const result = await client.authGet("/v1/referrals"); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } case "earnings": { const result = await client.authGet("/v1/referrals/earnings"); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } case "withdraw": { const result = await client.authPost("/v1/referrals/withdraw"); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } } } - src/tools/referrals.ts:9-15 (schema)Input schema validation using zod for the 'referrals' tool.
{ action: z .enum(["get_code", "list", "earnings", "withdraw"]) .describe( "get_code = get your referral code/link, list = see who you referred, earnings = detailed breakdown, withdraw = transfer to balance" ), }, - src/tools/referrals.ts:6-52 (registration)Registration of the 'referrals' tool within the McpServer.
server.tool( "referrals", "Manage your referral program on the402.ai. Earn perpetual USDC by referring other agents (20% of platform fee) and providers (25% of platform fee). Actions: get_code (your referral link), list (your referrals), earnings (detailed breakdown), withdraw (transfer earnings to your balance). Requires API key.", { action: z .enum(["get_code", "list", "earnings", "withdraw"]) .describe( "get_code = get your referral code/link, list = see who you referred, earnings = detailed breakdown, withdraw = transfer to balance" ), }, async ({ action }) => { switch (action) { case "get_code": { const result = await client.authGet("/v1/referrals/code"); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } case "list": { const result = await client.authGet("/v1/referrals"); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } case "earnings": { const result = await client.authGet("/v1/referrals/earnings"); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } case "withdraw": { const result = await client.authPost("/v1/referrals/withdraw"); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } } } );