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
- Open My memory › Keys and select Create key.
- Label it
Gemini CLIand choose Read and write, so Gemini CLI can save. - 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):
export ALEXEIN_API_KEY="tm_..."Open ~/.gemini/settings.json, or create it, and add the alexein entry under mcpServers:
{
"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.
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
alexeinis disconnected, or the server answers401.ALEXEIN_API_KEYis not set in the shell Gemini CLI started from. Set it and start Gemini CLI again.- It tries SSE, or
405. The entry saysurl. Change it tohttpUrl. - Gemini CLI asks before every save. Choose to always allow the tool when it asks.
"trust": trueon thealexeinentry skips every confirmation for this server. memory_addis 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.
gemini mcp add --transport http --scope user \
--header "Authorization: Bearer $ALEXEIN_API_KEY" \
--header "X-Alexein-User: me" \
alexein https://api.alexein.ai/v1/mcpThe 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.