网页搜索抓取工具

MCP Web Tools是一款本地运行的网页搜索和内容抓取工具,为AI助手提供直接的网络请求能力。

  • by SayreBlades
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 SayreBlades/mcp-web-tools

使用说明

MCP Web工具

一个模型上下文协议(MCP)服务器,为Claude Code等人工智能助手提供网络搜索和获取功能。

当您希望代码生成工具直接从您的计算机发出web请求,而不是通过您不控制的外部服务器代理这些请求时,这很有用。MCP服务器在您的主机上本地运行,因此所有web请求都来自您自己的网络。

特性

  • 网络搜索 -使用DuckDuckGo搜索网络

    • 返回带有标题、URL和代码段的格式化结果
    • 可配置的结果计数和区域
  • web_fetch -从网页中获取和提取内容

    • 自动HTML到文本转换(删除脚本、样式、导航)
    • JSON响应格式
    • 可配置超时

需求

安装

快速安装(推荐)

# Clone the repository
git clone <repo-url>
cd mcp-web-tools

# Install globally and configure Claude Code
make install

这将:

  1. 安装 mcp-web-tools 作为全局可执行文件,通过 uv tool install
  2. 使用Claude Code注册MCP服务器 claude mcp add
  3. 可执行文件将在以下网址提供 ~/.local/bin/mcp-web-tools

安装后重新启动Claude Code。

手动安装

# Install dependencies
uv sync

# Run directly from project
uv run mcp-web-tools

生成文件目标

目标 描述
make install 全局安装并配置Claude代码
make uninstall 删除全局安装
make test 使用pytest运行测试
make clean 删除构建工件

Claude代码配置

运行后 make install,您可以验证注册:

claude mcp list

这些工具将以Claude Code的形式提供:

  • mcp__web-tools__web_search
  • mcp__web-tools__web_fetch

人工注册

如果您更喜欢手动注册:

# User-wide (available in all projects)
claude mcp add --scope user web-tools mcp-web-tools

# Project-local (only current project)
claude mcp add --scope project web-tools mcp-web-tools

替代方案:从项目目录运行

对于开发,您可以注册直接从源代码运行:

claude mcp add --scope project web-tools uv run --directory /path/to/mcp-web-tools mcp-web-tools

工具参考

网络搜索

使用DuckDuckGo搜索网络。

参数:

参数 类型 必填 默认 说明
query string 是 - 搜索查询
max_results 整数 否 10 最大结果数
region string No “wt wt” 结果区域(例如,“us en”、“uk en”)

示例响应:

Search results for: python mcp server

1. Building MCP Servers in Python
   URL: https://example.com/article
   Learn how to build Model Context Protocol servers...

2. MCP Documentation
   URL: https://modelcontextprotocol.io/docs
   Official documentation for the Model Context Protocol...

web_fetch

获取网页的内容。

参数:

参数 类型 必填 默认 说明
url string 是 - 要获取的url
timeout 整数 否 30 请求超时(秒)

示例响应:

Content from https://example.com/article:

Building MCP Servers
This guide covers the basics of creating an MCP server...

发展

运行测试

make test

# Or directly
uv run pytest -v

项目结构

mcp-web-tools/
  src/
    mcp_web_tools/
      __init__.py       # Package metadata
      server.py         # MCP server implementation
      tools.py          # Tool implementations (search, fetch)
  tests/
    test_tools.py       # Unit tests
  pyproject.toml        # Project configuration
  Makefile              # Install/uninstall automation

依赖项

许可证

麻省理工学院