Skip to content

Connect Claude Code, Codex, Cursor and other agents with a token

A read-only token per website, and the config for six coding agents.

About 4 minutes · 4 steps · AI agents

  1. Create an agent token

    Open AI agents, then Create agent token. Copy the token once, because Margin stores only a digest of it. A token reaches one website, is read-only unless you allow writing, and expires after 90 days.

  2. Store it as MARGIN_MCP_TOKEN

    Put the token into an environment variable on your machine. Do not paste it into a config file that you commit, and never into your website.

    Shell
    export MARGIN_MCP_TOKEN="margin_..."
  3. Add Margin to your agent

    Each agent has its own way to send a bearer header without writing the token into the file. Use the block for yours.

    Claude Code: Terminal
    claude mcp add --transport http margin \
      https://app.margin-comments.com/mcp \
      --header "Authorization: Bearer $MARGIN_MCP_TOKEN"
    Codex: ~/.codex/config.toml
    [mcp_servers.margin]
    url = "https://app.margin-comments.com/mcp"
    bearer_token_env_var = "MARGIN_MCP_TOKEN"
    Cursor: .cursor/mcp.json
    {
      "mcpServers": {
        "margin": {
          "url": "https://app.margin-comments.com/mcp",
          "headers": { "Authorization": "Bearer ${env:MARGIN_MCP_TOKEN}" }
        }
      }
    }
    GitHub Copilot: .vscode/mcp.json
    {
      "inputs": [
        { "type": "promptString", "id": "margin-token", "description": "Margin token", "password": true }
      ],
      "servers": {
        "margin": {
          "type": "http",
          "url": "https://app.margin-comments.com/mcp",
          "headers": { "Authorization": "Bearer ${input:margin-token}" }
        }
      }
    }
    Windsurf: ~/.codeium/windsurf/mcp_config.json
    {
      "mcpServers": {
        "margin": {
          "serverUrl": "https://app.margin-comments.com/mcp",
          "headers": { "Authorization": "Bearer ${env:MARGIN_MCP_TOKEN}" }
        }
      }
    }
    Gemini CLI: ~/.gemini/settings.json
    {
      "mcpServers": {
        "margin": {
          "httpUrl": "https://app.margin-comments.com/mcp",
          "headers": { "Authorization": "Bearer $MARGIN_MCP_TOKEN" }
        }
      }
    }
  4. Ask the agent to list projects

    A good first prompt: “Use the margin tools to list my projects and show the open comments.” If the agent sees your website, the connection works.

Good to know

  • Read tools: list_projects, list_comments, get_comment, get_screenshot, get_asset, and show_feedback for the board in Claude. Write tools, only with write access: add_reply, update_comment and resolve_comments. Agents in a terminal get the comments as text.
  • Claude Code can also sign in like the Claude app, without a token: run “claude mcp add --transport http margin https://app.margin-comments.com/mcp”, then type /mcp in Claude Code and sign in. That connection reaches the workspace you pick.
  • No token can delete feedback, create projects or change which sites may load the widget.
  • Revoke a token under AI agents at any time. It stops working on the next request.

Next

Back to the Help Center. No account yet?