agnt-lock
Click on "Deploy 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., "@agnt-lock Acquire lock on src/auth.ts for refactoring authentication"
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.
The Context Traffic Controller for Multi-Agent Repositories
Stop AI agents from destroying each other's work.
Quick Start ยท How It Works ยท MCP Config ยท CLI Usage ยท Contributing
๐ฅ The Problem: Agentic Collision
You're running multiple AI agents on the same codebase. Maybe Claude Code is refactoring your auth module while Aider is updating your API routes. Everything seems fine until:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ ๐ค Agent A (Claude Code) ๐ค Agent B (Aider) โ
โ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Reading auth.ts... โ โ Reading auth.ts... โ โ
โ โ Planning refactor โ โ Planning new routes โ โ
โ โโโโโโโโโโฌโโโโโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโโโโ โ
โ โ โ โ
โ โผ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Writing auth.ts... โ โ Writing auth.ts... โ โ
โ โ โ
Refactor done! โ โ โ
Routes added! โ โ
โ โโโโโโโโโโฌโโโโโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโโโโ โ
โ โ โ โ
โ โโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โผ โผ โ
โ โโโโโโโโโโโโโโโโ โ
โ โ ๐ auth.ts โ โ
โ โ CORRUPTED โ โ
โ โ Build: FAIL โ โ
โ โโโโโโโโโโโโโโโโ โ
โ โ
โ Agent A's refactor is GONE. Agent B overwrote it. โ
โ Neither agent knows the other existed. โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโThis is "Agentic Collision" โ and it's the #1 reason multi-agent workflows fail silently.
What goes wrong:
๐ Silent overwrites โ Agent B nukes Agent A's changes with zero warning
๐ง Context loss โ Each agent hallucinates that it's the only one working
๐ Infinite loops โ Agents "fix" each other's changes back and forth forever
๐ Broken builds โ The repo ends up in a state no single agent intended
Related MCP server: asynkor
โ The Solution: AGNT-LOCK
AGNT-LOCK is a lightweight coordination layer that sits between your AI agents and your repository. It uses the Model Context Protocol (MCP) to give every agent awareness of what other agents are doing.
graph TB
subgraph Agents
A[๐ค Claude Code]
B[๐ค Roo Code]
C[๐ค Aider]
D[๐ค Cursor]
end
subgraph AGNT-LOCK
MCP[๐ MCP Server]
SM[๐ State Manager]
IL[๐ Intent Log]
end
subgraph Repository
F1[๐ auth.ts]
F2[๐ routes.ts]
F3[๐ config.ts]
end
A -->|acquire_lock| MCP
B -->|acquire_lock| MCP
C -->|get_repo_state| MCP
D -->|release_lock| MCP
MCP --> SM
SM --> IL
SM -->|โ
Grant / ๐ Block| Agents
SM -.->|tracks| RepositoryHow it works:
Before editing, an agent calls
acquire_lock(filepath, agent_name, intent)If the file is free โ lock is granted, intent is logged
If the file is locked by another agent โ request is blocked with details about who holds it and why
After editing, the agent calls
release_lock(filepath)to free the fileAny agent can call
get_repo_state()to see the full coordination map
๐ Quick Start
Install
# Clone the repository
git clone https://github.com/codewithriza/AGNT-LOCK.git
cd AGNT-LOCK
# Install dependencies
npm install
# Build
npm run buildRun as MCP Server
# Start the MCP server (stdio transport)
node dist/index.jsInstall globally (CLI)
npm install -g .
agnt-lock statusโ๏ธ MCP Configuration
For Claude Desktop / Claude Code
Add to your claude_desktop_config.json:
{
"mcpServers": {
"agnt-lock": {
"command": "node",
"args": ["/absolute/path/to/AGNT-LOCK/dist/index.js"],
"env": {}
}
}
}For Cursor
Add to your .cursor/mcp.json:
{
"mcpServers": {
"agnt-lock": {
"command": "node",
"args": ["/absolute/path/to/AGNT-LOCK/dist/index.js"]
}
}
}For Roo Code (VS Code)
Add to your MCP settings in Roo Code:
{
"mcpServers": {
"agnt-lock": {
"command": "node",
"args": ["/absolute/path/to/AGNT-LOCK/dist/index.js"],
"disabled": false,
"alwaysAllow": ["acquire_lock", "release_lock", "get_repo_state"]
}
}
}๐ก Tip: Replace
/absolute/path/to/AGNT-LOCKwith the actual path where you cloned the repo.
๐ ๏ธ MCP Tools
AGNT-LOCK exposes 4 tools via the Model Context Protocol:
Tool | Description |
| Lock a file before editing. Blocks if already locked by another agent. |
| Release a file lock after editing. Commits intent to session history. |
| Get the full coordination map: active locks, agents, recent activity. |
| Emergency reset: force-release all locks in the repository. |
acquire_lock
// Parameters
{
filepath: "src/auth.ts", // File to lock
agent_name: "claude-code", // Who's locking it
intent: "Refactoring auth middleware to use JWT" // Why
}
// Response (success)
{
"success": true,
"message": "โ
Lock acquired on \"src/auth.ts\" by \"claude-code\".",
"lock": {
"filepath": "src/auth.ts",
"agent_name": "claude-code",
"intent": "Refactoring auth middleware to use JWT",
"acquired_at": "2026-03-15T10:30:00.000Z",
"expires_at": "2026-03-15T10:45:00.000Z"
}
}
// Response (blocked)
{
"success": false,
"message": "๐ BLOCKED: File \"src/auth.ts\" is locked by agent \"aider\"...",
"blocked_by": { ... }
}get_repo_state
๐ AGNT-LOCK Repository State
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Session: session_20260315_a3f8k2
Active Locks: 2
Active Agents: claude-code, aider
๐ Locked Files:
โข src/auth.ts โ claude-code (intent: "Refactoring auth middleware")
โข src/routes.ts โ aider (intent: "Adding new API endpoints")
๐ Recent Activity:
๐ claude-code โ acquire "src/auth.ts"
๐ aider โ acquire "src/routes.ts"
๐ roo-code โ release "src/config.ts"๐ป CLI Usage
AGNT-LOCK also includes a CLI for manual coordination and debugging:
# Check repository coordination state
agnt-lock status
# Manually lock a file
agnt-lock lock src/index.ts my-agent "Updating the main entry point"
# Release a lock
agnt-lock unlock src/index.ts my-agent
# Emergency: release all locks
agnt-lock reset
# Start MCP server from CLI
agnt-lock serve๐ Project Structure
AGNT-LOCK/
โโโ src/
โ โโโ index.ts # MCP server entry point (stdio transport)
โ โโโ server.ts # MCP tool definitions (acquire, release, state)
โ โโโ state-manager.ts # Core .agentlock state engine
โ โโโ cli.ts # Color-coded CLI dashboard
โโโ tests/
โ โโโ state-manager.test.ts # Vitest unit tests (9 tests)
โโโ website/ # Next.js + Tailwind landing page
โ โโโ app/
โ โ โโโ page.tsx # Dark-mode landing page
โ โ โโโ layout.tsx # Root layout with metadata
โ โ โโโ globals.css # Tailwind + custom styles
โ โโโ package.json
โโโ dist/ # Compiled JavaScript (after build)
โโโ .agentlock/ # Runtime state directory (auto-created, gitignored)
โ โโโ state.json # Current locks & intent log
โโโ vitest.config.ts # Test configuration
โโโ package.json
โโโ tsconfig.json
โโโ LICENSE # MIT
โโโ README.md๐ How the Lock System Works
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ .agentlock/state.json โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ active_locks: { โ
โ "src/auth.ts": { โ
โ agent_name: "claude-code", โ
โ intent: "Refactoring auth middleware", โ
โ acquired_at: "2026-03-15T10:30:00Z", โ
โ expires_at: "2026-03-15T10:45:00Z" โ Auto-expiry โ
โ } โ
โ } โ
โ โ
โ intent_log: [ โ
โ { agent: "roo-code", action: "acquire", file: "..." }, โ
โ { agent: "roo-code", action: "release", file: "..." }, โ
โ { agent: "claude-code", action: "acquire", file: "..." } โ
โ ] โ Rolling log (max 500 entries) โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโKey Design Decisions:
File-level locking โ Granular enough to allow parallel work, broad enough to prevent conflicts
15-minute TTL โ Locks auto-expire to prevent deadlocks from crashed agents
Intent logging โ Every lock/unlock is logged with why the agent needed the file
Zero external dependencies โ State is a single JSON file, no database required
Ownership verification โ Only the locking agent (or force-release) can unlock a file
๐ค Contributing
Contributions are welcome! Here's how to get started:
# Fork and clone
git clone https://github.com/YOUR_USERNAME/AGNT-LOCK.git
cd AGNT-LOCK
# Install dependencies
npm install
# Build
npm run build
# Test the CLI
node dist/cli.js statusIdeas for contributions:
๐ HTTP/SSE transport (for remote agent coordination)
๐ Web dashboard for visualizing lock state
๐ Webhook notifications when locks are contested
๐งช Test suite
๐ฆ npm package publishing
๐ณ Docker container
Available Tools
4 toolsacquire_lockA
Acquire an exclusive lock on a file before editing. Prevents other AI agents from modifying the same file simultaneously. Returns lock status and blocker info if already locked.
Inputs: intent (required), filepath (required), agent_name (required).
force_release_allA
Emergency: Force-release ALL active locks. Use only when agents are stuck or locks are stale. This will free every locked file in the repository.
Inputs: no named parameters.
get_repo_stateA
Get the current coordination state of the repository. Shows all active locks, which agents are working, and recent intent history. Use this before starting work to understand what other agents are doing.
Inputs: no named parameters.
release_lockA
Release a previously acquired lock on a file. Call this after finishing edits to allow other agents to work on the file. The intent is committed to session history.
Inputs: filepath (required), agent_name.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: acquiring, releasing, viewing state, and emergency release. The only potential overlap is between release_lock and force_release_all, but their scopes (single vs. all) and contexts (normal vs. emergency) make them unambiguous.
All tool names follow a consistent verb_noun pattern: acquire_lock, release_lock, get_repo_state, force_release_all. The verbs and nouns are descriptive and match their functionality, making the set predictable and coherent.
With 4 tools, the server is well-scoped for a lock management purpose. Each tool covers a necessary operation without redundancy, and the count falls comfortably within the ideal 3-15 range.
The server covers the full lock lifecycle: acquire, release, query state, and emergency cleanup. The only minor gap is a lack of a per-file lock check endpoint, but get_repo_state provides sufficient visibility into lock status.
Maintenance
Related MCP Connectors
Parallel coding agents claim a file before editing, so none overwrites another.
Coordinate multiple AI agents over MCP: atomic claims, leases, shared ledger, handoffs, tasks.
Keeps AI coding agents on one codebase from overwriting each other, and briefs each on its code.
Project management MCP for AI agents with safe task reads and writes.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenancePrevents AI coding agents from conflicting by coordinating file claims and resolving conflicts in real-time across multiple sessions.29 npm1MIT
- AlicenseNot gradedqualityDmaintenanceCoordination layer for AI coding agents working on the same codebase. Adds file locks, shared project memory, and cross-machine file sync so Claude Code, Cursor, Windsurf, and other MCP agents stop overwriting each other.52Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables multi-agent coordination with file locking, shared registry, async messaging, and architectural decision logging via MCP tools.MIT
- AlicenseNot gradedqualityDmaintenanceProvides MCP tools for AI coding agents to coordinate on shared repositories, enabling task claiming, conflict detection, and plan management in real-time.25 npmMIT