opencode-session-context-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@opencode-session-context-mcpwhat was discussed in the previous session?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
opencode-session-context-mcp
osc-mcp
Demo
https://github.com/user-attachments/assets/d41fb2b8-96ca-4a03-9bcd-afede68212e2
Related MCP server: agent-mem0
Dictionary
Description
opencode-session-context-mcp (aka osc-mcp) is an MCP server that supplies new sessions
with context from prior sessions in the same project, so your OpenCode instance can pick
up where you left off and better align with your project’s ongoing needs.
⚠️ Caution: this tool is under active development, especially around optimizing token spend when fetching context. Contributions are welcome.
How It Works
On session start, the server stores a filtered summary of the previous session into
mcp.db.When a new session asks for context, it looks up recent summaries for the current project.
The client (OpenCode) uses those summaries to seed your new session with relevant context.
Tools
store_previous_session_content: stores filtered content from the most recent previous session intomcp.db.get_relevant_sessions: returns a lightweight list of recent session summaries for the current project.
Requirements
bungitOpenCode (installed and configured)
Install
Quick Start (best UX)
Linux/mac
curl -fsSL https://github.com/vohs-1980/osc-mcp/blob/main/scripts/install.sh?raw=1 | bashWindows (PowerShell):
irm https://github.com/vohs-1980/osc-mcp/blob/main/scripts/install.ps1?raw=1 | iexSecurity note: review scripts/install.sh before running or use the manual
steps below. For Windows, review scripts/install.ps1 before running.
What the installer does (Linux/mac):
Finds your
opencode.json(honorsXDG_CONFIG_HOME).Verifies
bunandgitare installed.Verifies the OpenCode data dir exists (honors
XDG_DATA_HOME).Clones or updates the repo in
~/.local/share/opencode/osc-mcp.Runs
bun installand builds the server.Updates
opencode.jsonto add the"osc-mcp"MCP entry.If config editing fails or
--no-configis set, prints manual steps.
If your config is invalid JSON or you pass --no-config, follow the manual
steps below.
Manual Install
git clone https://github.com/vohs-1980/osc-mcp.git \
~/.local/share/opencode/osc-mcp
cd ~/.local/share/opencode/osc-mcp
bun install
bun run buildOpenCode config (~/.config/opencode/opencode.json):
If you don't already have the instruction files listed, add them:
"instructions": [
"~/.local/share/opencode/osc-mcp/instructions/session-start.md",
"~/.local/share/opencode/osc-mcp/instructions/context-lookup.md"
]Then add the local MCP entry (if not present):
"osc-mcp": {
"type": "local",
"enabled": true,
"command": ["bun", "~/.local/share/opencode/osc-mcp/src/index.ts"]
}Run
# Run the MCP server
bun src/index.tsTips
Start OpenCode from your project root so the MCP can map sessions to the correct project.
Keep your project in git so sessions can be tied to a stable repo context.
Environment
OPENCODE_DB: Path to OpenCode DB (default~/.local/share/opencode/opencode.db)
If the default path doesn’t work for your setup, set it explicitly before launching OpenCode/MCP.
Example:
export OPENCODE_DB="$HOME/.local/share/opencode/opencode.db"
opencodeInstaller overrides (optional):
OSC_MCP_REPO_URL: Git repo URL to clone (defaulthttps://github.com/vohs-1980/osc-mcp.git).OSC_MCP_INSTALL_DIR: Install directory (default~/.local/share/opencode/osc-mcp).OSC_MCP_REF: Git ref to checkout (tag/branch/commit, defaultmain).XDG_CONFIG_HOME: Base config directory (default~/.config).XDG_DATA_HOME: Base data directory (default~/.local/share).
Example override:
export OSC_MCP_REPO_URL="https://github.com/vohs-1980/osc-mcp.git"
export OSC_MCP_INSTALL_DIR="$HOME/.local/share/opencode/osc-mcp"
export OSC_MCP_REF="v0.1.0"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"OS Notes
macOS/Linux: use
scripts/install.sh(requiresbash,git,bun)Windows: use
scripts/install.ps1in PowerShell.
Config path detection (installers search in this order):
macOS/Linux:
$XDG_CONFIG_HOME/opencode/opencode.json~/.config/opencode/opencode.json~/Library/Application Support/opencode/opencode.json
Windows:
%XDG_CONFIG_HOME%\opencode\opencode.json%APPDATA%\opencode\opencode.json%LOCALAPPDATA%\opencode\opencode.json~\.config\opencode\opencode.json~\Library\Application Support\opencode\opencode.json
Default data locations (databases):
macOS/Linux:
~/.local/share/opencode/opencode.db~/.local/share/opencode/osc-mcp/mcp.db
Windows:
%USERPROFILE%\.local\share\opencode\opencode.db%USERPROFILE%\.local\share\opencode\osc-mcp\mcp.db
License
MIT. See LICENSE.
Related MCP Connectors
Shared memory across AI dev tools: each session hands its context to the next, not starting cold.
Persistent memory for Claude Code and Cursor. Stop re-explaining your project every session.
Shared memory for coding agents. Stop re-explaining your codebase every session.
Persistent cross-session memory shared by Codex, Claude Code, ChatGPT, and other AI agents.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI coding assistants like Claude Code, Cursor, and Codex to share chat logs, terminal history, and session context with each other. Eliminates the need to re-explain context when switching between different AI coding tools.2MIT
- AlicenseNot gradedqualityDmaintenanceProvides persistent cross-session memory for Claude Code, enabling it to remember user preferences, decisions, and project context across new sessions.Apache 2.0
- AlicenseNot gradedqualityDmaintenanceProvides persistent memory for Claude Code, automatically extracting and surfacing relevant context from past sessions to avoid re-explaining issues and decisions.MIT
- AlicenseAqualityDmaintenanceProvides cross-session memory for Claude Code by extracting structured handoffs at session end and retrieving relevant past context at session start.27MIT