SameTree
Click on "Install 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., "@SameTreeclaim the file src/utils.ts for editing"
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.
SameTree
Local coordination for coding agents that share a Git working tree.
SameTree gives already-running Claude Code, OpenCode, and other MCP-capable agents a shared task board, inbox, path-claim registry, handoff protocol, and versioned collaboration policy. It runs locally, works in an existing dirty working tree, and needs no daemon, Docker container, PostgreSQL server, cloud account, or per-agent branch.
SameTree is alpha software. Its claims are cooperative leases, not operating-system locks. Back up important work and read theoperating boundaries before using it.
Why SameTree?
Parallel coding agents usually solve conflicts by isolating every worker in a branch or worktree. That is useful for independent tasks, but it gets in the way when two agents need to inspect the same uncommitted state, alternate edits, or review work before it is committed.
SameTree is deliberately for the other case:
Two to ten agents run on one machine.
Every agent sees the same working tree, including uncommitted changes.
Agents need durable context across Claude Code and OpenCode sessions.
Coordination should not require a server process or external database.
Repository policy should be shared once and acknowledged by every agent.
Checkable Git rules should be enforced mechanically, not left only in a prompt.
Related MCP server: Shift MCP Server
Features
Cross-harness MCP server with structured tools for Claude Code, OpenCode, and other MCP clients.
One-command project setup that safely merges Claude Code and OpenCode integration.
Structured CLI for humans, shell scripts, hooks, and agents without MCP.
Durable tasks with dependencies, priorities, revision checks, assignments, expiring execution leases, and explicit stale-work takeover.
Atomic path claims for exact files or recursive directories. A claim batch either succeeds completely or writes nothing.
Direct messages and broadcasts with threads, task links, unread state, and acknowledgements.
Structured handoffs that reject stale task revisions and can transfer selected path claims on acceptance.
Versioned policy and role files under
.sametree/, with content-hash acknowledgements.Optional Git hooks for conflicting staged paths, oversized diffs, Conventional Commits, and forbidden
Co-authored-bytrailers.Transactional audit events with a sequence cursor for polling and diagnostics.
Human-readable live watch for following tasks, claims, messages, and handoffs.
Worktree-local SQLite WAL state stored under Git's private directory instead of committed into the repository.
Requirements
Node.js 22.12 or newer
Git
A local filesystem with working file locks
SameTree does not support state databases on NFS, SMB, cloud-synced folders, or multiple machines.
Install
Install from source:
git clone https://github.com/simozampa/sametree.git
cd sametree
npm ci
npm run build
npm linknpm link exposes sametree and sametree-mcp on your current Node.js toolchain. SameTree is not yet published to the npm registry.
Quick Start
Configure both harnesses in the repository where agents will collaborate:
cd /path/to/your/project
sametree setup --claude --opencode
SAMETREE_AGENT=human sametree doctorSetup initializes the versioned policy, safely merges opencode.json or opencode.jsonc, updates AGENTS.md and CLAUDE.md, and registers SameTree with Claude Code at local project scope. Existing configuration and comments are preserved; conflicting entries are refused rather than overwritten.
SameTree's generated coordination directory is fully versioned:
.sametree/
├── config.json
├── coordination.md
├── policy.md
└── roles/
├── implementer.md
└── reviewer.mdLive state is created on first use inside Git's worktree-specific private directory. It is normally .git/sametree/state.sqlite3 and is never committed.
Manual Claude Code Configuration
From the target project, add SameTree as a local-scoped stdio MCP server:
claude mcp add --scope local --transport stdio sametree \
--env SAMETREE_HARNESS=claude-code -- sametree-mcpReference the generated coordination guide from the project's CLAUDE.md:
@.sametree/coordination.mdStart each Claude Code instance with a distinct name:
SAMETREE_AGENT=claude-1 claude
SAMETREE_AGENT=claude-reviewer SAMETREE_ROLE=reviewer claudeClaude Code passes its stable project directory to SameTree automatically.
Manual OpenCode Configuration
Add this to the target project's opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"sametree": {
"type": "local",
"command": ["sametree-mcp"],
"environment": {
"SAMETREE_HARNESS": "opencode"
},
"enabled": true
}
}
}Tell OpenCode to read .sametree/coordination.md from the project's AGENTS.md, then launch each instance with a distinct name:
SAMETREE_AGENT=opencode-1 opencode
SAMETREE_AGENT=opencode-reviewer SAMETREE_ROLE=reviewer opencodeThe name is inherited by the MCP process. Do not hard-code one shared name in the MCP configuration when running more than one instance.
Coordination Loop
An agent should follow this loop at natural work boundaries:
Call
sametree_statusandsametree_policy_getat session start.Acknowledge the current policy hash with
sametree_policy_ack.Read
sametree_inboxand pending handoffs.Claim a ready task, then atomically claim the smallest required paths.
Send messages when ownership or implementation decisions overlap.
Check the inbox before commits and after each task.
Update the task and release claims, or offer a structured handoff.
Example with the CLI:
export SAMETREE_AGENT=opencode-1
export SAMETREE_HARNESS=opencode
sametree status
sametree task create --title "Add request validation" --priority high
sametree task claim task_...
sametree claim acquire src/http/request.ts test/http/request.test.ts
sametree message send --to claude-reviewer \
--subject "Validation ready" \
--body "Please review task task_... at commit abc123" \
--task task_...
sametree task update task_... --status done
sametree claim release --allRegular command results and domain errors are JSON so agents and scripts can consume the interface reliably. Help, version output, and the default live watch remain conventional command-line text; watch --json emits JSON Lines.
CLI processes do not stay alive to heartbeat. The default task and path leases last 15 minutes. During longer CLI-only work, rerun task claim <task-id> and claim acquire <paths...> before expiry; use claim acquire --ttl <seconds> to request a path lease of up to 24 hours. MCP sessions renew their leases automatically.
Watch Activity
Follow coordination from a fifth terminal:
SAMETREE_AGENT=observer sametree watch --tailReplay history and continue following by omitting --tail. Use --once to print available events and exit, or --json for JSON Lines suitable for scripts.
See the four-agent review loop for launch commands and copy-paste worker and reviewer prompts.
MCP Tools
Tool | Purpose |
| Read the full coordination snapshot |
| Renew the current session and its leases |
| Create durable work and dependencies |
| List or filter tasks |
| Claim ready work or take over an expired lease |
| Change assigned work with an optional revision check |
| Atomically claim exact paths or directory trees |
| Inspect active path claims |
| Release selected or all owned claims |
| Send a direct message or broadcast |
| Poll direct and broadcast messages |
| Mark a message read |
| Offer task context and selected claims |
| Read incoming and outgoing handoffs |
| Accept or reject a handoff |
| Read the current policy and acknowledgement state |
| Acknowledge an exact policy hash |
| Poll the append-only audit stream |
The server also exposes sametree://snapshot and sametree://policy/current as read-only MCP resources.
Git Safety Rails
Install optional hooks after reviewing them:
export SAMETREE_AGENT=human
sametree hooks installKeep SAMETREE_AGENT set when committing from that shell. Agent-launched Git commands inherit the identity used to start their harness.
SameTree writes pre-commit and commit-msg only when those hook slots are empty or already managed by SameTree. Existing user hooks are reported and preserved, never overwritten.
The default policy checks:
Staged paths must not overlap another agent's active claim.
A staged diff must not exceed 400 changed lines.
Commit subjects must follow Conventional Commits.
Commit messages must not contain
Co-authored-bytrailers.
Configure these rules in .sametree/config.json. Hooks are safety rails, not a security boundary: Git permits --no-verify, and processes sharing an operating-system account can modify hooks.
How It Works
Every MCP client starts its own short-lived SameTree process. CLI commands are short-lived processes too. They all open one SQLite database directly:
Claude Code ─┐
Claude Code ─┼─ MCP stdio / CLI ─ Domain service ─ SQLite WAL
OpenCode ────┤ └─ Git working tree
OpenCode ────┘SQLite BEGIN IMMEDIATE transactions serialize small mutations before conflict checks. Current state and its audit event commit together. WAL mode allows readers to continue while one process writes. No server needs to remain running.
Read Architecture for storage and concurrency decisions, Protocol for state transitions and invariants, and Landscape for the alternatives reviewed before building SameTree.
Operating Boundaries
Claims coordinate cooperative agents; they cannot prevent a process from writing directly to a file.
SameTree is for one local host and one working tree. It is not a distributed coordination service.
Agents sharing an operating-system account are not mutually isolated or untrusted tenants.
Same-file work must be serialized by message and claim transfer. SameTree does not merge simultaneous edits.
Stdio MCP has no cross-process push channel here. Agents poll inboxes and events at natural boundaries.
The database is operational state, not project history. Important decisions should also appear in commits, task descriptions, or durable documentation.
Development
npm ci
npm run check
npm pack --dry-runThe test suite covers domain state transitions, path traversal and symlink escapes, task and claim conflicts, policy hooks, two-process SQLite contention, and a real MCP stdio handshake.
See CONTRIBUTING.md before opening a pull request and SECURITY.md for private vulnerability reports.
License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/simozampa/sametree'
If you have feedback or need assistance with the MCP directory API, please join our Discord server