@liangshanli/mcp-server-project-standards 3.0.0 → 3.0.2

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/README.md CHANGED
@@ -238,7 +238,7 @@ npm run dev
238
238
 
239
239
  ### Cursor Editor Configuration
240
240
 
241
- 1. Create `.cursor/mcp.json` file in your project root:
241
+ 1) Single-project example (no prefix isolation):
242
242
 
243
243
  ```json
244
244
  {
@@ -247,9 +247,7 @@ npm run dev
247
247
  "command": "npx",
248
248
  "args": ["@liangshanli/mcp-server-project-standards"],
249
249
  "env": {
250
- "TOOL_PREFIX": "projA",
251
- "PROJECT_NAME": "MyProject",
252
- "CONFIG_DIR": "./.setting",
250
+ "CONFIG_DIR": "./.setting",
253
251
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
254
252
  "API_DEBUG_LOGIN_URL": "/api/login",
255
253
  "API_DEBUG_LOGIN_METHOD": "POST",
@@ -261,26 +259,88 @@ npm run dev
261
259
  }
262
260
  ```
263
261
 
262
+ 2) Multi-project example (with TOOL_PREFIX + PROJECT_NAME):
263
+
264
+ ```json
265
+ {
266
+ "mcpServers": {
267
+ "project-standards-A": {
268
+ "command": "npx",
269
+ "args": ["@liangshanli/mcp-server-project-standards"],
270
+ "env": {
271
+ "TOOL_PREFIX": "projA",
272
+ "PROJECT_NAME": "Project A",
273
+ "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
274
+ "API_DEBUG_LOGIN_URL": "/api/login",
275
+ "API_DEBUG_LOGIN_METHOD": "POST",
276
+ "API_DEBUG_LOGIN_BODY": "{\"username\":\"\",\"password\":\"\"}"
277
+ }
278
+ },
279
+ "project-standards-B": {
280
+ "command": "npx",
281
+ "args": ["@liangshanli/mcp-server-project-standards"],
282
+ "env": {
283
+ "TOOL_PREFIX": "projB",
284
+ "PROJECT_NAME": "Project B",
285
+ "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
286
+ "API_DEBUG_LOGIN_URL": "/api/auth/login",
287
+ "API_DEBUG_LOGIN_METHOD": "POST",
288
+ "API_DEBUG_LOGIN_BODY": "{\"mobile\":\"\",\"password\":\"\"}"
289
+ }
290
+ }
291
+ }
292
+ }
293
+ ```
294
+
264
295
  ### VS Code Configuration
265
296
 
266
- 1. Install the MCP extension for VS Code
267
- 2. Create `.vscode/settings.json` file:
297
+ 1) Single-project example (no prefix isolation):
268
298
 
269
299
  ```json
270
300
  {
271
301
  "mcp.servers": {
272
302
  "project-standards": {
303
+ "command": "npx",
304
+ "args": ["@liangshanli/mcp-server-project-standards"],
305
+ "env": {
306
+ "CONFIG_DIR": "./.setting",
307
+ "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
308
+ "API_DEBUG_LOGIN_URL": "/api/login",
309
+ "API_DEBUG_LOGIN_METHOD": "POST",
310
+ "API_DEBUG_LOGIN_BODY": "{\"username\":\"\",\"password\":\"\"}"
311
+ }
312
+ }
313
+ }
314
+ }
315
+ ```
316
+
317
+ 2) Multi-project example (with TOOL_PREFIX + PROJECT_NAME):
318
+
319
+ ```json
320
+ {
321
+ "mcp.servers": {
322
+ "project-standards-A": {
273
323
  "command": "npx",
274
324
  "args": ["@liangshanli/mcp-server-project-standards"],
275
325
  "env": {
276
326
  "TOOL_PREFIX": "projA",
277
- "PROJECT_NAME": "MyProject",
278
- "CONFIG_DIR": "./.setting",
327
+ "PROJECT_NAME": "Project A",
279
328
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
280
329
  "API_DEBUG_LOGIN_URL": "/api/login",
281
330
  "API_DEBUG_LOGIN_METHOD": "POST",
282
- "API_DEBUG_LOGIN_BODY": "{\"username\":\"\",\"password\":\"\"}",
283
- "API_DEBUG_LOGIN_DESCRIPTION": "Save returned token to common headers in debug tool, field name Authorization, field value Bearer token"
331
+ "API_DEBUG_LOGIN_BODY": "{\"username\":\"\",\"password\":\"\"}"
332
+ }
333
+ },
334
+ "project-standards-B": {
335
+ "command": "npx",
336
+ "args": ["@liangshanli/mcp-server-project-standards"],
337
+ "env": {
338
+ "TOOL_PREFIX": "projB",
339
+ "PROJECT_NAME": "Project B",
340
+ "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
341
+ "API_DEBUG_LOGIN_URL": "/api/auth/login",
342
+ "API_DEBUG_LOGIN_METHOD": "POST",
343
+ "API_DEBUG_LOGIN_BODY": "{\"mobile\":\"\",\"password\":\"\"}"
284
344
  }
285
345
  }
286
346
  }
package/README.zh-CN.md CHANGED
@@ -222,7 +222,7 @@ npm run dev
222
222
 
223
223
  ### Cursor 编辑器配置
224
224
 
225
- 1. 在项目根目录创建 `.cursor/mcp.json` 文件:
225
+ 1)单项目示例(不做前缀隔离):
226
226
 
227
227
  ```json
