@liangshanli/mcp-server-project-standards 2.0.2 → 2.0.5

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/bin/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  const { spawn } = require('child_process');
3
3
  const path = require('path');
4
4
  const fs = require('fs');
@@ -19,6 +19,8 @@ if (!fs.existsSync(serverPath)) {
19
19
  }
20
20
 
21
21
  writeLog('INFO', `Starting MCP Project Standards server from: ${serverPath}`);
22
+ writeLog('INFO', `Current working directory: ${process.cwd()}`);
23
+ writeLog('INFO', `CLI script directory: ${__dirname}`);
22
24
 
23
25
  let server = null;
24
26
 
@@ -27,8 +29,8 @@ function startServer() {
27
29
  // Create environment object
28
30
  const env = {
29
31
  ...process.env,
30
- // Set CONFIG_DIR if specified, otherwise use default
31
- CONFIG_DIR: process.env.CONFIG_DIR || './.setting',
32
+ // Set CONFIG_DIR to current working directory
33
+ CONFIG_DIR: process.cwd(),
32
34
  // API Debug environment variables
33
35
  API_DEBUG_ALLOWED_METHODS: process.env.API_DEBUG_ALLOWED_METHODS || 'GET',
34
36
  API_DEBUG_LOGIN_URL: process.env.API_DEBUG_LOGIN_URL || '/api/login',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liangshanli/mcp-server-project-standards",
3
- "version": "2.0.2",
3
+ "version": "2.0.5",
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": {
@@ -656,8 +656,8 @@ class ProjectStandardsMCPServer {
656
656
  properties: {
657
657
  action: {
658
658
  type: 'string',
659
- enum: ['get', 'set', 'updateBaseUrl', 'updateHeaders', 'deleteHeader', 'search', 'list'],
660
- description: 'Action to perform: "get" to retrieve config, "set" to update config, "updateBaseUrl" to update base URL, "updateHeaders" to update headers, "deleteHeader" to delete header, "search" to search APIs, "list" to list all APIs'
659
+ enum: ['get', 'set', 'updateBaseUrl', 'updateHeaders', 'deleteHeader', 'addApi', 'search', 'list'],
660
+ description: 'Action to perform: "get" to retrieve config, "set" to update config, "updateBaseUrl" to update base URL, "updateHeaders" to update headers, "deleteHeader" to delete header, "addApi" to add API endpoint, "search" to search APIs, "list" to list all APIs'
661
661
  },
662
662
  config: {
663
663
  type: 'object',
@@ -723,6 +723,41 @@ class ProjectStandardsMCPServer {
723
723
  type: 'string',
724
724
  description: 'Name of header to delete (required for "deleteHeader" action)'
725
725
  },
726
+ api: {
727
+ type: 'object',
728
+ description: 'API configuration (required for "addApi" action)',
729
+ properties: {
730
+ url: {
731
+ type: 'string',
732
+ description: 'API endpoint URL'
733
+ },
734
+ method: {
735
+ type: 'string',
736
+ enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
737
+ description: 'HTTP method'
738
+ },
739
+ description: {
740
+ type: 'string',
741
+ description: 'API description'
742
+ },
743
+ query: {
744
+ type: 'object',
745
+ description: 'Query parameters'
746
+ },
747
+ body: {
748
+ description: 'Request body'
749
+ },
750
+ contentType: {
751
+ type: 'string',
752
+ description: 'Content-Type for request body'
753
+ },
754
+ header: {
755
+ type: 'object',
756
+ description: 'Additional headers for this specific request'
757
+ }
758
+ },
759
+ required: ['url']
760
+ },
726
761
  keyword: {
727
762
  type: 'string',
728
763
  description: 'Search keyword (required for "search" action)'
@@ -768,6 +803,13 @@ class ProjectStandardsMCPServer {
768
803
  },
769
804
  required: ['headerName']
770
805
  },
806
+ {
807
+ properties: {
808
+ action: { const: 'addApi' },
809
+ api: { type: 'object' }
810
+ },
811
+ required: ['api']
812
+ },
771
813
  {
772
814
  properties: {
773
815
  action: { const: 'search' },
@@ -3,21 +3,22 @@ const { loadApiConfig, saveApiConfig } = require('./api_common');
3
3
  /**
4
4
  * API 配置工具 - 专门处理API配置管理
5
5
  * @param {Object} params - 参数
6
- * @param {string} params.action - 操作类型 ('get', 'set', 'updateBaseUrl', 'updateHeaders', 'deleteHeader', 'search', 'list')
6
+ * @param {string} params.action - 操作类型 ('get', 'set', 'updateBaseUrl', 'updateHeaders', 'deleteHeader', 'addApi', 'search', 'list')
7
7
  * @param {Object} params.config - API配置(set 时必需)
8
8
  * @param {string} params.baseUrl - 基础URL(updateBaseUrl 时必需)
9
9
  * @param {Object} params.headers - 请求头(updateHeaders 时必需)
10
10
  * @param {string} params.headerName - 要删除的请求头名称(deleteHeader 时必需)
11
+ * @param {Object} params.api - API配置(addApi 时必需)
11
12
  * @param {string} params.keyword - 搜索关键词(search 时必需)
12
13
  * @param {Object} config - 服务器配置
13
14
  * @param {Function} saveConfig - 保存配置函数
14
15
  * @returns {Object} API配置结果
15
16
  */
16
17
  async function api_config(params, config, saveConfig) {
17
- const { action, config: apiConfig, baseUrl, headers, headerName, keyword } = params || {};
18
+ const { action, config: apiConfig, baseUrl, headers, headerName, api, keyword } = params || {};
18
19
 
19
20
  if (!action) {
20
- throw new Error('Missing action parameter. Must be "get", "set", "updateBaseUrl", "updateHeaders", "deleteHeader", "search", or "list"');
21
+ throw new Error('Missing action parameter. Must be "get", "set", "updateBaseUrl", "updateHeaders", "deleteHeader", "addApi", "search", or "list"');
21
22
  }
22
23
 
23
24
  if (action === 'get') {
@@ -162,6 +163,53 @@ async function api_config(params, config, saveConfig) {
162
163
  } catch (err) {
163
164
  throw new Error(`Failed to delete header: ${err.message}`);
164
165
  }
166
+ } else if (action === 'addApi') {
167
+ if (!api || !api.url) {
168
+ throw new Error('Missing or invalid api parameter for addApi action. API must have url property');
169
+ }
170
+
171
+ try {
172
+ const apiDebugConfig = loadApiConfig();
173
+
174
+ if (!apiDebugConfig.list) {
175
+ apiDebugConfig.list = [];
176
+ }
177
+
178
+ // 检查是否已存在相同URL的API
179
+ const existingIndex = apiDebugConfig.list.findIndex(item => item.url === api.url);
180
+
181
+ if (existingIndex >= 0) {
182
+ // 更新现有API
183
+ apiDebugConfig.list[existingIndex] = { ...apiDebugConfig.list[existingIndex], ...api };
184
+ const saved = saveApiConfig(apiDebugConfig);
185
+ if (!saved) {
186
+ throw new Error('Failed to save API configuration');
187
+ }
188
+
189
+ return {
190
+ success: true,
191
+ message: `Successfully updated existing API: ${api.url}`,
192
+ api: apiDebugConfig.list[existingIndex],
193
+ timestamp: new Date().toISOString()
194
+ };
195
+ } else {
196
+ // 添加新API
197
+ apiDebugConfig.list.push(api);
198
+ const saved = saveApiConfig(apiDebugConfig);
199
+ if (!saved) {
200
+ throw new Error('Failed to save API configuration');
201
+ }
202
+
203
+ return {
204
+ success: true,
205
+ message: `Successfully added new API: ${api.url}`,
206
+ api: api,
207
+ timestamp: new Date().toISOString()
208
+ };
209
+ }
210
+ } catch (err) {
211
+ throw new Error(`Failed to add API: ${err.message}`);
212
+ }
165
213
  } else if (action === 'search') {
166
214
  if (!keyword) {
167
215
  throw new Error('Missing keyword parameter for search action');
@@ -111,6 +111,7 @@ async function api_help(params, config, saveConfig) {
111
111
  'updateBaseUrl': '更新基础URL',
112
112
  'updateHeaders': '更新请求头',
113
113
  'deleteHeader': '删除指定请求头',
114
+ 'addApi': '添加API端点',
114
115
  'search': '搜索API',
115
116
  'list': '列出所有API'
116
117
  },
@@ -139,6 +140,18 @@ async function api_help(params, config, saveConfig) {
139
140
  action: 'search',
140
141
  keyword: 'user'
141
142
  }
143
+ },
144
+ {
145
+ description: '添加API端点',
146
+ request: {
147
+ action: 'addApi',
148
+ api: {
149
+ url: '/api/users',
150
+ method: 'GET',
151
+ description: '获取用户列表',
152
+ query: { page: 1, limit: 10 }
153
+ }
154
+ }
142
155
  }
143
156
  ]
144
157
  }