这是一个模型上下文协议(MCP)服务器,它使大语言模型(LLMs)能够与 VS Code 的简易浏览器进行交互,提供网站交互功能和控制台日志监控。
克隆仓库:
git clone https://github.com/YOUR_USERNAME/vscode-simple-browser-mcp.git
cd vscode-simple-browser-mcp
安装依赖:
npm install
构建项目:
npm run build
将服务器添加到你的 Claude Desktop 配置文件中:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\\Claude\\claude_desktop_config.json{
"mcpServers": {
"vscode-simple-browser": {
"command": "node",
"args": [
"/path/to/your/vscode-simple-browser-mcp/build/index.js"
]
}
}
}
直接运行服务器:
npm start
git clone https://github.com/YOUR_USERNAME/vscode-simple-browser-mcp.git
cd vscode-simple-browser-mcp
npm install
npm run build
请在简易浏览器中打开 https://example.com
执行 JavaScript 以获取页面标题:document.title
获取浏览器的最新控制台日志
浏览器的当前状态是什么?
在项目开发过程中,你可以根据需求灵活组合各个工具的使用,例如先打开一个网站,然后执行 JavaScript 代码对页面进行操作,同时监控控制台日志:
请在简易浏览器中打开 https://example.com
Execute JavaScript to get the page title: document.title
Get the latest console logs from the browser
| 属性 | 详情 |
|---|---|
| 工具 | 描述 |
| 参数 | 详情 |
| 工具 | 描述 | 参数 |
|---|---|---|
open_url |
在简易浏览器中打开一个 URL | url(必需),title(可选) |
navigate |
导航到不同的 URL | url(必需) |
get_current_url |
获取当前显示的 URL | 无 |
refresh_page |
刷新当前页面 | 无 |
execute_javascript |
在浏览器上下文中执行 JavaScript | code(必需),waitForResult(可选) |
get_console_logs |
检索控制台日志 | level(可选),limit(可选),since(可选) |
clear_console_logs |
清除存储的控制台日志 | 无 |
get_browser_state |
获取当前浏览器状态 | 无 |
close_browser |
关闭简易浏览器 | 无 |
vscode-simple-browser-mcp/
├── src/
│ └── index.ts # 主要的 MCP 服务器实现
├── build/ # 编译后的 JavaScript 输出
├── .vscode/
│ ├── mcp.json # MCP 服务器配置
│ └── tasks.json # VS Code 任务
├── .github/
│ └── copilot-instructions.md
├── package.json
├── tsconfig.json
└── README.md
npm run build - 构建 TypeScript 项目。npm run dev - 开发的监听模式。npm start - 运行编译后的服务器。server.tool(
"tool_name",
"Tool description",
{
parameter: z.string().describe("Parameter description"),
},
async ({ parameter }) => {
// 工具实现
return {
content: [
{
type: "text",
text: "Tool result",
},
],
};
}
);
这是一个基础实现,提供了以下功能:
对于生产环境的实现,可以考虑以下方面:
ISC 许可证
对于问题和疑问:
计划的未来改进:
git checkout -b feature/your-feature-name。git commit -am 'Add some feature'。git push origin feature/your-feature-name。如果你遇到任何问题或错误,请在 GitHub 上创建一个问题,并提供以下信息: