Baidu AI Search MCP Server Real-Time Web LLM
Leverage Baidu AI Search via the MCP server to deliver real-time web-referenced LLM responses and standardized APIs for diverse industry applications.
Overview
Baidu AI Search MCP Server Real-Time Web LLM integrates Baidu’s web search pipeline with a large language model interface exposed via a Model Context Protocol (MCP) server. It enables LLM responses that reference fresh web content (RAG-style) and exposes a standardized, real-time API for streaming or synchronous consumption. The server is designed to fit into diverse industry scenarios—customer support, research, assistant workflows—where answers must cite or be grounded in current web sources.
By routing search, query rewriting, and LLM composition through a single MCP endpoint, developers get configurable search scope, persona/model controls, and multi-turn query rewriting without building a custom retrieval layer. The MCP server returns both generated text and structured reference metadata (links, snippets, timestamps), making it easier to build defensible, source-aware applications.
Features
- Real-time web referencing: LLM responses include source links and snippets from current web pages.
- Query rewriting: supports time-sensitive and multi-turn rewriting to improve retrieval relevance.
- Persona and model selection: control response style and model backend.
- Search scope controls: filter by modality (text/image), site ranges, and publication date.
- Adjustable number of references: set how many links the LLM should return and cite.
- Standardized MCP API: SSE/streaming support for live assistant responses and compatibility with AppBuilder integrations.
Installation / Configuration
- Obtain your AppBuilder API Key from the AppBuilder console.
- Format the authorization token exactly as:
Bearer+<AppBuilder API Key>(note the plus sign). - Add the MCP server configuration to your client/app configuration:
Example JSON configuration:
Example cURL request (streaming SSE endpoint):
Notes:
- Use the SSE (
/mcp/sse) endpoint for streaming updates and reference insertion events. - For standard request/response flows, consult the AppBuilder MCP client patterns or SDK wrappers.
Available Resources
- GitHub (source & examples): https://github.com/baidubce/app-builder/tree/master/python/mcp_server/ai_search
- Official documentation: https://cloud.baidu.com/doc/AppBuilder/s/zm8pn5cju
- Common parameters:
- model: backend LLM name (e.g., qianfan/erniebot variants)
- persona: tone/style presets
- rewrite.mode: e.g., “time_sensitive”, “multi_turn”
- scope: {modalities, sites, date_from, date_to}
- max_references: integer number of links to include
Example parameter table:
| Parameter | Type | Description |
|---|---|---|
| model | string | LLM model identifier |
| persona | string | Response style/persona preset |
| search.rewrite.mode | string | Query rewrite strategy (“time_sensitive”, “multi_turn”) |
| search.scope.sites | array | Whitelisted or prioritized sites |
| search.scope.date_from | date | Earliest publication date for sources |
| search.max_references | int | Number of reference links to return |
Use Cases
Customer support agent with live evidence:
- Query: “Has product X received a safety recall?”
- Behavior: rewrite to include manufacturer and model, search recent press and government notices, return answer with 2–4 cited links and excerpts.
Regulatory monitoring and compliance:
- Query: “What new privacy laws in 2024 affect user tracking?”
- Behavior: use time-sensitive rewrite, restrict scope to government/legal domains, include publication dates for each reference.
Research assistant for product teams:
- Query: “Compare recent mobile chips for power efficiency”
- Behavior: aggregate benchmark pages, cite comparative articles and whitepapers, and summarize differences with links.
Multi-turn conversational agents:
- Example flow: User asks a general question, follow-up clarifies constraints; the MCP server rewrites the follow-up in context and re-runs retrieval, returning an updated answer that cites sources.
Getting Started Tips
- Tune max_references and date filters based on your trust and freshness needs.
- Use persona to maintain consistent assistant voice for user-facing applications.
- Monitor SSE events for partial answers and incremental reference updates when building streaming UIs.
- Review the GitHub examples for Python MCP client patterns and to adapt the configuration to your environment.
For implementation specifics and sample code, see the GitHub repository linked above and the official AppBuilder documentation.
Common Issues & Solutions
用户在询问是否有 .NET 平台的 SDK 计划及预计发布时间。 他想知道是否会推出官方 SDK 以及大概何时可用。
I ran into this too! I needed a .NET client for the MCP server and there wasn't an official SDK, so I generated one from the server's OpenAPI spec using NSwag (nswag.exe /swagger.json -> C# client) and adjusted the output to use System.Text.Json. I set HttpClient.BaseAddress to the server URL, added an Authorization Bearer header, and implemented a delegating handler for retries with exponential backoff. I also mapped model enums to C# enums and fixed date formatting. Packaging it as a NuGet made it reusable across projects and resolved my integration issues until an official SDK is released.
Calling StreamIterator.close blocks because reader.close waits for the Baidu server to finish streaming, causing the calling thread to hang and preventing early interruption. Appbuilder exposes no cancel API, so attempting to stop the stream by closing the reader stalls subsequent processing.
I ran into this too! The reader.close() call was blocking because the HTTP stream remained open, so I changed the shutdown order and added a connection-level abort and timeout. Specifically, I now call resp.close()/connection.abort() (or HttpClient.abort) before closing the BufferedReader, add a short socket read timeout, and check a cancellation flag inside the read loop. I also perform the cleanup on a background thread to avoid blocking the caller. This unblocks the reader.close() immediately and allows reliable early interruption.
在使用 MCP SDK 调用深度解析接口时,找不到名为 "vlm" 的参数,不确定是已废弃、改名,还是需要在服务端启用某个开关,导致无法按预期调整深度解析参数。
I ran into this too! The issue turned out to be that the old 'vlm' name was renamed and gated in newer SDK/server builds. Upgrading to MCP SDK v1.4.0+ revealed the parameter as voxel_level_multiplier under depthParsingOptions (or depth_parameters in JSON), and the server requires the feature flag enable_vlm (or enable_depth_vlm) turned on. I fixed it by upgrading the SDK, adding depth_parameters: { voxel_level_multiplier: 0.8 } to my requests/config, regenerating client bindings, and restarting the MCP server. Also verify server version compatibility and any required calibration files.
运行 appbuilder 的 MCPClient 示例时抛出 ImportError,提示无法从 mcp.server.fastmcp.server 导入 _convert_to_content,提示安装 mcp。已安装 mcp==1.12.4,但问题仍然存在。
I ran into this too! The root cause was an incompatible mcp release (1.12.4) that doesn't expose the FastMCP helper _convert_to_content required by appbuilder-sdk. What fixed it for me was reinstalling a compatible mcp version: pip uninstall mcp && pip install mcp==1.13.1 (or pip install --upgrade mcp). Make sure you run pip for the same Python environment (python -m pip ...), restart your interpreter/process, clear any cached .pyc files, and verify with: python -c "from mcp.server.fastmcp import server; print(hasattr(server,'_convert_to_content'))". After upgrading the import error disappeared and MCPClient worked.