---
title: "Connect Clam to Gemini CLI"
description: "Add your Clam Shell to Gemini CLI with one command and a key, so Gemini can work in your Gmail within your rules."
route: /docs/agents/gemini-cli
---

# Connect Clam to Gemini CLI

Gemini CLI connects to Clam with one command that carries your Shell's address and a key. There is no sign-in window. From then on, Gemini CLI's email requests follow your Shell's rules.

## Before you start

You need a Clam account with a Shell; the [Quickstart](https://useclam.ai/docs/get-started/quickstart) sets up both. Everything here starts on your Shell's Install tab in the [Clam console](https://console.useclam.ai), under Gemini CLI.

Gemini CLI talks to Clam over MCP, the standard way an AI agent plugs into an outside tool: each Shell is an MCP server, and its email tools go through your rules before they reach Gmail.

## Connect Gemini CLI

Two ways in. Start with the first; the other is for when it doesn't fit.

### Terminal command (Recommended)

The simplest path: Gemini CLI uses a key, so there is no sign-in window.

1. Paste this in your terminal

   Click **Copy command** on the Install tab. Copying is the step that matters: it creates a key for Gemini CLI and fills it in, and you see that key only once. Paste the command into your terminal and press Enter.

   ```bash
   gemini mcp add <server name> <your Shell's address> --transport http --header "Authorization: Bearer <your key>"
   ```

2. Open Gemini CLI and run /mcp

   Run `/mcp`. You should see your server in the list.

Try a prompt below, then click **Check connection** on the Install tab.

The key works for Gemini CLI only. **Regenerate key** makes a new one, and the old one stops working at once.

### settings.json file

For when you keep `~/.gemini/settings.json` by hand, say in dotfiles. Same key, same result; the Install tab shows the block and where it goes.

1. Add this block to ~/.gemini/settings.json

   Under `mcpServers`. Create it if it isn't there.

   ```json
   {
     "mcpServers": {
       "<server name>": {
         "httpUrl": "<your Shell's address>",
         "headers": { "Authorization": "Bearer <your key>" }
       }
     }
   }
   ```

2. Restart Gemini CLI, then run /mcp

   Run `/mcp`. You should see your server in the list.

Try a prompt below, then click **Check connection** on the Install tab.

## Try it

With the starter policy from the Quickstart, ask Gemini CLI:

Ask "Summarize the work email I got this week." Gemini CLI answers from your work email. Ask "Find my latest bank statement." Clam blocks it, and Gemini CLI says the action was not allowed. That refusal is Clam working as intended.

If Gemini CLI has other mail tools, start with "Use <your Shell's name>". Change what's allowed in [How rules work](https://useclam.ai/docs/policies/how-rules-work).

## Remove access

In Gemini CLI, run `gemini mcp remove <server name>`.

The removal that counts is Clam's: on the Shell's Install tab, under Connected agents, choose **Remove access** next to Gemini CLI. The key stops working at once, whether or not Gemini CLI still has it. [Remove access](https://useclam.ai/docs/trust/remove-access)

## If it doesn't work

More in [Common issues & solutions](https://useclam.ai/docs/troubleshooting).

### /mcp doesn't list your Shell

`gemini mcp list` shows what was saved. If you edited settings.json, check the block sits inside `mcpServers` and restart Gemini CLI.

### The server is unauthorized

The key is wrong or was removed. Regenerate it and add Clam again.

Connected? [Write your own rules](https://useclam.ai/docs/policies/writing-effective-policies).
