@lolkda/dsh-chrome-devtools-mcp 0.0.0-stage → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ ## 0.3.1
4
+
5
+ - 设置页新增“启动 Chrome”卡片,使用相对路径 `.\chrome.exe` 启动远程调试。
6
+ - 提供 PowerShell、CMD 命令和复制按钮,不硬编码 Chrome 安装路径。
7
+ - 修正 SSH 用户名说明,明确为 DSH 主机账号,不是 Windows 登录用户。
8
+ - 新增 GitHub Actions CI 和 npm trusted publishing(OIDC)发布工作流。
9
+ - 安装说明改为 npm 包 `@lolkda/dsh-chrome-devtools-mcp`。
10
+
11
+ ## 0.3.0
12
+
13
+ - 新增设置弹窗左侧“Chrome DevTools”页面。
14
+ - 展示 MCP 进程、CDP 连通性、配置版本、运行版本和最新版本。
15
+ - 支持在 `latest` 与 GitHub Releases 稳定版本之间切换。
16
+ - 新增版本状态文件、运行时 PID 记录和可切换版本的 launcher。
17
+ - 新增 SSH 反向隧道命令生成与复制。
18
+ - 新增 Windows OpenSSH Client/Server 安装与启用命令。
19
+ - 版本列表优先 GitHub Releases,失败时回退缓存与 npm。
20
+
21
+ ## 0.2.0
22
+
23
+ - 改为纯 patch bundle,通过 `npx chrome-devtools-mcp@latest` 跟随上游最新版。
24
+ - 移除本地 launcher 和 `chrome-devtools-mcp` 固定依赖。
25
+ - 每次 DSH 启动时重新解析 npm `latest` dist-tag。
26
+
27
+ ## 0.1.0
28
+
29
+ - 首个版本:把 Chrome DevTools MCP 封装成 DSH profile bundle。
30
+ - 通过包内依赖启动 `chrome-devtools-mcp`,不再依赖启动时的 `npx @latest`。
31
+ - 支持 `CHROME_DEVTOOLS_BROWSER_URL` 覆盖默认的 `http://127.0.0.1:9222`。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 lolkda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,170 @@
1
- # Temporary Holding Version
1
+ # @lolkda/dsh-chrome-devtools-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 把官方 [`chrome-devtools-mcp`](https://github.com/ChromeDevTools/chrome-devtools-mcp) 封装成 DeepSeek Harness 的 profile bundle,并在设置页提供状态、版本切换和 SSH 隧道命令。
4
+
5
+ ## 功能
6
+
7
+ ![设置页](docs/settings-page.png)
8
+
9
+ - 设置弹窗左侧导航新增“Chrome MCP”。
10
+ - 显示 MCP 进程、Chrome CDP 连通性、配置版本、运行版本和最新版本。
11
+ - 在 `latest` 与 GitHub Releases 的稳定版本之间切换。
12
+ - 版本选择保存到 `$DSH_HOME/dsh-chrome-devtools-mcp/state.json`,重启 DSH 后生效。
13
+ - 生成并复制 Chrome 远程调试启动命令。
14
+ - 生成并复制 SSH 反向隧道命令。
15
+ - 提供 Windows OpenSSH Client 与可选 OpenSSH Server 的安装、启用命令。
16
+
17
+ ## 安装
18
+
19
+ ```bash
20
+ dsh plugin --profile web add @lolkda/dsh-chrome-devtools-mcp@0.3.1
21
+ ```
22
+
23
+ 也可以从本地 tarball 安装:
24
+
25
+ ```bash
26
+ dsh plugin --profile web add file:/path/to/lolkda-dsh-chrome-devtools-mcp-0.3.1.tgz
27
+ ```
28
+
29
+ 安装前请删除 profile 里手工写的 `chrome-devtools-mcp` 插入块,避免同一个 `id` 冲突。安装后重启 DSH。
30
+
31
+ ## 版本策略
32
+
33
+ 默认是 `latest`:
34
+
35
+ - launcher 每次启动时解析 `chrome-devtools-mcp@latest`。
36
+ - 上游发新版后,下次重启 DSH 自动使用新版。
37
+ - 在设置页选择固定版本后,launcher 使用 `chrome-devtools-mcp@x.y.z`。
38
+ - 切换版本需要重启 DSH,当前运行的 MCP 不会被热替换。
39
+
40
+ 状态文件:
41
+
42
+ ```text
43
+ $DSH_HOME/dsh-chrome-devtools-mcp/state.json
44
+ $DSH_HOME/dsh-chrome-devtools-mcp/runtime.json
45
+ $DSH_HOME/dsh-chrome-devtools-mcp/releases-cache.json
46
+ ```
47
+
48
+ ## 启动 Chrome
49
+
50
+ 在 PowerShell 中先进入 Chrome 安装目录,再执行:
51
+
52
+ ```powershell
53
+ .\chrome.exe --remote-debugging-port=9222 --user-data-dir="$env:LOCALAPPDATA\ChromeDebug" --no-first-run --no-default-browser-check
54
+ ```
55
+
56
+ 不知道安装目录时,在 Chrome 地址栏打开 `chrome://version`,查看“可执行文件路径”,然后 `cd` 到该目录。这样使用相对路径 `.\chrome.exe`,不依赖固定的安装位置。
57
+
58
+ CMD 版本:
59
+
60
+ ```bat
61
+ .\chrome.exe --remote-debugging-port=9222 --user-data-dir=%LOCALAPPDATA%\ChromeDebug --no-first-run --no-default-browser-check
62
+ ```
63
+
64
+ `--user-data-dir` 会创建一个独立的调试 profile,第一次需要重新登录网站。
65
+
66
+ ## 连接 Chrome
67
+
68
+ > SSH 用户名是 **DSH 主机账号**,不是 Windows 登录用户。密码由 `ssh` 在运行时提示;不要把密码写进命令。
69
+
70
+ 默认连接 DSH 主机回环地址:
71
+
72
+ ```text
73
+ http://127.0.0.1:9222
74
+ ```
75
+
76
+ 如果 Chrome 在另一台 Windows 机器上,在 Windows PowerShell 中执行设置页生成的命令:
77
+
78
+ ```powershell
79
+ ssh -N -o ServerAliveInterval=30 -o ExitOnForwardFailure=yes -R 9222:127.0.0.1:9222 <user>@192.168.1.100
80
+ ```
81
+
82
+ Chrome 需要以远程调试方式启动,或通过 `chrome://inspect/#remote-debugging` 开启调试。
83
+
84
+ 反向隧道只需要 Windows 的 OpenSSH Client。OpenSSH Server 是可选能力,只有需要从 DSH 主动 SSH 到 Windows 时才需要。
85
+
86
+ ## CI 与发布
87
+
88
+ - `.github/workflows/ci.yml`:`main` push 和 PR 时运行测试与 `npm pack --dry-run`。
89
+ - `.github/workflows/publish.yml`:GitHub Release 发布时,通过 npm trusted publishing(OIDC)发布;也支持手动 `workflow_dispatch`,默认只做 dry run。
90
+
91
+ 工作流不使用 `NPM_TOKEN`。npm 侧需要先把仓库配置为 trusted publisher。
92
+
93
+ 在 npmjs.com 打开:
94
+
95
+ ```text
96
+ Packages → @lolkda/dsh-chrome-devtools-mcp → Settings → Trusted publishing
97
+ ```
98
+
99
+ 填写:
100
+
101
+ ```text
102
+ Provider: GitHub Actions
103
+ Repository: lolkda/dsh-chrome-devtools-mcp
104
+ Workflow filename: publish.yml
105
+ Environment: 留空
106
+ ```
107
+
108
+ 也可以用 npm 11.19.1+ 的 CLI:
109
+
110
+ ```bash
111
+ npm login
112
+ npm trust github @lolkda/dsh-chrome-devtools-mcp \
113
+ --file publish.yml \
114
+ --repo lolkda/dsh-chrome-devtools-mcp \
115
+ --allow-publish
116
+ ```
117
+
118
+ 新配置必须在 **2 天内完成首次成功发布**,否则会过期。
119
+
120
+ ### 首次发布 bootstrap
121
+
122
+ 如果 npm 上还没有这个包,最稳的顺序是先用本地 OAuth 登录发布一次,再配置 trusted publisher:
123
+
124
+ ```bash
125
+ npm login
126
+ npm publish --access public --registry=https://registry.npmjs.org
127
+ ```
128
+
129
+ `npm login` 会打开浏览器 OAuth 授权页,登录后本地会得到短期发布 token。
130
+
131
+ 首次发布成功后,在 npmjs.com 配置:
132
+
133
+ ```text
134
+ Packages → @lolkda/dsh-chrome-devtools-mcp → Settings → Trusted publishing
135
+ Provider: GitHub Actions
136
+ Repository: lolkda/dsh-chrome-devtools-mcp
137
+ Workflow filename: publish.yml
138
+ Environment: 留空
139
+ ```
140
+
141
+ 然后清掉本地 token:
142
+
143
+ ```bash
144
+ npm logout
145
+ ```
146
+
147
+ 并在包设置里选择“Require 2FA and disallow tokens”。之后的版本通过 GitHub Release 和 OIDC 发布;`0.3.0` 已通过本地 token 发布;`0.3.1` 开始通过 OIDC 发布。工作流遇到已存在的版本会自动跳过。
148
+
149
+ 发布 tag 必须与 `package.json` 的版本一致,例如:
150
+
151
+ ```bash
152
+ git tag v0.3.1
153
+ git push origin v0.3.1
154
+ ```
155
+
156
+ 然后在 GitHub 创建 Release,工作流会执行测试并发布到 npm。
157
+
158
+ ## 开发
159
+
160
+ ```bash
161
+ npm install
162
+ npm test
163
+ npm pack
164
+ ```
165
+
166
+ 规格见 [docs/specs/chrome-devtools-settings.md](docs/specs/chrome-devtools-settings.md)。
167
+
168
+ ## 许可
169
+
170
+ 本包代码使用 MIT。`chrome-devtools-mcp` 由 Google LLC 维护,使用 Apache-2.0,见其[仓库](https://github.com/ChromeDevTools/chrome-devtools-mcp)。
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The stable process the MCP client starts. It resolves the selected upstream
4
+ * version at launch, records the runtime PID, and proxies signals to npx.
5
+ */
6
+
7
+ import { spawn } from 'node:child_process'
8
+ import { buildNpxArgs, npxCommand, parseLauncherArgs, readLaunchState, resolveSpec, runtimeRecord } from '../lib/launch.js'
9
+ import { writeRuntime } from '../lib/state.js'
10
+
11
+ let launch
12
+ try {
13
+ launch = parseLauncherArgs(process.argv.slice(2))
14
+ } catch (error) {
15
+ console.error(`dsh-chrome-devtools-mcp: ${error.message}`)
16
+ process.exit(1)
17
+ }
18
+ const { dshHome, passthrough } = launch
19
+
20
+ let state
21
+ try {
22
+ state = await readLaunchState(dshHome)
23
+ } catch {
24
+ state = { mode: 'latest', version: null }
25
+ }
26
+ if (state.warning) console.error(`dsh-chrome-devtools-mcp: ${state.warning}`)
27
+
28
+ const spec = resolveSpec(state)
29
+ const startedAt = new Date().toISOString()
30
+ const command = npxCommand()
31
+ const args = buildNpxArgs(state, passthrough)
32
+
33
+ try {
34
+ await writeRuntime(dshHome, runtimeRecord({ pid: process.pid, spec, startedAt }))
35
+ } catch (error) {
36
+ console.error(`dsh-chrome-devtools-mcp: 无法写入运行状态:${error.message}`)
37
+ }
38
+
39
+ const child = spawn(command, args, {
40
+ stdio: 'inherit',
41
+ shell: process.platform === 'win32',
42
+ env: process.env,
43
+ })
44
+
45
+ let forwardedSignal
46
+
47
+ function forwardSignal(signal) {
48
+ if (forwardedSignal) return
49
+ forwardedSignal = signal
50
+ try {
51
+ child.kill(signal)
52
+ } catch {
53
+ // The child may already have exited.
54
+ }
55
+ const timer = setTimeout(() => {
56
+ try {
57
+ child.kill('SIGKILL')
58
+ } catch {
59
+ // The child may already have exited.
60
+ }
61
+ process.exit(1)
62
+ }, 750)
63
+ timer.unref()
64
+ }
65
+
66
+ for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
67
+ process.on(signal, () => forwardSignal(signal))
68
+ }
69
+
70
+ child.on('error', async (error) => {
71
+ console.error(`dsh-chrome-devtools-mcp: 无法启动 ${command}: ${error.message}`)
72
+ process.exitCode = 1
73
+ await writeRuntime(dshHome, {
74
+ ...runtimeRecord({ pid: process.pid, spec, startedAt }),
75
+ endedAt: new Date().toISOString(),
76
+ exitCode: 1,
77
+ }).catch(() => {})
78
+ })
79
+
80
+ child.on('exit', async (code) => {
81
+ process.exitCode = code ?? 1
82
+ await writeRuntime(dshHome, {
83
+ ...runtimeRecord({ pid: process.pid, spec, startedAt }),
84
+ endedAt: new Date().toISOString(),
85
+ exitCode: code ?? 1,
86
+ }).catch(() => {})
87
+ })