Skip to content

Commit faaa4b3

Browse files
authored
Merge pull request #1907 from link-assistant/issue-1901-c51faa4821dd
Fix Playwright MCP availability and solve preflight
2 parents 460df2a + 7b85046 commit faaa4b3

44 files changed

Lines changed: 244529 additions & 67 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/bright-mcp-pending.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@link-assistant/hive-mind": patch
3+
---
4+
5+
Fix Playwright MCP availability detection so pending or unavailable server status no longer enables browser automation hints, surface pending status in interactive session comments, and harden Docker verification so Playwright MCP/CLI availability is checked instead of only grepping for a registration.

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ RUN echo "Installing @link-assistant/hive-mind@${HIVE_MIND_VERSION}" && \
132132
# --force handles the shared 'playwright' binary conflict between packages.
133133
RUN npm install -g @playwright/mcp@latest --no-fund --force
134134

135+
# Verify both the Playwright CLI fallback and the locally installed MCP package.
136+
RUN playwright --version && \
137+
npx --no-install @playwright/mcp --help | grep -q -- '--headless'
138+
135139
# Configure Playwright MCP for Claude CLI — fail the build if registration fails (issue #1514)
136140
RUN if command -v claude &>/dev/null; then \
137141
claude mcp add playwright -s user -- npx -y @playwright/mcp@latest --isolated --headless --no-sandbox --timeout-action=600000 --viewport-size 1920x1080; \
@@ -142,6 +146,20 @@ RUN if command -v codex &>/dev/null; then \
142146
codex mcp add playwright -- npx -y @playwright/mcp@latest --isolated --headless --no-sandbox --timeout-action=600000 --viewport-size 1920x1080; \
143147
fi
144148

149+
# Fail the image build if MCP registration is merely present but unavailable.
150+
RUN if command -v claude >/dev/null 2>&1; then \
151+
CLAUDE_MCP_OUTPUT="$(claude mcp list 2>&1)" && \
152+
echo "$CLAUDE_MCP_OUTPUT" && \
153+
echo "$CLAUDE_MCP_OUTPUT" | grep -Eiq 'playwright.*(connected|enabled)' && \
154+
! echo "$CLAUDE_MCP_OUTPUT" | grep -Eiq 'playwright.*(pending|disabled|failed|error|disconnected|not[-_[:space:]]+connected|unavailable|timed[-_[:space:]]+out|(^|[^[:alnum:]_-])timeout($|[^[:alnum:]_-]))'; \
155+
fi && \
156+
if command -v codex >/dev/null 2>&1; then \
157+
CODEX_MCP_OUTPUT="$(codex mcp list 2>&1)" && \
158+
echo "$CODEX_MCP_OUTPUT" && \
159+
echo "$CODEX_MCP_OUTPUT" | grep -Eiq 'playwright.*(connected|enabled)' && \
160+
! echo "$CODEX_MCP_OUTPUT" | grep -Eiq 'playwright.*(pending|disabled|failed|error|disconnected|not[-_[:space:]]+connected|unavailable|timed[-_[:space:]]+out|(^|[^[:alnum:]_-])timeout($|[^[:alnum:]_-]))'; \
161+
fi
162+
145163
# --- Disable noisy/unused Claude Code features and tools (issue #1627, issue #1642) ---
146164
# Autonomous headless hive-mind runs never benefit from tools that wait for
147165
# human interaction (AskUserQuestion, EnterPlanMode) or that register local

Dockerfile.dind

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ RUN echo "Installing @link-assistant/hive-mind@${HIVE_MIND_VERSION}" && \
101101

102102
RUN npm install -g @playwright/mcp@latest --no-fund --force
103103

104+
RUN playwright --version && \
105+
npx --no-install @playwright/mcp --help | grep -q -- '--headless'
106+
104107
RUN if command -v claude &>/dev/null; then \
105108
claude mcp add playwright -s user -- npx -y @playwright/mcp@latest --isolated --headless --no-sandbox --timeout-action=600000 --viewport-size 1920x1080; \
106109
fi
@@ -109,6 +112,19 @@ RUN if command -v codex &>/dev/null; then \
109112
codex mcp add playwright -- npx -y @playwright/mcp@latest --isolated --headless --no-sandbox --timeout-action=600000 --viewport-size 1920x1080; \
110113
fi
111114

