Files
kartik-mem0 013718c817 refactor(opencode): native SDK tools, drop MCP, trim skills, expand telemetry
Reworks @mem0/opencode-plugin to expose memory operations as native OpenCode
tools (via the @opencode-ai/plugin `tool()` helper, backed by the mem0ai SDK)
instead of delegating to the remote MCP server. Skills load via the `config`
hook (`skills.paths`) instead of being copied into the project `.opencode/`.

- Drop MCP: remove the regex-based MCP tool interception, the bundled
  opencode.json MCP registration, and the cli.ts installer (mem0-opencode bin).
- Native tools: add_memory, search_memories, get_memories, get_memory,
  update_memory, delete_memory, delete_all_memories, delete_entities,
  list_entities, get_event_status.
- Trim skills 16 -> 8 (context-loader, dream, forget, health, peek, pin,
  remember, tour); remove import, export, memory-reviewer, mem0, list-projects,
  switch-project, stats, onboard. De-MCP/onboard wording in kept skills.
- Telemetry: emit the full shared plugin.* schema (adds user_prompt, bash_error,
  pre_compact, session_stop alongside session_start, tool_use); tool_use now
  fires from inside each native tool; add project_hash + os_version props.
- Fix duplicate error-search (single topK:6); correct the documented
  experimental.chat.messages.transform hook name.
- Bump to 0.2.0.
2026-06-16 12:35:58 +05:30
..

@mem0/opencode-plugin

Persistent memory for OpenCode. Your agent remembers decisions, preferences, and learnings across sessions automatically.

Install

opencode plugin @mem0/opencode-plugin

This adds the plugin to your ~/.config/opencode/opencode.json. The plugin registers its memory tools and skills itself — there is no MCP server to configure.

Or let your agent do it — paste this into OpenCode:

Install @mem0/opencode-plugin by following https://raw.githubusercontent.com/mem0ai/mem0/main/integrations/mem0-plugin/.opencode-plugin/README.md

Get your API key (free): app.mem0.ai/dashboard/api-keys

echo 'export MEM0_API_KEY="m0-your-key"' >> ~/.zshrc && source ~/.zshrc

Restart OpenCode.

What's included

Component Description
9 Native Memory Tools add_memory, search_memories, get_memories, update_memory, delete_memory, and more — registered as OpenCode tools, backed by the mem0ai SDK (no MCP server required)
Lifecycle Hooks Auto-search on session start and every prompt, error memory lookup, compaction context, secret redaction
8 Skills /mem0:remember, /mem0:tour, /mem0:peek, /mem0:health, /mem0:dream, /mem0:forget, /mem0:pin, /mem0:context-loader

Hooks

Pure TypeScript — no Python, no shell scripts. Memory operations are native OpenCode tools backed by the mem0ai SDK directly.

Hook Event What it does
Config config Registers the bundled skills (skills.paths) and /mem0:* slash commands at startup
Chat message chat.message Loads prior memories on session start, searches relevant memories before each prompt, auto-captures learnings periodically
Pre-tool tool.execute.before Blocks MEMORY.md writes, steering them to the add_memory tool
Post-tool tool.execute.after Scans bash errors and pre-fetches related memories
Messages transform experimental.chat.messages.transform Injects memory context (session memories, search results, error lookups) into the prompt
Compaction experimental.session.compacting Stores session state memory, then injects prior memories into compaction context so nothing is lost
Shell env shell.env Exports MEM0_USER_ID, MEM0_APP_ID, MEM0_SESSION_ID, and MEM0_BRANCH to shell

Memory Tools

Tool Description
add_memory Save text or conversation history
search_memories Semantic search across memories
get_memories List memories with filters and pagination
get_memory Retrieve a specific memory by ID
update_memory Overwrite a memory's text by ID
delete_memory Delete a single memory by ID
delete_all_memories Bulk delete all memories in scope
delete_entities Delete an entity and its memories
list_entities List users/agents/apps stored in Mem0

Verify

Start OpenCode and ask: "Search my memories for recent decisions"

If the mem0 tools respond, you're all set.

Troubleshooting

Problem Fix
No tools appearing Restart OpenCode after installing
401 Unauthorized echo $MEM0_API_KEY must print your m0- key
Plugin not loading Run opencode plugin @mem0/opencode-plugin again

License

Apache-2.0