Skip to main content
Glama
sai4447

agentfuse-mcp

by sai4447

generate_tracked_link

Generate tracked affiliate links for any program by providing a program slug and end user ID. Records clicks and attributes signups or commissions to the specified user.

Instructions

Generate a tracked affiliate link for a program and an end user. Pass the human-readable program slug (e.g. 'webflow') -- the tool resolves the UUID automatically. The link records clicks and attributes any resulting signups or commissions back to the specified end user. Returns a short redirect URL and a tracking_code you should save -- it is needed for record_signup and record_commission.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
program_slugYesSlug of the affiliate program (e.g. 'webflow', 'notion'). Use list_affiliate_programs to find available slugs.
end_user_idYesYour internal ID for the end user who will receive credit for this referral. Can be any stable unique string (UUID, email, username, etc.).
metadataNoOptional key-value metadata to attach to the link (e.g. { campaign: 'onboarding', source: 'chat' }).

Implementation Reference

  • Tool definition and inputSchema for 'generate_tracked_link'. Describes parameters program_slug, end_user_id, and optional metadata.
      name: "generate_tracked_link",
      description:
        "Generate a tracked affiliate link for a program and an end user. " +
        "Pass the human-readable program slug (e.g. 'webflow') -- the tool resolves the UUID automatically. " +
        "The link records clicks and attributes any resulting signups or commissions " +
        "back to the specified end user. Returns a short redirect URL and a tracking_code " +
        "you should save -- it is needed for record_signup and record_commission.",
      inputSchema: {
        type: "object",
        properties: {
          program_slug: {
            type: "string",
            description:
              "Slug of the affiliate program (e.g. 'webflow', 'notion'). " +
              "Use list_affiliate_programs to find available slugs.",
          },
          end_user_id: {
            type: "string",
            description:
              "Your internal ID for the end user who will receive credit for this referral. " +
              "Can be any stable unique string (UUID, email, username, etc.).",
          },
          metadata: {
            type: "object",
            description:
              "Optional key-value metadata to attach to the link " +
              "(e.g. { campaign: 'onboarding', source: 'chat' }).",
            additionalProperties: { type: "string" },
          },
        },
        required: ["program_slug", "end_user_id"],
      },
    },
  • Handler function handleGenerateTrackedLink that validates inputs, resolves program_slug to UUID via AgentFuse catalog API, and generates a tracked link via POST /api/links/generate.
    async function handleGenerateTrackedLink(args) {
      if (!args.program_slug) {
        throw new McpError(ErrorCode.InvalidParams, "program_slug is required");
      }
      if (!args.end_user_id) {
        throw new McpError(ErrorCode.InvalidParams, "end_user_id is required");
      }
    
      // Step 1: resolve slug -> UUID
      const catalogData = await agentfuse("GET", `/api/catalog/${encodeURIComponent(args.program_slug)}`);
      const program_id = catalogData?.data?.id;
      if (!program_id) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Program not found for slug "${args.program_slug}". Use list_affiliate_programs to check available slugs.`
        );
      }
    
      // Step 2: generate the tracked link
      const body = {
        program_id,
        end_user_id: args.end_user_id,
      };
      if (args.metadata) body.metadata = args.metadata;
    
      return agentfuse("POST", "/api/links/generate", body);
    }
  • src/index.js:446-454 (registration)
    Dispatch map (HANDLERS) that registers 'generate_tracked_link' to the handleGenerateTrackedLink function.
    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,
    };
  • The agentfuse helper function used by handleGenerateTrackedLink to make REST API calls to AgentFuse.
    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;
    }
Behavior4/5

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

With no annotations, the description discloses that the link records clicks, attributes signups/commissions, and returns a short redirect URL and tracking_code. It also mentions optional metadata. This is sufficient for a creation tool.

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?

The description is three sentences with no fluff. It front-loads the purpose, then provides usage details and behavioral implications. Every sentence is informative and earned.

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

Completeness5/5

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

Given no output schema, the description explains the return values (short redirect URL and tracking_code) and their importance for sibling tools. All parameters are covered, and the context of the affiliate system is clear.

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

Parameters4/5

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

Schema description coverage is 100%, but the description adds value by explaining that program_slug is human-readable with automatic UUID resolution, and that end_user_id can be any stable unique string. This goes beyond the schema descriptions.

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 states 'Generate a tracked affiliate link for a program and an end user' with a specific verb and resource. It clearly distinguishes from siblings by mentioning the tracking code needed for record_signup and record_commission, and clarifies that it uses human-readable slugs.

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 provides guidance on passing the human-readable slug and saving the tracking_code for later use. It implies usage context as a prerequisite for record_signup and record_commission, but does not explicitly state when not to use it.

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