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

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,23 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0
4
+
5
+ - 新增设置弹窗左侧“Chrome DevTools”页面。
6
+ - 展示 MCP 进程、CDP 连通性、配置版本、运行版本和最新版本。
7
+ - 支持在 `latest` 与 GitHub Releases 稳定版本之间切换。
8
+ - 新增版本状态文件、运行时 PID 记录和可切换版本的 launcher。
9
+ - 新增 SSH 反向隧道命令生成与复制。
10
+ - 新增 Windows OpenSSH Client/Server 安装与启用命令。
11
+ - 版本列表优先 GitHub Releases,失败时回退缓存与 npm。
12
+
13
+ ## 0.2.0
14
+
15
+ - 改为纯 patch bundle,通过 `npx chrome-devtools-mcp@latest` 跟随上游最新版。
16
+ - 移除本地 launcher 和 `chrome-devtools-mcp` 固定依赖。
17
+ - 每次 DSH 启动时重新解析 npm `latest` dist-tag。
18
+
19
+ ## 0.1.0
20
+
21
+ - 首个版本:把 Chrome DevTools MCP 封装成 DSH profile bundle。
22
+ - 通过包内依赖启动 `chrome-devtools-mcp`,不再依赖启动时的 `npx @latest`。
23
+ - 支持 `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,164 @@
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 file:/app/project/dsh-chrome-devtools-mcp/lolkda-dsh-chrome-devtools-mcp-0.3.0.tgz
21
+ ```
22
+
23
+ 安装前请删除 profile 里手工写的 `chrome-devtools-mcp` 插入块,避免同一个 `id` 冲突。安装后重启 DSH。
24
+
25
+ ## 版本策略
26
+
27
+ 默认是 `latest`:
28
+
29
+ - launcher 每次启动时解析 `chrome-devtools-mcp@latest`。
30
+ - 上游发新版后,下次重启 DSH 自动使用新版。
31
+ - 在设置页选择固定版本后,launcher 使用 `chrome-devtools-mcp@x.y.z`。
32
+ - 切换版本需要重启 DSH,当前运行的 MCP 不会被热替换。
33
+
34
+ 状态文件:
35
+
36
+ ```text
37
+ $DSH_HOME/dsh-chrome-devtools-mcp/state.json
38
+ $DSH_HOME/dsh-chrome-devtools-mcp/runtime.json
39
+ $DSH_HOME/dsh-chrome-devtools-mcp/releases-cache.json
40
+ ```
41
+
42
+ ## 启动 Chrome
43
+
44
+ 在 PowerShell 中先进入 Chrome 安装目录,再执行:
45
+
46
+ ```powershell
47
+ .\chrome.exe --remote-debugging-port=9222 --user-data-dir="$env:LOCALAPPDATA\ChromeDebug" --no-first-run --no-default-browser-check
48
+ ```
49
+
50
+ 不知道安装目录时,在 Chrome 地址栏打开 `chrome://version`,查看“可执行文件路径”,然后 `cd` 到该目录。这样使用相对路径 `.\chrome.exe`,不依赖固定的安装位置。
51
+
52
+ CMD 版本:
53
+
54
+ ```bat
55
+ .\chrome.exe --remote-debugging-port=9222 --user-data-dir=%LOCALAPPDATA%\ChromeDebug --no-first-run --no-default-browser-check
56
+ ```
57
+
58
+ `--user-data-dir` 会创建一个独立的调试 profile,第一次需要重新登录网站。
59
+
60
+ ## 连接 Chrome
61
+
62
+ > SSH 用户名是 **DSH 主机账号**,不是 Windows 登录用户。密码由 `ssh` 在运行时提示;不要把密码写进命令。
63
+
64
+ 默认连接 DSH 主机回环地址:
65
+
66
+ ```text
67
+ http://127.0.0.1:9222
68
+ ```
69
+
70
+ 如果 Chrome 在另一台 Windows 机器上,在 Windows PowerShell 中执行设置页生成的命令:
71
+
72
+ ```powershell
73
+ ssh -N -o ServerAliveInterval=30 -o ExitOnForwardFailure=yes -R 9222:127.0.0.1:9222 <user>@192.168.1.100
74
+ ```
75
+
76
+ Chrome 需要以远程调试方式启动,或通过 `chrome://inspect/#remote-debugging` 开启调试。
77
+
78
+ 反向隧道只需要 Windows 的 OpenSSH Client。OpenSSH Server 是可选能力,只有需要从 DSH 主动 SSH 到 Windows 时才需要。
79
+
80
+ ## CI 与发布
81
+
82
+ - `.github/workflows/ci.yml`:`main` push 和 PR 时运行测试与 `npm pack --dry-run`。
83
+ - `.github/workflows/publish.yml`:GitHub Release 发布时,通过 npm trusted publishing(OIDC)发布;也支持手动 `workflow_dispatch`,默认只做 dry run。
84
+
85
+ 工作流不使用 `NPM_TOKEN`。npm 侧需要先把仓库配置为 trusted publisher。
86
+
87
+ 在 npmjs.com 打开:
88
+
89
+ ```text
90
+ Packages → @lolkda/dsh-chrome-devtools-mcp → Settings → Trusted publishing
91
+ ```
92
+
93
+ 填写:
94
+
95
+ ```text
96
+ Provider: GitHub Actions
97
+ Repository: lolkda/dsh-chrome-devtools-mcp
98
+ Workflow filename: publish.yml
99
+ Environment: 留空
100
+ ```
101
+
102
+ 也可以用 npm 11.19.1+ 的 CLI:
103
+
104
+ ```bash
105
+ npm login
106
+ npm trust github @lolkda/dsh-chrome-devtools-mcp \
107
+ --file publish.yml \
108
+ --repo lolkda/dsh-chrome-devtools-mcp \
109
+ --allow-publish
110
+ ```
111
+
112
+ 新配置必须在 **2 天内完成首次成功发布**,否则会过期。
113
+
114
+ ### 首次发布 bootstrap
115
+
116
+ 如果 npm 上还没有这个包,最稳的顺序是先用本地 OAuth 登录发布一次,再配置 trusted publisher:
117
+
118
+ ```bash
119
+ npm login
120
+ npm publish --access public --registry=https://registry.npmjs.org
121
+ ```
122
+
123
+ `npm login` 会打开浏览器 OAuth 授权页,登录后本地会得到短期发布 token。
124
+
125
+ 首次发布成功后,在 npmjs.com 配置:
126
+
127
+ ```text
128
+ Packages → @lolkda/dsh-chrome-devtools-mcp → Settings → Trusted publishing
129
+ Provider: GitHub Actions
130
+ Repository: lolkda/dsh-chrome-devtools-mcp
131
+ Workflow filename: publish.yml
132
+ Environment: 留空
133
+ ```
134
+
135
+ 然后清掉本地 token:
136
+
137
+ ```bash
138
+ npm logout
139
+ ```
140
+
141
+ 并在包设置里选择“Require 2FA and disallow tokens”。之后的版本通过 GitHub Release 和 OIDC 发布;`0.3.0` 如果已经手动发布,工作流会因版本已存在而跳过,下一个版本开始走 OIDC。
142
+
143
+ 发布 tag 必须与 `package.json` 的版本一致,例如:
144
+
145
+ ```bash
146
+ git tag v0.3.0
147
+ git push origin v0.3.0
148
+ ```
149
+
150
+ 然后在 GitHub 创建 Release,工作流会执行测试并发布到 npm。
151
+
152
+ ## 开发
153
+
154
+ ```bash
155
+ npm install
156
+ npm test
157
+ npm pack
158
+ ```
159
+
160
+ 规格见 [docs/specs/chrome-devtools-settings.md](docs/specs/chrome-devtools-settings.md)。
161
+
162
+ ## 许可
163
+
164
+ 本包代码使用 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
+ })