115+
RUN if command -v claude >/dev/null 2>&1; then \
116+
CLAUDE_MCP_OUTPUT="$(claude mcp list 2>&1)" && \
117+
echo "$CLAUDE_MCP_OUTPUT" && \
118+
echo "$CLAUDE_MCP_OUTPUT" | grep -Eiq 'playwright.*(connected|enabled)' && \
119+
! echo "$CLAUDE_MCP_OUTPUT" | grep -Eiq 'playwright.*(pending|disabled|failed|error|disconnected|not[-_[:space:]]+connected|unavailable|timed[-_[:space:]]+out|(^|[^[:alnum:]_-])timeout($|[^[:alnum:]_-]))'; \
120+
fi && \
121+
if command -v codex >/dev/null 2>&1; then \
122+
CODEX_MCP_OUTPUT="$(codex mcp list 2>&1)" && \
123+
echo "$CODEX_MCP_OUTPUT" && \
124+
echo "$CODEX_MCP_OUTPUT" | grep -Eiq 'playwright.*(connected|enabled)' && \
125+
! echo "$CODEX_MCP_OUTPUT" | grep -Eiq 'playwright.*(pending|disabled|failed|error|disconnected|not[-_[:space:]]+connected|unavailable|timed[-_[:space:]]+out|(^|[^[:alnum:]_-])timeout($|[^[:alnum:]_-]))'; \
126+
fi
127+
112128
RUN mkdir -p /home/box/.claude && \
113129
if [ "${HIVE_MIND_VERSION}" != "latest" ]; then \
114130
configure-claude --settings-path /home/box/.claude/settings.json && \

coolify/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ RUN echo "Installing @link-assistant/hive-mind@${HIVE_MIND_VERSION}" && \
127127
# --force handles the shared 'playwright' binary conflict between packages.
128128
RUN npm install -g @playwright/mcp@latest --no-fund --force
129129

130+
# Verify both the Playwright CLI fallback and the locally installed MCP package.
131+
RUN playwright --version && \
132+
npx --no-install @playwright/mcp --help | grep -q -- '--headless'
133+
130134
# Configure Playwright MCP for Claude CLI — fail the build if registration fails (issue #1514)
131135
RUN if command -v claude &>/dev/null; then \
132136
claude mcp add playwright -s user -- npx -y @playwright/mcp@latest --isolated --headless --no-sandbox --timeout-action=600000 --viewport-size 1920x1080; \
@@ -137,6 +141,20 @@ RUN if command -v codex &>/dev/null; then \
137141
codex mcp add playwright -- npx -y @playwright/mcp@latest --isolated --headless --no-sandbox --timeout-action=600000 --viewport-size 1920x1080; \
138142
fi
139143

144+
# Fail the image build if MCP registration is merely present but unavailable.
145+
RUN if command -v claude >/dev/null 2>&1; then \
146+
CLAUDE_MCP_OUTPUT="$(claude mcp list 2>&1)" && \
147+
echo "$CLAUDE_MCP_OUTPUT" && \
148+
echo "$CLAUDE_MCP_OUTPUT" | grep -Eiq 'playwright.*(connected|enabled)' && \
149+
! echo "$CLAUDE_MCP_OUTPUT" | grep -Eiq 'playwright.*(pending|disabled|failed|error|disconnected|not[-_[:space:]]+connected|unavailable|timed[-_[:space:]]+out|(^|[^[:alnum:]_-])timeout($|[^[:alnum:]_-]))'; \
150+
fi && \
151+
if command -v codex >/dev/null 2>&1; then \
152+
CODEX_MCP_OUTPUT="$(codex mcp list 2>&1)" && \
153+
echo "$CODEX_MCP_OUTPUT" && \
154+
echo "$CODEX_MCP_OUTPUT" | grep -Eiq 'playwright.*(connected|enabled)' && \
155+
! echo "$CODEX_MCP_OUTPUT" | grep -Eiq 'playwright.*(pending|disabled|failed|error|disconnected|not[-_[:space:]]+connected|unavailable|timed[-_[:space:]]+out|(^|[^[:alnum:]_-])timeout($|[^[:alnum:]_-]))'; \
156+
fi
157+
140158
# --- Disable noisy/unused Claude Code features and tools (issue #1627, issue #1642) ---
141159
# Autonomous headless hive-mind runs never benefit from tools that wait for
142160
# human interaction or leave persistent side effects. Pre-seed the

