@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 +94 -6
- package/README.zh-CN.md +93 -6
- package/bin/cli.js +18 -3
- package/package.json +1 -1
- package/src/server-final.js +42 -18
- package/src/utils/api_common.js +17 -2
- package/src/utils/api_debug.js +19 -12
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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 |
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
33
|
-
CONFIG_DIR:
|
|
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": "
|
|
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": {
|
package/src/server-final.js
CHANGED
|
@@ -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 =
|
|
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 =
|
|
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: ${
|
|
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 =
|
|
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:
|
|
894
|
+
tools: finalTools,
|
|
880
895
|
environment: {
|
|
881
|
-
CONFIG_DIR:
|
|
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[
|
|
977
|
+
if (!this[actualToolName]) {
|
|
954
978
|
throw new Error(`Unknown tool: ${name}`);
|
|
955
979
|
}
|
|
956
980
|
|
|
957
|
-
result = await this[
|
|
981
|
+
result = await this[actualToolName](args || {});
|
|
958
982
|
|
|
959
983
|
// Check if result has contentType (special format)
|
|
960
984
|
if (result && result.contentType === "text") {
|
package/src/utils/api_common.js
CHANGED
|
@@ -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 =
|
|
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 =
|
|
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,
|
package/src/utils/api_debug.js
CHANGED
|
@@ -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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
};
|