OpenCode Memory MCP Server
The OpenCode Memory MCP server gives an OpenCode agent persistent memory across sessions — facts, decisions, conventions, and code snippets it would otherwise forget the moment the session ends.
Installation
.mcp.json
{
"mcpServers": {
"opencode-memory": {
"command": "npx",
"args": ["-y", "ainative-opencode-memory-mcp"]
}
}
}
Zero manual setup required. On first use the server calls AINative's instant-db endpoint to provision a free temporary ZeroDB project automatically — no signup, no key to paste in. Set AINATIVE_API_KEY yourself only if you already have a permanent key and want memories to persist past the temporary project's expiry.
| Variable | Required | Default | Description |
|---|---|---|---|
AINATIVE_API_KEY | No | auto-provisioned | A permanent key, if you have one — skips the instant-db provisioning step |
AINATIVE_API_URL | No | https://api.ainative.studio | API base URL |
OPENCODE_MEMORY_NAMESPACE | No | opencode | Isolates memories by namespace |
Tools (5)
opencode_store_memory— Store a fact, decision, convention, or code snippet (content,tags)opencode_search_memory— Semantic search over everything the agent has remembered (query,limit)opencode_recall_context— Pull the most relevant remembered context for the current task — call at the start of a session (task,limit)opencode_memory_stats— Report how many memories are stored for this namespaceopencode_clear_memory— Delete stored memories, optionally scoped to atag(destructive with no tag — clears the whole namespace)
Example usage
User: Remember that we use snake_case for all API response fields
Agent:
1. opencode_store_memory("API responses use snake_case field naming", tags=["conventions"])
2. → stored
## Next session:
Agent:
1. opencode_recall_context("writing a new API endpoint")
2. → "API responses use snake_case field naming" surfaces automatically