codex-control-chrome-mcp 1.0.0 → 1.0.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 +30 -0
- package/LICENSE +21 -0
- package/README.md +119 -15
- package/SECURITY.md +37 -0
- package/docs/install.md +38 -0
- package/docs/release.md +54 -0
- package/package.json +9 -3
- package/src/installer.js +28 -18
- package/src/mcp-server.js +3 -2
- package/src/package-meta.js +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
This project follows semantic versioning.
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [1.0.1] - 2026-06-26
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Open source governance files.
|
|
14
|
+
- CI and npm trusted publishing workflows.
|
|
15
|
+
- Node.js test coverage for framing, RPC, and installer behavior.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Runtime package name and version are now read from `package.json` instead of being hard-coded in implementation files.
|
|
20
|
+
|
|
21
|
+
## [1.0.0] - 2026-06-26
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- Initial npm package.
|
|
26
|
+
- MCP stdio server.
|
|
27
|
+
- Chrome Native Messaging host bridge.
|
|
28
|
+
- Native host install and uninstall commands with manifest backup.
|
|
29
|
+
- Basic Chrome tab, navigation, screenshot, CDP, and event MCP tools.
|
|
30
|
+
- Skill documentation for Agent tool usage.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 iola1999
|
|
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,55 +1,159 @@
|
|
|
1
1
|
# Codex Control Chrome MCP
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/codex-control-chrome-mcp)
|
|
4
|
+
[](https://github.com/iola1999/codex-control-chrome-mcp/actions/workflows/ci.yml)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
7
|
+
Expose the Codex Chrome Extension flow to other Agent tools through MCP.
|
|
8
|
+
|
|
9
|
+
This project lets MCP clients control the user's normal Chrome profile through the installed [Codex Chrome Extension](https://chromewebstore.google.com/detail/hehggadaopoacecdllhhajmbjkdcmajg). It is useful when an Agent needs existing tabs, cookies, logged-in sessions, installed extensions, screenshots, console/network events, or raw Chrome DevTools Protocol commands.
|
|
10
|
+
|
|
11
|
+
This is an independent community project. It is not affiliated with OpenAI, Codex, Google, or Chrome.
|
|
4
12
|
|
|
5
13
|
- NPM: [codex-control-chrome-mcp](https://www.npmjs.com/package/codex-control-chrome-mcp)
|
|
6
14
|
- GitHub: [iola1999/codex-control-chrome-mcp](https://github.com/iola1999/codex-control-chrome-mcp)
|
|
7
15
|
- Chrome Extension: [Codex Chrome Extension](https://chromewebstore.google.com/detail/hehggadaopoacecdllhhajmbjkdcmajg)
|
|
8
16
|
- Skill: [`skills/codex-control-chrome-mcp/SKILL.md`](./skills/codex-control-chrome-mcp/SKILL.md)
|
|
9
17
|
|
|
10
|
-
|
|
18
|
+
## Status
|
|
19
|
+
|
|
20
|
+
The current implementation provides:
|
|
11
21
|
|
|
12
22
|
- official `@modelcontextprotocol/sdk` stdio server
|
|
13
23
|
- Chrome Native Messaging host mode
|
|
14
|
-
- MCP stdio server mode
|
|
15
24
|
- install/uninstall commands with manifest backup
|
|
16
25
|
- JSON-RPC bridge socket under `/tmp/codex-browser-use`
|
|
17
|
-
-
|
|
26
|
+
- Chrome tab, navigation, screenshot, CDP, and event MCP tools
|
|
27
|
+
- bundled skill documentation for Agent tool ordering
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
## Platform Support
|
|
20
30
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
| Platform | Status | Notes |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| macOS | Tested | Primary supported platform. |
|
|
34
|
+
| Linux | Experimental | Manifest path targets Google Chrome under `~/.config/google-chrome`. |
|
|
35
|
+
| Windows | Unsupported | Native Messaging registration uses registry keys on Windows and is not implemented yet. |
|
|
24
36
|
|
|
25
|
-
|
|
37
|
+
Node.js 20 or newer is required. npm Trusted Publishing for releases uses Node.js 24 in GitHub Actions.
|
|
26
38
|
|
|
27
|
-
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
Install and enable the [Codex Chrome Extension](https://chromewebstore.google.com/detail/hehggadaopoacecdllhhajmbjkdcmajg) in the Chrome profile you want to automate.
|
|
42
|
+
|
|
43
|
+
Install the Chrome native host:
|
|
28
44
|
|
|
29
45
|
```bash
|
|
30
|
-
npx -y codex-control-chrome-mcp@latest
|
|
46
|
+
npx -y codex-control-chrome-mcp@latest install-native-host
|
|
31
47
|
```
|
|
32
48
|
|
|
33
|
-
|
|
49
|
+
Configure your Agent to use the MCP stdio server:
|
|
34
50
|
|
|
35
51
|
```json
|
|
36
52
|
{
|
|
37
53
|
"type": "stdio",
|
|
38
54
|
"command": "npx",
|
|
39
|
-
"args": ["-y", "codex-control-chrome-mcp@latest", "--stdio"]
|
|
55
|
+
"args": ["-y", "codex-control-chrome-mcp@latest", "--stdio"],
|
|
56
|
+
"startup_timeout_sec": 30
|
|
40
57
|
}
|
|
41
58
|
```
|
|
42
59
|
|
|
60
|
+
Check status:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx -y codex-control-chrome-mcp@latest status
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Uninstall and restore the previous Codex native host manifest:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx -y codex-control-chrome-mcp@latest uninstall-native-host
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Agent Skill
|
|
73
|
+
|
|
43
74
|
If your Agent supports skills, install or reference the bundled skill folder:
|
|
44
75
|
|
|
45
76
|
```text
|
|
46
77
|
skills/codex-control-chrome-mcp
|
|
47
78
|
```
|
|
48
79
|
|
|
49
|
-
The skill documents the recommended MCP tool order for
|
|
80
|
+
The skill documents the recommended MCP tool order for:
|
|
81
|
+
|
|
82
|
+
- status checks
|
|
83
|
+
- tab listing and claiming
|
|
84
|
+
- CDP attach and command execution
|
|
85
|
+
- screenshots
|
|
86
|
+
- network and console event reads
|
|
87
|
+
- tab finalization
|
|
88
|
+
|
|
89
|
+
## Security Notes
|
|
90
|
+
|
|
91
|
+
This project controls the user's normal Chrome profile. MCP clients connected to it can inspect page contents and send raw CDP commands to claimed tabs.
|
|
50
92
|
|
|
51
|
-
|
|
93
|
+
Only install and run it on machines and Chrome profiles you own or are explicitly authorized to automate. Do not send browser cookies, password stores, profile databases, tokens, or private session files in issues or logs.
|
|
94
|
+
|
|
95
|
+
See [SECURITY.md](./SECURITY.md) for the security model and reporting process.
|
|
96
|
+
|
|
97
|
+
## How It Works
|
|
98
|
+
|
|
99
|
+
The Codex Chrome Extension does not need an external Chrome remote debugging port. It uses Chrome Native Messaging and the extension's `chrome.debugger` permission:
|
|
100
|
+
|
|
101
|
+
```text
|
|
102
|
+
Chrome extension
|
|
103
|
+
-> chrome.runtime.connectNative("com.openai.codexextension")
|
|
104
|
+
-> codex-control-chrome-mcp native host
|
|
105
|
+
-> local MCP bridge socket
|
|
106
|
+
-> chrome.debugger.attach / chrome.debugger.sendCommand
|
|
107
|
+
-> CDP
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Because the control entrypoint is inside the normal Chrome profile, existing cookies, logged-in sessions, tabs, and extensions can be reused.
|
|
111
|
+
|
|
112
|
+
Read more:
|
|
52
113
|
|
|
53
114
|
- [Architecture](./docs/architecture.md)
|
|
54
115
|
- [Install And Uninstall](./docs/install.md)
|
|
55
116
|
- [Official Socket Probe Notes](./docs/socket-probe.md)
|
|
117
|
+
- [Release Process](./docs/release.md)
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
Install dependencies:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npm ci
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Run checks:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npm run ci
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Run the MCP server locally:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
node ./bin/codex-control-chrome-mcp.js --stdio
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Run native host mode locally for development:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
node ./bin/codex-control-chrome-mcp.js --native-host
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Troubleshooting
|
|
146
|
+
|
|
147
|
+
If `status` shows no bridge sockets, reload Chrome or the Codex Chrome Extension after installing the native host.
|
|
148
|
+
|
|
149
|
+
If Codex App integration stops working, uninstall this native host to restore the backed-up manifest:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npx -y codex-control-chrome-mcp@latest uninstall-native-host
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
If tab or CDP tools fail, use the bundled skill workflow: list tabs again, claim only current tab IDs, attach before raw CDP calls, and read CDP events after enabling the relevant domain.
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Security fixes are provided for the latest published npm version.
|
|
6
|
+
|
|
7
|
+
## Reporting a Vulnerability
|
|
8
|
+
|
|
9
|
+
Please report security issues privately by emailing `iola1999@foxmail.com`.
|
|
10
|
+
|
|
11
|
+
Include:
|
|
12
|
+
|
|
13
|
+
- affected version
|
|
14
|
+
- operating system
|
|
15
|
+
- Chrome version and profile type
|
|
16
|
+
- MCP client name and version
|
|
17
|
+
- reproduction steps
|
|
18
|
+
- relevant `codex-control-chrome-mcp status` output with sensitive paths or data redacted
|
|
19
|
+
|
|
20
|
+
Do not include browser cookies, password-store data, session databases, or other private Chrome profile files in reports.
|
|
21
|
+
|
|
22
|
+
## Security Model
|
|
23
|
+
|
|
24
|
+
This project controls the user's normal Chrome profile through the Codex Chrome Extension and Chrome DevTools Protocol. That can expose sensitive browser state, including logged-in sessions and page contents.
|
|
25
|
+
|
|
26
|
+
The trusted boundary is the local user account. Only install and run this tool on machines and Chrome profiles you own or are explicitly authorized to automate.
|
|
27
|
+
|
|
28
|
+
This project is not affiliated with OpenAI, Codex, Google, or Chrome. It reuses the installed Codex Chrome Extension native messaging host name so the extension can connect to this local bridge.
|
|
29
|
+
|
|
30
|
+
## Known Security Tradeoffs
|
|
31
|
+
|
|
32
|
+
- The native host manifest for `com.openai.codexextension` is replaced during install and restored during uninstall.
|
|
33
|
+
- The local bridge socket is intended for same-user local access only.
|
|
34
|
+
- MCP clients connected to this server can send raw CDP commands to claimed tabs.
|
|
35
|
+
- The project does not attempt to enforce per-site or per-command policy.
|
|
36
|
+
|
|
37
|
+
For operational details, see `docs/architecture.md` and `docs/install.md`.
|
package/docs/install.md
CHANGED
|
@@ -17,6 +17,16 @@ The current implementation provides:
|
|
|
17
17
|
|
|
18
18
|
Do not run install on a machine where Codex Chrome integration is important unless you are ready to test proxy mode or restore from backup.
|
|
19
19
|
|
|
20
|
+
This is an independent community project. It is not affiliated with OpenAI, Codex, Google, or Chrome.
|
|
21
|
+
|
|
22
|
+
## Platform Support
|
|
23
|
+
|
|
24
|
+
| Platform | Status | Notes |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| macOS | Tested | Primary supported platform. |
|
|
27
|
+
| Linux | Experimental | Uses the Google Chrome user-level Native Messaging host directory. |
|
|
28
|
+
| Windows | Unsupported | Chrome Native Messaging registration uses registry keys on Windows and is not implemented yet. |
|
|
29
|
+
|
|
20
30
|
## Install
|
|
21
31
|
|
|
22
32
|
First install and enable the [Codex Chrome Extension](https://chromewebstore.google.com/detail/hehggadaopoacecdllhhajmbjkdcmajg) in the Chrome profile you want to automate.
|
|
@@ -43,6 +53,7 @@ The installer:
|
|
|
43
53
|
2. Backs it up in the same directory with a timestamped suffix.
|
|
44
54
|
3. Writes a new manifest pointing to this project's CLI.
|
|
45
55
|
4. Records restore metadata in `~/.codex-control-chrome-mcp/install-state.json`.
|
|
56
|
+
5. Records the previous host path for proxy mode when available.
|
|
46
57
|
|
|
47
58
|
Example manifest path on macOS:
|
|
48
59
|
|
|
@@ -50,6 +61,12 @@ Example manifest path on macOS:
|
|
|
50
61
|
~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.openai.codexextension.json
|
|
51
62
|
```
|
|
52
63
|
|
|
64
|
+
Example manifest path on Linux:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
~/.config/google-chrome/NativeMessagingHosts/com.openai.codexextension.json
|
|
68
|
+
```
|
|
69
|
+
|
|
53
70
|
## MCP Client Config
|
|
54
71
|
|
|
55
72
|
Use stdio mode from other Agent tools:
|
|
@@ -117,3 +134,24 @@ If the extension is missing, install the [Codex Chrome Extension](https://chrome
|
|
|
117
134
|
Stopping the MCP stdio process does not uninstall the native host. Uninstall explicitly to restore the original manifest.
|
|
118
135
|
|
|
119
136
|
The MCP stdio server uses the official `@modelcontextprotocol/sdk` package and must not write logs to stdout. Use stderr for diagnostics.
|
|
137
|
+
|
|
138
|
+
## Troubleshooting
|
|
139
|
+
|
|
140
|
+
If `status` shows no sockets:
|
|
141
|
+
|
|
142
|
+
1. Confirm Chrome is running with the profile where the extension is installed.
|
|
143
|
+
2. Reload or disable/enable the Codex Chrome Extension.
|
|
144
|
+
3. Run `npx -y codex-control-chrome-mcp@latest status`.
|
|
145
|
+
4. Check that the active manifest path points to `~/.codex-control-chrome-mcp/native-host-launcher`.
|
|
146
|
+
|
|
147
|
+
If Codex App integration is affected, uninstall this project:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npx -y codex-control-chrome-mcp@latest uninstall-native-host
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
If the recorded backup is stale or manually changed, inspect the manifest and use `--force` only when you intentionally want to restore/remove the current project manifest.
|
|
154
|
+
|
|
155
|
+
## Publishing
|
|
156
|
+
|
|
157
|
+
This package is published from GitHub Actions through npm Trusted Publishing. See [Release Process](./release.md).
|
package/docs/release.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Release Process
|
|
2
|
+
|
|
3
|
+
Releases are published from GitHub Actions through npm Trusted Publishing.
|
|
4
|
+
|
|
5
|
+
## Trusted Publishing Setup
|
|
6
|
+
|
|
7
|
+
Configure the npm package settings:
|
|
8
|
+
|
|
9
|
+
- Package: `codex-control-chrome-mcp`
|
|
10
|
+
- Publisher: GitHub Actions
|
|
11
|
+
- Organization or user: `iola1999`
|
|
12
|
+
- Repository: `codex-control-chrome-mcp`
|
|
13
|
+
- Workflow filename: `publish.yml`
|
|
14
|
+
- Environment name: leave blank unless you add a GitHub deployment environment
|
|
15
|
+
- Allowed action: `npm publish`
|
|
16
|
+
|
|
17
|
+
Trusted Publishing requires a GitHub-hosted runner, OIDC permission, npm CLI 11.5.1 or newer, and Node.js 22.14.0 or newer. The publish workflow uses Node.js 24 and installs the latest npm before publishing.
|
|
18
|
+
|
|
19
|
+
## Publish A New Version
|
|
20
|
+
|
|
21
|
+
1. Update `package.json` version.
|
|
22
|
+
2. Update `CHANGELOG.md`.
|
|
23
|
+
3. Run checks locally:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run ci
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
4. Commit and push to `main`.
|
|
30
|
+
5. Create and push a matching tag:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git tag v1.0.1
|
|
34
|
+
git push origin v1.0.1
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The tag must match the package version exactly. For example, `package.json` version `1.0.1` must use tag `v1.0.1`.
|
|
38
|
+
|
|
39
|
+
## What The Workflow Does
|
|
40
|
+
|
|
41
|
+
The `publish.yml` workflow:
|
|
42
|
+
|
|
43
|
+
1. Installs dependencies with `npm ci`.
|
|
44
|
+
2. Verifies the tag matches `package.json`.
|
|
45
|
+
3. Runs `npm run ci`.
|
|
46
|
+
4. Publishes with `npm publish`.
|
|
47
|
+
|
|
48
|
+
No long-lived `NPM_TOKEN` is required.
|
|
49
|
+
|
|
50
|
+
## GitHub Release
|
|
51
|
+
|
|
52
|
+
After the npm publish workflow succeeds, create a GitHub Release from the same tag and copy the relevant section from `CHANGELOG.md` into the release notes.
|
|
53
|
+
|
|
54
|
+
Do not create a new GitHub Release for a tag if the npm publish failed.
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-control-chrome-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "MCP server and native host bridge for controlling Chrome through the Codex Chrome extension.",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"bin": {
|
|
7
8
|
"codex-control-chrome-mcp": "bin/codex-control-chrome-mcp.js"
|
|
@@ -32,13 +33,18 @@
|
|
|
32
33
|
"src",
|
|
33
34
|
"docs",
|
|
34
35
|
"skills",
|
|
35
|
-
"
|
|
36
|
+
"CHANGELOG.md",
|
|
37
|
+
"LICENSE",
|
|
38
|
+
"README.md",
|
|
39
|
+
"SECURITY.md"
|
|
36
40
|
],
|
|
37
41
|
"scripts": {
|
|
38
42
|
"start": "node ./bin/codex-control-chrome-mcp.js --stdio",
|
|
39
43
|
"native-host": "node ./bin/codex-control-chrome-mcp.js --native-host",
|
|
40
44
|
"status": "node ./bin/codex-control-chrome-mcp.js status",
|
|
41
|
-
"check": "node --check ./bin/codex-control-chrome-mcp.js && node --check ./src/*.js"
|
|
45
|
+
"check": "node --check ./bin/codex-control-chrome-mcp.js && node --check ./src/*.js && node --check ./test/*.test.js",
|
|
46
|
+
"test": "node --test",
|
|
47
|
+
"ci": "npm run check && npm test && npm pack --dry-run"
|
|
42
48
|
},
|
|
43
49
|
"engines": {
|
|
44
50
|
"node": ">=20"
|
package/src/installer.js
CHANGED
|
@@ -8,19 +8,20 @@ import {
|
|
|
8
8
|
INSTALL_STATE_PATH,
|
|
9
9
|
nativeHostManifestPath,
|
|
10
10
|
} from "./constants.js";
|
|
11
|
+
import { PACKAGE_NAME, PACKAGE_VERSION } from "./package-meta.js";
|
|
11
12
|
|
|
12
|
-
const PACKAGE_NAME = "codex-control-chrome-mcp";
|
|
13
|
-
const PACKAGE_VERSION = "1.0.0";
|
|
14
13
|
const MANIFEST_DESCRIPTION = "Codex Control Chrome MCP native messaging host";
|
|
15
14
|
|
|
16
|
-
export async function installNativeHost({ binPath, proxy = true } = {}) {
|
|
17
|
-
const manifestPath =
|
|
15
|
+
export async function installNativeHost({ binPath, proxy = true, paths = defaultInstallPaths() } = {}) {
|
|
16
|
+
const { manifestPath, appStateDir, configPath, installStatePath } = paths;
|
|
18
17
|
await fs.mkdir(path.dirname(manifestPath), { recursive: true });
|
|
19
|
-
await fs.mkdir(
|
|
18
|
+
await fs.mkdir(appStateDir, { recursive: true });
|
|
20
19
|
|
|
21
|
-
const hostPath = binPath
|
|
20
|
+
const hostPath = binPath
|
|
21
|
+
? await createLocalLauncher(path.resolve(binPath), appStateDir)
|
|
22
|
+
: await createNpxLauncher(appStateDir);
|
|
22
23
|
const existing = await readJsonIfExists(manifestPath);
|
|
23
|
-
const previousState = await readJsonIfExists(
|
|
24
|
+
const previousState = await readJsonIfExists(installStatePath);
|
|
24
25
|
const previousBackup = previousState?.backupPath
|
|
25
26
|
? await readJsonIfExists(previousState.backupPath)
|
|
26
27
|
: null;
|
|
@@ -69,14 +70,14 @@ export async function installNativeHost({ binPath, proxy = true } = {}) {
|
|
|
69
70
|
officialHostPath,
|
|
70
71
|
proxy,
|
|
71
72
|
};
|
|
72
|
-
await fs.writeFile(
|
|
73
|
-
await fs.writeFile(
|
|
73
|
+
await fs.writeFile(configPath, `${JSON.stringify(config, null, 2)}\n`, "utf8");
|
|
74
|
+
await fs.writeFile(installStatePath, `${JSON.stringify(config, null, 2)}\n`, "utf8");
|
|
74
75
|
return config;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
export async function uninstallNativeHost({ force = false } = {}) {
|
|
78
|
-
const manifestPath =
|
|
79
|
-
const state = await readJsonIfExists(
|
|
78
|
+
export async function uninstallNativeHost({ force = false, paths = defaultInstallPaths() } = {}) {
|
|
79
|
+
const { manifestPath, installStatePath } = paths;
|
|
80
|
+
const state = await readJsonIfExists(installStatePath);
|
|
80
81
|
const manifest = await readJsonIfExists(manifestPath);
|
|
81
82
|
|
|
82
83
|
if (!manifest && !state?.backupPath) {
|
|
@@ -99,12 +100,21 @@ export async function uninstallNativeHost({ force = false } = {}) {
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
export async function nativeHostInstallStatus() {
|
|
102
|
-
const manifestPath =
|
|
103
|
+
const { manifestPath, installStatePath } = defaultInstallPaths();
|
|
103
104
|
const manifest = await readJsonIfExists(manifestPath);
|
|
104
|
-
const state = await readJsonIfExists(
|
|
105
|
+
const state = await readJsonIfExists(installStatePath);
|
|
105
106
|
return { manifestPath, manifest, state };
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
function defaultInstallPaths() {
|
|
110
|
+
return {
|
|
111
|
+
manifestPath: nativeHostManifestPath(),
|
|
112
|
+
appStateDir: APP_STATE_DIR,
|
|
113
|
+
configPath: APP_CONFIG_PATH,
|
|
114
|
+
installStatePath: INSTALL_STATE_PATH,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
108
118
|
async function backupManifest(manifestPath) {
|
|
109
119
|
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
110
120
|
const backupPath = path.join(
|
|
@@ -115,11 +125,11 @@ async function backupManifest(manifestPath) {
|
|
|
115
125
|
return backupPath;
|
|
116
126
|
}
|
|
117
127
|
|
|
118
|
-
async function createNpxLauncher() {
|
|
128
|
+
async function createNpxLauncher(appStateDir) {
|
|
119
129
|
if (process.platform === "win32") {
|
|
120
130
|
throw new Error("NPX native host launcher installation is not implemented for Windows yet.");
|
|
121
131
|
}
|
|
122
|
-
const launcherPath = path.join(
|
|
132
|
+
const launcherPath = path.join(appStateDir, "native-host-launcher");
|
|
123
133
|
const script = `#!/usr/bin/env sh
|
|
124
134
|
exec npx -y ${PACKAGE_NAME}@${PACKAGE_VERSION} --native-host "$@"
|
|
125
135
|
`;
|
|
@@ -132,14 +142,14 @@ function isProjectManifest(manifest) {
|
|
|
132
142
|
return manifest?.description === MANIFEST_DESCRIPTION;
|
|
133
143
|
}
|
|
134
144
|
|
|
135
|
-
async function createLocalLauncher(binPath) {
|
|
145
|
+
async function createLocalLauncher(binPath, appStateDir) {
|
|
136
146
|
if (process.platform === "win32") {
|
|
137
147
|
return binPath;
|
|
138
148
|
}
|
|
139
149
|
if (!binPath.endsWith(".js")) {
|
|
140
150
|
return binPath;
|
|
141
151
|
}
|
|
142
|
-
const launcherPath = path.join(
|
|
152
|
+
const launcherPath = path.join(appStateDir, "native-host-local-launcher");
|
|
143
153
|
const script = `#!/usr/bin/env sh
|
|
144
154
|
exec ${shellQuote(process.execPath)} ${shellQuote(binPath)} "$@"
|
|
145
155
|
`;
|
package/src/mcp-server.js
CHANGED
|
@@ -4,12 +4,13 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { connectBridge, listBridgeSockets } from "./bridge-client.js";
|
|
6
6
|
import { nativeHostManifestPath } from "./constants.js";
|
|
7
|
+
import { PACKAGE_NAME, PACKAGE_VERSION } from "./package-meta.js";
|
|
7
8
|
|
|
8
9
|
export async function runMcpServer() {
|
|
9
10
|
const runtime = new ChromeUseRuntime();
|
|
10
11
|
const server = new McpServer({
|
|
11
|
-
name:
|
|
12
|
-
version:
|
|
12
|
+
name: PACKAGE_NAME,
|
|
13
|
+
version: PACKAGE_VERSION,
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
registerTools(server, runtime);
|