hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Uses .ENV files to manage API keys and configuration settings for the WebSearch server.

  • Provides integration for repository management, allowing users to fork, clone, and contribute to the WebSearch project.

  • Supports output of crawled and extracted web content in Markdown format for improved readability and structure.

WebSearch - 高级网页搜索和内容提取工具

使用 Python 构建的强大的网络搜索和内容提取工具,利用 Firecrawl API 实现高级网络抓取、搜索和内容分析功能。

🚀 功能

  • 高级网页搜索:使用可自定义的参数执行智能网页搜索
  • 内容提取:使用自然语言提示从网页中提取特定信息
  • 网络爬取:爬取具有可配置深度和限制的网站
  • 网页抓取:抓取网页,支持多种输出格式
  • MCP 集成:构建为模型上下文协议 (MCP) 服务器,实现无缝集成

📋 先决条件

  • Python 3.8 或更高版本
  • uv 包管理器
  • Firecrawl API 密钥
  • OpenAI API 密钥(可选,用于增强功能)
  • Tavily API 密钥(可选,用于附加搜索功能)

🛠️ 安装

  1. 安装 uv:
# On Windows (using pip) pip install uv # On Unix/MacOS curl -LsSf https://astral.sh/uv/install.sh | sh # Add uv to PATH (Unix/MacOS) export PATH="$HOME/.local/bin:$PATH" # Add uv to PATH (Windows - add to Environment Variables) # Add: %USERPROFILE%\.local\bin
  1. 克隆存储库:
git clone https://github.com/yourusername/websearch.git cd websearch
  1. 使用 uv 创建并激活虚拟环境:
# Create virtual environment uv venv # Activate on Windows .\.venv\Scripts\activate.ps1 # Activate on Unix/MacOS source .venv/bin/activate
  1. 使用 uv 安装依赖项:
# Install from requirements.txt uv sync
  1. 设置环境变量:
# Create .env file touch .env # Add your API keys FIRECRAWL_API_KEY=your_firecrawl_api_key OPENAI_API_KEY=your_openai_api_key

🎯 使用方法

使用 Claude 桌面版进行设置

您无需直接运行服务器,而是可以配置 Claude for Desktop 来访问 WebSearch 工具:

  1. 找到或创建您的 Claude for Desktop 配置文件:
    • Windows: %env:AppData%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  2. 将 WebSearch 服务器配置添加到mcpServers部分:
{ "mcpServers": { "websearch": { "command": "uv", "args": [ "--directory", "D:\\ABSOLUTE\\PATH\\TO\\WebSearch", "run", "main.py" ] } } }
  1. 确保将目录路径替换为 WebSearch 项目文件夹的绝对路径。
  2. 保存配置文件并重新启动 Claude for Desktop。
  3. 配置完成后,WebSearch 工具将出现在 Claude for Desktop 的工具菜单(锤子图标)中。

可用工具

  1. 搜索
  2. 提取信息
  3. 抓取网站
  4. 抓取内容

📚 API 参考

搜索

  • query (str):搜索查询
  • 返回:JSON格式的搜索结果

提炼

  • urls (List[str]):从中提取信息的 URL 列表
  • prompt (str): 提取说明
  • enableWebSearch (bool): 启用补充网页搜索
  • showSources (bool):包含源引用
  • 返回:以指定格式提取的信息

爬行

  • url (str): 起始 URL
  • maxDepth (int):最大爬行深度
  • limit (int):抓取的最大页面数
  • 返回:以 markdown/HTML 格式抓取的内容

  • url (str):目标 URL
  • 返回:带有可选屏幕截图的抓取内容

🔧 配置

环境变量

该工具需要特定的 API 密钥才能运行。我们提供了一个.env.example文件,您可以将其用作模板:

  1. 复制示例文件:
# On Unix/MacOS cp .env.example .env # On Windows copy .env.example .env
  1. 使用您的 API 密钥编辑.env文件:
# OpenAI API key - Required for AI-powered features OPENAI_API_KEY=your_openai_api_key_here # Firecrawl API key - Required for web scraping and searching FIRECRAWL_API_KEY=your_firecrawl_api_key_here

获取 API 密钥

  1. OpenAI API密钥
    • 访问OpenAI 平台
    • 注册或登录
    • 导航至 API 密钥部分
    • 创建新的密钥
  2. Firecrawl API密钥

如果一切配置正确,您应该会收到包含搜索结果的 JSON 响应。

故障排除

如果遇到错误:

  1. 确保所有必需的 API 密钥都已在.env文件中设置
  2. 验证 API 密钥是否有效且未过期
  3. 检查.env文件是否位于项目的根目录中
  4. 确保环境变量正确加载

🤝 贡献

  1. 分叉存储库
  2. 创建你的功能分支( git checkout -b feature/AmazingFeature
  3. 提交您的更改( git commit -m 'Add some AmazingFeature'
  4. 推送到分支( git push origin feature/AmazingFeature
  5. 打开拉取请求

📝 许可证

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

🙏 致谢

📬 联系方式

何塞·马丁·罗德里格斯·莫塔洛尼 - @m4s1t425 - jmrodriguezm13@gmail.com


使用 Python 和 Firecrawl 用 ❤️ 制作

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

构建为模型上下文协议 (MCP) 服务器,使用 Firecrawl API 提供高级网络搜索、内容提取、网络爬行和抓取功能。

  1. 🚀 Features
    1. 📋 Prerequisites
      1. 🛠️ Installation
        1. 🎯 Usage
          1. Setting Up With Claude for Desktop
          2. Available Tools
        2. 📚 API Reference
          1. Search
          2. Extract
          3. Crawl
          4. Scrape
        3. 🔧 Configuration
          1. Environment Variables
          2. Getting the API Keys
          3. Troubleshooting
        4. 🤝 Contributing
          1. 📝 License
            1. 🙏 Acknowledgments
              1. 📬 Contact
                ID: bpr128ue6j