mcp-mcp-locks
Wraps the mcp-locks CLI to expose coordination primitives as MCP tools, enabling multiple AI agents to claim, release, and list exclusive OS resources like browser profiles.
README
mcp-mcp-locks
An MCP server that wraps the mcp-locks CLI, exposing its coordination primitives as native MCP tools.
Use case: Multiple AI agents (across OpenCode, Claude Code, devcontainer/sandboxed runtimes, etc.) need to coordinate access to MCP instances that hold exclusive OS resources — Playwright Chromium profile dirs, the figma-desktop port, any future single-resource MCP server. mcp-locks solves this via a host-global state file and a small bash CLI. This server makes its operations discoverable in every MCP client's tool surface, so an agent that's been told "use Playwright instance X" can also see claim/release as first-class tools rather than something to remember to shell out to.
Why a wrapper?
The mcp-locks CLI works fine from a shell. But rules like "agents must claim before using" have been re-discovered as broken across many sessions because the agent has to know the convention exists and remember to invoke it. Exposing the operations as MCP tools puts them directly in the agent's function roster — claim/release/list/who become discoverable the same way playwright_browser_navigate is. Discoverability is the highest-leverage fix for "agent forgot the convention."
This server is thin by design: every tool shells out to mcp-locks --json and returns the structured envelope. State, locking, owner detection, and reaping all stay owned by the upstream binary (single source of truth).
Prerequisites
- Node.js 20+
mcp-locksinstalled and on PATH (or its path passed via theMCP_LOCKS_BINenv var). The wrapper requires a version that supports--jsonoutput.
Install
git clone https://github.com/mattbaylor/mcp-mcp-locks.git
cd mcp-mcp-locks
npm install
npm run build
Configure your MCP client
OpenCode (opencode.json or opencode.jsonc)
{
"mcp": {
"mcp-locks": {
"type": "local",
"command": ["node", "/path/to/mcp-mcp-locks/dist/index.js"],
"enabled": true
}
}
}
Claude Code (.claude.json)
{
"mcpServers": {
"mcp-locks": {
"type": "stdio",
"command": "node",
"args": ["/path/to/mcp-mcp-locks/dist/index.js"]
}
}
}
Custom mcp-locks binary location
If mcp-locks is not on the spawned process's PATH (common in sandboxed agent runtimes with minimal env), set MCP_LOCKS_BIN:
{
"mcp": {
"mcp-locks": {
"type": "local",
"command": ["node", "/path/to/mcp-mcp-locks/dist/index.js"],
"enabled": true,
"environment": {
"MCP_LOCKS_BIN": "/Users/you/bin/mcp-locks"
}
}
}
}
Tools
| Tool | Purpose |
|---|---|
list |
Array of all registered instances with current status, owners, TTLs |
who |
Detail on a single instance (free / claimed / expired / dead_pid) |
claim |
Acquire or refresh a lock (default 30m TTL); auto-detects owner |
release |
Release a claim; owner-checked unless force: true |
reap |
Clean up expired claims, dead-PID claims, orphaned Chromium, stale SingletonLocks |
doctor |
Health report; recommends reap when needed |
kill |
Kill Playwright-MCP Chromium processes on demand (mode: 'orphans' | 'all' | 'instance', plus safety: 'idle-only' | 'force' for all mode). Per-instance kill is not implemented in v1. |
Every tool returns the upstream mcp-locks --json envelope augmented with exitCode and (if present) stderr:
// success
{ "ok": true, "data": { ... }, "exitCode": 0 }
// denied
{ "ok": false, "error": "denied", "denied": { ... }, "exitCode": 2 }
Typical agent flow
1. agent calls list -> sees which instances are free
2. agent calls claim -> ok:true; agent proceeds with the corresponding browser tools
3. agent does its work
4. agent calls release -> ok:true
For conflict cases:
1. agent calls claim playwright2
2. response: { ok: false, error: "denied", denied: { current_owner: "...", ttl_remaining_seconds: 1200 } }
3. agent either: claims a different instance, waits, or asks the human whether to force-steal
Sub-agent pattern
When dispatching a sub-agent to do parallel work:
- Parent claims the instance and passes the assigned name to the sub-agent
- Sub-agent uses the assigned instance's browser tools (e.g.
playwright3_browser_*) - Sub-agent does NOT call
claimorrelease— the parent owns the lifecycle
This avoids the sub-agent's claim expiring mid-work due to a TTL shorter than the parent's task.
How it relates to mcp-locks
This server is one of several possible interfaces to the underlying coordination layer. Other valid callers:
- The
mcp-locksCLI directly from a shell or script - Any tool reading the state file at
~/.local/state/mcp-locks/state.json(read-only; never write) - CI scripts that gate execution on a lock
All callers share the same state and the same concurrency guarantees — this wrapper doesn't add a second source of truth.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。