Back to MCP directory
publicPublicdnsLocal runtime

chrome-debug-mcp

一个基于Playwright的浏览器自动化工具,支持Greasemonkey API和Chrome调试功能

article

README

🚀 Chrome 调试指南

本指南将为你详细介绍 Chrome 调试工具的安装、使用方法,帮助你高效地进行 Chrome 调试工作。

🚀 快速开始

初始化配置

在项目根目录下创建一个 config.js 文件:

// config.js
module.exports = {
  port: 9229, // 自定义调试端口
  chromePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe' // Chrome 安装路径
};

启动调试服务器

在终端中运行以下命令启动调试服务:

node index.js

✨ 主要特性

  • 支持通过 npm 安装,方便快捷。
  • 可手动安装,直接从 GitHub 下载源代码。
  • 提供丰富的调试命令,满足不同调试需求。

📦 安装指南

通过 npm 安装

你可以使用 Node.js 的包管理工具 npm 来安装项目:

npm install chrome-debug

手动安装

若不想使用 npm,可直接从 GitHub 下载源代码,并解压到项目目录中。

💻 使用示例

基础用法

const { Debugger } = require('chrome-debug');

// 初始化调试器
const debugger = new Debugger({
  port: 9229, // 自定义端口
  configPath: 'config.js' // 配置文件路径
});

// 启动调试服务
debugger.start().then(() => {
  console.log('调试服务器已启动');
});

高级用法

const { chrome } = require('@modelcontextprotocol/chrome-remote-interface');

async function main() {
  const chrome = await chrome.connect({
    url: 'ws://localhost:9229',
    target: {
      browserContextId: 0
    }
  });

  // 操作示例:获取当前页面标题
  const title = await chrome.Runtime.getTitle();
  console.log('页面标题:', title);

  // 关闭 Chrome 实例
  await chrome.close();
}

main().catch(console.error);

📚 详细文档

调试命令

启动新会话

chrome-debug --start --port=9230

连接到现有会话

chrome-debug --connect --url=http://localhost:9230

项目依赖

此项目使用了以下开源库:

📄 许可证

此项目遵循 MIT 协议,具体内容请参阅 LICENSE 文件。

贡献指南

有关贡献的详细信息,请参阅 Contributing.md

致谢

感谢以下资源和社区的支持:

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client