@cqsjjb/meter-sphere-mcp-server 1.0.0-beta.4 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/mcp-server.mjs +78 -4
  2. package/package.json +1 -1
package/mcp-server.mjs CHANGED
@@ -24,9 +24,9 @@ function getApiBaseUrl() {
24
24
  */
25
25
  function getModelConfig() {
26
26
  return {
27
- baseURL: process.env.MODEL_BASE_URL || 'https://api.deepseek.com',
28
- apiKey: process.env.MODEL_API_KEY || '',
29
- model: process.env.MODEL_ID || 'deepseek-chat'
27
+ baseURL: process.env.MODEL_BASE_URL,
28
+ apiKey: process.env.MODEL_API_KEY,
29
+ model: process.env.MODEL_ID
30
30
  };
31
31
  }
32
32
 
@@ -121,6 +121,29 @@ function markCompleted(testCaseId, priority, progress) {
121
121
  }
122
122
  }
123
123
 
124
+ /**
125
+ * 重置测试进度文件
126
+ */
127
+ function resetProgress(keepTestPlanId = false) {
128
+ const currentProgress = loadProgress();
129
+
130
+ const newProgress = {
131
+ testPlanId: keepTestPlanId ? currentProgress.testPlanId : null,
132
+ lastUpdate: null,
133
+ completed: [],
134
+ total: 0,
135
+ completedCount: 0
136
+ };
137
+
138
+ try {
139
+ saveProgress(newProgress);
140
+ return newProgress;
141
+ } catch (error) {
142
+ console.error('重置进度文件失败:', error);
143
+ throw new Error(`重置进度失败: ${error.message}`);
144
+ }
145
+ }
146
+
124
147
  /**
125
148
  * 发送 HTTP POST 请求
126
149
  */
@@ -324,7 +347,7 @@ ${promptText}
324
347
  5. 静态代码分析建议:[针对可通过静态代码分析的部分,给出具体的代码检查建议]`;
325
348
 
326
349
  return new Promise((resolve, reject) => {
327
- const urlObj = new URL(`${config.baseURL}/v1/chat/completions`);
350
+ const urlObj = new URL(`${config.baseURL}/chat/completions`);
328
351
  const postData = JSON.stringify({
329
352
  model: config.model,
330
353
  messages: [
@@ -487,6 +510,20 @@ class MeterSphereMCPServer {
487
510
  required: [],
488
511
  },
489
512
  },
513
+ {
514
+ name: 'reset_test_progress',
515
+ description: '重置测试进度文件(test-progress.json),清空所有已完成的测试用例记录。可选择是否保留当前测试计划ID。',
516
+ inputSchema: {
517
+ type: 'object',
518
+ properties: {
519
+ keepTestPlanId: {
520
+ type: 'boolean',
521
+ description: '是否保留当前测试计划ID。默认为false(完全重置)。设置为true时,只清空已完成用例记录,但保留testPlanId。',
522
+ },
523
+ },
524
+ required: [],
525
+ },
526
+ },
490
527
  ],
491
528
  };
492
529
  });
@@ -504,6 +541,8 @@ class MeterSphereMCPServer {
504
541
  return await this.handleMarkTestCompleted(args);
505
542
  } else if (name === 'get_test_progress') {
506
543
  return await this.handleGetTestProgress(args);
544
+ } else if (name === 'reset_test_progress') {
545
+ return await this.handleResetTestProgress(args);
507
546
  } else {
508
547
  throw new Error(`未知工具: ${name}`);
509
548
  }
@@ -842,6 +881,41 @@ class MeterSphereMCPServer {
842
881
  };
843
882
  }
844
883
 
884
+ async handleResetTestProgress(args) {
885
+ const { keepTestPlanId = false } = args || {};
886
+
887
+ const progressPath = getProgressFilePath();
888
+ const oldProgress = loadProgress();
889
+
890
+ // 重置进度
891
+ const newProgress = resetProgress(keepTestPlanId);
892
+
893
+ const resetInfo = [
894
+ `✅ 测试进度文件已重置`,
895
+ ``,
896
+ `重置前状态:`,
897
+ `- 测试计划ID: ${oldProgress.testPlanId || '无'}`,
898
+ `- 已完成用例数: ${oldProgress.completedCount}`,
899
+ `- 总用例数: ${oldProgress.total}`,
900
+ ``,
901
+ `重置后状态:`,
902
+ `- 测试计划ID: ${newProgress.testPlanId || '无'}${keepTestPlanId ? ' (已保留)' : ' (已清空)'}`,
903
+ `- 已完成用例数: ${newProgress.completedCount}`,
904
+ `- 总用例数: ${newProgress.total}`,
905
+ ``,
906
+ `进度文件路径: ${progressPath}`
907
+ ].join('\n');
908
+
909
+ return {
910
+ content: [
911
+ {
912
+ type: 'text',
913
+ text: resetInfo
914
+ },
915
+ ],
916
+ };
917
+ }
918
+
845
919
  async run() {
846
920
  const transport = new StdioServerTransport();
847
921
  await this.server.connect(transport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cqsjjb/meter-sphere-mcp-server",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.1",
4
4
  "description": "MCP server for MeterSphere test cases platform - Get test cases, generate AI test prompts, track testing progress, and execute browser automation tests",
5
5
  "main": "mcp-server.mjs",
6
6
  "type": "module",