docs/DOCKER.hi.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,43 @@ claude
115115
- ✅ प्रत्येक container की अपनी अलग-थलग authentication है
116116
- ✅ Interactive authentication के बिना सफल Docker builds
117117

118+
## Docker में Playwright MCP State
119+
120+
Image build अब Claude और Codex दोनों के लिए Playwright MCP register करता है:
121+
122+
- `claude mcp add playwright -s user -- ...`
123+
- `codex mcp add playwright -- ...`
124+
125+
CI workflow Docker image भी build करता है और verify करता है कि:
126+
127+
- `playwright --version` CLI fallback के रूप में काम करता है;
128+
- `npx --no-install @playwright/mcp --help` MCP package को reinstall किए बिना काम करता है;
129+
- `claude mcp list` Playwright server को connected/enabled दिखाता है, pending या unavailable नहीं;
130+
- `codex mcp list` Playwright server को connected/enabled दिखाता है, pending या unavailable नहीं।
131+
132+
यदि running container में `codex mcp list` अभी भी `No MCP servers configured yet` दिखाता है, तो सबसे संभावित root cause host से mounted `/home/box/.codex` directory है। इस image में `HOME=/home/box` है, इसलिए `/home/box/.codex` mount करने से image-baked Codex config replace हो जाता है, जिसमें preconfigured MCP entries भी शामिल हैं।
133+
134+
इसका अर्थ है:
135+
136+
- published image सही हो सकती है;
137+
- runtime container फिर भी Codex को unconfigured दिखा सकता है;
138+
- अंतर persisted host state के container defaults को override करने से आता है।
139+
140+
इसे जल्दी confirm करने के लिए इन दो cases की तुलना करें:
141+
142+
```bash
143+
# Host-mounted Codex state के बिना fresh container
144+
docker run --rm -it konard/hive-mind:latest bash -lc 'codex mcp list'
145+
146+
# Host से persisted Codex state के साथ container
147+
docker run --rm -it \
148+
-v /root/.hive-mind/codex:/home/box/.codex \
149+
konard/hive-mind:latest \
150+
bash -lc 'codex mcp list'
151+
```
152+
153+
यदि पहला command `playwright` दिखाता है और दूसरा नहीं, तो host-mounted Codex directory mismatch का source है।
154+
118155
## पूर्वापेक्षाएं
119156

120157
1. **Docker:** Docker Desktop या Docker Engine (version 20.10 या उच्चतर) install करें
@@ -148,6 +185,14 @@ docker volume create box-home
148185
docker run -it -v box-home:/home/box konard/hive-mind:latest
149186
```
150187

188+
यदि persisted `/home/box/.codex/config.toml` किसी पुराने image से आया है, तो उसमें newer images द्वारा जोड़ी गई Playwright MCP registration नहीं हो सकती। Container start होने के बाद फिर से चलाएं:
189+
190+
```bash
191+
codex mcp add playwright -- npx -y @playwright/mcp@latest --isolated --headless --no-sandbox --timeout-action=600000 --viewport-size 1920x1080
192+
```
193+
194+
जब `codex mcp list` में Playwright row नहीं होती और `@playwright/mcp` installed होता है, तब Hive Mind runtime पर भी यह default registration repair try करता है। यह existing pending, disabled, या customized Playwright row को overwrite नहीं करता; उन states के लिए MCP startup path को सीधे debug करना होगा।
195+
151196
### Detached Mode में चलाना
152197

153198
```bash

