record_commission
Record affiliate commission events with a tracking code and network event ID. Idempotent, so each commission is safely recorded only once.
Instructions
Record an affiliate commission event (e.g. when a referred user makes a purchase or renews a subscription). Requires the tracking_code from the original affiliate link. Idempotent -- safe to call multiple times with the same network + network_event_id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tracking_code | Yes | The tracking code from the affiliate link (returned by generate_tracked_link). | |
| network | Yes | The affiliate network that reported this event. One of: 'partnerstack', 'impact', 'direct'. | |
| network_event_id | Yes | Unique commission event ID from the affiliate network. Used for idempotency. | |
| amount | Yes | Commission amount in dollars (e.g. 29.99). | |
| currency | No | ISO 4217 currency code (default: 'USD'). | USD |
| commission_type | No | Type of commission. One of: 'initial', 'recurring', 'one_time'. Defaults to 'recurring'. | |
| period_start | No | Billing period start date in ISO 8601 format (optional). | |
| period_end | No | Billing period end date in ISO 8601 format (optional). | |
| metadata | No | Optional extra data (e.g. order ID, plan name). |
Implementation Reference
- src/index.js:413-440 (handler)The handler function for the record_commission tool. Validates required arguments (tracking_code, network, network_event_id, amount), builds the request body with optional fields (currency, commission_type, period_start, period_end, metadata), and POSTs to /api/webhooks/commission.
async function handleRecordCommission(args) { if (!args.tracking_code) { throw new McpError(ErrorCode.InvalidParams, "tracking_code is required"); } if (!args.network) { throw new McpError(ErrorCode.InvalidParams, "network is required (partnerstack, impact, or direct)"); } if (!args.network_event_id) { throw new McpError(ErrorCode.InvalidParams, "network_event_id is required"); } if (args.amount === undefined) { throw new McpError(ErrorCode.InvalidParams, "amount is required"); } const body = { tracking_code: args.tracking_code, network: args.network, network_event_id: args.network_event_id, amount: args.amount, }; if (args.currency) body.currency = args.currency; if (args.commission_type) body.commission_type = args.commission_type; if (args.period_start) body.period_start = args.period_start; if (args.period_end) body.period_end = args.period_end; if (args.metadata) body.metadata = args.metadata; return agentfuse("POST", "/api/webhooks/commission", body); } - src/index.js:256-312 (schema)Input schema definition for record_commission. Defines the tool name, description, and JSON Schema properties including required fields: tracking_code (string), network (enum: partnerstack/impact/direct), network_event_id (string), amount (number), and optional fields: currency, commission_type, period_start, period_end, metadata.
{ name: "record_commission", description: "Record an affiliate commission event (e.g. when a referred user makes a purchase " + "or renews a subscription). Requires the tracking_code from the original affiliate link. " + "Idempotent -- safe to call multiple times with the same network + network_event_id.", inputSchema: { type: "object", properties: { tracking_code: { type: "string", description: "The tracking code from the affiliate link (returned by generate_tracked_link).", }, network: { type: "string", description: "The affiliate network that reported this event. One of: 'partnerstack', 'impact', 'direct'.", enum: ["partnerstack", "impact", "direct"], }, network_event_id: { type: "string", description: "Unique commission event ID from the affiliate network. Used for idempotency.", }, amount: { type: "number", description: "Commission amount in dollars (e.g. 29.99).", minimum: 0, }, currency: { type: "string", description: "ISO 4217 currency code (default: 'USD').", default: "USD", }, commission_type: { type: "string", description: "Type of commission. One of: 'initial', 'recurring', 'one_time'. Defaults to 'recurring'.", enum: ["initial", "recurring", "one_time"], }, period_start: { type: "string", description: "Billing period start date in ISO 8601 format (optional).", }, period_end: { type: "string", description: "Billing period end date in ISO 8601 format (optional).", }, metadata: { type: "object", description: "Optional extra data (e.g. order ID, plan name).", additionalProperties: true, }, }, required: ["tracking_code", "network", "network_event_id", "amount"], }, }, - src/index.js:446-454 (registration)Dispatch map (HANDLERS) that registers record_commission to the handleRecordCommission function so the MCP server can route incoming tool calls.
export const HANDLERS = { list_affiliate_programs: handleListAffiliatePrograms, get_affiliate_program: handleGetAffiliateProgram, generate_tracked_link: handleGenerateTrackedLink, list_tracked_links: handleListTrackedLinks, get_stats: handleGetStats, record_signup: handleRecordSignup, record_commission: handleRecordCommission, };