Integration
Long-term memory for OpenCode
OpenCode is the open-source answer to Claude Code and Codex: fast, terminal-native, model-agnostic. It also forgets everything between sessions. Add Engram to `opencode.json` with `{env:ENGRAM_API_KEY}` interpolation and OpenCode gets persistent memory without changes to the agent code.
Install
Three steps: sign up for an Engram API key, paste a BYOK LLM-provider key on /models, then drop the snippet below into OpenCode.
Three steps to memory in your agent
- Sign up. Free, no card. You'll land on a Getting Started page that walks the next two steps.
- Add your LLM key. Engram is BYOK. Paste an OpenAI / Anthropic / Groq / Together / Fireworks key and we'll route every extraction and query call through your provider. You pay your provider directly. We never see your inference.
- Paste the snippet below into your agent and restart it. Use
Authorization: Bearer <api-key>with the API key from your portal.
engram-opencode-plugin: OpenCode integration
Six Engram MCP tools wired into the open-source terminal AI coding agent. Source: github.com/lumetra-io/engram-opencode-plugin.
- Export your API key (add to your shell rc so OpenCode resolves
{env:ENGRAM_API_KEY}at launch): - Edit
~/.config/opencode/opencode.json(or./opencode.jsonfor project scope) and add themcp.engramblock: - Verify with
opencode mcp list;engramshould appear as✓ connected.
export ENGRAM_API_KEY="<api-key>"{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"engram": {
"type": "remote",
"url": "https://mcp.lumetra.io/mcp/sse",
"enabled": true,
"headers": {
"Authorization": "Bearer {env:ENGRAM_API_KEY}"
}
}
}
}What you can do once memory's wired in
- Remember the architectural choices you've made on this open-source project
- Recall which contributors prefer which review style when drafting feedback
- Pull up the bug-triage decisions from last sprint
- Keep context on the long-running refactor when you switch to a different repo and come back
FAQ
Does OpenCode support env-var interpolation in MCP headers?
Yes. `{env:ENGRAM_API_KEY}` is resolved at runtime. Export the var in your shell rc and the JSON config stays key-free and safe to commit.
Where does OpenCode look for the config?
`~/.config/opencode/opencode.json` for global, or `./opencode.json` in your project root for project scope. The project config wins if both exist.
Why does `opencode mcp debug engram` show 401?
`mcp debug` exercises the OAuth discovery flow, which is a different path than the static `Authorization` header your runtime config uses. A 401 from `debug` doesn't mean your bearer-header setup is broken. If `opencode mcp list` shows `engram` connected, the runtime path is fine.
Related integrations
Ship durable memory in OpenCode today
Free tier: 10K memories and 50K retrievals per month. No credit card. Same Engram backend powers all 41 integrations, so memories you write from one client are immediately queryable from the rest.