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: One-click automatic configuration lets you quickly enable external invocation.
Integrate with your own project: You can use the MCP SDK for flexible coding and deep customization.
Enable an MCP service
The 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 configuring MCP services in Cherry Studio and Cursor. Both automatic and manual configuration methods are supported. The following example uses the Amap Maps service.
Cherry Studio
Install Cherry Studio.
Go to the Amap Maps MCP service page. In the External Call section, select Cherry Studio.
Click One-Click Configuration for Cherry Studio. Select an API key and click OK.
You can also configure the MCP service manually. In the External Call section, get the DASHSCOPE_API_KEY and copy the configuration file. In Cherry Studio, go to the MCP Settings page. Click Add Server > Import from JSON. Paste the configuration and click OK.
Use the MCP service in Cherry Studio. Create a new topic and select the AliyunBailianMCP_amap-maps service below the input field.
In the dialog box, enter
Start now. Provide three public transportation routes from Hangzhou Xiaoshan International Airport to West Lake Scenic Area.The Large Language Model (LLM) successfully calls the MCP tool for route planning.If the model fails to call the MCP tool, refer to the FAQ.
Cursor
Install Cursor.
Go to the Amap Maps MCP service page. In the External Call section, select Cursor.
Click One-Click Configuration for Cursor. Select an API key and click OK. In the Cursor window, click Install.
A green status indicator appears in the bottom-right corner of your profile picture after successful installation.
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 mcpYou 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 Cherry Studio and Cursor, supporting automatic configuration. 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.