External Invocation
Alibaba Cloud Model Studio provides end-to-end MCP services. You can configure these services within the platform (such as in agent applications or workflows) or invoke them externally from third-party applications or your own projects. To invoke them externally, choose one of the following options:
- Integrate with a third-party application: Install MCP services into Qoder, Codex, Claude Code, and Cursor, or add them manually to other MCP clients.
- Integrate with your own project: You can use the MCP SDK for flexible coding and deep customization.
ImportantYou can also invoke MCP services externally via the Bailian CLI: bl mcp list to view enabled services and bl mcp call --target <name>.<tool> to invoke directly. See Use the CLI.
ImportantTo manage MCP services through an API, use the MCP API to query, create, activate, start, stop services, and call tools.
Enable an MCP service
NoteThe Alibaba Cloud Model Studio MCP service has been upgraded from the legacy Server-Sent Events (SSE) protocol to the new Streamable HTTP protocol. Choose the steps that match your situation:
First-time setup (new users)
-
Go to the Alibaba Cloud Model Studio MCP Marketplace and select an MCP service. For example, you can click the Amap Maps card.
-
Click Enable Now and then Confirm activation to enable the Amap Maps MCP service.
NoteThe Amap Maps MCP service is hosted on Alibaba Cloud Model Studio. For trial use, you do not need to provide an AMAP_MAPS_API_KEY. For commercial customization, you can use your own AMAP_MAPS_API_KEY.
To enter sensitive information, encrypt it using a KMS credential.
Protocol upgrade (existing users)
- Go to the Alibaba Cloud Model Studio MCP Marketplace and select an MCP service. For example, you can click the Amap Maps card.
- Click Disable on the right. Then click Enable Now and Confirm activation to update the Amap Maps MCP service.
Invoke an MCP service externally
Integrate into a third-party application
Alibaba Cloud Model Studio supports installing MCP services into Qoder, Codex, Claude Code, and Cursor. The following example uses the Amap Maps service.
Qoder
- Go to the Amap Maps MCP service page, and select Client in the Install section.
- Click the Qoder icon to copy the installation command.
- Replace
${DASHSCOPE_API_KEY}in the command with your API key, or set the environment variable with the same name before running the command. - Confirm that the MCP service is added and enabled in Qoder.
Codex
- Go to the Amap Maps MCP service page, and select Client in the Install section.
- Click the Codex icon to copy the installation command.
- Replace
${DASHSCOPE_API_KEY}in the command with your API key, or set the environment variable with the same name before running the command. - Confirm that the MCP service is added and enabled in Codex.
Claude Code
- Go to the Amap Maps MCP service page, and select Client in the Install section.
- Click the Claude Code icon to copy the installation command.
- Replace
${DASHSCOPE_API_KEY}in the command with your API key, or set the environment variable with the same name before running the command. - Confirm that the MCP service is added and enabled in Claude Code.
Cursor
- Install Cursor.
- Go to the Amap Maps MCP service page, and select Client in the Install section.
- Click the Cursor icon, confirm the MCP Server configuration in the Cursor window that opens, and complete the installation as prompted.
- If the API key in the configuration is the
${DASHSCOPE_API_KEY}placeholder, replace it with your API key.
NoteCherry Studio, Cline, and other clients do not currently support one-click installation. After installing the client, in the Install section, copy the MCP service address, add the MCP service manually in the client (select Streamable HTTP, or SSE if the address ends with /sse), and add Authorization: Bearer ${DASHSCOPE_API_KEY} to the request headers.
If the model fails to call the MCP tool, refer to the FAQ.
Develop integration using the SDK
You can use the MCP SDK to call Alibaba Cloud Model Studio MCP services. This provides full coding flexibility.
The following example uses the OpenAI SDK and MCP SDK to call the Model Studio WebSearch MCP service for web search.
- Install the dependencies.
pip install openai mcp
-
You can set your Alibaba Cloud Model Studio API key as an environment variable.
-
Sample code:
Python
# -*- coding: utf-8 -*- # Use OpenAI SDK + MCP SDK to call the Model Studio WebSearch MCP service import os import asyncio import json from openai import OpenAI from mcp.client.streamable_http import streamablehttp_client from mcp import ClientSession async def main(): api_key = os.getenv("DASHSCOPE_API_KEY") if not api_key: print("Error: Set the DASHSCOPE_API_KEY environment variable") return mcp_url = "https://dashscope.aliyuncs.com/api/v1/mcps/WebSearch/mcp" headers = {"Authorization": f"Bearer {api_key}"} # 1. Connect to the MCP server and list available tools async with streamablehttp_client(mcp_url, headers=headers) as (read, write, _): async with ClientSession(read, write) as session: await session.initialize() tools_result = await session.list_tools() # Convert to OpenAI function calling format openai_tools = [] for tool in tools_result.tools: openai_tools.append({ "type": "function", "function": { "name": tool.name, "description": tool.description or "", "parameters": tool.inputSchema or {"type": "object", "properties": {}}, }, }) # 2. Call DashScope (OpenAI-compatible endpoint) client = OpenAI( api_key=api_key, base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", ) messages = [{"role": "user", "content": "Search for the latest updates on Alibaba Cloud Model Studio MCP"}] print("Searching the web...") print("=" * 50) # 3. Multi-turn tool call loop while True: response = client.chat.completions.create( model="qwen-max", messages=messages, tools=openai_tools or None, ) choice = response.choices[0] msg = choice.message if not msg.tool_calls: print(msg.content) break messages.append(msg) for tc in msg.tool_calls: args = json.loads(tc.function.arguments) result = await session.call_tool(tc.function.name, args) tool_content = "" for block in result.content: if hasattr(block, "text"): tool_content += block.text messages.append({ "role": "tool", "tool_call_id": tc.id, "content": tool_content, }) if __name__ == "__main__": asyncio.run(main()) -
You can run the code. The output appears as follows:
Searching the web...
==================================================
Alibaba Cloud Model Studio MCP (Model Context Protocol) is a newly launched service that allows users to uniformly access and manage MCP services on the Model Studio platform. Latest updates include:
1. Supports one-click activation of various MCP services (such as Amap Maps, Web Search, etc.) through the MCP Marketplace.
2. Provides the Streamable HTTP protocol, allowing external applications to call via standard HTTP.
3. Integrated with mainstream tools such as Qoder and Cursor, supporting quick installation.
4. Developers can flexibly integrate MCP into their own projects via the MCP SDK.
FAQ
What do I do if I cannot connect to an MCP service?
- MCP service not enabled or not upgraded: Ensure the MCP service is enabled or upgraded in the Model Studio MCP Marketplace. See Enable an MCP service.
- Invalid API key: Confirm that you are using a valid Alibaba Cloud Model Studio API key.
- Quota exhausted: Some MCP services, such as web search, have monthly quotas. They stop automatically when the quota is exhausted.
For answers to common questions and information about other errors, see the FAQ.
The model responds normally and no MCP errors appear, but the MCP tool still does not run. What do I do?
The Large Language Model needs clear instructions to correctly call an MCP service. Specify the tool name and its capabilities in your prompt. For example, call the Alibaba Cloud Model Studio Amap Maps MCP service to plan a driving route from Hangzhou to Shanghai.