Skip to content

Gemini CLI

Add Alexein to Gemini CLI in ~/.gemini/settings.json, so it searches your memory and saves what it learns in every project.

Gemini CLI searches your Alexein memory before it answers, and saves what you tell it and what you build together.

Google replaced Gemini CLI for its unpaid tier and Google One users in June 2026. These steps are for the plans that still have it.

Filled in for you

My memory › AI assistants › Gemini CLI shows this setup with your own key.

1. Get a key

  1. Open My memory › Keys and select Create key.
  2. Label it Gemini CLI and choose Read and write, so Gemini CLI can save.
  3. Copy the key. It is shown once.

2. Add Alexein

Put your key in an environment variable, in the shell profile Gemini CLI starts from (~/.zshrc, ~/.bashrc):

~/.zshrc
export ALEXEIN_API_KEY="tm_..."

Open ~/.gemini/settings.json, or create it, and add the alexein entry under mcpServers:

~/.gemini/settings.json
{
  "mcpServers": {
    "alexein": {
      "httpUrl": "https://api.alexein.ai/v1/mcp",
      "headers": {
        "Authorization": "Bearer ${ALEXEIN_API_KEY}",
        "X-Alexein-User": "me"
      }
    }
  }
}

Start Gemini CLI again.

Use httpUrl, not url: in Gemini CLI, url means the older SSE transport, which Alexein does not serve. Gemini CLI fills in ${ALEXEIN_API_KEY} from the environment, so the key is not written into the file. X-Alexein-User: me names your own memory.

3. Teach it to use memory

Add these lines to ~/.gemini/GEMINI.md, the instructions Gemini CLI reads in every project. Create the file if it does not exist.

~/.gemini/GEMINI.md
Use Alexein as my memory.
Before you answer anything about me, my work or my plans, search it with memory_search.
When I tell you something new, save it with memory_add, without asking.
Save small details too: preferences, people, places, dates and decisions.
Never save passwords, keys or other secrets.

Then run /memory reload in Gemini CLI, so it reads the file again. /memory show shows what it read.

4. Check it works

Run /mcp in Gemini CLI. alexein is listed as connected, with its tools.

Ask: "What do you remember about me?" Gemini CLI calls memory_search. It asks you to confirm each tool call.

Tell it something new about you. Then open My memory: it is there within a few minutes.

Troubleshooting

  • alexein is disconnected, or the server answers 401. ALEXEIN_API_KEY is not set in the shell Gemini CLI started from. Set it and start Gemini CLI again.
  • It tries SSE, or 405. The entry says url. Change it to httpUrl.
  • Gemini CLI asks before every save. Choose to always allow the tool when it asks. "trust": true on the alexein entry skips every confirmation for this server.
  • memory_add is missing. The key is Read. Create a Read and write key.

More in Troubleshooting.

Add it with a command

gemini mcp add writes the same entry. Pass --scope user for every project: without it, the entry goes into the project you are in.

Terminal
gemini mcp add --transport http --scope user \
  --header "Authorization: Bearer $ALEXEIN_API_KEY" \
  --header "X-Alexein-User: me" \
  alexein https://api.alexein.ai/v1/mcp

The shell fills in $ALEXEIN_API_KEY when you run it, so the key itself is written into the file. Run gemini mcp list to see it.