OpenCode Peer
v0.3.0MCP server bridging OpenCode sessions on this machine and across machines
Let one OpenCode agent read, search, compare, and prompt other OpenCode sessions — on this machine first, across machines when you need it. Quickstart · Tools · Configuration Illustrative session with two configured servers:
Summary extracted from the README.
Why this exists
- Sessions are isolated. OpenCode sessions cannot share context, even on the same machine.
- Same machine, no setup. Without a config file, the bridge discovers the local OpenCode server from its service registration and exposes it as
local. - Across machines, when needed. Add remote servers in config to read, search, and compare sessions on a workstation without copying context by hand.
Demo
Illustrative session with two configured servers:
> List my servers, then find sessions about the billing migration.
servers_list
laptop General coding and repository work
workstation Data analysis, reporting, and dashboards
sessions_search query="billing migration"
laptop/ses_4f2a Refactor invoice retry logic
workstation/ses_9c1d Billing migration rollout plan
Quickstart
-
Install the CLI:
npm install -g opencode-peer-mcp -
Add the bridge to your MCP client. For OpenCode, edit
~/.config/opencode/opencode.json:{ "mcp": { "opencode-peer": { "type": "local", "command": ["opencode-peer-mcp"] } } }Without a
servers.yaml, the bridge discovers the OpenCode server running on this machine and calls itlocal. -
Restart your client and ask:
List my servers, then find sessions about the billing migration.
Discovery reads OpenCode's service registration at $XDG_STATE_HOME/opencode/service.json, or ~/.local/state/opencode/service.json when XDG_STATE_HOME is unset. For a server started manually, add it to servers.yaml with its URL and password.
Cross-machine use
Create ~/.config/opencode-peer-mcp/servers.yaml only when you want additional machines:
servers:
- id: laptop
description: General coding and repository work
url: http://127.0.0.1:49374
password_env: OPENCODE_LOCAL_PASSWORD
- id: workstation
description: Data analysis, reporting, and dashboards
url: http://127.0.0.2:49374
password_env: OPENCODE_WORKSTATION_PASSWORD
Every server uses HTTP Basic auth. password_env names the environment variable holding its password; the username is fixed to opencode. Secrets are referenced by name, never stored in the file.
When a config file exists, discovery does not run and only configured servers are used. With multiple servers, pass server on server-addressed tools. With exactly one server, you can omit it. sessions_search always searches every server unless you pass servers.
[!IMPORTANT] Keep OpenCode servers on a trusted private network. We highly recommend Tailscale or a similar private subnetting service for cross-machine access. Do not expose an OpenCode server directly to the public internet.
What you get
| Group | Tools | Notes |
|---|---|---|
| Servers | servers_list, server_get |
Discover available targets and descriptions. |
| Read | sessions_list, session_get, session_status, session_messages, session_diff, sessions_search, sessions_compare |
Never mutate OpenCode state. |
| Write (gated) | session_create, session_prompt, session_interrupt, session_schedule |
Require the write gate and allowlist. |
Full parameters and return shapes: docs/tools.md.
Write access and audit
Writes are disabled by default. To enable them:
- Set
OPENCODE_PEER_MCP_WRITE_ENABLED=true(exact lowercase string). - Allowlist target sessions in the config, use
*for all sessions, or addcreateforsession_create.
The implicit local server allows all sessions. Configured servers use their own allowlists. Each write tool also accepts allowed: true, which is caller-supplied and bypasses the allowlist, so do not expose write tools to untrusted clients.
Denied and allowed writes go to ~/.opencode-peer-mcp/audit.log. Override the path with OPENCODE_PEER_MCP_AUDIT_LOG.
Documentation
- Architecture
- Configuration
- MCP tools
- Deployment
- Testing
- Evals
- Troubleshooting
- Versioning
- Release
- MCP Registry
- Examples
Development
Use the Bun canary build. bun lint exists only in canary builds: bun upgrade --canary.
bun install: installs dependencies and points Git at the committed.githooks/directory.bun run test: unit tests.bun run test:integration: starts fixture OpenCode servers. RequiresopencodeonPATH.bun run typecheck,bun run lint,bun run format:check: static checks.
The pre-commit hook runs bun fmt --staged, bun lint --staged --fix, bun check, and bun check -p tsconfig.tests.json. Run the commit with the canary bun first on PATH.
Contributing
See CONTRIBUTING.md.
License
This project is licensed under the MIT License. See LICENSE.