Scenarios
Query log data stored in CLS through MCP Server (Model Context Protocol Server) or Dify Tool to integrate large model platforms/tools with log data. Such as the following use cases:
Using natural language to query logs reduces the complexity of log queries.
Integrate into the Ops troubleshooting process for intelligent analysis of system anomalies.
MCP Server and Dify Tool support the following features:
|
Supported | Supported |
Supported | Not supported. |
Supported | Not supported. |
Supported | Not supported. Depending on general large models to generate query statements results in low accuracy. |
Supported Query the topic ID by topic name. Query the region abbreviation by region name. Timestamp conversion | Not supported. |
Note:
CLS MCP Server has been open-sourced on Github. You can go to the cls-mcp-server project to view detailed information. Prerequisites
To access CLS using Tencent Cloud sub-user keys (SecretId/SecretKey), first create a sub-user and grant it the following permissions. Then go to the API Key Management page to obtain the keys. {
"version": "2.0",
"statement": [
{
"effect": "allow",
"action": [
"cls:SearchLog",
"cls:DescribeLogContext",
"cls:ChatCompletions",
"cls:DescribeIndex",
"cls:DescribeIndexs",
"cls:DescribeLogHistogram",
"cls:QueryMetric",
"cls:QueryRangeMetric",
"cls:DescribeAlarms",
"cls:DescribeAlertRecordHistory",
"cls:GetAlarmLog",
"cls:DescribeAlarmNotices",
"cls:DescribeAlarmShields",
"cls:DescribeNoticeContents",
"cls:DescribeWebCallbacks",
"cls:DescribeTopics"
],
"resource": [
"*"
]
}
]
}
MCP Server
Installation Instructions
1. Install Node.js, preferably using the LTS (long-term support) version. 2. In the MCP Server configuration file, add the following configuration:
{
"mcpServers": {
"cls-mcp-server": {
"isActive": true,
"name": "cls-mcp-server",
"type": "stdio",
"command": "npx",
"args": [
"-y",
"cls-mcp-server@latest"
],
"env": {
"TRANSPORT": "stdio",
"TENCENTCLOUD_SECRET_ID": "YOUR_TENCENT_SECRET_ID",
"TENCENTCLOUD_SECRET_KEY": "YOUR_TENCENT_SECRET_KEY",
"TENCENTCLOUD_API_BASE_HOST": "tencentcloudapi.com",
"TZ": "Asia/Shanghai"
}
}
}
}
TRANSPORT: Optional. The MCP transport protocol. Available values: stdio (standard input/output) or sse (server-sent events). Default value: stdio.
TENCENTCLOUD_SECRET_ID: Required. The Tencent Cloud sub-user SecretId mentioned in the Prerequisites. TENCENTCLOUD_SECRET_KEY: Required. The Tencent Cloud sub-user SecretKey mentioned in the Prerequisites. TENCENTCLOUD_API_BASE_HOST: Optional. The TencentCloud API request domain.
Note:
If you use MCP in the private network, or the administrator restricts access to TencentCloud API only through the private network, please use the private network domain internal.tencentcloudapi.com.
Example
Taking Cherry Studio as an example to demonstrate the configuration method of CLS MCP Server:
1. In Settings > MCP Server, edit the JSON configuration, add the aforementioned JSON configuration, then click OK to save the configuration.
2. After saving the configuration, click cls-mcp-server > Tools. If the list of available tools is displayed, it indicates successful installation.
3. In Assistant, add and edit an assistant, and fill in the following prompt:"Log TopicId :02b7613d-94b2-XXXX-a390-ce2285f3 region: ap-guangzhou", Please follow my requirements for inquiry.
In Model Settings, select an appropriate model (when using Cherry Studio for the first time, configure model services in the Cherry Studio settings menu):
In the MCP Server, enable cls-mcp-server.
4. Using natural language to query logs.
Dify Tool
Installation Instructions
2. After the installation is completed, click the plugin, then click Go to Authorization.
3. Fill in the Tencent Cloud sub-user SecretId and SecretKey in Prerequisites, and set the default log topic for queries. 4. Click Save to complete the plugin installation and configuration.
Example
1. In Dify Studio, click Create Blank Application.
Select the application type Agent.
2. Add Tencent Cloud CLS > CLS Log Search and Analysis in the bottom Tools section.
3. Select the large model to be used in the upper-right corner (install the model when using it for the first time).
4. In the dialog box, use natural language to query logs.
Note:
This method relies on the general large model's understanding of log query syntax, and accuracy may be lower when query requirements are complex. If you have usage needs in this regard, it is recommended to use MCP Server or contact us.