智能网络搜索服务器

一个基于OpenAI推理模型的智能网络搜索服务器,为AI助手提供最新的信息检索和智能推理能力。

  • by ConechoAI
  • Python
  • 本地部署
  • 94 星标
  • 更新于
在 GitHub 查看 ConechoAI/openai-websearch-mcp

使用说明

OpenAI WebSearch MCP服务器🔍

一种先进的MCP服务器,使用OpenAI的推理模型提供智能网络搜索功能。非常适合需要具有智能推理能力的最新信息的人工智能助手。

✨ 特性

  • 🧠 推理模型支持:与OpenAI最新的推理模型(gpt-5、gpt-5-mini、gpt-5-纳米、o3、o4-mini)完全兼容
  • ⚡ 智能努力控制:智能 reasoning_effort 基于用例的默认值
  • 🔄 多模式搜索:使用gpt-5-mini进行快速迭代或使用gpt-5进行深入研究
  • 🌍 本地化结果:支持基于位置的搜索自定义
  • 📝 丰富的描述:完整的参数文档,便于集成
  • 🔧 灵活的配置:环境变量支持,便于部署

🚀 快速开始

Claude Desktop的一键安装

OPENAI_API_KEY=sk-xxxx uvx --with openai-websearch-mcp openai-websearch-mcp-install

替换 sk-xxxx 使用来自的OpenAI API密钥 OpenAI平台.

⚙️ 配置

克劳德桌面

添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "openai-websearch-mcp": {
      "command": "uvx",
      "args": ["openai-websearch-mcp"],
      "env": {
        "OPENAI_API_KEY": "your-api-key-here",
        "OPENAI_DEFAULT_MODEL": "gpt-5-mini"
      }
    }
  }
}

光标

在Cursor中添加到MCP设置中:

  1. 打开光标设置(Cmd/Ctrl + ,)
  2. 搜索“MCP”或转到扩展→ MCP
  3. 添加服务器配置:
{
  "mcpServers": {
    "openai-websearch-mcp": {
      "command": "uvx",
      "args": ["openai-websearch-mcp"],
      "env": {
        "OPENAI_API_KEY": "your-api-key-here",
        "OPENAI_DEFAULT_MODEL": "gpt-5-mini"
      }
    }
  }
}

克劳德代码

Claude Code会自动检测为Claude Desktop配置的MCP服务器。对Claude Desktop使用与上述相同的配置。

地方发展

对于本地测试,请使用虚拟环境的绝对路径:

{
  "mcpServers": {
    "openai-websearch-mcp": {
      "command": "/path/to/your/project/.venv/bin/python",
      "args": ["-m", "openai_websearch_mcp"],
      "env": {
        "OPENAI_API_KEY": "your-api-key-here",
        "OPENAI_DEFAULT_MODEL": "gpt-5-mini",
        "PYTHONPATH": "/path/to/your/project/src"
      }
    }
  }
}

🛠️ 可用工具

openai_web_search

支持推理模型的智能网络搜索。

参数

参数 类型 描述 默认值
input string 要搜索的搜索查询或问题 必需
model string 要使用的AI模型。支持gpt-4o、gpt-4o-mini、gpt-5、gpt-5-mini、gpt-5-nano、o3、o4 mini gpt-5-mini
reasoning_effort string 推理工作量级别:低、中、高、最小 智能默认
type string Web搜索API版本 web_search_preview
search_context_size string 上下文量:低、中、高 medium
user_location object 本地化结果的可选位置 null

💬 使用示例

配置后,只需让您的AI助手使用自然语言搜索信息:

快速搜索

“使用openai_web_Search搜索人工智能推理模型的最新发展”

深入研究

“使用openai_web_search结合gpt-5和高推理能力,对量子计算突破进行全面分析”

本地化搜索

“使用openai_web_Search搜索本周旧金山的本地技术会议”

AI助手将自动使用 openai_web_search 根据您的要求,使用具有适当参数的工具。

🤖 选型指南

快速多轮搜索🚀

  • 推荐: gpt-5-mini 随着 reasoning_effort: "low"
  • 用例:快速迭代、实时信息、多次快速查询
  • 益处:延迟更低,对于频繁搜索更具成本效益

深入研究🔬

  • 推荐: gpt-5 随着 reasoning_effort: "medium" 或 "high"
  • 用例:综合分析、复杂主题、详细调查
  • 益处:多轮推理结果,无需代理迭代

模型比较

模型 推理 默认努力 最适合
gpt-4o ❌ N/A 标准搜索
gpt-4o-mini ❌ N/A 基本查询
gpt-5-mini ✅ low 快速迭代
gpt-5 ✅ medium 深入研究
gpt-5-nano ✅ medium 平衡的方法
o3 ✅ medium 高级推理
o4-mini ✅ medium 高效推理

📦 安装

使用uvx(推荐)

# Install and run directly
uvx openai-websearch-mcp

# Or install globally
uvx install openai-websearch-mcp

使用pip

# Install from PyPI
pip install openai-websearch-mcp

# Run the server
python -m openai_websearch_mcp

来源

# Clone the repository
git clone https://github.com/yourusername/openai-websearch-mcp.git
cd openai-websearch-mcp

# Install dependencies
uv sync

# Run in development mode
uv run python -m openai_websearch_mcp

👩‍💻 发展

设置开发环境

# Clone and setup
git clone https://github.com/yourusername/openai-websearch-mcp.git
cd openai-websearch-mcp

# Create virtual environment and install dependencies
uv sync

# Run tests
uv run python -m pytest

# Install in development mode
uv pip install -e .

环境变量

变量 描述 默认值
OPENAI_API_KEY 您的OpenAI API密钥 必需
OPENAI_DEFAULT_MODEL 要使用的默认模型 gpt-5-mini

🐛 调试

使用MCP检查器

# For uvx installations
npx @modelcontextprotocol/inspector uvx openai-websearch-mcp

# For pip installations
npx @modelcontextprotocol/inspector python -m openai_websearch_mcp

常见问题

问题:“不支持的参数:'reasong.effort'” 解决方案:当使用带有reasoning_effort参数的非推理模型(gpt-4o、gpt-4o-mini)时,会发生这种情况。服务器通过仅将推理参数应用于兼容模型来自动处理此问题。

问题:“没有名为'openai_websearch_mcp'的模块” 解决方案:确保您已正确安装包,并且Python路径包含包位置。

📄 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

🙏 致谢


合著者:克劳德 noreply@anthropic.com