record_signup
Record affiliate signup conversion events using tracking codes from generate_tracked_link. Supports multiple networks and ensures idempotent logging with unique event IDs.
Instructions
Record an affiliate signup conversion event. Call this when one of your end users successfully signs up for a referred product. Requires the tracking_code returned by generate_tracked_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). This ties the signup back to the original referral. | |
| network | Yes | The affiliate network that reported this event. One of: 'partnerstack', 'impact', 'direct'. | |
| network_event_id | Yes | Unique event ID from the affiliate network (or any unique string for 'direct'). Used for idempotency -- duplicate calls with the same ID are ignored. | |
| signup_email | No | Email address the user signed up with (optional but recommended). | |
| metadata | No | Optional extra data to attach to this event. |
Implementation Reference
- src/index.js:391-411 (handler)The handler function that executes the record_signup tool logic. Validates required args (tracking_code, network, network_event_id), builds a body with optional signup_email and metadata, then POSTs to /api/webhooks/signup via the agentfuse helper.
async function handleRecordSignup(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"); } const body = { tracking_code: args.tracking_code, network: args.network, network_event_id: args.network_event_id, }; if (args.signup_email) body.signup_email = args.signup_email; if (args.metadata) body.metadata = args.metadata; return agentfuse("POST", "/api/webhooks/signup", body); } - src/index.js:216-254 (schema)Tool definition and input schema for record_signup. Defines name, description, and inputSchema with properties: tracking_code (string, required), network (enum: partnerstack/impact/direct, required), network_event_id (string, required), signup_email (string, optional), metadata (object, optional).
name: "record_signup", description: "Record an affiliate signup conversion event. Call this when one of your end users " + "successfully signs up for a referred product. Requires the tracking_code returned " + "by generate_tracked_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). " + "This ties the signup back to the original referral.", }, 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 event ID from the affiliate network (or any unique string for 'direct'). " + "Used for idempotency -- duplicate calls with the same ID are ignored.", }, signup_email: { type: "string", description: "Email address the user signed up with (optional but recommended).", }, metadata: { type: "object", description: "Optional extra data to attach to this event.", additionalProperties: true, }, }, required: ["tracking_code", "network", "network_event_id"], }, - src/index.js:446-453 (registration)Dispatch map (HANDLERS) that maps the tool name 'record_signup' to the handler function handleRecordSignup. This is used by the CallToolRequestSchema handler to 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, - src/index.js:32-78 (helper)The agentfuse helper function used by handleRecordSignup to make the actual HTTP POST request to the AgentFuse API. Handles auth, JSON serialization/parsing, and error handling.
export async function agentfuse(method, path, body = null) { const apiKey = process.env.AGENTFUSE_API_KEY || ""; const baseUrl = (process.env.AGENTFUSE_API_URL || "https://api.agentfuse.io").replace(/\/$/, ""); if (!apiKey) { throw new McpError( ErrorCode.InvalidRequest, "AGENTFUSE_API_KEY environment variable is not set. " + "Get a key at https://agentfuse.io and add it to your MCP config." ); } const url = `${baseUrl}${path}`; const headers = { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", "User-Agent": "agentfuse-mcp/1.1.2", }; const options = { method, headers }; if (body !== null) { options.body = JSON.stringify(body); } const res = await fetch(url, options); const text = await res.text(); let data; try { data = JSON.parse(text); } catch { throw new McpError( ErrorCode.InternalError, `AgentFuse API returned non-JSON response (status ${res.status}): ${text.slice(0, 200)}` ); } if (!res.ok) { const msg = data?.error || data?.message || JSON.stringify(data); throw new McpError( ErrorCode.InternalError, `AgentFuse API error ${res.status}: ${msg}` ); } return data; }