谷歌搜索API深度研究代理

一个基于Google Custom Search API的深度研究代理,用于进行多轮搜索并回答问题。

  • by AI-Hub-Admin
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 AI-Hub-Admin/google-deep-research-agent

使用说明

基于谷歌搜索API的深度研究代理

GitHub | 代理MCP部署 | AI代理市场 | OneKey MCP路由器

谷歌搜索深度研究代理通过调用谷歌定制搜索API进行多轮搜索,并进行深度研究以回答您的问题。

代理实时URL 在aiagenta2z.com上部署。

特性

  • 谷歌搜索:直接使用Google自定义搜索API搜索网页
  • 简化结果:获取包含标题、链接、片段和排名的简化搜索结果

先决条件

  1. Google API密钥:您需要启用自定义搜索API的Google API密钥

  2. 谷歌自定义搜索引擎ID:您需要创建自定义搜索引擎

安装

  1. 安装依赖项:
pip install -r requirements.txt
  1. 设置环境变量:
export GOOGLE_SEARCH_ACCESS_KEY="your-api-key-here"
export GOOGLE_SEARCH_ENGINE_ID="your-search-engine-id-here"

或者创建一个 .env 文件:

GOOGLE_SEARCH_ACCESS_KEY=your-api-key-here

用法

启动MCP服务器

选项1:使用启动脚本(推荐)

./run_mcp_server.sh [PORT]

默认端口为7005。您可以指定其他端口:

./run_mcp_server.sh 7006

选项2:使用玉米(生产)

uvicorn server:app --host 0.0.0.0 --port 7005

选项3:直接执行Python(开发)

python3 server.py --port 7005

API终点

服务器在以下位置公开MCP端点:

  • http://0.0.0.0:7005/mcp (或您指定的端口)

可用工具

  1. 谷歌搜索:使用简化或完整结果进行搜索
    • 参数:
      • query (必填):搜索查询字符串
      • num (可选):结果数量(1-10,默认值:10)
      • full_response (可选):如果为True,则返回完整的API响应(默认值:False)
    • 返回:包含结果、total_results、查询、消息和可选完整响应的字典

测试MCP服务器

您可以使用curl或测试脚本测试MCP服务器:

# Test MCP endpoint
curl http://127.0.0.1:7005/mcp

项目结构

google_search_agent/
├── google_search_agent/
│   ├── __init__.py
│   ├── agent.py              # GoogleSearchAgent implementation
│   └── google-search-api.py  # Original Google Search API implementation
├── server.py                  # MCP server implementation
├── requirements.txt           # Python dependencies
├── pyproject.toml             # Project configuration
├── run_mcp_server.sh          # Startup script
└── README.md                  # This file

生产模式

uvicorn server:app --host 0.0.0.0 --port 7005
  • 更好的性能
  • 支持热重载(--reload)
  • 支持多名员工(--workers N)
  • 推荐用于生产