228
228
  {
@@ -231,8 +231,6 @@ npm run dev
231
231
  "command": "npx",
232
232
  "args": ["@liangshanli/mcp-server-project-standards"],
233
233
  "env": {
234
- "TOOL_PREFIX": "projA",
235
- "PROJECT_NAME": "MyProject",
236
234
  "CONFIG_DIR": "./.setting",
237
235
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
238
236
  "API_DEBUG_LOGIN_URL": "/api/login",
@@ -245,10 +243,42 @@ npm run dev
245
243
  }
246
244
  ```
247
245
 
246
+ 2)多项目示例(使用 TOOL_PREFIX + PROJECT_NAME):
247
+
248
+ ```json
249
+ {
250
+ "mcpServers": {
251
+ "project-standards-A": {
252
+ "command": "npx",
253
+ "args": ["@liangshanli/mcp-server-project-standards"],
254
+ "env": {
255
+ "TOOL_PREFIX": "projA",
256
+ "PROJECT_NAME": "项目A",
257
+ "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
258
+ "API_DEBUG_LOGIN_URL": "/api/login",
259
+ "API_DEBUG_LOGIN_METHOD": "POST",
260
+ "API_DEBUG_LOGIN_BODY": "{\"username\":\"\",\"password\":\"\"}"
261
+ }
262
+ },
263
+ "project-standards-B": {
264
+ "command": "npx",
265
+ "args": ["@liangshanli/mcp-server-project-standards"],
266
+ "env": {
267
+ "TOOL_PREFIX": "projB",
268
+ "PROJECT_NAME": "项目B",
269
+ "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
270
+ "API_DEBUG_LOGIN_URL": "/api/auth/login",
271
+ "API_DEBUG_LOGIN_METHOD": "POST",
272
+ "API_DEBUG_LOGIN_BODY": "{\"mobile\":\"\",\"password\":\"\"}"
273
+ }
274
+ }
275
+ }
276
+ }
277
+ ```
278
+
248
279
  ### VS Code 配置
249
280
 
250
- 1. 安装 VS Code 的 MCP 扩展
251
- 2. 创建 `.vscode/settings.json` 文件:
281
+ 1)单项目示例(不做前缀隔离):
252
282
 
253
283
  ```json
254
284
  {
@@ -257,14 +287,44 @@ npm run dev
257
287
  "command": "npx",
258
288
  "args": ["@liangshanli/mcp-server-project-standards"],
259
289
  "env": {
260
- "TOOL_PREFIX": "projA",
261
- "PROJECT_NAME": "MyProject",
262
290
  "CONFIG_DIR": "./.setting",
263
291
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
264
292
  "API_DEBUG_LOGIN_URL": "/api/login",
265
293
  "API_DEBUG_LOGIN_METHOD": "POST",
266
- "API_DEBUG_LOGIN_BODY": "{\"username\":\"\",\"password\":\"\"}",
267
- "API_DEBUG_LOGIN_DESCRIPTION": "将返回的token保存到调试工具中的公共header,字段名Authorization,字段值是Bearer token"
294
+ "API_DEBUG_LOGIN_BODY": "{\"username\":\"\",\"password\":\"\"}"
295
+ }
296
+ }
297
+ }
298
+ }
299
+ ```
300
+
301
+ 2)多项目示例(使用 TOOL_PREFIX + PROJECT_NAME):
302
+
303
+ ```json
304
+ {
305
+ "mcp.servers": {
306
+ "project-standards-A": {
307
+ "command": "npx",
308
+ "args": ["@liangshanli/mcp-server-project-standards"],
309
+ "env": {
310
+ "TOOL_PREFIX": "projA",
311
+ "PROJECT_NAME": "项目A",
312
+ "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
313
+ "API_DEBUG_LOGIN_URL": "/api/login",
314
+ "API_DEBUG_LOGIN_METHOD": "POST",
315
+ "API_DEBUG_LOGIN_BODY": "{\"username\":\"\",\"password\":\"\"}"
316
+ }
317
+ },
318
+ "project-standards-B": {
319
+ "command": "npx",
320
+ "args": ["@liangshanli/mcp-server-project-standards"],
321
+ "env": {
322
+ "TOOL_PREFIX": "projB",
323
+ "PROJECT_NAME": "项目B",
324
+ "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
325
+ "API_DEBUG_LOGIN_URL": "/api/auth/login",
326
+ "API_DEBUG_LOGIN_METHOD": "POST",
327
+ "API_DEBUG_LOGIN_BODY": "{\"mobile\":\"\",\"password\":\"\"}"
268
328
  }
269
329
  }
270
330
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liangshanli/mcp-server-project-standards",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
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": {
@@ -334,6 +334,7 @@ async function api_debug(params, config, saveConfig) {
334
334
  };
335
335
  }
336
336
  } else {
337
+ // 失败时也要返回响应数据
337
338
  return {
338
339
  success: false,
339
340
  message: `Failed to execute API: ${url}`,
@@ -343,6 +344,12 @@ async function api_debug(params, config, saveConfig) {
343
344
  headers: finalHeaders,
344
345
  body: requestBody
345
346
  },
347
+ response: response ? {
348
+ status: response.status,
349
+ statusText: response.statusText,
350
+ headers: Object.fromEntries(response.headers.entries()),
351
+ data: responseData
352
+ } : undefined,
346
353
  error: error || (response ? `HTTP ${response.status}: ${response.statusText}` : 'Request failed'),
347
354
  timestamp: new Date().toISOString()
348
355
  };
@@ -1,9 +1,10 @@
1
1
  const { loadApiConfig, getAllowedMethods } = require('./api_common');
2
+ const https = require('https');
2
3
 
3
- // 设置全局环境变量以跳过证书验证
4
- if (!process.env.NODE_TLS_REJECT_UNAUTHORIZED) {
5
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
6
- }
4
+ // 为 HTTPS 请求创建跳过证书验证的 agent
5
+ const httpsAgent = new https.Agent({
6
+ rejectUnauthorized: false
7
+ });
7
8
 
8
9
  /**
9
10
  * API 执行工具 - 通过索引执行已配置的API
@@ -95,21 +96,39 @@ async function api_execute(params, config, saveConfig) {
95
96
 
96
97
  // 执行请求
97
98
  const startTime = Date.now();
98
- const response = await fetch(fullUrl, requestOptions);
99
- const endTime = Date.now();
100
-
101
- // 处理响应
99
+ let response;
102
100
  let responseData;
103
- const contentType = response.headers.get('content-type') || '';
101
+ let error = null;
104
102
 
105
- if (contentType.includes('application/json')) {
106
- responseData = await response.json();
107
- } else {
108
- responseData = await response.text();
103
+ try {
104
+ // HTTPS 请求添加 agent 以跳过证书验证
105
+ if (fullUrl.startsWith('https')) {
106
+ requestOptions.agent = httpsAgent;
107
+ }
108
+
109
+ response = await fetch(fullUrl, requestOptions);
110
+
111
+ // 处理响应
112
+ const contentType = response.headers.get('content-type') || '';
113
+
114
+ if (contentType.includes('application/json')) {
115
+ responseData = await response.json();
116
+ } else {
117
+ responseData = await response.text();
118
+ }
119
+ } catch (fetchError) {
120
+ error = fetchError.message;
121
+ throw new Error(`Failed to execute API request: ${error}`);
109
122
  }
110
123
 
124
+ const endTime = Date.now();
125
+
126
+ // 判断请求是否成功(HTTP 状态码 200-299 为成功)
127
+ const isHttpSuccess = response.status >= 200 && response.status < 300;
128
+ const success = isHttpSuccess;
129
+
111
130
  return {
112
- success: true,
131
+ success: success,
113
132
  index: index,
114
133
  api: {
115
134
  url: apiConfig.url,
@@ -129,6 +148,7 @@ async function api_execute(params, config, saveConfig) {
129
148
  headers: Object.fromEntries(response.headers.entries()),
130
149
  data: responseData
131
150
  },
151
+ error: success ? undefined : (error || `HTTP ${response.status}: ${response.statusText}`),
132
152
  timing: {
133
153
  duration: endTime - startTime,
134
154
  timestamp: new Date().toISOString()