Skip to content

Commit 5af3202

Browse files
committed
feat(telemetry): 🔧 optimize telemetry and tool wrapper utilities
1 parent b999e72 commit 5af3202

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

mcp/package-lock.json

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mcp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"license": "MIT",
5757
"dependencies": {
5858
"@cloudbase/cals": "^1.2.18-alpha.1",
59-
"@cloudbase/manager-node": "^4.4.2",
59+
"@cloudbase/manager-node": "^4.4.5",
6060
"@cloudbase/mcp": "^1.0.0-beta.25",
6161
"@cloudbase/toolbox": "^0.7.7",
6262
"@modelcontextprotocol/sdk": "1.13.1",

mcp/src/utils/telemetry.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ class TelemetryReporter {
185185
eventCode,
186186
eventTime: String(now),
187187
mapValue: {
188-
...eventData
188+
...this.additionalParams,
189+
...eventData,
189190
}
190191
}
191192
]

mcp/src/utils/tool-wrapper.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ declare const __MCP_VERSION__: string;
3232
* @param cloudBaseOptions CloudBase 配置选项
3333
* @returns GitHub Issue 创建链接
3434
*/
35-
async function generateGitHubIssueLink(toolName: string, errorMessage: string, args: any, cloudBaseOptions?: CloudBaseOptions): Promise<string> {
35+
async function generateGitHubIssueLink(toolName: string, errorMessage: string, args: any, cloudBaseOptions?: CloudBaseOptions, payload?: {
36+
requestId: string;
37+
ide: string;
38+
}): Promise<string> {
39+
const { requestId, ide } = payload || {};
3640
const baseUrl = 'https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/issues/new';
3741

3842
// 尝试获取环境ID
@@ -68,6 +72,8 @@ ${envIdSection}
6872
- MCP 版本:${process.env.npm_package_version || __MCP_VERSION__ || 'unknown'}
6973
- 系统架构: ${os.arch()}
7074
- 时间: ${new Date().toISOString()}
75+
- 请求ID: ${requestId}
76+
- 集成IDE: ${ide}
7177
7278
## 工具参数
7379
\`\`\`json
@@ -122,9 +128,10 @@ function createWrappedHandler(name: string, handler: any, server: ExtendedMcpSer
122128
});
123129

124130
// 生成 GitHub Issue 创建链接
125-
const issueLink = await generateGitHubIssueLink(name, errorMessage, args, server.cloudBaseOptions);
126-
127-
// 创建增强的错误消息,包含 GitHub Issue 链接
131+
const issueLink = await generateGitHubIssueLink(name, errorMessage, args, server.cloudBaseOptions, {
132+
requestId: (typeof error === 'object' && error && 'requestId' in error) ? (error as any).requestId : '',
133+
ide: server.ide || process.env.INTEGRATION_IDE || ''
134+
});
128135
const enhancedErrorMessage = `${errorMessage}\n\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
129136

130137
// 创建新的错误对象,保持原有的错误类型但更新消息

0 commit comments

Comments
 (0)