Skip to main content

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.

VariableRequiredDefaultDescription
AINATIVE_API_KEYNoauto-provisionedA permanent key, if you have one — skips the instant-db provisioning step
AINATIVE_API_URLNohttps://api.ainative.studioAPI base URL
OPENCODE_MEMORY_NAMESPACENoopencodeIsolates 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 namespace
  • opencode_clear_memory — Delete stored memories, optionally scoped to a tag (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