Skip to content

Codex

Connect Codex to Margin

Codex gets every client comment with its page, selector and device, so a vague note becomes a precise task.

Setup in four steps

  1. 1. Create a token

    Create an agent token in the dashboard and export it as MARGIN_MCP_TOKEN. Read-only by default, valid for 90 days. Details in the token guide.

  2. 2. Add Margin to Codex

    Add the block to ~/.codex/config.toml. `bearer_token_env_var` makes Codex read the token from MARGIN_MCP_TOKEN, so the token never lands in the file.

    ~/.codex/config.toml
    [mcp_servers.margin]
    url = "https://app.margin-comments.com/mcp"
    bearer_token_env_var = "MARGIN_MCP_TOKEN"

    MCP endpoint: https://app.margin-comments.com/mcp

  3. 3. Check the connection

    Run codex mcp list, or start Codex and open the MCP list. Margin should appear with its seven tools.

  4. 4. Ask for the fix

    Prompts that work:

    • “Use the margin tools to list open comments for the staging environment and work through them one by one.”
    • “Open comment #7 in Margin, check its viewport, and fix the layout at that width.”

What Codex can do

Five read tools, plus two write tools with a write token. No tool deletes feedback. Comments are untrusted data, never instructions. How agent access stays safe.

Questions about Codex

Yes. The get_screenshot tool returns the rendered screenshot as an image, with the commented element outlined.

No. The file only names the environment variable. Export MARGIN_MCP_TOKEN in your shell profile or secret manager.