Prerequisite: Install the
engram binary first via Homebrew or binary download.One-Command Setup (Recommended)
Installs the plugin AND registers the MCP server automatically:- Copies
engram.tsto~/.config/opencode/plugins/(Windows:%APPDATA%\opencode\plugins\) - Adds the
engramMCP server entry toopencode.json
What the Plugin Provides
The OpenCode plugin is a thin TypeScript adapter that enhances bare MCP:| Feature | Bare MCP | With Plugin |
|---|---|---|
| 13 memory tools | ✓ | ✓ |
| Auto-start server | ✗ | ✓ |
| Session tracking | ✗ | ✓ |
| Auto-import git-synced memories | ✗ | ✓ |
| Memory Protocol injection | ✗ | ✓ |
| Compaction recovery | ✗ | ✓ |
| Privacy tag stripping | ✗ | ✓ |
Auto-Start Server
The plugin automatically startsengram serve if it’s not running. No manual engram serve & needed.
Session Tracking
Uses session resilience viaensureSession():
- Creates sessions on-demand in engram’s database
- Survives plugin reloads and reconnects
- Session IDs come from OpenCode’s hook inputs (
input.sessionID)
Auto-Import
If.engram/manifest.json exists in your project, the plugin runs engram sync --import at startup to load git-synced memories.
Clone a repo → open OpenCode → team memories are loaded.
Memory Protocol Injection
The plugin injects the Memory Protocol viaexperimental.chat.system.transform:
The protocol is concatenated into the existing system message, not pushed as a separate one. This ensures compatibility with models that only accept a single system block (Qwen, Mistral/Ministral via llama.cpp).
Compaction Recovery
When OpenCode compacts (summarizes long conversations), the plugin:- Auto-saves a session checkpoint
- Injects context from previous sessions
- Tells the compressor to instruct the new agent to save memories
experimental.session.compacting hook:
Privacy Stripping
The plugin strips<private>...</private> tags before sending to engram:
Manual MCP-Only Setup (Alternative)
If you only want the 13 memory tools without session tracking: Add to~/.config/opencode/opencode.json (Windows: %APPDATA%\opencode\opencode.json):
Platform-Specific Notes
Windows
engram setup opencode writes to:
- Plugin:
%APPDATA%\opencode\plugins\engram.ts - Config:
%APPDATA%\opencode\opencode.json
macOS / Linux
engram setup opencode writes to:
- Plugin:
~/.config/opencode/plugins/engram.ts - Config:
~/.config/opencode/opencode.json
Bun.spawn().
Local Model Compatibility
The plugin works with all models, including local ones served via llama.cpp, Ollama, or similar. The Memory Protocol is concatenated into the existing system prompt (not added as a separate system message), so models with strict Jinja templates work correctly.Troubleshooting
Plugin not loading
Check plugin directory:engram.ts.
MCP tools not available
Checkopencode.json for the engram server entry:
Server not starting
Manually start the server:Next Steps
- Learn about the Memory Protocol
- Explore MCP Tools
- Set up Git Sync for team memory sharing