baton-mcp
Enables coding agents to convert and transfer sessions between different agent interfaces, allowing seamless continuation of work across agents.
README
<div align="center">
<img src="assets/logo.svg" width="420" alt="baton">
Pass the baton between coding agents.
Convert any coding-agent session to any other. One command. Keep going where you left off.
<img src="assets/demo.gif" width="800" alt="baton converting a Claude Code session to opencode">
A passed transcript kept 14/17 concrete facts. A hand-written handoff summary kept 3/17. Benchmark ↓
</div>
The 4 p.m. problem
It's 4 p.m. Claude Code says "usage limit reached — resets at 10 p.m." You're three hours into a session: architecture decided, edge cases mapped, half the diff written.
❌ Without baton — open another agent and start from zero. Re-explain the plan. Re-read the files. Re-litigate every decision you already made.
✅ With baton — pass the session and keep going:
baton convert --from claude-code --to opencode --latest --import
# using latest claude-code session: 2026-07-09 15:58 Refactor the auth middleware to…
# passed baton: claude-code → opencode (1388 messages) → handoff.json
# Imported session: ses_8c4c973a521549e2
opencode -s ses_8c4c973a521549e2 # same conversation, different runner
Works in every direction: switch agents mid-task, try a second opinion on a hard bug, move a session from your editor agent to a terminal agent, or archive everything in one format.
Quick start
# zero-install run (downloads prebuilt binary)
npx @kasabeh/baton-mcp --help
# convert your most recent session + auto-import into the target agent
baton convert --from claude-code --to opencode --latest --import
# or omit the path to pick interactively — newest first,
# each session previewed by its first user message
baton convert --from claude-code --to opencode --import
# or pass an explicit session file
baton convert --from claude-code --to opencode <session.jsonl> --import
# see every session on your machine, across all agents
baton list
Where do session files live?
You never have to hunt these down (--latest and the interactive picker find them for you), but for reference — each agent stores its transcripts on disk:
| Agent | Location |
|---|---|
| Claude Code | ~/.claude/projects/<encoded-cwd>/<session-uuid>.jsonl |
| Codex CLI | ~/.codex/sessions/<YYYY>/<MM>/<DD>/rollout-*.jsonl |
baton list prints the path of every session it can find, across all agents.
Supported formats
| Agent | Read | Write | Auto-import |
|---|---|---|---|
| Claude Code | ✅ | ✅ | — |
| OpenCode | ✅ | ✅ | ✅ opencode import |
| Codex CLI | ✅ | ✅ | — |
| Gemini CLI | ✅ | ✅ | — |
| Zed | ✅ | ✅ | — |
| Aider | ✅ | ✅ | — |
| Cursor | ✅¹ | —² | — |
| Continue | ✅ | — | — |
| Cline / Roo | ✅ | —² | — |
¹ Cursor reads from exported JSON (sqlite3 state.vscdb "SELECT value FROM ItemTable WHERE key='aiService:chats'")
² Not planned: Cursor and Cline keep session state inside editor databases (SQLite / VS Code globalState) with no file-level import path.
Benchmark
Does carrying the full transcript beat writing a handoff summary for the next agent? We measured both on a real 3.4 MB Claude Code session (same model both arms, only the context differs):
| session size | baton transcript | handoff summary |
|---|---|---|
| sm (93 KB) | 3/3 details recalled | 1/3 |
| md (198 KB) | 6/6 | 1/6 |
| lg (599 KB) | 5/8 | 1/8 |
| total | 14/17 | 3/17 |
The summary lost concrete facts (versions, line counts, MSRV) even on the smallest slice — the receiving agent had to re-read files and re-run commands to rediscover them. Mechanical fidelity: all 896 messages are written to every target; round-trip loss reflects each target format's expressiveness (claude-code 896/896, codex 736, gemini-cli 723, aider 111 — it stores chat text only).
We also measured task continuation: cut the session at three mid-task points, ask a fresh agent to state the task, state, and next steps. Result: parity (baton 10/12, handoff 10/12) — a good summary is enough for what to do next; the transcript is what answers the specific factual questions the summary's author didn't anticipate. And the summary only exists if an agent spends a full transcript read writing it — baton makes the transfer free.
Full methodology, caveats, and reproduction steps: benchmark/RESULTS.md.
MCP server
baton is also an MCP server — your agent can pass the baton itself, mid-conversation:
| Tool | Description |
|---|---|
list_sessions |
Scan all agents, return a unified list |
convert_session |
Convert a session from one format to another |
import_to_target |
Convert + run the target agent's import command |
detect_format |
Sniff a file/dir and report which agent produced it |
baton install # registers baton in every detected agent's MCP config
baton doctor # verify
baton uninstall # remove from all agents
How it works
Claude Code session (.jsonl)
│
▼
baton read ──► canonical Session { messages: [Text, Reasoning, ToolCall, ToolResult] }
│
▼
baton write ──► OpenCode import JSON (SessionV1 schema)
Every agent format is read into a canonical intermediate representation, then written out in the target format. Adding a new format is O(1), not O(N×M) per-pair converters.
Install
# npm (prebuilt binary, no Rust needed)
npm install -g @kasabeh/baton-mcp
# Homebrew
brew install kaseban/tap/baton-mcp
# Cargo binstall (prebuilt binary)
cargo binstall baton-mcp
# Cargo (from source)
cargo install baton-mcp
# Shell installer (prebuilt binary)
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/Kaseban/baton/releases/latest/download/baton-mcp-installer.sh | sh
Or grab a binary from GitHub Releases.
Building
git clone https://github.com/Kaseban/baton.git
cd baton
cargo build --release
./target/release/baton --help
Contributing
Each format lives in src/formats/<name>.rs and implements the Format trait (read + write). See src/formats/claude_code.rs for a complete reference implementation.
All nine formats have readers; Claude Code, OpenCode, Codex, Zed, Aider, and Gemini CLI also have writers. The most impactful contribution now is a writer for Continue.
Regenerating the demo
The README GIF is scripted with VHS: vhs assets/demo.tape. It records against a sandboxed $HOME (/tmp/demo) populated with fabricated sessions, so no real session data ends up in the GIF.
Don't drop the baton.
License
Dual-licensed under MIT OR Apache-2.0.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。