@memextend/opencode
v0.3.3
Published
OpenCode adapter for memextend - MCP server for anomalyco/opencode AI memory
Maintainers
Readme
@memextend/opencode
OpenCode adapter for memextend - Memory extension for AI coding agents
Status: ⚠️ Experimental/Untested - This adapter was developed based on OpenCode's MCP documentation but has not been tested in a production OpenCode environment. Community feedback and contributions are welcome!
This adapter provides memextend integration for OpenCode by Anomaly, an open-source AI coding agent.
Features
- MCP (Model Context Protocol) server for mid-session memory operations
- Search through past work and decisions
- Save important context and patterns
- Store global preferences across projects
- Semantic search using vector embeddings
Requirements
- Node.js 18+
- OpenCode installed (
npm i -g opencode-ai) - memextend CLI initialized (
memextend init)
Installation
# Install the adapter
npm install @memextend/opencode
# Or if using the memextend monorepo
pnpm install
pnpm buildConfiguration
Option 1: Global Configuration
Add memextend to your global OpenCode configuration at ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"memextend": {
"type": "local",
"command": ["node", "/path/to/node_modules/@memextend/opencode/dist/mcp/server.cjs"],
"enabled": true
}
}
}Option 2: Project-Local Configuration
Add to your project's opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"memextend": {
"type": "local",
"command": ["node", "./node_modules/@memextend/opencode/dist/mcp/server.cjs"],
"enabled": true
}
}
}Option 3: Using npx
If you have the package installed globally, you can reference it directly:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"memextend": {
"type": "local",
"command": ["npx", "@memextend/opencode", "mcp"],
"enabled": true
}
}
}Finding the Server Path
To find the correct path for your installation:
# If installed globally
npm root -g
# Then append: /@memextend/opencode/dist/mcp/server.cjs
# If installed locally in a project
npm root
# Then append: /@memextend/opencode/dist/mcp/server.cjsAvailable MCP Tools
Once configured, the following tools are available in your OpenCode sessions:
memextend_search
Search through your memories using semantic and full-text search.
Use: Search for "authentication flow" or "Redis caching decisions"memextend_save
Save a memory for the current project.
Use: Save important decisions, patterns, or context for future referencememextend_save_global
Save a global preference or fact that applies across all projects.
Use: Save coding style preferences, common patterns, or personal facts
Types: preference, pattern, factmemextend_forget
Delete a specific memory by ID.
Use: Remove outdated or incorrect memoriesmemextend_status
Get memextend status and memory statistics.
Use: Check how many memories are stored, database location, etc.memextend_context
Get relevant context for the current session.
Use: Retrieve recent memories, global preferences, and semantically related past workUsage Examples
After configuring memextend in your opencode.json, start OpenCode in your project:
opencodeThen interact with memextend through natural language:
> Search my memories for authentication patterns
> Save this as a memory: We decided to use JWT tokens with 24-hour expiry for API authentication
> Remember globally that I prefer TypeScript with strict mode enabled
> What context do you have about this project?
> Show me the memextend statusAgent Instructions
To give your agent memory guidance, copy the included AGENTS.md file to your project root or global config:
# Project-level (recommended)
cp node_modules/@memextend/opencode/AGENTS.md AGENTS.md
# Or global
cp node_modules/@memextend/opencode/AGENTS.md ~/.config/opencode/AGENTS.mdOpenCode automatically loads AGENTS.md files and includes them in the agent's context. The file contains instructions for when to search and save memories.
Note: OpenCode also falls back to CLAUDE.md if no AGENTS.md exists, so if you already have ~/.claude/CLAUDE.md from Claude Code, it will work automatically.
How It Works
- MCP Integration: OpenCode connects to the memextend MCP server via stdio
- Tool Discovery: OpenCode discovers the memextend tools at startup
- Semantic Search: Memories are embedded using the Nomic embed model for semantic search
- Hybrid Search: Combines vector similarity with full-text search for best results
- Persistent Storage: Memories are stored in SQLite with sqlite-vec for vectors
Configuration Reference
OpenCode MCP Config
interface MCPConfig {
type: 'local' | 'remote'; // 'local' for stdio servers
command?: string[]; // Command and arguments to run
environment?: Record<string, string>; // Environment variables
enabled?: boolean; // Enable/disable the server
timeout?: number; // Request timeout in ms
}memextend Config (~/.memextend/config.json)
{
"retrieval": {
"autoInject": true,
"maxMemories": 10,
"recentDays": 7,
"includeGlobal": true
},
"capture": {
"tools": ["Edit", "Write", "Bash", "Task"],
"skipTools": ["Read", "Glob", "Grep"],
"maxContentLength": 2000
}
}Differences from Claude Code Adapter
| Feature | Claude Code | OpenCode | |---------|-------------|----------| | Hook System | Native hooks (SessionStart, Stop) | No native hooks | | Auto Context Injection | Yes (via SessionStart hook) | Manual via memextend_context | | Auto Memory Capture | Yes (via Stop hook) | Manual via memextend_save | | MCP Support | Yes | Yes | | Mid-Session Tools | Yes | Yes |
Since OpenCode does not have a native hook system like Claude Code, automatic context injection and memory capture are not available. Instead, users should:
- Use
memextend_contextat the start of a session to get relevant memories - Explicitly save important information using
memextend_saveormemextend_save_global
Troubleshooting
MCP Server Not Found
If OpenCode cannot find the memextend MCP server:
- Verify the path in your config is correct
- Ensure the package is built:
npm run build - Check Node.js is in your PATH
No Memories Found
If searches return no results:
- Run
memextend initto initialize the database - Verify memextend is working:
memextend status - Save some test memories first
Permission Errors
If you see permission errors:
- Ensure memextend directories exist:
~/.memextend/ - Check write permissions on the database files
Development
# Build the adapter
npm run build
# Run tests
npm test
# Build only the MCP server bundle
npm run build:bundleRelated
- memextend - Main memextend project
- OpenCode - OpenCode by Anomaly
- MCP Specification - Model Context Protocol
License
MIT - Copyright (c) 2026 ZodTTD LLC
