Agent Lease logo

Agent Lease

Enforces path leases between coding agents with hooks, shared presence, messages, task delivery, and audit history.

Install Agent Lease

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "agent-lease": {
      "command": "uvx",
      "args": [
        "agent-lease-mcp"
      ],
      "env": {
        "AGENT_NAME": "YOUR_VALUE_HERE",
        "AGENT_LEASE_DB": "YOUR_VALUE_HERE",
        "AGENT_LEASE_TTL": "YOUR_VALUE_HERE",
        "AGENT_LEASE_RETENTION_DAYS": "YOUR_VALUE_HERE",
        "AGENT_LEASE_FAIL_CLOSED": "YOUR_VALUE_HERE",
        "AGENT_LEASE_CODEX_THREAD": "YOUR_VALUE_HERE"
      }
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Values are written into the snippet above so you can paste it as is. They never leave your browser.

Automated check passed— started and listed 15 tools correctly ().

Overview

Agent Lease coordinates Claude Code and Codex sessions through expiring path leases, presence, messages, and delivery-aware tasks. PreToolUse hooks refuse edits to files held by another agent, automatically claim free files, and lease scripts that may write into the repository. Reach for it when multiple coding agents share a workspace and advisory coordination is not sufficient. It uses a shared SQLite state file while each MCP client runs its own stdio process.

Use cases

  • Prevent two coding agents from editing the same files
  • Reserve a directory before running a multi-file build script
  • Pass addressed tasks between Claude Code and Codex sessions
  • Inspect who blocked an edit and review prior path activity

Key features

  • Atomic file and directory leases with automatic expiry
  • PreToolUse enforcement for edits and selected shell writes
  • Shared presence, room messages, and addressed task delivery
  • Automatic claims for free files and script execution
  • SQLite-backed history and collision diagnostics
  • CLI, optional web room, and agent wake-up support

Tools15

What Agent Lease lets your agent do. Expand a tool for its parameters.

Verified live~1.3k tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

11/11 checks healthy over the last 40d

What it can do

From the 15 tools this server returned when we ran it.

Handles credentials · 1Makes network requests · 1Read-only tools · 15
Network at startup2 connections
Files written at startup14

Observed 2026-11-22 in an isolated sandbox. A description of reach, not a security audit.

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 7d ago via OSV.dev · agent-lease-mcp (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

Last commitTodayMost recent push to the default branch.
Availability100%Our rolling endpoint + install checks that succeeded.
Install checkPassedOur sandbox started it and listed its tools.
Tools exposed15Callable tools this server registers over MCP.
Directory activity5 viewsConfig copies, upvotes, and views on AllMCPs.

How Agent Lease works

What Agent Lease does

Agent Lease coordinates multiple coding-agent sessions working in the same repository. Its central mechanism is a path lease: an agent can reserve files or directories before editing, while a directory lease covers everything below that path. Claims are atomic across all requested paths, so a partial reservation is not created when one path is unavailable.

Leases normally expire after 30 minutes, which prevents a crashed session from blocking work indefinitely. Free files can also be claimed automatically when an agent edits them. Explicit leases and leases created for running scripts remain until they are released or expire; automatically acquired edit leases are returned when the session finishes its turn.

The server also provides presence, room messages, addressed messages, durable tasks, delivery acknowledgements, and audit history. Messages are pull-based rather than live chat: another agent reads them on its next room or inbox check.

How it works

The MCP server runs over stdio, with a separate process for each client. Sessions share coordination state through a SQLite database, normally stored at ~/.agent-lease/room.db. Hooks supply enforcement around the MCP tools. SessionStart and UserPromptSubmit can inject room state and new messages, while PreToolUse checks edits and shell commands before they run.

For file-editing tools, the guard refuses an operation when another agent holds the path. For Bash, it leases the script being run and checks obvious writes such as redirection, tee, sed -i, and cp or mv targets. The default behavior is fail-open if coordination itself breaks; AGENT_LEASE_FAIL_CLOSED=1 changes this for unattended operation.

Claude Code can use an optional re-wake hook for addressed messages. Codex can use the agent-lease-codex-wake service to nudge a named session without sending message text through the queue.

Setup and configuration

Install the package with:

bash
uv tool install agent-lease-mcp

The agent-lease init command can generate Claude Code or Codex hook configuration, with --write applying changes and retaining a backup. The MCP server itself can be registered as a stdio server. Claude Code uses claude mcp add; Codex configures an mcp_servers.agent-lease entry in ~/.codex/config.toml.

Set the same AGENT_NAME value for the server and its hooks. A mismatch can make an agent treat its own files as belonging to someone else. Useful configuration includes AGENT_LEASE_DB for the SQLite path, AGENT_LEASE_TTL for the default lease duration, and AGENT_LEASE_RETENTION_DAYS for message and audit retention. agent-lease doctor checks the installation, and agent-lease simulate replays a scenario in a temporary database.

Tools and capabilities

  • claim reserves files or directories atomically, with an optional purpose and TTL.
  • release returns selected leases or everything held by the caller.
  • owner identifies the holder of a path, including an enclosing directory lease.
  • room reports agents, held paths, and new coordination activity.
  • say broadcasts to the room; send addresses a message or durable task.
  • jobs, next_task, accept, ack, retry, and cancel manage addressed work and delivery state.
  • inbox reads messages after a cursor, while history explains prior path activity and blocked edits.
  • report_limit hands unstarted tasks to the fallback agent when an agent reaches a quota or rate limit.

The same operations are available through the agent-lease CLI. A local loopback web room can show live coordination state.

Limitations and notes

Hooks only run when an agent acts, so an idle session needs an external re-wake mechanism for addressed messages. Room messaging is pull-based and should not be treated as immediate chat. An addressed task is another agent's request, not an automatic human instruction; agents should follow their own allowed-scope rules before acting.

Without the enforcement hooks, the MCP server functions as a coordination notice board rather than a deterministic edit barrier. The Codex setup may also need permission for its SQLite directory when workspace sandboxing is enabled.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Agent Lease

Agent Lease is an MCP server that connects Claude Code and Codex sessions through shared path leases, presence, messages, and task delivery. Its main tools claim and release files, identify owners, inspect room state, exchange messages, manage addressed jobs, acknowledge work, and review edit history with hook-based enforcement.

Install it with `uv tool install agent-lease-mcp`. Then register the stdio command with Claude Code or add an `mcp_servers.agent-lease` entry to Codex configuration. Configure the hooks as well, because path enforcement depends on the PreToolUse, session, prompt, and release hooks.

Agent Lease uses the standard stdio MCP transport, so it can be configured in MCP clients that support stdio servers. Its documented hook setup targets Claude Code and Codex; the edit-enforcement behavior depends on a client exposing compatible tool-use hooks.

A PreToolUse hook checks the target path before an edit and refuses the operation when another agent holds a lease. Free files are claimed automatically, directory leases cover descendants, and Bash checks selected write patterns while a script is running.

Call `history` with the path to inspect who touched it and how the event ended. `owner` identifies the current holder, including a lease inherited from a parent directory, while `room` shows current agents, held paths, and new coordination activity.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewAgent Lease AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/agent-lease?style=directory)](https://allmcps.com/mcp/agent-lease)
HTML Embed
<a href="https://allmcps.com/mcp/agent-lease"><img src="https://allmcps.com/api/badge/agent-lease?style=directory" alt="Agent Lease on AllMCPs" /></a>