@liangshanli/mcp-server-project-standards 2.1.1 → 2.1.3

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.1",
3
+ "version": "2.1.3",
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": {
@@ -222,7 +222,10 @@ async function api_config(params, config, saveConfig) {
222
222
  let searchResults = [];
223
223
 
224
224
  if (apiDebugConfig.list && Array.isArray(apiDebugConfig.list)) {
225
- searchResults = apiDebugConfig.list.filter((item) => {
225
+ searchResults = apiDebugConfig.list.map((item, index) => ({
226
+ ...item,
227
+ index: index
228
+ })).filter((item) => {
226
229
  const urlMatch = item.url && item.url.toLowerCase().includes(keyword.toLowerCase());
227
230
  const descMatch = item.description && item.description.toLowerCase().includes(keyword.toLowerCase());
228
231
  return urlMatch || descMatch;
@@ -245,10 +248,16 @@ async function api_config(params, config, saveConfig) {
245
248
  const apiDebugConfig = loadApiConfig();
246
249
  const apiList = apiDebugConfig.list || [];
247
250
 
251
+ // Add index to each API
252
+ const apisWithIndex = apiList.map((api, index) => ({
253
+ ...api,
254
+ index: index
255
+ }));
256
+
248
257
  return {
249
258
  success: true,
250
259
  message: `Found ${apiList.length} configured API(s)`,
251
- apis: apiList,
260
+ apis: apisWithIndex,
252
261
  totalCount: apiList.length,
253
262
  config: {
254
263
  baseUrl: apiDebugConfig.baseUrl,
@@ -66,6 +66,31 @@ async function api_debug(params, config, saveConfig) {
66
66
  let requestBody = null;
67
67
  if (body && (requestMethod === 'POST' || requestMethod === 'PUT' || requestMethod === 'PATCH')) {
68
68
  if (typeof body === 'string') {
69
+ // 检查是否以 { 开头但无法解析为JSON对象
70
+ if (body.trim().startsWith('{')) {
71
+ try {
72
+ JSON.parse(body);
73
+ // 如果能解析成功,继续正常处理
74
+ } catch (parseError) {
75
+ // 无法解析为JSON,给出建议
76
+ return {
77
+ success: false,
78
+ message: 'Detected body starting with { but cannot be parsed as JSON object. Suggested approach:',
79
+ suggestion: {
80
+ step1: 'Use api_config tool to add the API to the list',
81
+ step2: 'Use api_execute tool to execute the API by index',
82
+ example: {
83
+ addApi: 'api_config with action="addApi" and api={"url":"' + url + '","method":"' + requestMethod + '","body":"' + body + '"}',
84
+ execute: 'api_execute with index=<returned index>'
85
+ }
86
+ },
87
+ body: body,
88
+ parseError: parseError.message,
89
+ timestamp: new Date().toISOString()
90
+ };
91
+ }
92
+ }
93
+
69
94
  // 检查是否指定了 Content-Type
70
95
  if (contentType) {
71
96
  finalHeaders['Content-Type'] = contentType;