Skip to main content
Prerequisite: Install the engram binary first via Homebrew or binary download.
This command does three things:
  1. Registers mcpServers.engram in ~/.gemini/settings.json (Windows: %APPDATA%\gemini\settings.json)
  2. Writes ~/.gemini/system.md with the Engram Memory Protocol
  3. Ensures ~/.gemini/.env contains GEMINI_SYSTEM_MD=1 so Gemini loads the system prompt
1

Install engram binary

2

Run setup command

Output:
3

Verify installation

The agent should list mem_save, mem_search, etc.

What Gets Configured

MCP Server Registration

Adds to ~/.gemini/settings.json:

Memory Protocol System Prompt

Writes the full Memory Protocol to ~/.gemini/system.md:

Environment Variable

Adds to ~/.gemini/.env:
This tells Gemini CLI to load system.md on every session start.

Manual Setup (Alternative)

If you prefer to configure manually:

Add MCP Server

Edit ~/.gemini/settings.json (Windows: %APPDATA%\gemini\settings.json):
Or via CLI:

Add Memory Protocol

Copy the Memory Protocol from DOCS.md to ~/.gemini/system.md.

Enable System Prompt

Add to ~/.gemini/.env:

Compaction Recovery

The Memory Protocol in system.md includes compaction recovery instructions:
This ensures the agent persists work before compaction and recovers state after.

Platform-Specific Notes

Windows

engram setup gemini-cli writes to:
  • MCP config: %APPDATA%\gemini\settings.json
  • System prompt: %APPDATA%\gemini\system.md
  • Environment: %APPDATA%\gemini\.env

macOS / Linux

engram setup gemini-cli writes to:
  • MCP config: ~/.gemini/settings.json
  • System prompt: ~/.gemini/system.md
  • Environment: ~/.gemini/.env

Memory Protocol Behavior

With the Memory Protocol in system.md, the agent:
  • Saves proactively after bugfixes, decisions, discoveries, patterns
  • Searches reactively when you say “remember” or “what did we do”
  • Searches proactively when starting work that might overlap past sessions
  • Closes sessions with mem_session_summary before saying “done”
  • Recovers state after compaction with mem_context
No manual prompting needed — the protocol is always active.

Troubleshooting

MCP tools not available

Check MCP server registration:

Agent doesn’t use memory

Check that system.md exists and GEMINI_SYSTEM_MD=1 is set:

Server not running

Manually start the server:
Gemini CLI will connect via stdio, but the HTTP API is useful for debugging.

Next Steps