Allows AI agents to manage affiliate programs by reporting clicks, leads, sales, and refunds while tracking integration readiness.
Also known as Affitor/cli, mcp, @affitor/mcp
- Stars
- 0
- Tools
- 10
- Downloads, 30 days
- 750
- Latest version
- 0.2.5
- Last commit
- Oct 21, 2026
- License
- MIT
What is Affitor MCP?
Affitor allows AI agents to manage affiliate programs by reporting clicks, leads, sales, and refunds while tracking integration readiness. It exposes 10 tools, such as affitor_readiness, affitor_track_lead, affitor_track_sale.
Summary generated from the project's README
About Affitor MCP server
Managing affiliate programs through AI agents is possible with Affitor, which allows clients like Claude Desktop or Cursor to report clicks, leads, sales, and refunds. This stdio server connects your agent to the Affitor platform using a program API key provided via the AFFITOR_API_KEY environment variable. It is designed for developers who want to automate the tracking of affiliate attribution and integration status directly from their development environment.
To prevent accidental financial changes, the server requires the AFFITOR_MCP_WRITE environment variable to be set to 1 before the affitor_track_sale and affitor_track_refund tools become available. The server also includes specialized tools for technical setup, such as affitor_get_integration_plan for retrieving implementation steps and affitor_run_verification to test the attribution pipeline. Users can also monitor their setup progress using the affitor_readiness tool to check for blockers or required next actions.
What you can do with it
- 1Verify affiliate integration readinessAsk the agent to check if the current affiliate program setup is fully verified and ready for production.
- 2Report new customer salesInstruct the agent to record a completed transaction and its associated commission using a specific invoice ID.
- 3Generate technical implementation plansRequest a step-by-step guide for injecting tracking snippets into a specific web framework and payment provider stack.
- 4Process transaction refundsHave the agent reverse a commission by reporting a full or partial refund for a previously recorded invoice.
Written from the project's README. Every use case is checked against a quote from it.
How to install Affitor MCP
Formats verified 10 Nov 2026Add to CursorAdd to GooseInstall Affitor MCP in Claude Code
$ claude mcp add --env 'AFFITOR_API_KEY=<YOUR_AFFITOR_API_KEY>' mcp -- npx -y @affitor/mcpInstall Affitor MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@affitor/mcp"
],
"env": {
"AFFITOR_API_KEY": "<YOUR_AFFITOR_API_KEY>"
}
}
}
}Install Affitor MCP in VS Code
.vscode/mcp.json
{
"servers": {
"mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@affitor/mcp"
],
"env": {
"AFFITOR_API_KEY": "<YOUR_AFFITOR_API_KEY>"
}
}
}
}Install Affitor MCP in VS Code CLI
$ code --add-mcp '{"name":"mcp","type":"stdio","command":"npx","args":["-y","@affitor/mcp"],"env":{"AFFITOR_API_KEY":"<YOUR_AFFITOR_API_KEY>"}}'Install Affitor MCP in Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@affitor/mcp"
],
"env": {
"AFFITOR_API_KEY": "<YOUR_AFFITOR_API_KEY>"
}
}
}
}Install Affitor MCP in Codex
$ codex mcp add mcp --env 'AFFITOR_API_KEY=<YOUR_AFFITOR_API_KEY>' -- npx -y @affitor/mcpInstall Affitor MCP in Codex config.toml
~/.codex/config.toml
[mcp_servers.mcp] command = "npx" args = ["-y", "@affitor/mcp"] [mcp_servers.mcp.env] AFFITOR_API_KEY = "<YOUR_AFFITOR_API_KEY>"
Install Affitor MCP in Gemini CLI
$ gemini mcp add -s user -e 'AFFITOR_API_KEY=<YOUR_AFFITOR_API_KEY>' mcp npx -- -y @affitor/mcpInstall Affitor MCP in Gemini settings.json
~/.gemini/settings.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@affitor/mcp"
],
"env": {
"AFFITOR_API_KEY": "<YOUR_AFFITOR_API_KEY>"
}
}
}
}Affitor MCP tools 10
Detected from the READMEaffitor_readinessaffitor_track_leadaffitor_track_saleaffitor_track_refundaffitor_track_clickaffitor_get_integration_planaffitor_run_verificationamountinvoiceIdframework
| affitor_readiness | — | |
| affitor_track_lead | — | |
| affitor_track_sale | — | |
| affitor_track_refund | — | |
| affitor_track_click | — | |
| affitor_get_integration_plan | — | |
| affitor_run_verification | — | |
| amount | — | |
| invoiceId | — | |
| framework | — |
Configuration
AFFITOR_API_KEYRequiredSecretYour Affitor program API key. Server-side only.
AFFITOR_API_URLAPI base override. Defaults to https://api.affitor.com.
AFFITOR_MCP_WRITESet to 1 to register the two tools that move money (track sale, track refund). Off by default.
| Name | Description | |
|---|---|---|
| AFFITOR_API_KEY | Your Affitor program API key. Server-side only. | RequiredSecret |
| AFFITOR_API_URL | API base override. Defaults to https://api.affitor.com. | |
| AFFITOR_MCP_WRITE | Set to 1 to register the two tools that move money (track sale, track refund). Off by default. |
Automated checks
Ran Nov 12, 2026Full report →Passed our automated checks. That is not a security audit: read the code and give the server the narrowest access it needs. How checks work
- Source repository linked and reachablePass
- Open source license (OSI)Pass
- Commit or release in the last yearPass
- Package name not close to a popular packagePass
- Remote endpoint uses HTTPSPass
- Destructive tools are labelledPass
- No hidden instructions to the modelPass
- No critical advisory in the package or its dependenciesPass
README
View on GitHub@affitor/mcp
A Model Context Protocol (MCP) stdio server for Affitor.
It exposes Affitor's affiliate-tracking capabilities as MCP tools so AI agents — Claude Desktop, Cursor, and any other MCP client — can report clicks, leads, sales and refunds, and poll integration readiness, directly as tool calls.
Under the hood it wraps the consolidated server client @affitor/sdk/server (the Affitor class). Authentication is your program API key, supplied via the AFFITOR_API_KEY environment variable.
Add it to your MCP client
Add this to your client's MCP server config (e.g. claude_desktop_config.json for Claude Desktop, or .cursor/mcp.json for Cursor):
{
"mcpServers": {
"affitor": {
"command": "npx",
"args": ["-y", "@affitor/mcp"],
"env": {
"AFFITOR_API_KEY": "your_program_key"
}
}
}
}
Restart your client and the affitor tools will be available to the agent.
Environment variables
| Variable | Required | Description |
|---|---|---|
AFFITOR_API_KEY |
Yes | Your Affitor program API key (Bearer). Server-side only — never ship it to a browser. |
AFFITOR_API_URL |
No | API base override. Defaults to https://api.affitor.com. |
AFFITOR_MCP_WRITE |
No | Set to 1 to register the two tools that move money: affitor_track_sale and affitor_track_refund. Off by default, so an agent exploring tools cannot create a real sale or reverse a commission. |
If AFFITOR_API_KEY is not set, the server prints a clear message to stderr and exits.
Tools
Every tool carries MCP annotations (readOnlyHint, destructiveHint, idempotentHint), so a client can ask before a write. affitor_track_sale and affitor_track_refund are marked destructive and only exist with AFFITOR_MCP_WRITE=1.
| Tool | Description |
|---|---|
affitor_readiness |
Check this program's integration/onboarding readiness — returns a 5-gate verdict + blocker + next_action. Poll until integration_verified is true. |
affitor_track_lead |
Report a lead/signup. Binds the customer to the click so later sales attribute by customerExternalId alone. |
affitor_track_sale |
Needs AFFITOR_MCP_WRITE=1. Report a sale: creates a real sale and commission unless testMode is true. Resolves attribution by customerExternalId (bound at lead time). |
affitor_track_refund |
Needs AFFITOR_MCP_WRITE=1. Report a refund (omit amount = full → commission reversed; partial → refunded). Idempotent by invoiceId. testMode is a dry run. |
affitor_track_click |
Report a click (usually browser-side; public, no customer needed). |
affitor_get_integration_plan |
Return the deterministic payment-tracking integration plan for a stack — install, checkout-metadata snippet, trackSale snippet + where to inject it, and the verify step. Pure — reads the canonical @affitor/recipes registry; no SDK client, no network, no side-effects. The agent follows this instead of guessing a contract. |
affitor_run_verification |
Fire the synthetic click → lead → sale verification chain through Affitor's REAL attribution pipeline (isolated is_test rows). The agent's proof step: run it, then poll affitor_readiness until integration_verified is true. Rate-limited to 10/program/hour — on a rate_limited result, wait retry_after_seconds, don't hammer. |
Inputs
affitor_readiness
forceRecheck?: boolean— force a fresh server-side recheck instead of the cached verdict.
affitor_track_lead (one of customerExternalId / clickId is required)
customerExternalId?: string— your own user id; binds this customer to the click.clickId?: string— Affitor click id (from theaffitor_click_idcookie).email?: stringtestMode?: boolean— record a test lead (is_test).
affitor_track_sale (one of customerExternalId / clickId is required)
customerExternalId?: string— your own user id; resolves attribution (noclickIdneeded once bound at lead time).clickId?: stringamount: number— sale amount in integer cents (e.g.4999= $49.99).invoiceId: string— idempotency key (your invoice / transaction id).currency?: string— ISO currency code (defaultUSD).saleType?: "payment" | "subscription"isRecurring?: booleansubscriptionId?: stringsubscriptionInterval?: "monthly" | "quarterly" | "annual"testMode?: boolean— record a test sale (is_test, no commission), sent as transactiontest_<invoiceId>so it never blocks the real sale with the same invoice.
affitor_track_refund
invoiceId: string— the sale's idempotency key (theinvoiceIdyou passed toaffitor_track_sale).refundAmountCents?: number— integer cents. Omit (or0) = full refund → commission reversed; partial → refunded.refundReason?: stringtestMode?: boolean— dry run: returns the refund that would be sent and calls nothing (the API has no test refunds).
affitor_track_click (all optional)
affiliateUrl?: stringpageUrl?: stringreferrerUrl?: stringexistingClickId?: string
affitor_get_integration_plan
framework: "next-app" | "next-pages" | "fastify" | "express" | "node" | "unknown"— the detected app framework; determines wheretrackSaleis injected.provider?: "stripe" | "polar" | "lemonsqueezy" | "paddle" | "unknown"— the detected payment provider (defaultstripe).mode?: "stripe_connect" | "s2s"— payment-tracking mode (defaultstripe_connect).stripe_connect= Connect autocaptures the sale (metadata only, notrackSale);s2s= injecttrackSalein your webhook. Returns{ steps, recipe }.
affitor_run_verification (no input)
- Fires the synthetic verification chain and returns the parsed result. On a rate limit it returns
{ http_status: 429, retry_after_seconds, … }rather than throwing — back off and retry.
Each tool returns the Affitor API's JSON payload as text content. On a failed request (a thrown error or an { ok: false } envelope) the tool returns an MCP error result with the message.
License
MIT
Affitor MCP questions
How do I add Affitor MCP to Claude Code?
Run claude mcp add --env 'AFFITOR_API_KEY=<YOUR_AFFITOR_API_KEY>' mcp -- npx -y @affitor/mcp in your terminal. Add --scope user to make it available in every project.
How do I add Affitor MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.
What tools does Affitor MCP provide?
It exposes 10 tools, including affitor_readiness, affitor_track_lead, affitor_track_sale, affitor_track_refund, affitor_track_click.
How do I enable sales and refund tracking?
You must set the AFFITOR_MCP_WRITE environment variable to 1 to enable the tools that move money.
What authentication method does Affitor use?
The server uses a program API key provided through the AFFITOR_API_KEY environment variable.
How can I verify if my integration is working correctly?
You can use the affitor_run_verification tool to fire a synthetic click, lead, and sale verification chain through the real attribution pipeline.
Can I test sales without affecting real commissions?
Yes, you can use the testMode parameter to record a test sale which does not create a real commission.