Tencent Cloud APM: Using MCP in Agents for Call Chain and Performance Analysis

Introduction

When production endpoints slow down or experience sporadic timeouts, you often have to switch between the APM console to check business systems, traces, and span durations, and then jump to flame graphs to locate hotspots. Conversational Agents can write code and execute commands, but usually cannot access the Tencent Cloud APM data you have already integrated. This article introduces Tencent Cloud APM (@tencent-adm/apm-performance-analysis) on SkillHub: it enables an Agent to connect to a remote APM MCP Server via the Tencent Cloud official SDK’s ApmClient.SendMCPMessage, completing tool discovery, parameter confirmation, and performance diagnosis calls directly within a conversation.

What is this

Tencent Cloud APM is an Agent Skill designed for APM performance analysis, published by the Tencent Cloud APM Team. It originates from an enterprise source, with the current version being v1.0.3. It is categorized under it-ops-security on SkillHub and tagged with requires_api_key=true (requiring configuration of Tencent Cloud API keys).

The Skill does not replace the APM console; rather, it solidifies the process of “Connect MCP → List Tools → Call per Specification → Interpret Results” into the SKILL.md and accompanying scripts. The Agent executes scripts/apm_mcp_client.py within the skill directory, accessing the MCP Server via standard cloud API signatures (TC3-HMAC-SHA256). This supports capabilities such as business system queries, distributed tracing, flame graphs, and span duration analysis (subject to the tools actually exposed by the MCP).

Trigger scenarios are specified in the Skill description: it can be enabled when the user mentions APM, performance analysis, traces, flame graphs, spans, or duration analysis.

Core Features

The following capabilities are derived from the official Skill description and client scripts. Specific tool names are subject to the list-tools response.

  1. Remote MCP Access: Interacts with the APM MCP Server via ApmClient.SendMCPMessage, supporting connectivity checks (ping), tool listing (tools/list), and tool invocation (tools/call).
  2. Business and Trace Analysis: The Skill overview explicitly includes operations-oriented capabilities such as business system queries, distributed tracing, flame graphs, and span duration analysis.
  3. Embedded Official SDK: The skill package vendors the Tencent Cloud Python SDK (documented as v3.1.93), so there is no need for separate pip install or virtual environment maintenance to run the client script.
  4. Credentials and Security Constraints: SecretId/SecretKey are read only via shell environment variables (or command-line arguments); hardcoding and .env files are prohibited. Placeholders must be used in conversations. Errors are written to ./logs/apm_error.log (permissions 600, keys are never logged).
  5. Interaction Specifications: Functionality and parameters must be confirmed before invocation. Reuse of InstanceId, Region, etc., from the conversation context is supported. See references/interaction_guide.md within the skill for details.

The allowed-tools declared by the Skill are Bash and Read, making it suitable for invoking scripts via the terminal in Agents that support Skills, such as Cursor.

Installation and Activation

Install via SkillHub

The installation prompt provided on the SkillHub page is: Follow the SkillHub Installation Guide to install the coordinate @tencent-adm/apm-performance-analysis.

If the skillhub CLI is already available on your machine, use --dir during installation to point to the current Agent’s skills directory (installing to the default ./skills/ might not be recognized by the Agent). Example:

command -v skillhub && skillhub --version
skillhub install @tencent-adm/apm-performance-analysis --dir ~/.cursor/skills/

Common paths (excerpted from SkillHub installation documentation):

  • Cursor: ~/.cursor/skills/
  • Claude Code: ~/.claude/skills/
  • Codex: ~/.codex/skills/ or .agents/skills/ under the project

If the CLI is not installed, follow the SkillHub documentation to use the official installation script (internet connection required).

Configure Tencent Cloud Credentials

Check if environment variables are ready before making calls:

echo $TENCENTCLOUD_SECRET_ID

Required fields:

Variable Name Description
TENCENTCLOUD_SECRET_ID Tencent Cloud API SecretId
TENCENTCLOUD_SECRET_KEY Tencent Cloud API SecretKey

Optional fields include APM_API_ENDPOINT (default public apm.tencentcloudapi.com) and APM_ERROR_LOG_DIR (default ./logs/). Please create keys in Tencent Cloud API Key Management; a sub-account with least privilege is recommended. Do not send plaintext keys in chats.

Agent-side MCP Notes

This Skill accesses the APM MCP Server via Cloud API + SendMCPMessage, rather than configuring a separate local MCP Server entry in the IDE. After the Agent reads the skill, it should execute python scripts/apm_mcp_client.py within the skill directory to perform ping, list-tools, and call-tool operations.

Typical Usage

After installation and credential configuration, it is recommended to follow the “Execution Flow” order within the Skill. The following commands are executed in the skill package root directory (the path containing scripts/).

1. Verify Connectivity

python scripts/apm_mcp_client.py ping

2. Discover MCP Tools

python scripts/apm_mcp_client.py list-tools --output json

Present the name, description, and inputSchema from the JSON to the user using the table template from interaction_guide.md, and confirm the tool and parameters to be invoked.

3. Call Specific Tool

--args takes a JSON object, which the client converts to the KV structure required by APM. Example from official script comments:

python scripts/apm_mcp_client.py call-tool \
  --name DescribeApmOverview \
  --args '{"start_time":"1744786829","end_time":"1744787429","region":"ap-beijing"}'

General form:

python scripts/apm_mcp_client.py call-tool --name <tool_name> --args '{"param1": "value1"}'

4. Natural Language Entry in Conversation

Users can directly ask “What can APM do?”, “Check what operations MCP supports,” or describe performance issues. The Agent should first explain the need for SecretId/SecretKey, then proceed with ping → list-tools → parameter confirmation → call-tool. Skill requirement: Do not call tools directly without confirming functionality and parameters.

Use Cases and Notes

Who it is for

  • Operations and back-end engineers already using APM on Tencent Cloud who wish to query traces, spans, flame graphs, and other data using natural language within Agents like Cursor / Claude Code / Codex.
  • Teams that want to delegate “listing tools, filling in Region/InstanceId/time ranges” to an Agent while retaining manual parameter confirmation.

Limitations and Notes

  • Must have valid Tencent Cloud API keys; SkillHub marks requires_api_key=true. If service role authorization failures occur, authorization must be completed in the console according to references/error_log_guide.md within the skill.
  • The toolset is determined by the remote MCP Server; this article cannot enumerate all interface names. Real-time results from list-tools prevail.
  • For mobile remote usage, the Skill strictly forbids creating temporary files, forbids rm, and requires displaying data via Markdown within the conversation (see mobile_compat_guide.md).
  • SkillHub page statistics (as of data retrieval): Rating 100000, Downloads 1615, Installs 13. If the Agent does not load the new skill after installation, refresh or restart according to the client’s instructions.

Conclusion

Tencent Cloud APM packages the MCP capabilities of Tencent Cloud APM into an installable Agent Skill: embedded SDK, standard signature authentication, scripted ping / list-tools / call-tool, combined with interaction and security specifications. This transforms performance analysis from “switching consoles” to “querying step-by-step in conversation.” For installation or to check for updates, visit the SkillHub official page: Tencent Cloud APM; API Entry: https://api.skillhub.cn/tencent-adm/apm-performance-analysis.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye