Note This feature is available only in the AI Premium Edition. For details about different editions, see Version Introduction.
The performance of the MCP service depends on the capabilities of your AI agent. We recommend optimizing the prompt and knowledge base for your AI agent.
Tokens are valid for 30 days.
What is the MCP service
The Model Context Protocol (MCP) provides a unified, standard interface for large language models and AI assistants. It works like a USB port, allowing an AI to easily connect to and operate external tools to perform complex tasks.
Alibaba Mail now supports the MCP, which allows you to authorize an AI to access your mailbox. You can then interact with the AI through chat to send emails and retrieve email information.
MCP service capabilities
You can find detailed descriptions, parameters, and other information for each tool using the MCP tool discovery API.
Tools list
Search emails: search_mail
Searches for emails based on a KQL expression, supporting conditions like dates and keywords.
Get email: get_mail
Retrieves the full content of an email, including sender, recipients, and body, based on an email ID. You can obtain the email ID from the email search tool.
Create draft: create_draft
Generates an email draft and saves it to the Drafts folder.
Send email: send
Sends an email with the specified recipients, subject, and body.
List calendars: list_calendars
Retrieves calendar information for the account, including ID, name, and sharing status. The default calendar has an ID of 1 and the name calendar.
Get calendar events view: get_calendar_events_view
Retrieves a list of events for a specified time range based on a calendar ID.
Get calendar event: get_calendar_event
Retrieves the details of a specific event, including start and end times, organizer, attendees, subject, and body. This requires a calendar ID and an event ID, which can be obtained from the calendar events view.
Create or send calendar event: create_calendar_event
Creates or sends a calendar event with a specified organizer, attendees, and start and end times. If you set notify to true, the service sends an event invitation to the attendees. If you set notify to false, the service only creates the event in the organizer's calendar and does not send an invitation.
Use the MCP service
Configure the MCP service in Alibaba Mail
Step 1: Go to Mail Settings > MCP Service

Step 2: Generate a token
Copy the token or the JSON configuration.

Example 1: DingTalk AI Assistant
Follow the instructions in the "Use MCP skills in the AI assistant skill template" section of the DingTalk MCP Skill Quick Start guide. Paste the JSON configuration for the Alibaba Mail MCP service into the DingTalk MCP plug-in.

Once the plug-in is configured and passes the connection test, save the AI assistant.
You can then chat with the assistant to verify that the MCP service is working. For example, you can ask, "Check if I have any emails to handle today."

Example 2: Model Studio
Go to the Model Studio console and navigate to MCP Management > Custom Service > Create MCP Service.

To configure a custom MCP service in Model Studio, you must enable Function Compute.

Note Your MCP service is deployed to Function Compute (FC). FC prepares and runs your code using elastic and reliable resources. You are billed based on actual invocation duration and count. For details, see FC Resource Usage.
Enter the Alibaba Mail MCP configuration and submit the deployment.

Once the service connects successfully, the corresponding mail APIs are displayed.

In Application Management, add the Alibaba Mail MCP service to your application to use it.


Example 3: Tongyi Lingma
You can add the service in two ways: Add Manually or Add by Configuration File.

Method 1: Add Manually
Parameters
-y mcp-remote@latest https://qiye.aliyun.com/mcp/streamable/ --header Authorization:${AUTH_TOKEN}
Environment variable
Key: AUTH_TOKEN
Value: Bearer <token>
Note Replace <token> with the token value generated from your Alibaba Mail MCP settings.

Method 2: Add by Configuration File
Enter the JSON configuration from the Alibaba Mail MCP service.

Configuration complete.

Demonstration


Example 4: Wukong
Go to the Wukong official website to download and install the application, and then open Wukong.
Click Settings in the lower-left corner.
Click MCP Service, and then click Add.
Select Streamable HTTP for Type, enter a custom name, set the URL to https://qiye.aliyun.com/mcp/streamable/, and add an HTTP Header with the key Authorization and the value Bearer acd61799xxxxxxxxxxxxxxxxxxx86. Finally, click Add.
Note The token value after Bearer is the token you generated in your Alibaba Mail MCP settings. The full header format is "Authorization: Bearer xxx".

Wait for the MCP to connect successfully.

Demonstration
After the connection is successful, you can use the chat window in Wukong to manage your mail with MCP.

FAQ
Cannot connect to the Alibaba Mail MCP server
Error message 1:
failed to initialize MCP client for alimail: [35244] Warning: ignoring invalid header argument: "Authorization: [35244] Using automatically selected callback port: 30785 [35244] [35244] Connecting to remote server: https://qiye.aliyun.com/mcp/streamable/ [35244] Using transport strategy: http-first Could not load OAuth Protected Resource metadata, falling back to /.well-known/oauth-authorization-server Error: Resource server does not implement OAuth 2.0 Protected Resource Metadata.
Error message 2:
Could not load OAuth Protected Resource metadata, falling back to /.well-known/oauth-authorization-server Error: Resource server does not implement OAuth 2.0 Protected Resource Metadata.
This error can occur if the command is formatted incorrectly. Different AI tools may have slightly different formatting requirements for MCP, such as whether to include quotation marks.
For example:
In the Windows command line, the token requires quotation marks:
npx -y mcp-remote@latest https://qiye.aliyun.com/mcp/streamable/ --header "Authorization: Bearer <token>"

In Tongyi Lingma, the token does not require quotation marks when configured in the UI:

If you see the following error in Model Studio:
Verify that your JSON configuration is correct. Try generating or copying the JSON value from Alibaba Mail again.