R

ReAct MCP智能搜索服务器

@mshojaei77/ReActMCP
0 Stars 415 次浏览 mshojaei77 更新于 2026-08-23

一个MCP服务器,通过Exa API将实时网络搜索功能集成到人工智能助手当中,提供基础和高级搜索功能,并带有格式化的Markdown结果。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "websearch": {
      "args": [
        "path/to/servers/exa_web_search.py"
      ],
      "command": "python"
    }
  }
}

该服务需要配置环境变量:EXA_API_KEY

服务介绍

ReActMCP Web Search

ReActMCP Web Search 是一个 MCP(模型上下文协议)服务器,它将网页搜索功能集成到您的 AI 助手框架中。它利用 Exa API 执行基本和高级网页搜索,返回实时的、Markdown 格式的结果,包括标题、URL、发布日期和内容摘要。

此仓库是更广泛的 ReActMCP 项目的一部分,该项目连接了各种 MCP 工具和服务,为您的 AI 助手赋予了广泛的能力。


目录


特性

  • 基本网页搜索:使用 Exa API 执行简单的搜索。
  • 高级网页搜索:使用额外的过滤选项,如域名限制、文本包含要求和日期过滤器。
  • Markdown 输出:以 Markdown 格式格式化搜索结果,轻松整合标题、URL 和摘要。
  • MCP 集成:轻松将此工具添加到您的 MCP 服务器生态系统中,实现多工具 AI 辅助。

要求

  • Python 3.8+
  • python-dotenv
  • exa_py (Exa API 客户端)
  • 您的 MCP 框架可能需要的其他依赖项

安装

  1. 克隆仓库

    git clone https://github.com/mshojaei77/ReActMCP.git
    cd ReActMCP
    
  2. 创建虚拟环境(可选但推荐)

    python -m venv venv
    source venv/bin/activate  # 在 Windows 上使用: venv\Scripts\activate
    
  3. 安装依赖项

    pip install -r requirements.txt
    

配置

环境变量

在项目根目录下创建一个 .env 文件,并至少包含以下变量:

EXA_API_KEY=your_exa_api_key_here
OPENAI_API_KEY=...

此密钥是 Exa API 执行网页搜索所必需的。

MCP 配置

MCP 配置文件 mcp_config.json 定义了您的 MCP 服务器可用的设置和工具。提供了一个示例配置:

{
  "websearch": {
    "script": "web_search.py",
    "encoding_error_handler": "ignore",
    "description": "Web search capability using Exa API that provides real-time internet search results. Supports both basic and advanced search with filtering options including domain restrictions, text inclusion requirements, and date filtering. Returns formatted results with titles, URLs, publication dates, and content summaries.",
    "required_env_vars": ["EXA_API_KEY"],
    "active": true
  },
  "settings": {
    "model": "gpt-4o",
    "system_prompt_path": "system_prompt.txt"
  }
}

您可以通过修改参数(如默认结果数量)或添加新的 MCP 工具来个性化或扩展此配置。

系统提示

system_prompt.txt 文件配置了您的 AI 助手的行为和语气。它指导响应友好、吸引人且信息丰富,并包含表情符号。提供了一个示例提示:

You are a helpful, knowledgeable AI assistant with web search capabilities. Your goal is to provide accurate, comprehensive, and up-to-date information to users.
Use lots of emojis and make your responses fun and engaging.

## Available Search Tools

- `search_web`: Basic web search that returns results based on a query
- `advanced_search_web`: Advanced search with filtering options for domains, required text, and date ranges

## Guidelines for Responding to Questions

1. For current information or facts that might have changed since your training data, use the appropriate search tool to find the most recent and relevant information.

2. Use `search_web` for general queries and `advanced_search_web` with appropriate filters for more specific needs.

3. Formulate precise search queries to maximize result relevance.

4. For recent information, use the `max_age_days` parameter in advanced search to limit results to recent publications.

5. When targeting specific sources, use the `include_domains` parameter to focus your search.

6. Cite sources by including URLs from search results.

7. For insufficient or contradictory results, acknowledge limitations and explain findings.

8. Break down complex topics into organized sections.

9. Provide balanced perspectives on controversial topics.

10. Be transparent about uncertainty rather than making up information.

11. Maintain a helpful, informative, and conversational tone.

## Response Quality Standards

Your responses should be well-structured, factually accurate, and tailored to the user's level of understanding on the topic. Use the web search capabilities as your primary tools for accessing current information before responding to time-sensitive or factual queries.

请根据您期望的助手行为自由调整系统提示。


使用

运行网页搜索服务器

MCP 服务器实现在 servers 目录中。要运行一个服务器,只需执行它:

python servers/web_search.py

此命令将启动 MCP 服务器,该服务器监听请求并提供以下工具:

  • search_web: 执行基本的网页搜索。
  • advanced_search_web: 执行带有过滤选项的高级网页搜索。

测试工具

web_search.py 中,提供了一个测试函数 test_search()(目前被注释掉了)来演示搜索功能的基本使用方法。你可以通过取消注释测试执行块并使用 Python 的 asyncio 运行器来运行这个测试:

if __name__ == "__main__":
    import asyncio
    # Uncomment the following line to perform a test search
    # asyncio.run(test_search())
    mcp.run()

这将会打印示例查询的搜索结果,并帮助你验证工具是否按预期工作。


Claude Desktop 配置:

通过向你的配置中添加以下内容来配置 Claude Desktop 使用此服务器:

{
  "mcpServers": {
    "websearch": {
         "command": "python",
         "args": ["path/to/servers/exa_web_search.py"]
       }
  }
}

故障排除

  • 缺少 EXA_API_KEY: 确保 .env 文件正确设置了有效的 Exa API 密钥。
  • 依赖问题: 确认所有必需的 Python 包都已安装(检查你的 requirements.txt 文件)。如果需要,请重新安装包。
  • API 错误: 如果在网络搜索过程中遇到错误,请检查网络连接并验证 Exa API 的状态。

许可证

本项目根据 MIT 许可证授权。详情请参阅 LICENSE 文件。


贡献

欢迎贡献!如果你有建议、修复 bug 或改进,请提出问题或提交拉取请求。

愉快编码,享受使用 ReActMCP Web Search 构建您的个性化多功能 AI 助手吧!🚀😊

星星历史

相关 MCP 服务