Add a referral program with GitHub Copilot

Copilot agent mode in VS Code connects to remote MCP servers with OAuth, and every Copilot surface reads repository instructions from .github. The instructions file also guides the Copilot coding agent on GitHub, which cannot use an OAuth MCP server.

01Rules file.github/instructions/refref.instructions.md

Give GitHub Copilot the RefRef rules

The rules tell the agent where each part of a referral integration belongs: the landing script in the browser, one signup call where your backend creates the account, and the API key only on the server. Save it as .github/instructions/refref.instructions.md. Or add the text without the frontmatter to .github/copilot-instructions.md.

Copilot adds .github/copilot-instructions.md to every chat request in the repository, and a file in .github/instructions when its applyTo glob matches the files in context. The RefRef file uses applyTo: "**", so it applies everywhere. The Copilot coding agent on GitHub reads the same files.

.github/instructions/refref.instructions.md
---
applyTo: "**"
---

# RefRef referral tracking

This app uses RefRef (https://refref.ai) for its referral program. Follow these rules when you add or change referral code.

## Configuration

- Server-only secrets: `REFREF_API_KEY` (a Workspace API key), `REFREF_PROJECT_ID`, and `REFREF_PROGRAM_ID`.
- `REFREF_API_URL` defaults to `https://api.refref.ai`, and `REFREF_ASSETS_URL` to `https://assets.refref.ai`. Read both from configuration, so that a Sandbox or local environment can change them.
- Never put `REFREF_API_KEY` in browser code, in a public variable (`NEXT_PUBLIC_*`, `VITE_*`), in a prompt, in a log, or in a commit.
- Every RefRef call is a backend `POST` with a JSON body that contains `projectId`, and the header `X-Api-Key`. The current schemas are at `GET $REFREF_API_URL/openapi`.

The start of the file. Open the whole file.

Or fetch it from the command line: curl -fsSL --create-dirs https://refref.ai/agents/github-copilot/rules.md -o .github/instructions/refref.instructions.md

02MCP serverConfiguration

Connect GitHub Copilot to RefRef MCP

Optional. With the MCP server, GitHub Copilot can read your Workspaces, Projects, and Programs, and prepare configuration changes for you to approve in the Console. It never sends signups: that is the app code from the rules. See the MCP reference for scopes and approvals.

Configuration: .vscode/mcp.json (workspace) or your VS Code user profile

.vscode/mcp.json (workspace) or your VS Code user profile
{
  "servers": {
    "refref": {
      "type": "http",
      "url": "https://mcp.refref.ai/mcp"
    }
  }
}

Or with the CLI

Add command
code --add-mcp '{"name":"refref","type":"http","url":"https://mcp.refref.ai/mcp"}'

Sign in

Start the server from the Start action in mcp.json or with MCP: List Servers. VS Code opens the browser; sign in with your RefRef Console account. Manage access later under Accounts → Manage Trusted MCP Servers. The connection uses your Console sign-in, never a Workspace API key.

Check it

MCP: List Servers in the Command Palette shows refref as running.

  • VS Code uses "servers", not "mcpServers", in .vscode/mcp.json.
  • The Copilot coding agent on GitHub supports only MCP servers with static headers, so it cannot connect to the RefRef MCP server. It still follows the instructions file.
  • A chat request can use at most 128 tools.
03PromptsPaste in order

1. Configure the Program through MCP

Optional. Needs the refref MCP server and a Console account with the owner or admin role.

Configure the Program through MCP
Use the refref MCP server. Call get_workflow with workflow="configuration", then list_workspaces. Ask me to choose the Workspace, and use only the Sandbox Project that I confirm. Read its Programs and rules. Propose a referral Program that gives the referrer a reward when a referred person signs up. Ask me for the reward, the currency, and the limits; do not assume them. Return the proposal and its review link. Do not approve or apply it.

2. Add referral tracking to the signup

The rehearsal ran this prompt with "the project instructions" in place of the rules file name, on a Node app whose tests use node --test.

Add referral tracking to the signup
Add RefRef referral tracking to the signup of this app. Follow the RefRef rules in .github/instructions/refref.instructions.md. Configuration comes from environment variables. Do not add dependencies. Add focused tests and run them.

3. Review the change before you merge it

Run it in a new session, so that the agent reads the diff with fresh context.

Review the change before you merge it
Review the RefRef integration in the current diff against .github/instructions/refref.instructions.md. Check each item of "Tests to write" and "Do not". Confirm that the signup is sent once, only where the account is created, and that REFREF_API_KEY never reaches the browser. List each problem with its file and line. Change nothing.

Set REFREF_API_KEY, REFREF_PROJECT_ID, and REFREF_PROGRAM_ID in your backend environment. The integration reference has each call, and the auth recipes cover email verification, magic links, and hosted login.

04Rehearsal recordChecks open

What we ran, and what happened

Some checks have not run yet. Treat the open steps as a guide to verify yourself, and record your own results.

pendingConfigure the MCP server and sign in with VS Code
Not run: VS Code is not installed on the rehearsal machine.
pendingPrompt 2 and the instructions file produce a working signup integration
Not run. Run prompt 2 in agent mode with .github/instructions/refref.instructions.md on a test app, then follow A's link as B and check the referral, a repeated sign-in, and the browser bundle.
05QuestionsFAQ
01

Can the Copilot coding agent on GitHub use the RefRef MCP server?

No. It accepts only MCP servers that authenticate with static headers, and the RefRef MCP server uses OAuth with your Console sign-in. The coding agent still reads the instructions file, so it can write the tracking code. Configure the Program in the Console or from VS Code.

02

Why does VS Code use "servers" and not "mcpServers"?

It is the VS Code format of .vscode/mcp.json. Other clients use mcpServers. Copy the snippet on this page as it is.

Official references

Start with a Sandbox Project

Create a RefRef account, add a Project, and get the keys that the GitHub Copilot prompts need. Sandbox data never mixes with live data.

Get Started