docs/DOCKER.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ The image build now registers Playwright MCP for both Claude and Codex:
174174
- `claude mcp add playwright -s user -- ...`
175175
- `codex mcp add playwright -- ...`
176176

177-
The CI workflow also builds the Docker image and verifies that both `claude mcp list` and `codex mcp list` contain `playwright`.
177+
The CI workflow also builds the Docker image and verifies that:
178+
179+
- `playwright --version` works as a CLI fallback;
180+
- `npx --no-install @playwright/mcp --help` works without reinstalling the MCP package;
181+
- `claude mcp list` reports the Playwright server as connected/enabled, not pending or unavailable;
182+
- `codex mcp list` reports the Playwright server as connected/enabled, not pending or unavailable.
178183

179184
If you still reproduce `codex mcp list` showing `No MCP servers configured yet` in a running container, the most likely root cause is a mounted `/home/box/.codex` directory from the host. In this image `HOME=/home/box`, so mounting `/home/box/.codex` replaces the image-baked Codex config, including any preconfigured MCP entries.
180185

@@ -255,6 +260,11 @@ Because this mount fully overrides the image's `/home/box/.codex` directory, it
255260
codex mcp add playwright -- npx -y @playwright/mcp@latest --isolated --headless --no-sandbox --timeout-action=600000 --viewport-size 1920x1080
256261
```
257262

263+
Hive Mind also attempts this default registration repair at runtime when
264+
`codex mcp list` has no Playwright row and `@playwright/mcp` is installed. It
265+
does not overwrite an existing Playwright row that is pending, disabled, or
266+
customized; those states need direct MCP startup debugging.
267+
258268
### Running in Detached Mode
259269

260270
```bash

docs/DOCKER.ru.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,43 @@ claude
115115
- ✅ Каждый контейнер имеет собственную изолированную аутентификацию
116116
- ✅ Успешные сборки Docker без интерактивной аутентификации
117117

118+
## Состояние Playwright MCP в Docker
119+
120+
Сборка образа теперь регистрирует Playwright MCP и для Claude, и для Codex:
121+
122+
- `claude mcp add playwright -s user -- ...`
123+
- `codex mcp add playwright -- ...`
124+
125+
CI workflow также собирает Docker-образ и проверяет, что:
126+
127+
- `playwright --version` работает как CLI fallback;
128+
- `npx --no-install @playwright/mcp --help` работает без повторной установки MCP package;
129+
- `claude mcp list` сообщает Playwright server как connected/enabled, а не pending или unavailable;
130+
- `codex mcp list` сообщает Playwright server как connected/enabled, а не pending или unavailable.
131+
132+
Если в запущенном контейнере `codex mcp list` всё ещё показывает `No MCP servers configured yet`, наиболее вероятная причина — смонтированная с хоста директория `/home/box/.codex`. В этом образе `HOME=/home/box`, поэтому mount `/home/box/.codex` заменяет встроенную в образ Codex config, включая заранее настроенные MCP entries.
133+
134+
Это означает:
135+
136+
- опубликованный образ может быть корректным;
137+
- runtime container всё равно может показывать Codex как unconfigured;
138+
- отличие вызвано persisted host state, который переопределяет defaults контейнера.
139+
140+
Чтобы быстро проверить это, сравните два случая:
141+
142+
```bash
143+
# Fresh container without host-mounted Codex state
144+
docker run --rm -it konard/hive-mind:latest bash -lc 'codex mcp list'
145+
146+
# Container with persisted Codex state from host
147+
docker run --rm -it \
148+
-v /root/.hive-mind/codex:/home/box/.codex \
149+
konard/hive-mind:latest \
150+
bash -lc 'codex mcp list'
151+
```
152+
153+
Если первая команда показывает `playwright`, а вторая нет, источник расхождения — смонтированная с хоста директория Codex.
154+
118155
## Предварительные требования
119156

