opencode-session-context-mcp
opencode-session-context-mcp
osc-mcp
デモ
https://github.com/user-attachments/assets/d41fb2b8-96ca-4a03-9bcd-afede68212e2
Related MCP server: agent-mem0
目次
説明
opencode-session-context-mcp (別名: osc-mcp) は、同じプロジェクト内の以前のセッションからコンテキストを新しいセッションに提供するMCPサーバーです。これにより、OpenCodeインスタンスは中断したところから作業を再開し、プロジェクトの継続的なニーズにより適切に合わせることができます。
⚠️ 注意: このツールは現在活発に開発中です。特にコンテキスト取得時のトークン消費の最適化に注力しています。貢献を歓迎します。
仕組み
セッション開始時に、サーバーは前回のセッションのフィルタリングされた要約を
mcp.dbに保存します。新しいセッションがコンテキストを要求すると、現在のプロジェクトの最近の要約を検索します。
クライアント (OpenCode) はそれらの要約を使用して、関連するコンテキストを新しいセッションにシードします。
ツール
store_previous_session_content: 直前のセッションからフィルタリングされたコンテンツをmcp.dbに保存します。get_relevant_sessions: 現在のプロジェクトに関する最近のセッション要約の軽量なリストを返します。
要件
bungitOpenCode (インストールおよび設定済みであること)
インストール
クイックスタート (推奨)
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 | iexセキュリティ上の注意: 実行前に scripts/install.sh を確認するか、以下の手動手順を使用してください。Windowsの場合は、実行前に scripts/install.ps1 を確認してください。
インストーラーの動作 (Linux/mac):
opencode.jsonを検索します (XDG_CONFIG_HOMEを尊重します)。bunとgitがインストールされていることを確認します。OpenCodeのデータディレクトリが存在することを確認します (
XDG_DATA_HOMEを尊重します)。~/.local/share/opencode/osc-mcpにリポジトリをクローンまたは更新します。bun installを実行し、サーバーをビルドします。opencode.jsonを更新し、"osc-mcp"MCPエントリを追加します。設定ファイルの編集に失敗した場合や
--no-configが設定されている場合は、手動手順を表示します。
設定ファイルが不正なJSONである場合や --no-config を渡した場合は、以下の手動手順に従ってください。
手動インストール
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/opencode/opencode.json):
指示ファイルがまだリストにない場合は、追加してください:
"instructions": [
"~/.local/share/opencode/osc-mcp/instructions/session-start.md",
"~/.local/share/opencode/osc-mcp/instructions/context-lookup.md"
]次に、ローカルのMCPエントリを追加します (存在しない場合):
"osc-mcp": {
"type": "local",
"enabled": true,
"command": ["bun", "~/.local/share/opencode/osc-mcp/src/index.ts"]
}実行
# Run the MCP server
bun src/index.tsヒント
MCPがセッションを正しいプロジェクトにマッピングできるように、プロジェクトのルートからOpenCodeを起動してください。
セッションを安定したリポジトリのコンテキストに関連付けられるよう、プロジェクトをgitで管理してください。
環境変数
OPENCODE_DB: OpenCode DBへのパス (デフォルト:~/.local/share/opencode/opencode.db)
デフォルトのパスが環境に合わない場合は、OpenCode/MCPを起動する前に明示的に設定してください。
例:
export OPENCODE_DB="$HOME/.local/share/opencode/opencode.db"
opencodeインストーラーのオーバーライド (オプション):
OSC_MCP_REPO_URL: クローンするGitリポジトリURL (デフォルト:https://github.com/vohs-1980/osc-mcp.git)OSC_MCP_INSTALL_DIR: インストールディレクトリ (デフォルト:~/.local/share/opencode/osc-mcp)OSC_MCP_REF: チェックアウトするGit参照 (タグ/ブランチ/コミット、デフォルト:main)XDG_CONFIG_HOME: 基本設定ディレクトリ (デフォルト:~/.config)XDG_DATA_HOME: 基本データディレクトリ (デフォルト:~/.local/share)
オーバーライドの例:
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に関する注意点
macOS/Linux:
scripts/install.shを使用してください (bash,git,bunが必要)Windows: PowerShellで
scripts/install.ps1を使用してください。
設定パスの検出 (インストーラーはこの順序で検索します):
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
デフォルトのデータ場所 (データベース):
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
ライセンス
MIT。LICENSE を参照してください。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Sync coding-agent sessions and resume them in any other agent: Claude Code, Codex, Cursor, more.
Bring your saved preferences, project decisions, and useful context into your next AI conversation.
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.
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