Google Search MCP Server

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Provides Google Custom Search capabilities with advanced filtering, allowing search queries with parameters for trusted domains, excluded domains, result count, safe search, and date restrictions

  • Converts web content to markdown format for improved readability, with options to include/exclude images and videos, preserve links, and format code blocks

  • Leverages Puppeteer (via rebrowser-puppeteer) for advanced bot detection avoidance, enabling reliable web content viewing and scraping

网页搜索 MCP 服务器

MCP 服务器提供 Google 搜索功能和网页内容浏览功能,并具有高级机器人检测规避功能。

特征

  • 具有高级过滤功能的 Google 自定义搜索
  • 使用 markdown 转换查看网页内容
  • 速率限制和缓存
  • 浏览器实例池
  • 使用 rebrowser-puppeteer 规避机器人检测

先决条件

  • Bun 运行时 v1.0 或更高版本
  • Google API 凭证(API 密钥和搜索引擎 ID)

安装

# Install dependencies bun install # Build the TypeScript files bun run build

配置

Cookie设置

对于经过身份验证的站点访问,您需要:

  1. 安装“本地获取 cookies.txt” Chrome 扩展程序
  2. 访问您想要验证的网站并登录
  3. 使用扩展程序以 JSON 格式导出您的 Cookie
  4. 将导出的 cookies 文件存储在安全的位置
  5. BROWSER_COOKIES_PATH环境变量设置为 cookies 文件的绝对路径

MCP 服务器配置

将服务器配置添加到您的 MCP 设置文件:

  • 对于 Cline: %APPDATA%\Code\User\globalStorage\rooveterinaryinc.roo-cline\settings\cline_mcp_settings.json
  • 对于 Claude 桌面:
    • MacOS/Linux: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
{ "mcpServers": { "web-search": { "command": "bun", "args": [ "run", "/ABSOLUTE/PATH/TO/web_search_mcp/dist/index.js" ], "env": { "GOOGLE_API_KEY": "your_api_key", "GOOGLE_SEARCH_ENGINE_ID": "your_search_engine_id", "MAX_CONCURRENT_BROWSERS": "3", "BROWSER_TIMEOUT": "30000", "RATE_LIMIT_WINDOW": "60000", "RATE_LIMIT_MAX_REQUESTS": "60", "SEARCH_CACHE_TTL": "3600", "VIEW_URL_CACHE_TTL": "7200", "MAX_CACHE_ITEMS": "1000", "BROWSER_POOL_MIN": "1", "BROWSER_POOL_MAX": "5", "BROWSER_POOL_IDLE_TIMEOUT": "30000", "REBROWSER_PATCHES_RUNTIME_FIX_MODE": "addBinding", "REBROWSER_PATCHES_SOURCE_URL": "jquery.min.js", "REBROWSER_PATCHES_UTILITY_WORLD_NAME": "util", "REBROWSER_PATCHES_DEBUG": "0", "BROWSER_COOKIES_PATH": "C:\\path\\to\\cookies.json", "LOG_LEVEL": "info", "NO_COLOR": "0", "BUN_FORCE_COLOR": "1", "FORCE_COLOR": "1" } } } }

/ABSOLUTE/PATH/TO/web_search_mcp替换为服务器目录的绝对路径。

日志配置

以下环境变量控制日志记录行为:

  • LOG_LEVEL :设置日志级别(错误、警告、信息、调试)。默认值:信息
  • NO_COLOR :设置为“1”时禁用彩色输出
  • BUN_FORCE_COLOR :控制 Bun 运行时的彩色输出(设置为“0”以禁用)
  • FORCE_COLOR :全局控制彩色输出(设置为“0”以禁用)

避免机器人检测

该服务器使用 rebrowser-puppeteer 来避免机器人检测:

  1. 运行时启用泄漏预防:
    • 使用 addBinding 技术来避免 Runtime.Enable 检测
    • 适用于 Web Worker 和 iframe
    • 保持对主要世界背景的访问
  2. 源 URL 屏蔽:
    • 将 Puppeteer 的 sourceURL 更改为看起来像合法脚本
    • 有助于避免被自动化工具检测到
  3. 实用世界名称:
    • 使用通用实用程序世界名称
    • 通过世界名称模式防止检测
  4. 浏览器启动配置:
    • 禁用自动化标志
    • 使用优化的 Chrome 参数
    • 配置视口和窗口设置

与 Claude Desktop 一起使用

  1. 确保已安装 Claude Desktop 并更新至最新版本
  2. 打开您的 Claude Desktop 配置文件:
    • MacOS/Linux: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  3. 按照上面的配置部分所示添加服务器配置。
  4. 重启Claude桌面
  5. 寻找锤子图标确认工具可用

可用工具

1. 搜索工具

{ name: "search", params: { query: string; trustedDomains?: string[]; excludedDomains?: string[]; resultCount?: number; safeSearch?: boolean; dateRestrict?: string; } }

2.查看URL工具

{ name: "view_url", params: { url: string; includeImages?: boolean; includeVideos?: boolean; preserveLinks?: boolean; formatCode?: boolean; } }

故障排除

Claude 桌面集成问题

  1. 检查日志:
    # MacOS/Linux tail -n 20 -f ~/Library/Logs/Claude/mcp*.log # Windows type %APPDATA%\Claude\Logs\mcp*.log
  2. 常见问题:
    • 服务器未显示:检查配置文件语法和路径
    • 工具调用失败:检查服务器日志并重新启动 Claude Desktop
    • 路径问题:确保使用绝对路径

有关更详细的故障排除,请参阅MCP 调试指南

发展

# Run in development mode with watch bun --watch run dev # Run tests bun run test # Run linter bun run lint

重要提示

  1. 机器人检测:
    • 机器人检测规避功能有助于防止最常见的检测方法
    • 然而,可能需要采取适当的代理和用户代理等额外措施
    • 一些网站可能仍会通过其他方式检测自动化
  2. 表现:
    • 浏览器实例被池化并重用
    • 自动清理空闲浏览器
    • 资源限制防止过载

执照

麻省理工学院

-
security - not tested
A
license - permissive license
-
quality - not tested

通过 MCP 协议提供 Google 搜索功能、网页内容提取和屏幕截图功能以及高级机器人检测规避功能。

  1. Features
    1. Prerequisites
      1. Installation
        1. Configuration
          1. Cookie Setup
          2. MCP Server Configuration
          3. Logging Configuration
        2. Bot Detection Avoidance
          1. Using with Claude Desktop
            1. Available Tools
              1. 1. Search Tool
              2. 2. View URL Tool
            2. Troubleshooting
              1. Claude Desktop Integration Issues
            3. Development
              1. Important Notes
                1. License
                  ID: na33znv5mg