120157
1. **Docker:** Установите Docker Desktop или Docker Engine (версия 20.10 или выше)
@@ -148,6 +185,14 @@ docker volume create box-home
148185
docker run -it -v box-home:/home/box konard/hive-mind:latest
149186
```
150187

188+
Если persisted `/home/box/.codex/config.toml` пришёл из старого образа, в нём может не быть Playwright MCP registration, добавленной в новых образах. После запуска контейнера выполните заново:
189+
190+
```bash
191+
codex mcp add playwright -- npx -y @playwright/mcp@latest --isolated --headless --no-sandbox --timeout-action=600000 --viewport-size 1920x1080
192+
```
193+
194+
Hive Mind также пытается выполнить этот default registration repair во время runtime, когда `codex mcp list` не содержит Playwright row и `@playwright/mcp` установлен. Он не перезаписывает существующую Playwright row в состоянии pending, disabled или с custom settings; такие состояния требуют прямой отладки MCP startup path.
195+
151196
### Запуск в фоновом режиме
152197

153198
```bash

docs/DOCKER.zh.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,43 @@ claude
115115
- ✅ 每个容器拥有独立的身份验证
116116
- ✅ 无需交互式身份验证即可成功构建 Docker 镜像
117117

118+
## Docker 中的 Playwright MCP 状态
119+
120+
镜像构建现在会为 Claude 和 Codex 注册 Playwright MCP:
121+
122+
- `claude mcp add playwright -s user -- ...`
123+
- `codex mcp add playwright -- ...`
124+
125+
CI 工作流还会构建 Docker 镜像并验证:
126+
127+
- `playwright --version` 可作为 CLI fallback 使用;
128+
- `npx --no-install @playwright/mcp --help` 可在不重新安装 MCP 包的情况下运行;
129+
- `claude mcp list` 将 Playwright server 报告为 connected/enabled,而不是 pending 或 unavailable;
130+
- `codex mcp list` 将 Playwright server 报告为 connected/enabled,而不是 pending 或 unavailable。
131+
132+
如果运行中的容器里 `codex mcp list` 仍显示 `No MCP servers configured yet`,最可能的原因是从宿主机挂载了 `/home/box/.codex`。在此镜像中 `HOME=/home/box`,因此挂载 `/home/box/.codex` 会替换镜像内置的 Codex 配置,包括预配置的 MCP 条目。
133+
134+
这意味着:
135+
136+
- 发布的镜像可能是正确的;
137+
- 运行时容器仍可能显示 Codex 未配置;
138+
- 差异来自持久化宿主机状态覆盖了容器默认值。
139+
140+
快速确认方式是比较以下两种情况:
141+
142+
```bash
143+
# 不挂载宿主机 Codex 状态的新容器
144+
docker run --rm -it konard/hive-mind:latest bash -lc 'codex mcp list'
145+
146+
# 挂载宿主机持久化 Codex 状态的容器
147+
docker run --rm -it \
148+
-v /root/.hive-mind/codex:/home/box/.codex \
149+
konard/hive-mind:latest \
150+
bash -lc 'codex mcp list'
151+
```
152+
153+
如果第一条命令显示 `playwright` 而第二条没有,则宿主机挂载的 Codex 目录就是差异来源。
154+
118155
## 前提条件
119156

120157
1. **Docker**:安装 Docker Desktop 或 Docker Engine(版本 20.10 或更高)
@@ -148,6 +185,14 @@ docker volume create box-home
148185
docker run -it -v box-home:/home/box konard/hive-mind:latest
149186
```
150187

188+
如果持久化的 `/home/box/.codex/config.toml` 来自较旧镜像,可能缺少新版镜像添加的 Playwright MCP 注册。容器启动后可重新运行:
189+
190+
```bash
191+
codex mcp add playwright -- npx -y @playwright/mcp@latest --isolated --headless --no-sandbox --timeout-action=600000 --viewport-size 1920x1080
192+
```
193+
194+
`codex mcp list` 没有 Playwright 行且已安装 `@playwright/mcp` 时,Hive Mind 也会在运行时尝试这种默认注册修复。它不会覆盖已有的 pending、disabled 或自定义 Playwright 行;这些状态需要直接调试 MCP 启动路径。
195+
151196
### 以守护进程模式运行
152197

153198
```bash

0 commit comments

Comments
 (0)