Skip to content

Gemini CLI

Connect Gemini CLI to Margin

Gemini CLI pulls your client's comments into the terminal session and works from the selector and screenshot.

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 Gemini CLI

    Add the block to ~/.gemini/settings.json. Gemini CLI uses the `httpUrl` field for Streamable HTTP servers and expands $MARGIN_MCP_TOKEN in the header.

    ~/.gemini/settings.json
    {
      "mcpServers": {
        "margin": {
          "httpUrl": "https://app.margin-comments.com/mcp",
          "headers": { "Authorization": "Bearer $MARGIN_MCP_TOKEN" }
        }
      }
    }

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

  3. 3. Check the connection

    Start Gemini CLI and type /mcp. Margin should be listed as connected with its tools.

  4. 4. Ask for the fix

    Prompts that work:

    • “List the open Margin comments on production and propose fixes before changing anything.”
    • “Read Margin comment #9 with its screenshot and fix it.”

What Gemini CLI 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 Gemini CLI

Streamable HTTP at one endpoint. In Gemini CLI that is the `httpUrl` field, not `url`, which is for server-sent events.

Export MARGIN_MCP_TOKEN in your shell. The header in settings.json refers to it, so the file holds no secret.