OpenCode
OpenCode (sst/opencode) speaks MCP natively and runs the full OAuth
2.1 + Dynamic Client Registration handshake against Engram, the same
handshake Claude Desktop uses. Drop one block in opencode.json and
let the CLI walk you through auth. Protocol background lives at
MCP.
Prerequisites
Section titled “Prerequisites”Before you start, confirm:
- You have an Engram account at app.engram.page.
- At least one vault is synced. Open the Obsidian plugin or the web app and confirm notes have synced within the last day.
- You can sign in via browser. The MCP auth flow opens a browser window.
Endpoint
Section titled “Endpoint”https://mcp.engram.page/api/mcp1. Edit opencode.json. Create or edit
~/.config/opencode/opencode.json (global) or ./opencode.json at
your project root (project-scoped, overrides global). Add the
mcp.engram block:
{ "$schema": "https://opencode.ai/config.json", "mcp": { "engram": { "type": "remote", "url": "https://mcp.engram.page/api/mcp", "enabled": true } }}2. Restart the session. Exit and re-launch the opencode CLI.
Config is read on launch.
3. Verify. Run opencode mcp list and confirm Engram appears in
the server list.
First-run auth
Section titled “First-run auth”The first time OpenCode calls an Engram tool, it detects the 401,
runs the OAuth handshake (Dynamic Client Registration where the
server supports it, which Engram does), and opens your browser to
sign in. Tokens are stored at
~/.local/share/opencode/mcp-auth.json and reused after that.
To trigger the flow up-front instead of waiting for the first call, run:
opencode mcp auth engramThe grant is the full mcp scope. Granular
per-action scopes are on the roadmap.
To skip OAuth (for headless or scripted setups), pin to an API key instead:
{ "mcp": { "engram": { "type": "remote", "url": "https://mcp.engram.page/api/mcp", "enabled": true, "oauth": false, "headers": { "Authorization": "Bearer {env:ENGRAM_API_KEY}" } } }}Get a key at app.engram.page/settings/api-keys.
OpenCode rules
Section titled “OpenCode rules”Add the snippet below to AGENTS.md at your project root.
OpenCode loads this file on every session in the project.
Engram holds my personal notes — treat it as your long-term memory of me. Search it when a question depends on context I might have shared before. Before saving or updating a note, ask first.Try it
Section titled “Try it”In an OpenCode session, ask:
- Search my vault for notes about the engineering interview process and summarize the top three.
- Find anything I wrote about embeddings in the last month.
OpenCode calls Engram’s search (or get_note, write_note, etc.)
tool, pulls back results, and answers in-context. If the tool fires,
you’re set.
Troubleshooting (OpenCode specific)
Section titled “Troubleshooting (OpenCode specific)”- Stale or corrupt token after a vault swap. Clear it with
opencode mcp logout engram, then re-auth usingopencode mcp auth engram. (Alternative: delete the engram entry from~/.local/share/opencode/mcp-auth.json.) - Tools time out on launch. Bump
"timeout": 15000(or higher) inside theengramblock. Default is 5000ms. - OAuth discovery fails. Run
opencode mcp debug engramto print the connection trace including the/.well-known/oauth-authorization-serverround-trip. Confirm your endpoint is reachable over HTTPS.
For cross-client failures, see Troubleshooting.
Revocation
Section titled “Revocation”To disconnect OpenCode from Engram:
- In OpenCode, find the connector or MCP server entry and remove it.
- In Engram, open your account → API Keys & Sessions and revoke the matching session.
- The OAuth token is invalidated server-side. OpenCode will need to re-authenticate to reconnect.
Locally: run opencode mcp logout engram and remove the block from
opencode.json.