@liangshanli/mcp-server-project-standards 2.1.10 โ†’ 3.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.
package/README.md CHANGED
@@ -4,6 +4,28 @@ A MCP (Model Context Protocol) server for project standards management, designed
4
4
 
5
5
  ## ๐Ÿ“‹ Version Updates
6
6
 
7
+ ### v3.0.0 (2025-10-31) - Major Release
8
+
9
+ #### ๐Ÿš€ Breaking Changes
10
+ - Config directory resolution now depends on both `CONFIG_DIR` and `TOOL_PREFIX`:
11
+ - If `CONFIG_DIR` is set, it is used as-is
12
+ - If `CONFIG_DIR` is not set and `TOOL_PREFIX` is set, use `./.setting.<TOOL_PREFIX>`
13
+ - Otherwise default to `./.setting`
14
+ - `tools/call` now strips the `TOOL_PREFIX` from tool names before method dispatch. If you call `xxx_api_debug` (with `TOOL_PREFIX=xxx`), the server routes the call to `api_debug` internally.
15
+
16
+ #### โœจ New/Improved
17
+ - Unified `getConfigDir()` used by both `server-final.js` and `api_common.js`
18
+ - `tools/list` shows environment with resolved `CONFIG_DIR`
19
+ - Prefixed tool names and project-branded descriptions when both `TOOL_PREFIX` and `PROJECT_NAME` are provided
20
+
21
+ #### ๐Ÿงน Cleanup
22
+ - Removed duplicate legacy `api_debug` method definition
23
+
24
+ #### ๐Ÿ’ก Benefits
25
+ - Multi-project isolation: simple per-project segregation via `TOOL_PREFIX` without code changes
26
+ - Zero-friction switching: swap project context by environment only
27
+ - Smoother tool calling: clients can call prefixed names, server auto-routes
28
+
7
29
  ### v2.0.0 (2024-12-19) - Major Release
8
30
 
9
31
  #### ๐Ÿš€ New Tools & Features
@@ -127,7 +149,9 @@ The server uses the `./.setting/` directory to store configuration files by defa
127
149
 
128
150
  | Variable | Default | Description | Example |
129
151
  |----------|---------|-------------|---------|
130
- | CONFIG_DIR | ./.setting | Configuration file directory (contains config.json and api.json) | `export CONFIG_DIR="./config"` |
152
+ | CONFIG_DIR | ./.setting or ./.setting.<TOOL_PREFIX> | Configuration directory. If set, used as-is; else if TOOL_PREFIX set, uses ./.setting.<TOOL_PREFIX>; else ./.setting | `export CONFIG_DIR="./config"` |
153
+ | TOOL_PREFIX | | Optional tool prefix for tool names and config isolation | `export TOOL_PREFIX="projA"` |
154
+ | PROJECT_NAME | | Optional project branding for tool descriptions | `export PROJECT_NAME="MyProject"` |
131
155
  | API_DEBUG_ALLOWED_METHODS | GET | Control allowed request methods (supports: GET,POST,PUT,DELETE,PATCH, etc.) | `export API_DEBUG_ALLOWED_METHODS="GET,POST"` |
132
156
  | API_DEBUG_LOGIN_URL | /api/login | Set login API URL | `export API_DEBUG_LOGIN_URL="/api/auth/login"` |
133
157
  | API_DEBUG_LOGIN_METHOD | POST | Set login request method | `export API_DEBUG_LOGIN_METHOD="POST"` |
@@ -214,7 +238,7 @@ npm run dev
214
238
 
215
239
  ### Cursor Editor Configuration
216
240
 
217
- 1. Create `.cursor/mcp.json` file in your project root:
241
+ 1) Single-project example (no prefix isolation):
218
242
 
219
243
  ```json
220
244
  {
@@ -235,10 +259,42 @@ npm run dev
235
259
  }
236
260
  ```
237
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
+
238
295
  ### VS Code Configuration
239
296
 
240
- 1. Install the MCP extension for VS Code
241
- 2. Create `.vscode/settings.json` file:
297
+ 1) Single-project example (no prefix isolation):
242
298
 
