
Airlock
io.github.adamorad由 GitHub 账号 adamorad 发布v2.0.0更新于 Oct 24, 2026
Local daemon giving AI agents named locks, shared state, events, and a task queue over MCP.
概览
Airlock 是一个本地守护进程,通过 MCP 为 AI 代理提供命名锁、共享状态、在线状态、事件和任务队列,让并行会话互相协调。
- 可以做什么
- 获取、续期、释放和列出命名资源锁,支持阻塞等待和全有或全无的多锁获取,用于在代理和会话之间串行化工作。读取、写入、比较并交换和删除共享笔记,并以无冲突方式递增计数器生成唯一编号。注册、注销和列出带心跳的代理,代理失效时其锁自动释放。发送、等待和清除按代数计数的事件,实现无需轮询的交接。推送、领取、完成、失败和列出队列任务,租约在崩溃时自动重新排队。
- 适用场景
- 当多个 AI 代理会话、终端或 CI 任务在同一仓库或同一台机器上工作,需要避免在安装、迁移、文件编辑或共享计数器上发生冲突时使用。它适合协调相互合作的代理,而不是隔离不受信任的代理。
- 运行要求
- 本地 Go 守护进程,可通过 go install、Homebrew 或源码安装,注册为常驻后台服务并监听 127.0.0.1:27183;MCP 客户端通过 HTTP 连接。在 Linux 和多用户主机上需要 ~/.airlock/token 中的 bearer 令牌,可用 AIRLOCK_TOKEN 覆盖。状态存储在 ~/.airlock/state.db 的 SQLite 中。
安装
在 SourceWeft 中
- 打开 控制台中的 Airlock,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Airlock
Run five agents on one repo without them stomping on each other.
Named resource locks, atomic shared state, presence, events, and a task queue for AI agents — exposed over a local HTTP MCP server that's always running, so any session, terminal, or CI job can coordinate with any other. Cross-platform Go daemon, SQLite-backed, with real blocking waits — no more poll loops.
[CI] [License] [Platform] [MCP]
Two agents reach for the same npm-install lock — one wins, the other blocks on a server-side wait and acquires the instant the first releases.
The problem
Open two Claude Code sessions on the same repo — one adding auth, one adding notifications. Both reach for npm install at the same time. Both pick 003_ as the next migration filename. Neither knows the other exists.
There's no shared state. No handoff. No way for one agent to know what another is doing. Coordination lives in fragile prompt instructions ("please wait until migrations finish") that nothing enforces.
How it works
Airlock is a single Go daemon that runs as a background service — always on, surviving IDE and terminal restarts. It listens on 127.0.0.1:27183 and speaks MCP over HTTP. Any agent that has it configured can:
- acquire locks — and block on a contended one (
wait_seconds, up to 50s), so the daemon parks the caller and wakes it the instant the lock frees. No agent-authored retry loops. - share atomic state —
increment_counterfor collision-free unique numbers,set_note_iffor compare-and-swap. Read-modify-write is race-free, not best-effort. - announce presence —
register_agentheartbeats; when an agent dies, its locks release and its waiters wake immediately. - signal events — generation-counted
signal_event/wait_for_eventfor handoffs without polling. - queue work — a small task queue with presence-bound leases that auto-requeue on crash.
State lives in SQLite (WAL mode) at ~/.airlock/state.db — transactional, crash-safe, with concurrent readers and a single writer. The store is pure-Go (modernc.org/sqlite, no cgo), which is what makes the Linux build a trivial cross-compile. One binary, no language runtime, no external database.
Install
(a) go install
(b) Homebrew
(c) Build from source
install-service registers an always-on background service (and unloads the old v1 LaunchAgent if present, so the v2 daemon takes port 27183 cleanly).
Verify
Configure your agent
Claude Code — one command:
Cursor / Windsurf / any MCP client — add this to your MCP config:
On Linux (and any multi-user host) a bearer token is required — loopback is shared across all users there, so it isn't an authorization boundary on its own. The daemon writes a 0600 token to ~/.airlock/token on first run; send it as an Authorization: Bearer <token> header:
On macOS the daemon is loopback-only by default and the token is optional. AIRLOCK_TOKEN overrides the file on any OS.
Tools
Airlock exposes 22 tools over MCP. Every tool result is a JSON object (the list_* tools return a JSON array). TTLs are in ttl_seconds; ttl_minutes is accepted as a deprecated alias.
Locks
wait_seconds is the coordination-by-default knob: pass it (up to 50) and lock_resource blocks server-side until the lock frees, instead of returning locked:false immediately. The cap stays under Claude Code's 60s default per-tool-call timeout. The returned lock_token is a capability — unlock_resource/renew_lock require it (the agent_id path is kept for v1 compatibility). lock_resources acquires in a documented lock-ordering (lexicographic by name) so two callers can't deadlock.
Notes & State
Presence
Events
Events are generation-counted, not latched: pass back the generation you last saw and a signal that fired between calls is never missed.
Tasks
A claim is a lease: if the claimant doesn't complete_task/fail_task within lease_seconds, the task auto-requeues for another consumer — no work is lost to a crashed worker. The lease_token from claim_next_task is the capability complete_task/fail_task require.
Naming conventions
Use consistent names so agents understand each other:
- Files:
file:/abs/path/to/package.json - Processes:
npm-install,db-migrations,tests:unit - Agent identity:
agent:claude-session-abc
Recipes
(a) Serialize edits to one file with a blocking lock
Two subagents both need to edit package.json. They serialize on a single lock — the second one blocks (no retry loop) and wakes the instant the first releases.
(b) Unique migration filenames — race-free
The classic v1 hazard: two agents get_note the counter at the same instant, both read 003, both write 004. In v2 there is no read-modify-write to lose — increment_counter is atomic, so 100 concurrent callers get 100 distinct numbers.
(c) Producer/consumer handoff via the task queue
A planner agent pushes work; one or more worker agents claim it. A lease means a crashed worker's task auto-requeues instead of vanishing.
airlock status
One-shot snapshot of everything the daemon is coordinating — locks (and who holds them), present agents, notes, counters, events, and tasks. Runs against ~/.airlock/state.db, so it works even from a different shell. airlock watch reprints it live once a second.
Architecture
A single Go daemon, one process, on 127.0.0.1:27183.
- Store. SQLite in WAL mode at
~/.airlock/state.db— pure-Go (modernc.org/sqlite, no cgo), transactional, crash-safe. A single dedicated write connection serializes writes; readers use the WAL's concurrent path. SQLite's single-writer model is what makesincrement_counterandset_note_ifcorrect for free. - Blocking waits. A parked waiter is a goroutine on a per-resource in-memory FIFO channel with a
contextdeadline — outside any SQLite transaction, so a blocking daemon never melts the database under contention. A background reaper sweeps expired lock TTLs and presence leases and wakes the FIFO head, so waiters behind a dead holder don't eat their full wait window. - Capability tokens.
lock_token/lease_tokengateunlock/renewandcomplete/fail.agent_idis provenance, not authorization. - Security. Loopback-only bind,
Host-header allowlist, reject anyOriginheader (DNS-rebinding defense), requireapplication/jsonon POST — plus a0600bearer token at~/.airlock/token, required on Linux/multi-user hosts. See SECURITY.md. - Port 27183. PortPeek owns
27182(the digits of e); Airlock takes the next port so the two daemons coexist.
v1 (Swift, macOS-only) is archived at legacy/swift/ and tagged v1.1.0. The full v1 wire contract still works unchanged on v2 — same port, same JSON.
Roadmap / v2 status
v2.0.0 ships the core — locks with blocking waits, atomic state, presence, and events — plus the task queue, all in Go and cross-platform (macOS + Linux). The design spec and rationale, including how Airlock sits against adjacent tools, live in docs/ROADMAP-v2.md. If the roadmap is wrong for your workflow, open an issue — there's a pinned "tear this apart" thread for exactly that.
Uninstall
FAQ
Why port 27183? PortPeek already uses 27182 (the first digits of e, Euler's number). Airlock takes the next port, 27183, so the two daemons coexist on one machine without colliding.
What's the security model? Airlock binds loopback only, validates the Host header, rejects any Origin header, and requires application/json on POST. On Linux/multi-user hosts a 0600 bearer token at ~/.airlock/token is required (loopback is shared across users there); on macOS it's optional. Capability tokens (lock_token / lease_token) mean a buggy or prompt-injected agent can't drop or steal another agent's lock just by guessing its agent_id. The deliberate, documented limit: any process running as the same local user can call the API — Airlock coordinates cooperating agents, it doesn't sandbox them. Note/task content is untrusted cross-agent input; consuming agents must treat it as data, never instructions. Full threat model: SECURITY.md.
How does it relate to PortPeek? PortPeek solves port conflicts for AI agents (who's bound to which port). Airlock solves the broader coordination problem (who's doing which task). Same lineage, adjacent ports (27182 / 27183), designed to run side by side.
Contributing
Issues and PRs welcome — see CONTRIBUTING.md.
Licensed under the MIT License.
Built by Adam Morad.
来源:README.md,提交 adb287c
工具
0版本历史
1- v2.0.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分