Skip to main content
Glama

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
NameRequiredDescriptionDefault
actionYesget_code = get your referral code/link, list = see who you referred, earnings = detailed breakdown, withdraw = transfer to balance

Implementation Reference

  • 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) },
    				],
    			};
    		}
    	}
    }
  • 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"
    		),
    },
  • 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) },
    					],
    				};
    			}
    		}
    	}
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/the402ai/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server