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. (Relies on general large models to generate query statements, with 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 Method 1: Local Standard Input/Output Mode (stdio)
It is suitable for local development and personal use, for example, within local Claude Desktop, Cursor, or VS Code.
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. For this deployment mode, stdio is recommended.
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.
TZ: Optional. The system time zone.
Installation Method 2: Remote/Standalone Service Mode (Streamable HTTP)
It is suitable for team sharing and remote deployment, for example, integrating with internal enterprise AI platforms.
1. Install Node.js, preferably using the LTS (long-term support) version. 2. Create a .env file in the server's current directory:
TRANSPORT=http
TENCENTCLOUD_SECRET_ID=<YOUR_SECRET_ID>
TENCENTCLOUD_SECRET_KEY=<YOUR_SECRET_KEY>
PORT=3000
TZ=Asia/Shanghai
TRANSPORT: Required. The MCP transport protocol. For this deployment mode, use http.
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.
PORT: Optional. The listening port.
TZ: Optional. The system time zone.
3. Start the service.
npx -y cls-mcp-server@latest
4. Configure it in the MCP client.
{
"mcpServers": {
"cls-mcp-server": {
"name": "cls-mcp-server",
"type": "http",
"isActive": true,
"url": "http://localhost:3000/mcp"
}
}
}
Note:
Replace localhost:3000 in the url with the actual server IP address and PORT from Step 2. More Installation Methods
For more installation methods, refer to the cls-mcp-server open-source project documentation. Dify Tool
2. After installation is complete, click the plugin, then click API Key Authorization Configuration.
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.
Note:
This method supports fewer features. It is recommended to use MCP Server.