@liangshanli/mcp-server-project-standards 2.1.8 → 2.1.10

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liangshanli/mcp-server-project-standards",
3
- "version": "2.1.8",
3
+ "version": "2.1.10",
4
4
  "description": "MCP Project Standards server with project info, structure, API standards, development standards, API debugging, login authentication and configuration management tools",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {
@@ -30,7 +30,7 @@
30
30
  "license": "MIT",
31
31
  "repository": {
32
32
  "type": "git",
33
- "url": "https://github.com/liliangshan/mcp-server-project-standards"
33
+ "url": "git+https://github.com/liliangshan/mcp-server-project-standards.git"
34
34
  },
35
35
  "dependencies": {
36
36
  "fs-extra": "^11.2.0",
@@ -1,4 +1,10 @@
1
1
  const { getAllowedMethods, loadApiConfig, saveApiConfig, detectContentType } = require('./api_common');
2
+ const https = require('https');
3
+
4
+ // 为 HTTPS 请求创建跳过证书验证的 agent
5
+ const httpsAgent = new https.Agent({
6
+ rejectUnauthorized: false
7
+ });
2
8
 
3
9
  /**
4
10
  * API 调试工具 - 直接执行API请求
@@ -61,35 +67,6 @@ async function api_debug(params, config, saveConfig) {
61
67
  }
62
68
  ]
63
69
  };
64
- /* return {
65
- contentType: "text",
66
- content: [
67
- {
68
- type: "text",
69
- text: "⚠️ IMPORTANT: URL parameter is required for API debugging!\n\n🔧 Step 1: Provide URL Parameter\n\nCall: api_debug with url parameter\n\nExample: {\"url\": \"/api/users\", \"method\": \"GET\"}\n\n⚠️ REMINDER: URL is required for API execution!"
70
- },
71
- {
72
- type: "text",
73
- text: "🔧 Step 2: Optional Parameters\n\nYou can also provide:\n- method: GET, POST, PUT, DELETE, PATCH\n- headers: Additional request headers\n- query: Query parameters\n- body: Request body\n- contentType: Content type override"
74
- },
75
- {
76
- type: "text",
77
- text: "🚨 REMINDER: URL is mandatory!\n\n- Use api_debug with url parameter\n- URL can be relative (/api/users) or absolute (https://api.example.com/users)"
78
- },
79
- {
80
- type: "text",
81
- text: "💡 IMPORTANT: Remember to provide URL!\n\n- First: api_debug with url parameter\n- Second: Add other optional parameters as needed"
82
- },
83
- {
84
- type: "text",
85
- text: "📋 Final Reminder: URL is required\n\n1. First: api_debug with url parameter\n2. Then: Add optional parameters\n\nThis is the ONLY way to execute API requests."
86
- },
87
- {
88
- type: "text",
89
- text: "⚠️ ESSENTIAL: URL parameter is required!\n\n- Use api_debug with url parameter\n- URL can be relative or absolute"
90
- }
91
- ]
92
- };*/
93
70
  }
94
71
 
95
72
  try {
@@ -219,11 +196,18 @@ async function api_debug(params, config, saveConfig) {
219
196
 
220
197
  try {
221
198
  // 执行请求
222
- response = await fetch(finalRequestUrl, {
199
+ const fetchOptions = {
223
200
  method: requestMethod,
224
201
  headers: finalHeaders,
225
202
  body: requestBody
226
- });
203
+ };
204
+
205
+ // 为 HTTPS 请求添加 agent 以跳过证书验证
206
+ if (finalRequestUrl.startsWith('https')) {
207
+ fetchOptions.agent = httpsAgent;
208
+ }
209
+
210
+ response = await fetch(finalRequestUrl, fetchOptions);
227
211
 
228
212
  // 获取响应数据
229
213
  const responseContentType = response.headers.get('content-type');
@@ -244,23 +228,104 @@ async function api_debug(params, config, saveConfig) {
244
228
  }
245
229
 
246
230
  if (success && response) {
247
- return {
248
- success: true,
249
- message: `Successfully executed API: ${url}`,
250
- request: {
251
- url: finalRequestUrl,
252
- method: requestMethod,
253
- headers: finalHeaders,
254
- body: requestBody
255
- },
256
- response: {
257
- status: response.status,
258
- statusText: response.statusText,
259
- headers: Object.fromEntries(response.headers.entries()),
260
- data: responseData
261
- },
262
- timestamp: new Date().toISOString()
263
- };
231
+ // 自动将接口添加到配置列表中
232
+ try {
233
+ const apiConfig = loadApiConfig();
234
+ if (!apiConfig.list) {
235
+ apiConfig.list = [];
236
+ }
237
+
238
+ // 检查是否已存在相同的接口
239
+ const existingApiIndex = apiConfig.list.findIndex(api =>
240
+ api.url === url && api.method === requestMethod
241
+ );
242
+
243
+ if (existingApiIndex === -1) {
244
+ // 如果不存在,添加到列表
245
+ const newApi = {
246
+ url: url,
247
+ method: requestMethod,
248
+ description: `API added from api_debug: ${url}`,
249
+ headers: headers,
250
+ query: query,
251
+ body: body,
252
+ contentType: contentType
253
+ };
254
+
255
+ apiConfig.list.push(newApi);
256
+ saveApiConfig(apiConfig);
257
+
258
+ return {
259
+ success: true,
260
+ message: `Successfully executed API: ${url} (Added to list at index ${apiConfig.list.length - 1})`,
261
+ apiIndex: apiConfig.list.length - 1,
262
+ request: {
263
+ url: finalRequestUrl,
264
+ method: requestMethod,
265
+ headers: finalHeaders,
266
+ body: requestBody
267
+ },
268
+ response: {
269
+ status: response.status,
270
+ statusText: response.statusText,
271
+ headers: Object.fromEntries(response.headers.entries()),
272
+ data: responseData
273
+ },
274
+ timestamp: new Date().toISOString()
275
+ };
276
+ } else {
277
+ // 如果已存在,更新接口信息
278
+ apiConfig.list[existingApiIndex] = {
279
+ ...apiConfig.list[existingApiIndex],
280
+ url: url,
281
+ method: requestMethod,
282
+ headers: headers,
283
+ query: query,
284
+ body: body,
285
+ contentType: contentType
286
+ };
287
+ saveApiConfig(apiConfig);
288
+
289
+ return {
290
+ success: true,
291
+ message: `Successfully executed API: ${url} (Updated existing API at index ${existingApiIndex})`,
292
+ apiIndex: existingApiIndex,
293
+ request: {
294
+ url: finalRequestUrl,
295
+ method: requestMethod,
296
+ headers: finalHeaders,
297
+ body: requestBody
298
+ },
299
+ response: {
300
+ status: response.status,
301
+ statusText: response.statusText,
302
+ headers: Object.fromEntries(response.headers.entries()),
303
+ data: responseData
304
+ },
305
+ timestamp: new Date().toISOString()
306
+ };
307
+ }
308
+ } catch (saveError) {
309
+ // 如果保存失败,仍然返回成功响应
310
+ console.error('Failed to save API to list:', saveError.message);
311
+ return {
312
+ success: true,
313
+ message: `Successfully executed API: ${url} (Failed to save to list)`,
314
+ request: {
315
+ url: finalRequestUrl,
316
+ method: requestMethod,
317
+ headers: finalHeaders,
318
+ body: requestBody
319
+ },
320
+ response: {
321
+ status: response.status,
322
+ statusText: response.statusText,
323
+ headers: Object.fromEntries(response.headers.entries()),
324
+ data: responseData
325
+ },
326
+ timestamp: new Date().toISOString()
327
+ };
328
+ }
264
329
  } else {
265
330
  return {
266
331
  success: false,
@@ -1,5 +1,10 @@
1
1
  const { loadApiConfig, getAllowedMethods } = require('./api_common');
2
2
 
3
+ // 设置全局环境变量以跳过证书验证
4
+ if (!process.env.NODE_TLS_REJECT_UNAUTHORIZED) {
5
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
6
+ }
7
+
3
8
  /**
4
9
  * API 执行工具 - 通过索引执行已配置的API
5
10
  * @param {Object} params - 参数
@@ -131,6 +136,7 @@ async function api_execute(params, config, saveConfig) {
131
136
  };
132
137
 
133
138
  } catch (err) {
139
+ console.error(err);
134
140
  throw new Error(`Failed to execute API at index ${index}: ${err.message}`);
135
141
  }
136
142
  }
@@ -1,4 +1,10 @@
1
1
  const { getLoginUrl, getLoginMethod, getLoginBody, loadApiConfig, saveApiConfig } = require('./api_common');
2
+ const https = require('https');
3
+
4
+ // 为 HTTPS 请求创建跳过证书验证的 agent
5
+ const httpsAgent = new https.Agent({
6
+ rejectUnauthorized: false
7
+ });
2
8
 
3
9
  /**
4
10
  * API 登录工具 - 直接执行登录请求(从环境变量获取登录信息)
@@ -57,11 +63,18 @@ async function api_login(params, config, saveConfig) {
57
63
  let error = null;
58
64
 
59
65
  try {
60
- response = await fetch(fullLoginUrl, {
66
+ const fetchOptions = {
61
67
  method: loginMethod,
62
68
  headers: headers,
63
69
  body: loginBody
64
- });
70
+ };
71
+
72
+ // 为 HTTPS 请求添加 agent 以跳过证书验证
73
+ if (fullLoginUrl.startsWith('https')) {
74
+ fetchOptions.agent = httpsAgent;
75
+ }
76
+
77
+ response = await fetch(fullLoginUrl, fetchOptions);
65
78
 
66
79
  // 获取响应数据
67
80
  const contentType = response.headers.get('content-type');