Skip to main content
Glama
sai4447

agentfuse-mcp

by sai4447

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

TableJSON Schema
NameRequiredDescriptionDefault
tracking_codeYesThe tracking code from the affiliate link (returned by generate_tracked_link).
networkYesThe affiliate network that reported this event. One of: 'partnerstack', 'impact', 'direct'.
network_event_idYesUnique commission event ID from the affiliate network. Used for idempotency.
amountYesCommission amount in dollars (e.g. 29.99).
currencyNoISO 4217 currency code (default: 'USD').USD
commission_typeNoType of commission. One of: 'initial', 'recurring', 'one_time'. Defaults to 'recurring'.
period_startNoBilling period start date in ISO 8601 format (optional).
period_endNoBilling period end date in ISO 8601 format (optional).
metadataNoOptional extra data (e.g. order ID, plan name).

Implementation Reference

  • 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);
    }
  • 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,
    };
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must compensate. It discloses idempotency (safe to call multiple times with same network+network_event_id), which is key. However, it does not describe what happens on failure (e.g., invalid tracking_code), whether the endpoint is read-only or not, or any side effects. Some behavioral context is missing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three concise sentences: purpose with example, prerequisite, and idempotency note. No unnecessary words, front-loaded with key information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 9 parameters and no output schema, the description covers the essential usage context but lacks explanation of return values or error handling. It adequately complements the detailed schema but could be more comprehensive (e.g., what the response looks like, permissions needed).

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Since schema description coverage is 100%, baseline is 3. The description adds minimal extra meaning: it emphasizes that tracking_code comes from generate_tracked_link (already in schema) and that network_event_id is used for idempotency (also in schema). No significant new parameter information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Record an affiliate commission event') and provides a concrete example (purchase or renewal). It distinguishes from sibling tools like record_signup and generate_tracked_link by specifying the trigger (referred user purchase/renewal) and the required tracking_code from generate_tracked_link.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use (upon purchase or subscription renewal) and notes the prerequisite of having a tracking_code from generate_tracked_link. It also mentions idempotency, suggesting safe retries. However, it does not explicitly state when not to use or provide alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/sai4447/agentfuse-mcp'

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