Long-term access to MCP with a bearer token

更新时间:
复制 MD 格式

Authorizing the OpenAPI MCP Server in clients like Cherry Studio and Cursor requires logging in as a RAM user. This temporary authorization makes long-term use difficult. This topic explains how to generate a non-expiring SSE configuration for these clients.

Prerequisites

Obtain SSE configuration

In the Alibaba Cloud Model Studio console - MCP Management, click your imported MCP service. On the details page, select External Invocation to view the SSE configuration methods provided by Alibaba Cloud Model Studio. Because Alibaba Cloud Model Studio encapsulates the authorization logic for the OpenAPI MCP Server, you can call the service by using an Alibaba Cloud Model Studio API key without managing the authorization details.

The Cherry Studio configuration page offers two methods. Method 1 is automatic configuration: click the One-click Configuration to Cherry Studio button. Method 2 is manual configuration: for authentication, obtain the DASHSCOPE_API_KEY and configure mcpServers in the JSON configuration. The key fields include "type": "sse", "baseUrl" pointing to https://dashscope.aliyuncs.com/compatible-mode/v1/mcp/{instance ID}/sse, and the header Authorization: Bearer $DASHSCOPE_API_KEY.

Configure SSE in clients

The SSE configuration provided by Alibaba Cloud Model Studio can be used in client tools such as Cherry Studio and Cursor. This section uses Cursor as an example.

  1. Use the one-click configuration feature to apply the SSE configuration to Cursor. After automatic authentication completes, you can connect to the OpenAPI MCP Server.

    Note

    When you use the one-click configuration, you must change the name of the MCP configuration. The name must start with AliyunBailianMCP_ and the name should not exceed 20 characters.

    After a successful connection, go to the Settings > MCP & Integrations page in Cursor. In the MCP Tools section, a green dot appears to the left of the added MCP Server entry, indicating it is online. It also shows the number of enabled tools, such as 3 tools enabled, and the toggle switch on the right is turned on.

  2. In the Cursor dialog box, click Add Context and select the mcp.json file. You can then enter natural language commands to call MCP Tools and manage Alibaba Cloud resources.

    For example, switch to Agent mode at the bottom, and then enter a request in natural language, such as "Query the number of ECS instances in China (Hangzhou)". Cursor automatically calls the matching MCP Tool (such as Ecs-20140526-DescribeInstances) and returns details such as the instance ID, name, status, instance type, availability zone, operating system, IP address, and billing method.