> The index of all pages is at https://docs.afffast.com/llms.txt.

# VS Code

Add the MCP server to VS Code with an install link or .vscode/mcp.json.

VS Code reads MCP servers from `.vscode/mcp.json`. The key goes in a header. VS Code can ask you for the key one time and store it. The file then does not hold the key.

## Install with a file

1. Make a test key in the dashboard. A test key starts with `sk_test_`.
2. Make the file `.vscode/mcp.json`:

   ```json
   {
     "inputs": [
       {
         "type": "promptString",
         "id": "ans-api-key",
         "description": "AffFast API key",
         "password": true
       }
     ],
     "servers": {
       "afffast": {
         "type": "http",
         "url": "https://api.afffast.com/mcp",
         "headers": { "Authorization": "Bearer ${input:ans-api-key}" }
       }
     }
   }
   ```

3. Start the server. Open the Command Palette and run **MCP: List Servers**. Select `afffast`, then **Start Server**.
4. VS Code asks for the key. Paste the test key into this prompt. VS Code stores it. Do not paste it in a chat.

You can also run **MCP: Add Server**, choose **HTTP**, and enter `https://api.afffast.com/mcp`. Then add the `headers` field to the new entry.

## Install with a link

This link opens VS Code and shows the server for review: [Install in VS Code](https://vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522afffast%2522%252C%2522type%2522%253A%2522http%2522%252C%2522url%2522%253A%2522https%253A%252F%252Fapi.afffast.com%252Fmcp%2522%257D).

The link does not carry a key. After the install, add the `headers` field from the file above.

## Check that it works

- Run **MCP: List Servers**. The server must be running.
- Open the Chat view in agent mode. Select the tools icon. The tools of the server must be in the list.

## Example prompts

- "Use the afffast tools to show the revenue by network this year."
- "List the conversions that have the status pending and are older than 30 days."
- "Show the clicks by country for the link `link_...`."

## Troubleshooting

- **The server does not start.** Run **MCP: List Servers**, select the server and look at the output. A 401 error means that the key is wrong. Make a new key, and start the server again.
- **The tools are missing.** The key decides the tools. A read-only key has no write tools.
- **The link does not work.** Use the file method.
- **A 429 error.** Wait for the time in `Retry-After`.

## Security

- Never paste a key into a chat. Use the `promptString` input.
- Start with a test key. A test key reads and writes test data only.
- Use a read-only key if the tool must only read.
- Never write the key in `.vscode/mcp.json`. The file is often committed.
