-
Notifications
You must be signed in to change notification settings - Fork 2.2k
docs: fix Codex MCP add instructions #968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df246d9
e1756db
44a72cc
8a884cc
bae0694
74fcf9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,19 @@ Using `.mcp.json` to debug while using a client: | |
|
|
||
| ## Specific problems | ||
|
|
||
| ### Codex: `error: unexpected argument 'add' found` | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the latest codex version supports add, then we probably should not need to document it as users will upgrade soon? |
||
|
|
||
| Some older Codex CLI versions don't include the `codex mcp add`/`list` subcommands. | ||
|
|
||
| - Run `codex mcp --help` and check whether it shows `add`. | ||
| - If it does not, upgrade Codex, or add the server manually by editing `~/.codex/config.toml`: | ||
|
|
||
| ```toml | ||
| [mcp_servers.chrome-devtools] | ||
| command = "npx" | ||
| args = ["-y", "chrome-devtools-mcp@latest"] | ||
| ``` | ||
|
|
||
| ### `Error [ERR_MODULE_NOT_FOUND]: Cannot find module ...` | ||
|
|
||
| This usually indicates either a non-supported Node version is in use or that the | ||
|
|
@@ -71,6 +84,33 @@ ssh -N -L 127.0.0.1:9222:127.0.0.1:9222 <user>@<host-ip> | |
|
|
||
| Point the MCP connection inside the VM to `http://127.0.0.1:9222`. This allows DevTools to reach the host browser without triggering the Host validation error. | ||
|
|
||
| ### Connecting to a running Chrome instance (remote debugging, 9222) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this does not seem to be related to codex. Please remove this section. |
||
|
|
||
| If you want `chrome-devtools-mcp` to attach to an existing Chrome instance, start Chrome with remote debugging enabled, then pass `--browserUrl`. | ||
|
|
||
| 1. Start Chrome with a remote debugging port: | ||
| - Linux: | ||
|
|
||
| ```sh | ||
| google-chrome --remote-debugging-port=9222 | ||
| ``` | ||
|
|
||
| - macOS: | ||
| ```sh | ||
| /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 | ||
| ``` | ||
|
|
||
| 2. Verify the endpoint is reachable: | ||
| - `http://127.0.0.1:9222/json/version` should return JSON | ||
|
|
||
| 3. Start the MCP server and point it at the debugging endpoint: | ||
|
|
||
| ```sh | ||
| npx --yes chrome-devtools-mcp@latest --browserUrl http://127.0.0.1:9222 | ||
| ``` | ||
|
|
||
| See also: `examples/remote-debugging-9222.mjs`. | ||
|
|
||
| ### Operating system sandboxes | ||
|
|
||
| Some MCP clients allow sandboxing the MCP server using macOS Seatbelt or Linux | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /** | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove this example (not related to codex). |
||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| // Example: connect to a Chrome instance that was started with a remote debugging port, | ||
| // using the official MCP TypeScript SDK. | ||
| // | ||
| // 1) Start Chrome manually with remote debugging enabled, e.g.: | ||
| // macOS: | ||
| // /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 | ||
| // Linux: | ||
| // google-chrome --remote-debugging-port=9222 | ||
| // | ||
| // 2) Run this script: | ||
| // node examples/remote-debugging-9222.mjs | ||
| // | ||
| // This starts chrome-devtools-mcp with --browserUrl and connects through MCP stdio. | ||
| // | ||
| // For SDK details, see: | ||
| // https://modelcontextprotocol.io/docs/develop/build-client#typescript | ||
|
|
||
| import {Client} from '@modelcontextprotocol/sdk/client/index.js'; | ||
| import {StdioClientTransport} from '@modelcontextprotocol/sdk/client/stdio.js'; | ||
|
|
||
| const DEBUG_URL = process.env.CHROME_DEBUG_URL ?? 'http://127.0.0.1:9222'; | ||
|
|
||
| const transport = new StdioClientTransport({ | ||
| command: 'npx', | ||
| args: ['--yes', 'chrome-devtools-mcp@latest', '--browserUrl', DEBUG_URL], | ||
| env: { | ||
| ...process.env, | ||
| CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS: 'true', | ||
| }, | ||
| stderr: 'inherit', | ||
| }); | ||
|
|
||
| const client = new Client( | ||
| {name: 'remote-debugging-9222', version: '0.0.0'}, | ||
| {capabilities: {}}, | ||
| ); | ||
|
|
||
| try { | ||
| await client.connect(transport); | ||
|
|
||
| const {tools} = await client.listTools(); | ||
| console.log(`Connected to ${DEBUG_URL}. Found ${tools.length} tools.`); | ||
|
|
||
| for (const tool of tools.slice(0, 10)) { | ||
| console.log(`- ${tool.name}`); | ||
| } | ||
| } finally { | ||
| await transport.close(); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we be more specific in which codex version does add work?