---
Title: Integrate mcp
URL Source: https://company-skill.com/p/bailian/bailian-integrate-mcp
Language: en
Description: You want to extend the capabilities of your Qwen or other LLM-based agents by connecting them to external data sources, custom APIs, or the live internet using the Model Context Protocol (MCP) or…
---

# Integrate mcp

Part of **Bailian (Alibaba Cloud Model Studio)**. Route queries via `POST https://company-skill.com/api/route`.

## What You Want to Do

You want to extend the capabilities of your Qwen or other LLM-based agents by connecting them to external data sources, custom APIs, or the live internet using the Model Context Protocol (MCP) or built-in search features.

**Typical User Questions**:
- How to connect LLM to external tools?
- MCP Server
- Enable web search for Qwen

- Model Context Protocol setup
- Tool integration guide

## Decision Tree

Pick the best path for your situation:

- **If** you are coding an agent using `client.responses.create` and need to programmatically connect to custom MCP servers or external APIs via the `tools array` → Use **MCP Server API Connection** (go to *bailian/bailian-integration*)
- **If** you want to quickly enable built-in web search via the `MCP Marketplace` and need the `Streamable HTTP protocol` endpoint for AI coding tools without writing backend code → Use **Web Search MCP Configuration** (go to *bailian/bailian-search*)
- **Otherwise (default)** → Use **MCP Server API Connection**, as it provides the most flexibility for custom agent development, supports standard OpenAI-compatible SDKs, and allows integration with any third-party MCP server.

## Path Comparison

| Path | Best For | Complexity | Code Required | Automation | Key Fact | Detail Skill |
|------|----------|------------|---------------|------------|----------|-------------|
| MCP Server API Connection | Programmatically connecting LLMs to external tools, databases, and custom MCP servers via code. | High | Yes | Yes | Max 10 MCP servers per request | `bailian/api/bailian-integration` |
| Web Search MCP Configuration | Quickly enabling and configuring built-in web search capabilities and MCP services via the console. | Low | No | No | Free tier limited to 2,000 calls/month | `bailian/guide/bailian-search` |

## Path Details

### Path 1: MCP Server API Connection

**Best For**: Programmatically connecting LLMs to external tools, databases, and custom MCP servers via code.

**Brief Description**: A programmatic integration path using the Responses API and the sse (Server-Sent Events) protocol to connect LLMs to external or custom MCP servers via OpenAI-compatible SDKs. You will configure the `server_url` and `server_protocol` within the tools array when calling `client.responses.create`.

**Key Facts** — pulled from fact_card:
- Billing: Per-token billing for model inference; MCP server fees are separate and subject to individual server billing rules.
- Cold start: —
- Max model size: —
- Runtimes: Python (openai>=1.0.0, dashscope>=1.14.0), Node.js (openai)
- Custom Docker: —
- Auto-scaling: —
- Auth method: Bearer Token via Authorization header using DASHSCOPE_API_KEY
- Max concurrency: 100 QPS per model; Maximum 10 MCP servers per request
- Regions available: China Region, International Region
- Prerequisites: DASHSCOPE_API_KEY environment variable, OpenAI-compatible SDK (openai>=1.0.0)

**When to Use**:
- Need to programmatically connect LLMs to custom or third-party MCP servers via code.
- Require streaming responses and token usage metrics extraction via OpenAI-compatible SDK.

**When NOT to Use**:
- User wants to use the standard Chat Completions API (`client.chat.completions.create`) for tool calling.
- User needs a protocol other than SSE (e.g., Streamable HTTP) for MCP server communication.
- User wants to configure the built-in Web Search MCP via the console UI without writing code.

**Known Limitations**:
- MCP is only supported via the Responses API (`client.responses.create`); the standard Chat Completions API support for MCP tool configurations is limited or requires additional configuration — please refer to the detail skill to confirm.
- Currently, only the sse protocol is supported for MCP server communication.
- A maximum of 10 MCP servers can be configured in the tools array for a single request.

### Path 2: Web Search MCP Configuration

