Skip to content

Commit 5a844c9

Browse files
committed
refactor(mcp): move chrome-devtools recipe into agents/ai.just
Encapsulate what can be encapsulated today. The justfile recipe moves from project-root `justfile` into `agents/ai.just` (sibling to the rest of the APM/agent dev tooling), and `shell.nix` reverts its `KOLU_CHROME_EXECUTABLE` addition — the recipe now resolves Chrome-for-Testing inline by globbing `$PLAYWRIGHT_BROWSERS_PATH/chromium-*/chrome-linux64/chrome`. `.mcp.json` stays at project root (that's where Claude Code reads it from) and its command updates to `just ai::mcp-chrome-devtools` via the existing `mod ai 'agents/ai.just'` import. Full encapsulation — declaring the MCP server inside `agents/apm.yml` and letting `just ai::apm` regenerate `.mcp.json` — is blocked on microsoft/apm#655 (Claude Code MCP adapter) landing in juspay's fork. The follow-up TODO is captured in the recipe's doc comment. Trade-off: the hickey-iteration's elegant Nix-eval-time chrome-path resolution (read browsers.json at eval, fail loud on layout change) is dropped in favor of a runtime shell glob. Failure mode shifts from "fails at `nix develop` eval" to "empty --executable-path at MCP startup → chrome-devtools-mcp errors out loud" — different failure point, still loud, and keeps `shell.nix` free of MCP-specific env vars.
1 parent 63a28ec commit 5a844c9

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

.mcp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"mcpServers": {
33
"chrome-devtools": {
44
"command": "nix",
5-
"args": ["develop", "--command", "just", "mcp-chrome-devtools"]
5+
"args": ["develop", "--command", "just", "ai::mcp-chrome-devtools"]
66
}
77
}
88
}

agents/ai.just

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,16 @@ apm-sync: apm-audit
6161
agent *args: apm
6262
just prepare
6363
{{ env('AI_AGENT', 'claude --dangerously-skip-permissions') }} {{ args }}
64+
65+
# Launch chrome-devtools-mcp server over stdio — wired up via the root
66+
# `.mcp.json`, which shells out via `nix develop --command just
67+
# ai::mcp-chrome-devtools` (Claude Code starts outside the nix devshell).
68+
# Chrome binary resolved from Playwright's nix-provided Chrome-for-Testing;
69+
# glob misses fail loud downstream (empty --executable-path → MCP server
70+
# errors out visibly). Headless Linux only.
71+
#
72+
# TODO: fold .mcp.json's entry into `dependencies.mcp` above once
73+
# microsoft/apm#655 (Claude Code MCP adapter) merges and lands in juspay's
74+
# fork — `.mcp.json` then becomes a generated artifact of `just ai::apm`.
75+
mcp-chrome-devtools:
76+
sh -c 'chrome="$(ls -d "$PLAYWRIGHT_BROWSERS_PATH"/chromium-*/chrome-linux64/chrome 2>/dev/null | head -1)"; exec npx -y chrome-devtools-mcp@latest --headless=true --isolated=true --executable-path="$chrome"'

justfile

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,6 @@ fmt:
9595
fmt-check:
9696
{{ nix_shell }} sh -c 'prettier --check --cache --ignore-unknown . && nixpkgs-fmt --check *.nix nix/**/*.nix'
9797

98-
# Launch chrome-devtools-mcp server over stdio — wired up via .mcp.json.
99-
# Drives Playwright's nix-provided Chrome-for-Testing (headless, isolated
100-
# profile). Claude Code starts outside the devshell, so .mcp.json wraps
101-
# this with `nix develop --command just mcp-chrome-devtools`.
102-
#
103-
# TODO: fold this + .mcp.json into agents/apm.yml's `dependencies.mcp` once
104-
# microsoft/apm#655 (Claude Code MCP adapter) merges and lands in juspay's
105-
# fork — then the recipe moves into agents/ai.just and .mcp.json becomes a
106-
# generated artifact.
107-
mcp-chrome-devtools:
108-
{{ nix_shell }} sh -c 'exec npx -y chrome-devtools-mcp@latest --headless=true --isolated=true --executable-path="$KOLU_CHROME_EXECUTABLE"'
109-
11098
# Nix build (server + client)
11199
build:
112100
nix build

shell.nix

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22
{ pkgs ? import ./nix/nixpkgs.nix { } }:
33
let
44
packages = import ./default.nix { inherit pkgs; };
5-
6-
# Chrome-for-Testing path for chrome-devtools-mcp (see .mcp.json). Pulled
7-
# from playwright-driver's browsers.json at eval time so the chromium-N
8-
# revision tracks whatever nixpkgs pins — fails loud here if layout changes
9-
# instead of silently at MCP startup. Idiom from https://wiki.nixos.org/wiki/Playwright.
10-
playwrightBrowsers = (builtins.fromJSON
11-
(builtins.readFile "${pkgs.playwright-driver}/browsers.json")).browsers;
12-
chromiumRev = (builtins.head
13-
(builtins.filter (b: b.name == "chromium") playwrightBrowsers)).revision;
14-
koluChromeExecutable =
15-
"${pkgs.playwright-driver.browsers}/chromium-${chromiumRev}/chrome-linux64/chrome";
165
in
176
pkgs.mkShell {
187
name = "kolu-shell";
@@ -22,7 +11,6 @@ pkgs.mkShell {
2211
KOLU_COMMIT_HASH = "dev";
2312
PLAYWRIGHT_BROWSERS_PATH = "${pkgs.playwright-driver.browsers}";
2413
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1";
25-
KOLU_CHROME_EXECUTABLE = koluChromeExecutable;
2614
};
2715

2816
shellHook = ''

0 commit comments

Comments
 (0)