chrome-devtools-mcp 0.2.2 → 0.2.4

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/README.md CHANGED
@@ -66,6 +66,17 @@ claude mcp add chrome-devtools npx chrome-devtools-mcp@latest
66
66
  Follow https://docs.cline.bot/mcp/configuring-mcp-servers and use the config provided above.
67
67
  </details>
68
68
 
69
+ <details>
70
+ <summary>Codex</summary>
71
+ Follow the <a href="https://github.com/openai/codex/blob/main/docs/advanced.md#model-context-protocol-mcp">configure MCP guide</a>
72
+ using the standard config from above. You can also install the Chrome DevTools MCP server using the Codex CLI:
73
+
74
+ ```bash
75
+ codex mcp add chrome-devtools -- npx chrome-devtools-mcp@latest
76
+ ```
77
+
78
+ </details>
79
+
69
80
  <details>
70
81
  <summary>Copilot / VS Code</summary>
71
82
  Follow the MCP install <a href="https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server">guide</a>,
@@ -101,6 +112,19 @@ Go to `Cursor Settings` -> `MCP` -> `New MCP Server`. Use the config provided ab
101
112
  using the standard config from above.
102
113
  </details>
103
114
 
115
+ ### Your first prompt
116
+
117
+ Enter the following prompt in your MCP Client to check if everything is working:
118
+
119
+ ```
120
+ Check the performance of https://developers.chrome.com
121
+ ```
122
+
123
+ Your MCP client should open the browser and record a performance trace.
124
+
125
+ > [!NOTE]
126
+ > The MCP server will start the browser automatically once the MCP client uses a tool that requires a running browser instance. Connecting to the Chrome DevTools MCP server on its own will not automatically start the browser.
127
+
104
128
  ## Tools
105
129
 
106
130
  <!-- BEGIN AUTO GENERATED TOOLS -->
@@ -80,6 +80,14 @@ export class McpContext {
80
80
  this.#consoleCollector.addPage(page);
81
81
  return page;
82
82
  }
83
+ async closePage(pageIdx) {
84
+ if (this.#pages.length === 1) {
85
+ throw new Error('Unable to close the last page in the browser. It is fine to keep the last page open.');
86
+ }
87
+ const page = this.getPageByIdx(pageIdx);
88
+ this.setSelectedPageIdx(0);
89
+ await page.close({ runBeforeUnload: false });
90
+ }
83
91
  getNetworkRequestByUrl(url) {
84
92
  const requests = this.getNetworkRequests();
85
93
  if (!requests.length) {
@@ -123,7 +123,12 @@ Call browser_handle_dialog to handle it before continuing.`);
123
123
  }
124
124
  if (this.#includeConsoleData && this.#formattedConsoleData) {
125
125
  response.push('## Console messages');
126
- response.push(...this.#formattedConsoleData);
126
+ if (this.#formattedConsoleData.length) {
127
+ response.push(...this.#formattedConsoleData);
128
+ }
129
+ else {
130
+ response.push('<no console messages found>');
131
+ }
127
132
  }
128
133
  const text = {
129
134
  type: 'text',
@@ -110,7 +110,14 @@ export class WaitForHelper {
110
110
  return;
111
111
  })
112
112
  .catch(error => logger(error));
113
- await action();
113
+ try {
114
+ await action();
115
+ }
116
+ catch (error) {
117
+ // Clear up pending promises
118
+ this.#abortController.abort();
119
+ throw error;
120
+ }
114
121
  try {
115
122
  await navigationFinished;
116
123
  // Wait for stable dom after navigation so we execute in
@@ -39,7 +39,7 @@ export const selectPage = defineTool({
39
39
  });
40
40
  export const closePage = defineTool({
41
41
  name: 'close_page',
42
- description: `Closes the page by its index.`,
42
+ description: `Closes the page by its index. The last open page cannot be closed.`,
43
43
  annotations: {
44
44
  category: ToolCategories.NAVIGATION_AUTOMATION,
45
45
  readOnlyHint: false,
@@ -50,9 +50,7 @@ export const closePage = defineTool({
50
50
  .describe('The index of the page to close. Call list_pages to list pages.'),
51
51
  },
52
52
  handler: async (request, response, context) => {
53
- const page = context.getPageByIdx(request.params.pageIdx);
54
- context.setSelectedPageIdx(0);
55
- await page.close({ runBeforeUnload: false });
53
+ await context.closePage(request.params.pageIdx);
56
54
  response.setIncludePages(true);
57
55
  },
58
56
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-devtools-mcp",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "MCP server for Chrome DevTools",
5
5
  "type": "module",
6
6
  "bin": "./build/src/index.js",