MCP for AI agents

Connect Claude Code, Claude Desktop, Cursor or any MCP client to your Referalli program with @referalli/mcp: read tools, plus writes that only run after a confirmed second call.

Embed
Preview of the card
<a href="https://referalli.com/docs/mcp"><img src="https://referalli.com/docs/_api/public/orgs/07f432f4-34b9-46a7-aaad-c0e395d2e4f9/spaces/2bf4f614-3630-4fbf-85f9-5ecafa6b7d97/pages/6a9f9c72-1687-4024-a65e-1241f45fd415/social-card.svg?v=3e7ae33eec8b" alt="MCP for AI agents" width="600" height="315"></a>

@referalli/mcp is a Model Context Protocol server for Referalli. With it, Claude, Cursor or any MCP client can read your referral and affiliate program: programs, partners, referrals, fraud cases and credit ROI. With your confirmation, it can also act on the program: create partners, links and coupons, approve or void referrals, and draft payout runs.

It runs on your machine over stdio with npx and calls https://referalli.com with your API key. It needs Node.js 20 or later. The source is at github.com/Referalli/referalli-mcp.

1. Create an API key

In Referalli, open Settings → API keys and create a key. Start with a test-mode key (rk_test_...), which only sees your test data. The key's scopes decide what the server can do: a read-only key gives you a read-only assistant. See Authentication for scopes.

2. Add the server to your client

claude mcp add --transport stdio --env REFERALLI_API_KEY=rk_test_your_key referalli -- npx -y @referalli/mcp
  • Claude Code: add --scope user to make the server available in every project. Check it with claude mcp list, or with /mcp inside a session.

  • Claude Desktop: open Settings → Developer → Edit Config. That opens claude_desktop_config.json, in ~/Library/Application Support/Claude/ on macOS and %APPDATA%\Claude\ on Windows. Add the block, then restart Claude Desktop.

  • Cursor: put the block in ~/.cursor/mcp.json (every project) or .cursor/mcp.json (one project), then enable referalli under Cursor Settings → MCP.

  • Any other client that launches stdio servers works the same way: the command is npx -y @referalli/mcp, with REFERALLI_API_KEY in its environment.

Keep the key out of files you commit. A project-level .cursor/mcp.json is usually checked in, so prefer the user-level file for a real key.

Variable

Meaning

REFERALLI_API_KEY

Required. A Referalli API key. The server exits without one.

REFERALLI_API_URL

API base URL. Default https://referalli.com; http://localhost:4000 for a local API.

3. Ask about your program

Try prompts such as:

  • "Which partners drove the most revenue this month, and what did we pay them?"

  • "Are there open fraud cases? Summarize each one."

  • "Did the store credit we granted pay for itself? Explain the ROI for partner ptr_..."

  • "Create a link for Dana in the Acme Partners program that points to /pricing."

Tools

Read tools answer directly:

Tool

Returns

Calls

list_programs

The affiliate programs in the organization

GET /v1/programs

program_overview

Funnel and revenue for the last 30 days

GET /v1/analytics/overview?days=30

partner_performance

Per-partner clicks, referrals, revenue and commissions

GET /v1/reports/partner-performance

list_referrals

Recent referrals with attribution channel and status

GET /v1/referrals

list_fraud_cases

Open fraud cases awaiting review

GET /v1/fraud/cases?status=open

roi_summary

What granted credit cost and the cash it earned back; filters from, to, programId, partnerId, currency

GET /v1/roi/summary

roi_trace

The timeline behind an ROI figure for one customerRef or one partnerId

GET /v1/roi/trace/{customerRef}, GET /v1/roi/partners/{id}/trace

roi_patterns

Customers or partners matching a pattern (credit_only, churn_at_exhaustion, bonus_collector, negative_partner)

GET /v1/roi/patterns/{pattern}

Write tools never act on the first call:

Tool

Does

create_partner, create_link, create_coupon

Create a partner, a tracked link or a coupon

approve_referral, void_referral, pause_referral, resume_referral

Change a referral's status

approve_due_commissions

Approve the commission lines whose hold has passed

create_payout_run

Create a payout run (a draft: it isn't executed, and no money moves)

settle_commission

Mark a line paid as store credit

The first call returns a preview: the exact request, and for referrals and commissions the current object, with a confirmToken. Nothing changes until the agent calls the same tool again with the same arguments, confirm: true and that token, within 5 minutes. A token works once and only for those arguments, and it doubles as the request's Idempotency-Key, so a retried confirmation never applies twice. The API key's scopes still apply: give the server a key with only the scopes it needs.

Other ways for agents to use Referalli

  • The OpenAPI document describes every operation, so agent frameworks that load OpenAPI tools can call the API directly.

  • /llms.txt points language models at these docs, the SDKs and the spec.

Updated