243
299
  ```json
244
300
  {
@@ -251,8 +307,40 @@ npm run dev
251
307
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
252
308
  "API_DEBUG_LOGIN_URL": "/api/login",
253
309
  "API_DEBUG_LOGIN_METHOD": "POST",
254
- "API_DEBUG_LOGIN_BODY": "{\"username\":\"\",\"password\":\"\"}",
255
- "API_DEBUG_LOGIN_DESCRIPTION": "Save returned token to common headers in debug tool, field name Authorization, field value Bearer token"
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": {
323
+ "command": "npx",
324
+ "args": ["@liangshanli/mcp-server-project-standards"],
325
+ "env": {
326
+ "TOOL_PREFIX": "projA",
327
+ "PROJECT_NAME": "Project A",
328
+ "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
329
+ "API_DEBUG_LOGIN_URL": "/api/login",
330
+ "API_DEBUG_LOGIN_METHOD": "POST",
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\":\"\"}"
256
344
  }
257
345
  }
258
346
  }
package/README.zh-CN.md CHANGED
@@ -4,6 +4,27 @@
4
4
 
5
5
  ## ๐Ÿ“‹ ็‰ˆๆœฌๆ›ดๆ–ฐ่ฏดๆ˜Ž
6
6
 
7
+ ### v3.0.0 (2025-10-31) - ้‡ๅคงๆ›ดๆ–ฐ
8
+
9
+ #### ๐Ÿš€ ็ ดๅๆ€งๅ˜ๆ›ด
10
+ - ้…็ฝฎ็›ฎๅฝ•่งฃๆžๆ–ฐๅขž `TOOL_PREFIX` ๅ‚ไธŽ๏ผš
11
+ - ่‹ฅ่ฎพ็ฝฎไบ† `CONFIG_DIR`๏ผŒไผ˜ๅ…ˆไฝฟ็”จ่ฏฅๅ€ผ
12
+ - ่‹ฅๆœช่ฎพ็ฝฎ `CONFIG_DIR` ไธ”่ฎพ็ฝฎไบ† `TOOL_PREFIX`๏ผŒไฝฟ็”จ `./.setting.<TOOL_PREFIX>`
13
+ - ๅฆๅˆ™้ป˜่ฎค `./.setting`
14
+ - ๅœจ `tools/call` ไธญ๏ผŒ่‹ฅๅทฅๅ…ทๅๅธฆๆœ‰ๅ‰็ผ€๏ผˆๅฆ‚ `xxx_api_debug` ไธ” `TOOL_PREFIX=xxx`๏ผ‰๏ผŒ่ฐƒ็”จๆ—ถไผš่‡ชๅŠจๅŽป้™คๅ‰็ผ€๏ผŒ่ทฏ็”ฑๅˆฐ็œŸๅฎžๆ–นๆณ•๏ผˆ`api_debug`๏ผ‰ใ€‚
15
+
16
+ #### โœจ ๆ–ฐๅขž / ๆ”น่ฟ›
17
+ - ๅœจ `server-final.js` ไธŽ `api_common.js` ไธญ็ปŸไธ€ไฝฟ็”จ `getConfigDir()`
18
+ - `tools/list` ็Žฏๅขƒไฟกๆฏๅฑ•็คบๆœ€็ปˆ็”Ÿๆ•ˆ็š„ `CONFIG_DIR`
19
+ - ๅŒๆ—ถๅญ˜ๅœจ `TOOL_PREFIX` ๅ’Œ `PROJECT_NAME` ๆ—ถ๏ผŒๅทฅๅ…ทๅ่‡ชๅŠจๅŠ ๅ‰็ผ€ใ€ๆ่ฟฐ่‡ชๅŠจๅŠ ้กน็›ฎๅ
20
+
21
+ #### ๐Ÿงน ๆธ…็†
22
+ - ็งป้™คไบ†้‡ๅค็š„ๆ—ง็‰ˆ `api_debug` ๆ–นๆณ•ๅฎšไน‰
23
+
24
+ #### ๐Ÿ’ก ไผ˜ๅŠฟ
25
+ - ๅคš้กน็›ฎ้š”็ฆปๆ›ด็ฎ€ๅ•๏ผš้€š่ฟ‡ `TOOL_PREFIX` ๅณๅฏๅฎž็Žฐๆฏ้กน็›ฎ็‹ฌ็ซ‹้…็ฝฎ๏ผŒๆ— ้œ€ๆ”นไปฃ็ 
26
+ - ๅˆ‡ๆข้›ถไพตๅ…ฅ๏ผšไป…ๆ”น็Žฏๅขƒๅ˜้‡ๅณๅฏๅˆ‡ๆข้กน็›ฎไธŠไธ‹ๆ–‡
27
+ - ่ฐƒ็”จๆ›ด้กบๆป‘๏ผšๅฎขๆˆท็ซฏๅฏไฝฟ็”จๅธฆๅ‰็ผ€ๅ๏ผŒๆœๅŠก็ซฏ่‡ชๅŠจๅ‰ฅๅ‰็ผ€ๅนถ็ฒพๅ‡†่ทฏ็”ฑ
7
28
  ### v1.1.0 (2024-12-19)
8
29
 
9
30
  #### ๐Ÿ†• ๆ–ฐๅขžๅŠŸ่ƒฝ
@@ -112,7 +133,9 @@ npm install
112
133
 
113
134
  | ๅ˜้‡ๅ | ้ป˜่ฎคๅ€ผ | ๆ่ฟฐ | ็คบไพ‹ |
114
135
  |--------|--------|------|------|
115
- | CONFIG_DIR | ./.setting | ้…็ฝฎๆ–‡ไปถ็›ฎๅฝ•๏ผˆๅŒ…ๅซ config.json ๅ’Œ api.json๏ผ‰ | `export CONFIG_DIR="./config"` |
136
+ | CONFIG_DIR | ./.setting ๆˆ– ./.setting.<TOOL_PREFIX> | ้…็ฝฎ็›ฎๅฝ•ใ€‚่‹ฅ่ฎพ็ฝฎๅˆ™็›ดๆŽฅไฝฟ็”จ๏ผ›ๅฆๅˆ™่‹ฅ่ฎพ็ฝฎไบ† TOOL_PREFIX ๅˆ™ไฝฟ็”จ ./.setting.<TOOL_PREFIX>๏ผ›ๅฆๅˆ™ ./.setting | `export CONFIG_DIR="./config"` |
137
+ | TOOL_PREFIX | | ๅทฅๅ…ทๅๅ‰็ผ€๏ผŒๅŒๆ—ถ็”จไบŽๅคš้กน็›ฎ้…็ฝฎ้š”็ฆป | `export TOOL_PREFIX="projA"` |
138
+ | PROJECT_NAME | | ๅทฅๅ…ทๆ่ฟฐๅ‰ๆทปๅŠ ้กน็›ฎๅ็งฐ็”จไบŽๆ ‡่ฏ† | `export PROJECT_NAME="MyProject"` |
116
139
  | API_DEBUG_ALLOWED_METHODS | GET | ๆŽงๅˆถๅ…่ฎธ็š„่ฏทๆฑ‚ๆ–นๆณ•๏ผˆๆ”ฏๆŒ๏ผšGET,POST,PUT,DELETE,PATCH็ญ‰๏ผ‰ | `export API_DEBUG_ALLOWED_METHODS="GET,POST"` |
117
140
  | API_DEBUG_LOGIN_URL | /api/login | ่ฎพ็ฝฎ็™ปๅฝ•ๆŽฅๅฃ URL | `export API_DEBUG_LOGIN_URL="/api/auth/login"` |
118
141
  | API_DEBUG_LOGIN_METHOD | POST | ่ฎพ็ฝฎ็™ปๅฝ•่ฏทๆฑ‚ๆ–นๆณ• | `export API_DEBUG_LOGIN_METHOD="POST"` |
@@ -199,7 +222,7 @@ npm run dev
199
222
 
200
223
  ### Cursor ็ผ–่พ‘ๅ™จ้…็ฝฎ
201
224
 
202
- 1. ๅœจ้กน็›ฎๆ น็›ฎๅฝ•ๅˆ›ๅปบ `.cursor/mcp.json` ๆ–‡ไปถ๏ผš
225
+ 1๏ผ‰ๅ•้กน็›ฎ็คบไพ‹๏ผˆไธๅšๅ‰็ผ€้š”็ฆป๏ผ‰๏ผš
203
226
 
204
227
  ```json
