Skip to main content

百度AI搜索 MCP服务 - 在Cursor等支持MCP的应用中使用百度AI搜索功能

Project description

百度AI搜索 MCP服务

PyPI version Python License: MIT

基于百度千帆AI搜索API的MCP服务,可在Cursor等支持MCP的应用中使用百度AI搜索功能。

功能特性

  • 智能问答: 基于百度搜索的AI智能回答,支持实时信息获取
  • 深度搜索: 可选开启深度搜索获取更全面的信息
  • 新闻获取: 快速获取各领域最新新闻
  • 时间过滤: 支持按时间范围筛选搜索结果
  • 参考来源: 返回回答的参考来源链接

安装

方式一:使用 uvx(推荐)

无需安装,直接在 Cursor MCP 配置中使用:

{
  "mcpServers": {
    "baidu-ai-search": {
      "command": "uvx",
      "args": ["baidu-ai-search-mcp"],
      "env": {
        "BAIDU_API_KEY": "your-api-key-here"
      }
    }
  }
}

方式二:使用 pip 安装

pip install baidu-ai-search-mcp

然后在 Cursor MCP 配置中:

{
  "mcpServers": {
    "baidu-ai-search": {
      "command": "python",
      "args": ["-m", "baidu_ai_search_mcp"],
      "env": {
        "BAIDU_API_KEY": "your-api-key-here"
      }
    }
  }
}

配置

获取 API Key

  1. 访问 百度千帆控制台
  2. 创建应用并获取 API Key(格式:bce-v3/ALTAK***/xxx

Cursor 配置文件位置

  • Windows: %USERPROFILE%\.cursor\mcp.json
  • macOS/Linux: ~/.cursor/mcp.json

完整配置示例

{
  "mcpServers": {
    "baidu-ai-search": {
      "command": "uvx",
      "args": ["baidu-ai-search-mcp"],
      "env": {
        "BAIDU_API_KEY": "bce-v3/ALTAK-xxxxx/xxxxxxxxxx",
        "BAIDU_MODEL": "ernie-3.5-8k"
      }
    }
  }
}

配置完成后,重启 Cursor 即可使用。

可用工具

baidu_ai_ask

向百度AI搜索提问,获取基于实时搜索的智能回答。

参数:

  • question (必需): 要询问的问题
  • enable_deep_search (可选): 是否开启深度搜索,默认 false
  • time_filter (可选): 时间过滤 (week/month/semiyear/year)

示例:

使用 baidu_ai_ask 工具查询"Python 3.12有什么新特性?"

baidu_ai_search

智能搜索,返回搜索结果摘要和链接。

参数:

  • query (必需): 搜索查询词
  • max_results (可选): 最大结果数量,默认 5

baidu_ai_news

获取最新新闻资讯。

参数:

  • topic (可选): 新闻主题(如"科技"、"财经"、"体育")
  • time_range (可选): 时间范围 (week/month),默认 week

支持的模型

模型 特点
ernie-3.5-8k 默认模型,速度快,性价比高
ernie-4.0-turbo-8k 更智能,适合复杂问题
ernie-4.0-turbo-128k 支持长文本上下文
deepseek-r1 深度推理,适合复杂分析
deepseek-v3 DeepSeek最新模型

通过 BAIDU_MODEL 环境变量设置使用的模型。

API 配额

  • 每天 100次 免费调用
  • 超出后按量计费
  • 详见 计费说明

开发

本地开发安装

git clone https://github.com/yourusername/baidu-ai-search-mcp.git
cd baidu-ai-search-mcp
pip install -e .

运行测试

# 设置环境变量
export BAIDU_API_KEY="your-api-key"

# 直接运行
python -m baidu_ai_search_mcp

常见问题

Q: 提示 "未配置 BAIDU_API_KEY"

A: 请确保在 mcp.jsonenv 中正确配置了 API Key。

Q: 请求超时

A: 深度搜索模式耗时较长,可尝试关闭 enable_deep_search

Q: 返回错误 "Authentication error"

A: API Key 格式不正确或已过期,请检查配置。

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baidu_ai_search_mcp-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

baidu_ai_search_mcp-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file baidu_ai_search_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: baidu_ai_search_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for baidu_ai_search_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a6b400b0d57fccff3f7a0d79a26b5473491b51f723d6289088ad19b6ea23efe1
MD5 22fa69503bd813e95c65fb24c124d00d
BLAKE2b-256 90470da985d16269fc342d3d091673434e6b38b4df905c6711ea4e9fcd067b7f

See more details on using hashes here.

File details

Details for the file baidu_ai_search_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for baidu_ai_search_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea380c17ad0ace4040023e3c56d55aea0961f7e5826686b3c03f3027e3e79d35
MD5 79d9b0fa5877ac1cc0da4d78be3d409a
BLAKE2b-256 f385e2ded502199ceab00b6e5f7f349ba954383a417ee5b22c6afb56466a3c82

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page