Skip to main content

百度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有什么新特性?"

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

参数:

  • 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.json 的 env 中正确配置了 API Key。

Q: 请求超时

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

Q: 返回错误 "Authentication error"

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

License

MIT

Metadata

Release files for baidu-ai-search-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for baidu-ai-search-mcp 0.1.0
File Size Uploaded Provenance Actions
baidu_ai_search_mcp-0.1.0.tar.gz 8.3 kB Without provenance Details for baidu_ai_search_mcp-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for baidu-ai-search-mcp 0.1.0
File Interpreter ABI Platform Actions
baidu_ai_search_mcp-0.1.0-py3-none-any.whl Python 3 none any Details for baidu_ai_search_mcp-0.1.0-py3-none-any.whl

Total release size: 18.4 kB

Release files / baidu_ai_search_mcp-0.1.0.tar.gz

Download URL baidu_ai_search_mcp-0.1.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a6b400b0d57fccff3f7a0d79a26b5473491b51f723d6289088ad19b6ea23efe1
BLAKE2b-256 checksum
How to use checksums
90470da985d16269fc342d3d091673434e6b38b4df905c6711ea4e9fcd067b7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / baidu_ai_search_mcp-0.1.0-py3-none-any.whl

Download URL baidu_ai_search_mcp-0.1.0-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea380c17ad0ace4040023e3c56d55aea0961f7e5826686b3c03f3027e3e79d35
BLAKE2b-256 checksum
How to use checksums
f385e2ded502199ceab00b6e5f7f349ba954383a417ee5b22c6afb56466a3c82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Security for baidu-ai-search-mcp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page