205
228
  {
@@ -220,10 +243,42 @@ npm run dev
220
243
  }
221
244
  ```
222
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
+
223
279
  ### VS Code ้…็ฝฎ
224
280
 
225
- 1. ๅฎ‰่ฃ… VS Code ็š„ MCP ๆ‰ฉๅฑ•
226
- 2. ๅˆ›ๅปบ `.vscode/settings.json` ๆ–‡ไปถ๏ผš
281
+ 1๏ผ‰ๅ•้กน็›ฎ็คบไพ‹๏ผˆไธๅšๅ‰็ผ€้š”็ฆป๏ผ‰๏ผš
227
282
 
228
283
  ```json
229
284
  {
@@ -236,8 +291,40 @@ npm run dev
236
291
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
237
292
  "API_DEBUG_LOGIN_URL": "/api/login",
238
293
  "API_DEBUG_LOGIN_METHOD": "POST",
239
- "API_DEBUG_LOGIN_BODY": "{\"username\":\"\",\"password\":\"\"}",
240
- "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\":\"\"}"
241
328
  }
242
329
  }
243
330
  }
package/bin/cli.js CHANGED
@@ -27,16 +27,31 @@ let server = null;
27
27
  // Function to start server
28
28
  function startServer() {
29
29
  // Create environment object
30
+ // Determine CONFIG_DIR: use env var if set, otherwise use .setting with TOOL_PREFIX if available
31
+ let configDir = process.env.CONFIG_DIR;
32
+ if (!configDir) {
33
+ const toolPrefix = process.env.TOOL_PREFIX || '';
34
+ if (toolPrefix) {
35
+ configDir = `./.setting.${toolPrefix}`;
36
+ } else {
37
+ configDir = './.setting';
38
+ }
39
+ }
40
+
30
41
  const env = {
31
42
  ...process.env,
32
- // Set CONFIG_DIR if specified, otherwise use default
33
- CONFIG_DIR: process.env.CONFIG_DIR || './.setting',
43
+ // Set CONFIG_DIR based on logic above
44
+ CONFIG_DIR: configDir,
34
45
  // API Debug environment variables
35
46
  API_DEBUG_ALLOWED_METHODS: process.env.API_DEBUG_ALLOWED_METHODS || 'GET',
36
47
  API_DEBUG_LOGIN_URL: process.env.API_DEBUG_LOGIN_URL || '/api/login',
37
48
  API_DEBUG_LOGIN_METHOD: process.env.API_DEBUG_LOGIN_METHOD || 'POST',
38
49
  API_DEBUG_LOGIN_BODY: process.env.API_DEBUG_LOGIN_BODY || '{"username":"","password":""}',
39
- API_DEBUG_LOGIN_DESCRIPTION: process.env.API_DEBUG_LOGIN_DESCRIPTION || 'Save returned token to common headers in debug tool, field name Authorization, field value Bearer token'
50
+ API_DEBUG_LOGIN_DESCRIPTION: process.env.API_DEBUG_LOGIN_DESCRIPTION || 'Save returned token to common headers in debug tool, field name Authorization, field value Bearer token',
51
+ // Tool prefix for naming/identification
52
+ TOOL_PREFIX: process.env.TOOL_PREFIX || '',
53
+ // Project name for display/metadata
54
+ PROJECT_NAME: process.env.PROJECT_NAME || ''
40
55
  };
41
56
 
42
57
  // Convert allowed methods to uppercase if specified
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liangshanli/mcp-server-project-standards",
3
- "version": "2.1.10",
3
+ "version": "3.0.1",
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": {
@@ -13,9 +13,23 @@ const api_config = require('./utils/api_config');
13
13
  const api_help = require('./utils/api_help');
14
14
  const api_execute = require('./utils/api_execute');
15
15
 
16
+ // Get config directory based on CONFIG_DIR and TOOL_PREFIX
17
+ const getConfigDir = () => {
18
+ let configDir = process.env.CONFIG_DIR;
19
+ if (!configDir) {
20
+ const toolPrefix = process.env.TOOL_PREFIX || '';
21
+ if (toolPrefix) {
22
+ configDir = `./.setting.${toolPrefix}`;
23
+ } else {
24
+ configDir = './.setting';
25
+ }
26
+ }
27
+ return configDir;
28
+ };
29
+
16
30
  // Get configuration from file or environment
17
31
  const getConfig = () => {
18
- const configDir = process.env.CONFIG_DIR || './.setting';
32
+ const configDir = getConfigDir();
19
33
  const configPath = path.join(configDir, 'config.json');
20
34
 
21
35
  try {
@@ -33,7 +47,7 @@ const getConfig = () => {
33
47
 
34
48
  // Save configuration to file
35
49
  const saveConfig = (config) => {
36
- const configDir = process.env.CONFIG_DIR || './.setting';
50
+ const configDir = getConfigDir();
37
51
  const configPath = path.join(configDir, 'config.json');
38
52
 
39
53
  try {
@@ -51,7 +65,7 @@ const saveConfig = (config) => {
51
65
  // ๅฏๅŠจๆ—ฅๅฟ—
52
66
  console.error('=== MCP Project Standards Server Starting ===');
53
67
  console.error(`Time: ${new Date().toISOString()}`);
54
- console.error(`Config Dir: ${process.env.CONFIG_DIR || './.setting'}`);
68
+ console.error(`Config Dir: ${getConfigDir()}`);
55
69
  console.error('==============================================');
56
70
 
57
71
  // Final MCP Server
@@ -71,7 +85,7 @@ class ProjectStandardsMCPServer {
71
85
 
72
86
  // ๅˆ›ๅปบ้ป˜่ฎค้…็ฝฎๆ–‡ไปถ
73
87
  createDefaultConfig() {
74
- const configDir = process.env.CONFIG_DIR || './.setting';
88
+ const configDir = getConfigDir();
75
89
  const configPath = path.join(configDir, 'config.json');
76
90
 
77
91
  try {
@@ -153,16 +167,6 @@ class ProjectStandardsMCPServer {
153
167
  return result;
154
168
  }
155
169
 
156
- // API debug tool (legacy)
157
- async api_debug(params) {
158
- const result = await api_debug(params, this.config, saveConfig);
159
- // Update local config if action was 'set'
160
- if (params?.action === 'set') {
161
- this.config = getConfig();
162
- }
163
- return result;
164
- }
165
-
166
170
  // API login tool
167
171
  async api_login(params) {
168
172
  const result = await api_login(params, this.config, saveConfig);
@@ -874,11 +878,24 @@ class ProjectStandardsMCPServer {
874
878
  }
875
879
  });
876
880
 
881
+ // Apply tool prefix and project name if both provided
882
+ const toolPrefix = process.env.TOOL_PREFIX || '';
883
+ const projectName = process.env.PROJECT_NAME || '';
884
+ let finalTools = tools;
885
+ if (toolPrefix && projectName) {
886
+ finalTools = tools.map(t => ({
887
+ ...t,
888
+ name: `${toolPrefix}_${t.name}`,
889
+ description: `${projectName} - ${t.description}`
890
+ }));
891
+ }
877
892
 
878
893
  result = {
879
- tools: tools,
894
+ tools: finalTools,
880
895
  environment: {
881
- CONFIG_DIR: process.env.CONFIG_DIR || './.setting',
896
+ CONFIG_DIR: getConfigDir(),
897
+ PROJECT_NAME: process.env.PROJECT_NAME || '',
898
+ TOOL_PREFIX: process.env.TOOL_PREFIX || '',
882
899
  serverInfo: {
883
900
  name: this.name,
884
901
  version: this.version
@@ -949,12 +966,19 @@ class ProjectStandardsMCPServer {
949
966
  throw new Error('Missing tool name');
950
967
  }
951
968
 
969
+ // Remove tool prefix if present
970
+ const toolPrefix = process.env.TOOL_PREFIX || '';
971
+ let actualToolName = name;
972
+ if (toolPrefix && name.startsWith(`${toolPrefix}_`)) {
973
+ actualToolName = name.substring(toolPrefix.length + 1);
974
+ }
975
+
952
976
  // Check if method exists
953
- if (!this[name]) {
977
+ if (!this[actualToolName]) {
954
978
  throw new Error(`Unknown tool: ${name}`);
955
979
  }
956
980
 
957
- result = await this[name](args || {});
981
+ result = await this[actualToolName](args || {});
958
982
 
959
983
  // Check if result has contentType (special format)
960
984
  if (result && result.contentType === "text") {
@@ -1,9 +1,23 @@
1
1
  const fs = require('fs-extra');
2
2
  const path = require('path');
3
3
 
4
+ // Get config directory based on CONFIG_DIR and TOOL_PREFIX
5
+ const getConfigDir = () => {
6
+ let configDir = process.env.CONFIG_DIR;
7
+ if (!configDir) {
8
+ const toolPrefix = process.env.TOOL_PREFIX || '';
9
+ if (toolPrefix) {
10
+ configDir = `./.setting.${toolPrefix}`;
11
+ } else {
12
+ configDir = './.setting';
13
+ }
14
+ }
15
+ return configDir;
16
+ };
17
+
4
18
  // Get API debug config file path
5
19
  const getApiConfigPath = () => {
6
- const configDir = process.env.CONFIG_DIR || './.setting';
20
+ const configDir = getConfigDir();
7
21
  return path.join(configDir, 'api.json');
8
22
  };
9
23
 
@@ -30,7 +44,7 @@ const loadApiConfig = () => {
30
44
 
31
45
  // Save API debug config
32
46
  const saveApiConfig = (apiConfig) => {
33
- const configDir = process.env.CONFIG_DIR || './.setting';
47
+ const configDir = getConfigDir();
34
48
  const apiConfigPath = path.join(configDir, 'api.json');
35
49
 
36
50
  try {
@@ -125,6 +139,7 @@ const detectContentType = (body) => {
125
139
  };
126
140
 
127
141
  module.exports = {
142
+ getConfigDir,
128
143
  getApiConfigPath,
129
144
  loadApiConfig,
130
145
  saveApiConfig,
@@ -37,33 +37,40 @@ const httpsAgent = new https.Agent({
37
37
  async function api_debug(params, config, saveConfig) {
38
38
  const { url, method = 'GET', headers = {}, query, body, contentType } = params || {};
39
39
 
40
+ // Resolve dynamic tool names based on prefix and project name
41
+ const toolPrefix = process.env.TOOL_PREFIX || '';
42
+ const projectName = process.env.PROJECT_NAME || '';
43
+ const hasCustomTools = !!(toolPrefix && projectName);
44
+ const configToolName = hasCustomTools ? `${toolPrefix}_api_config` : 'api_config';
45
+ const executeToolName = hasCustomTools ? `${toolPrefix}_api_execute` : 'api_execute';
46
+
40
47
  if (!url) {
41
48
  return {
42
49
  contentType: "text",
43
50
  content: [
44
51
  {
45
52
  type: "text",
46
- text: "โš ๏ธ IMPORTANT: You MUST use addApi to add the API to the list first! Use api_config tool.\n\n๐Ÿ”ง Step 1: Add API to Configuration (REQUIRED)\n\nCall: api_config with action=\"addApi\" and api={\"url\":\"${url}\",\"method\":\"${requestMethod}\",\"body\":\"your corrected JSON here\"}\n\nโš ๏ธ REMINDER: You MUST use api_config with addApi to add the API to the list!"
53
+ text: `โš ๏ธ IMPORTANT: You MUST use addApi to add the API to the list first! Use ${configToolName} tool.\n\n๐Ÿ”ง Step 1: Add API to Configuration (REQUIRED)\n\nCall: ${configToolName} with action="addApi" and api={"url":"<your url>","method":"<METHOD>","body":"your corrected JSON here"}\n\nโš ๏ธ REMINDER: You MUST use ${configToolName} with addApi to add the API to the list!`
47
54
  },
48
55
  {
49
56
  type: "text",
50
- text: "๐Ÿ”ง Step 2: Execute API by Index\n\nAfter adding the API, call: api_execute with index=<returned index>\n\nThis will execute the pre-configured API with the correct format."
57
+ text: `๐Ÿ”ง Step 2: Execute API by Index\n\nAfter adding the API, call: ${executeToolName} with index=<returned index>\n\nThis will execute the pre-configured API with the correct format.`
51
58
  },
52
59
  {
53
60
  type: "text",
54
- text: "๐Ÿšจ REMINDER: You MUST use addApi first!\n\n- Use api_config with action=\"addApi\" to add the API to the list\n- Then use api_execute with the returned index to execute"
61
+ text: `๐Ÿšจ REMINDER: You MUST use addApi first!\n\n- Use ${configToolName} with action="addApi" to add the API to the list\n- Then use ${executeToolName} with the returned index to execute`
55
62
  },
56
63
  {
57
64
  type: "text",
58
- text: "๐Ÿ’ก IMPORTANT: Remember to use addApi!\n\n- First: api_config with action=\"addApi\" to add the API\n- Second: api_execute with index to run the API"
65
+ text: `๐Ÿ’ก IMPORTANT: Remember to use addApi!\n\n- First: ${configToolName} with action="addApi" to add the API\n- Second: ${executeToolName} with index to run the API`
59
66
  },
60
67
  {
61
68
  type: "text",
62
- text: "๐Ÿ“‹ Final Reminder: Use addApi โ†’ Then api_execute\n\n1. First: api_config with action=\"addApi\"\n2. Then: api_execute with index=<number>\n\nThis is the ONLY way to handle invalid JSON requests."
69
+ text: `๐Ÿ“‹ Final Reminder: Use addApi โ†’ Then ${executeToolName}\n\n1. First: ${configToolName} with action="addApi"\n2. Then: ${executeToolName} with index=<number>\n\nThis is the ONLY way to handle invalid JSON requests.`
63
70
  },
64
71
  {
65
72
  type: "text",
66
- text: "โš ๏ธ ESSENTIAL: You MUST use addApi!\n\n- First: api_config with action=\"addApi\" to add the API\n- Second: api_execute with index to run the API"
73
+ text: `โš ๏ธ ESSENTIAL: You MUST use addApi!\n\n- First: ${configToolName} with action="addApi" to add the API\n- Second: ${executeToolName} with index to run the API`
67
74
  }
68
75
  ]
69
76
  };
@@ -112,27 +119,27 @@ async function api_debug(params, config, saveConfig) {
112
119
  content: [
113
120
  {
114
121
  type: "text",
115
- text: "โš ๏ธ IMPORTANT: You MUST use addApi to add the API to the list first! Use api_config tool.\n\n๐Ÿ”ง Step 1: Add API to Configuration (REQUIRED)\n\nCall: api_config with action=\"addApi\" and api={\"url\":\"${url}\",\"method\":\"${requestMethod}\",\"body\":\"your corrected JSON here\"}\n\nโš ๏ธ REMINDER: You MUST use api_config with addApi to add the API to the list!"
122
+ text: `โš ๏ธ IMPORTANT: You MUST use addApi to add the API to the list first! Use ${configToolName} tool.\n\n๐Ÿ”ง Step 1: Add API to Configuration (REQUIRED)\n\nCall: ${configToolName} with action="addApi" and api={"url":"${url}","method":"${requestMethod}","body":"your corrected JSON here"}\n\nโš ๏ธ REMINDER: You MUST use ${configToolName} with addApi to add the API to the list!`
116
123
  },
117
124
  {
118
125
  type: "text",
119
- text: "๐Ÿ”ง Step 2: Execute API by Index\n\nAfter adding the API, call: api_execute with index=<returned index>\n\nThis will execute the pre-configured API with the correct format."
126
+ text: `๐Ÿ”ง Step 2: Execute API by Index\n\nAfter adding the API, call: ${executeToolName} with index=<returned index>\n\nThis will execute the pre-configured API with the correct format.`
120
127
  },
121
128
  {
122
129
  type: "text",
123
- text: "๐Ÿšจ REMINDER: You MUST use addApi first!\n\n- Use api_config with action=\"addApi\" to add the API to the list\n- Then use api_execute with the returned index to execute"
130
+ text: `๐Ÿšจ REMINDER: You MUST use addApi first!\n\n- Use ${configToolName} with action="addApi" to add the API to the list\n- Then use ${executeToolName} with the returned index to execute`
124
131
  },
125
132
  {
126
133
  type: "text",
127
- text: "๐Ÿ’ก IMPORTANT: Remember to use addApi!\n\n- First: api_config with action=\"addApi\" to add the API\n- Second: api_execute with index to run the API"
134
+ text: `๐Ÿ’ก IMPORTANT: Remember to use addApi!\n\n- First: ${configToolName} with action="addApi" to add the API\n- Second: ${executeToolName} with index to run the API`
128
135
  },
129
136
  {
130
137
  type: "text",
131
- text: "๐Ÿ“‹ Final Reminder: Use addApi โ†’ Then api_execute\n\n1. First: api_config with action=\"addApi\"\n2. Then: api_execute with index=<number>\n\nThis is the ONLY way to handle invalid JSON requests."
138
+ text: `๐Ÿ“‹ Final Reminder: Use addApi โ†’ Then ${executeToolName}\n\n1. First: ${configToolName} with action="addApi"\n2. Then: ${executeToolName} with index=<number>\n\nThis is the ONLY way to handle invalid JSON requests.`
132
139
  },
133
140
  {
134
141
  type: "text",
135
- text: "โš ๏ธ ESSENTIAL: You MUST use addApi!\n\n- First: api_config with action=\"addApi\" to add the API\n- Second: api_execute with index to run the API"
142
+ text: `โš ๏ธ ESSENTIAL: You MUST use addApi!\n\n- First: ${configToolName} with action="addApi" to add the API\n- Second: ${executeToolName} with index to run the API`
136
143
  }
137
144
  ]
138
145
  };