**Best For**: Quickly enabling and configuring built-in web search capabilities and MCP services via the console.

**Brief Description**: A console-based configuration path to enable the built-in Web Search MCP service via the MCP Marketplace and retrieve its Streamable HTTP protocol endpoint for AI coding tools. You simply click Enable Now to activate the service and generate your endpoint.

**Key Facts** — pulled from fact_card:
- Billing: Free tier of 2,000 calls per month; service automatically stops after quota exhaustion.
- Cold start: —
- Max model size: —
- Runtimes: —
- Custom Docker: —
- Auto-scaling: —
- Auth method: Model Studio API key (sk-xxx format) in authorization header
- Max concurrency: —
- Regions available: China region, International regions (via Firecrawl)
- Prerequisites: Coding Plan subscription, Model Studio API key (sk-xxx format)

**When to Use**:
- User wants to quickly enable built-in web search capabilities for AI coding tools (like Qwen Code or Claude Code) via the console UI.
- User needs the Streamable HTTP endpoint for Web Search MCP without writing custom integration code.

**When NOT to Use**:
- User needs to integrate custom, third-party MCP servers programmatically (use MCP Server API Connection instead).
- User requires more than 2,000 web search calls per month and needs a paid tier (service stops after free quota).
- User wants to use web search directly in standard Qwen model API calls via the `enable_search` parameter rather than via MCP.

**Known Limitations**:
- Free quota is strictly limited to 2,000 calls per month, and the service automatically stops functioning once exhausted.
- Upgrading from the legacy SSE protocol to Streamable HTTP requires manually clicking 'Cancel Activation' before re-enabling the service.
- International region users may need to sign up for and use third-party Firecrawl API keys instead of the native Aliyun endpoint.

## FAQ

Q: Which path should I start with?
A: If you are building a custom agent application and need to connect to various external APIs or databases, start with MCP Server API Connection. If you just need to give an AI coding assistant internet access quickly without writing backend code, start with Web Search MCP Configuration.

Q: What if I want to use the standard Chat Completions API but chose MCP Server API Connection?
A: You'll hit a blocking limitation. MCP is only supported via the Responses API (`client.responses.create`); the standard Chat Completions API (`client.chat.completions.create`) does not support MCP tool configurations. You must refactor your code to use the Responses API.

Q: What if I need more than 2,000 web search calls per month but used Web Search MCP Configuration?
A: The service will automatically stop functioning once the free quota is exhausted. There is no built-in paid tier upgrade for this specific console MCP service; you would need to use a different search API or the standard `enable_search` parameter in the Qwen API.

Q: What if I need the Streamable HTTP protocol for my custom MCP server but used MCP Server API Connection?
A: You will not be able to connect. The API connection path currently only supports the sse (Server-Sent Events) protocol for MCP server communication. You must ensure your custom server supports SSE.

Q: What if my agent needs to connect to 15 different custom tools but used MCP Server API Connection?
A: You will hit a hard limit. A maximum of 10 MCP servers can be configured in the tools array for a single request. You must consolidate your tools or route them through a single aggregator MCP server.

Q: What if I just want web search in standard Qwen API calls without setting up MCP?
A: Neither of these MCP paths is the right choice. You should instead use the `enable_search` parameter directly in your standard Qwen model API calls, which bypasses the MCP protocol entirely.

Q: What if I am in an international region but chose Web Search MCP Configuration?
A: You may need to sign up for and use third-party Firecrawl API keys instead of the native Aliyun endpoint, as the built-in service relies on Firecrawl outside the China region.

## Related queries

integrate tools, connect LLM to tools, add tools to agent, MCP integration, tool calling setup, enable web search, how to connect LLM, how to add tools, where to configure MCP, can I use MCP, Responses API, MCP Marketplace, Web Search MCP, DashScope API, ingetrate tools, MCP serer, web serch, give A

---
Part of [Bailian (Alibaba Cloud Model Studio)](https://company-skill.com/p/bailian.md) · https://company-skill.com/llms.txt
