OpenCode Peer MCP
<h1 align="center">OpenCode Peer MCP</h1>
<p align="center">
<strong>Let one OpenCode agent read, search, compare, and prompt other OpenCode sessions — on this machine first, across machines when you need it.</strong>
</p>
<p align="center">
<a href="https://www.npmjs.com/package/opencode-peer-mcp"><img alt="npm version" src="https://img.shields.io/npm/v/opencode-peer-mcp?style=flat-square&color=0550ae"></a>
<a href="https://github.com/jacklaw1410/opencode-peer-mcp/actions/workflows/ci.yml"><img alt="CI status" src="https://img.shields.io/github/actions/workflow/status/jacklaw1410/opencode-peer-mcp/ci.yml?branch=main&style=flat-square&color=1a7f37"></a>
<a href="https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/LICENSE"><img alt="MIT license" src="https://img.shields.io/github/license/jacklaw1410/opencode-peer-mcp?style=flat-square&color=57606a"></a>
</p>
<p align="center">
<a href="#quickstart">Quickstart</a> ·
<a href="https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/tools.md">Tools</a> ·
<a href="https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/configuration.md">Configuration</a>
</p>
## 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:
```text
> 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
1. Install the CLI:
```bash
npm install -g opencode-peer-mcp
```
2. Add the bridge to your MCP client. For OpenCode, edit `~/.config/opencode/opencode.json`:
```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 it `local`.
3. 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:
```yaml
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](https://tailscale.com/) 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](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/tools.md).
## Write access and audit
Writes are disabled by default. To enable them:
1. Set `OPENCODE_PEER_MCP_WRITE_ENABLED=true` (exact lowercase string).
2. Allowlist target sessions in the config, use `*` for all sessions, or add `create` for `session_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](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/architecture.md)
- [Configuration](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/configuration.md)
- [MCP tools](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/tools.md)
- [Deployment](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/deployment.md)
- [Testing](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/testing.md)
- [Evals](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/evals.md)
- [Troubleshooting](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/troubleshooting.md)
- [Versioning](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/versioning.md)
- [Release](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/release.md)
- [MCP Registry](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/docs/mcp-registry.md)
- [Examples](https://github.com/jacklaw1410/opencode-peer-mcp/tree/main/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. Requires `opencode` on `PATH`.
- `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](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/CONTRIBUTING.md).
## License
This project is licensed under the MIT License. See [LICENSE](https://github.com/jacklaw1410/opencode-peer-mcp/blob/main/LICENSE).
TDQS
Scored across 13 tools
Descriptions actively carve out boundaries: sessions_list vs sessions_search (single server vs cross-server), session_get vs session_status (raw vs derived), and session_messages/session_diff/sessions_compare each explicitly state what they do NOT return. Similar-sounding pairs (session_prompt vs session_schedule, server_get vs servers_list) are separated by immediate-vs-delayed semantics and cardinality.
The pattern is <noun>_<action> throughout, with a meaningful singular/plural convention: singular session_/server_ for one-entity operations, plural sessions_/servers_ for collection operations. The only rough edges are noun-style suffixes (session_status, session_messages, session_diff) instead of a pure verb, which slightly breaks the verb_noun expectation.
13 tools sit in the sweet spot and each maps to a distinct session lifecycle action (create, prompt, interrupt, schedule, inspect, compare, search). Nothing appears redundant or bolted on.
The session lifecycle is well covered end-to-end — create, prompt, interrupt, schedule, read messages, diff, compare, status, search — plus read access to servers. Missing a session delete/cleanup or rename/update operation, which leaves a dead end for housekeeping tasks.