@liangshanli/mcp-server-project-standards 1.2.2 → 2.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 +15 -0
- package/bin/cli.js +1 -1
- package/package.json +8 -4
- package/src/server-final.js +445 -268
- package/src/utils/api_common.js +137 -0
- package/src/utils/api_config.js +217 -0
- package/src/utils/api_debug.js +145 -604
- package/src/utils/api_login.js +165 -0
package/src/server-final.js
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
1
96
|
const fs = require('fs-extra');
|
|
2
97
|
const path = require('path');
|
|
3
98
|
|
|
@@ -7,13 +102,15 @@ const project_structure = require('./utils/get_project_structure');
|
|
|
7
102
|
const api_standards = require('./utils/get_api_standards');
|
|
8
103
|
const development_standards = require('./utils/get_development_standards');
|
|
9
104
|
const database_standards = require('./utils/database_standards');
|
|
105
|
+
const api_login = require('./utils/api_login');
|
|
10
106
|
const api_debug = require('./utils/api_debug');
|
|
107
|
+
const api_config = require('./utils/api_config');
|
|
11
108
|
|
|
12
109
|
// Get configuration from file or environment
|
|
13
110
|
const getConfig = () => {
|
|
14
111
|
const configDir = process.env.CONFIG_DIR || './.setting';
|
|
15
112
|
const configPath = path.join(configDir, 'config.json');
|
|
16
|
-
|
|
113
|
+
|
|
17
114
|
try {
|
|
18
115
|
if (fs.existsSync(configPath)) {
|
|
19
116
|
const configData = fs.readFileSync(configPath, 'utf8');
|
|
@@ -31,7 +128,7 @@ const getConfig = () => {
|
|
|
31
128
|
const saveConfig = (config) => {
|
|
32
129
|
const configDir = process.env.CONFIG_DIR || './.setting';
|
|
33
130
|
const configPath = path.join(configDir, 'config.json');
|
|
34
|
-
|
|
131
|
+
|
|
35
132
|
try {
|
|
36
133
|
if (!fs.existsSync(configDir)) {
|
|
37
134
|
fs.mkdirSync(configDir, { recursive: true });
|
|
@@ -58,7 +155,7 @@ class ProjectStandardsMCPServer {
|
|
|
58
155
|
this.initialized = false;
|
|
59
156
|
this.config = getConfig();
|
|
60
157
|
this.needsProjectFolder = this.config === null;
|
|
61
|
-
|
|
158
|
+
|
|
62
159
|
// 如果配置文件不存在,创建默认配置
|
|
63
160
|
if (this.needsProjectFolder) {
|
|
64
161
|
this.createDefaultConfig();
|
|
@@ -69,14 +166,14 @@ class ProjectStandardsMCPServer {
|
|
|
69
166
|
createDefaultConfig() {
|
|
70
167
|
const configDir = process.env.CONFIG_DIR || './.setting';
|
|
71
168
|
const configPath = path.join(configDir, 'config.json');
|
|
72
|
-
|
|
169
|
+
|
|
73
170
|
try {
|
|
74
171
|
// 创建配置目录
|
|
75
172
|
if (!fs.existsSync(configDir)) {
|
|
76
173
|
fs.mkdirSync(configDir, { recursive: true });
|
|
77
174
|
console.error(`Created config directory: ${configDir}`);
|
|
78
175
|
}
|
|
79
|
-
|
|
176
|
+
|
|
80
177
|
// 创建默认配置文件
|
|
81
178
|
const defaultConfig = {
|
|
82
179
|
project_info: {},
|
|
@@ -85,10 +182,10 @@ class ProjectStandardsMCPServer {
|
|
|
85
182
|
development_standards: [],
|
|
86
183
|
database_standards: []
|
|
87
184
|
};
|
|
88
|
-
|
|
185
|
+
|
|
89
186
|
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), 'utf8');
|
|
90
187
|
console.error(`Created default config file: ${configPath}`);
|
|
91
|
-
|
|
188
|
+
|
|
92
189
|
// 更新配置和状态
|
|
93
190
|
this.config = defaultConfig;
|
|
94
191
|
this.needsProjectFolder = false;
|
|
@@ -149,7 +246,7 @@ class ProjectStandardsMCPServer {
|
|
|
149
246
|
return result;
|
|
150
247
|
}
|
|
151
248
|
|
|
152
|
-
// API debug tool
|
|
249
|
+
// API debug tool (legacy)
|
|
153
250
|
async api_debug(params) {
|
|
154
251
|
const result = await api_debug(params, this.config, saveConfig);
|
|
155
252
|
// Update local config if action was 'set'
|
|
@@ -159,6 +256,24 @@ class ProjectStandardsMCPServer {
|
|
|
159
256
|
return result;
|
|
160
257
|
}
|
|
161
258
|
|
|
259
|
+
// API login tool
|
|
260
|
+
async api_login(params) {
|
|
261
|
+
const result = await api_login(params, this.config, saveConfig);
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// API debug tool
|
|
266
|
+
async api_debug(params) {
|
|
267
|
+
const result = await api_debug(params, this.config, saveConfig);
|
|
268
|
+
return result;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// API config tool
|
|
272
|
+
async api_config(params) {
|
|
273
|
+
const result = await api_config(params, this.config, saveConfig);
|
|
274
|
+
return result;
|
|
275
|
+
}
|
|
276
|
+
|
|
162
277
|
|
|
163
278
|
|
|
164
279
|
|
|
@@ -180,42 +295,42 @@ class ProjectStandardsMCPServer {
|
|
|
180
295
|
if (!this.initialized) {
|
|
181
296
|
this.initialized = true;
|
|
182
297
|
}
|
|
183
|
-
|
|
298
|
+
|
|
184
299
|
// Build server capabilities to match client capabilities
|
|
185
300
|
const serverCapabilities = {
|
|
186
301
|
tools: {
|
|
187
302
|
listChanged: false
|
|
188
303
|
}
|
|
189
304
|
};
|
|
190
|
-
|
|
305
|
+
|
|
191
306
|
// If client supports prompts, we also support it
|
|
192
307
|
if (params?.capabilities?.prompts) {
|
|
193
308
|
serverCapabilities.prompts = {
|
|
194
309
|
listChanged: false
|
|
195
310
|
};
|
|
196
311
|
}
|
|
197
|
-
|
|
312
|
+
|
|
198
313
|
// If client supports resources, we also support it
|
|
199
314
|
if (params?.capabilities?.resources) {
|
|
200
315
|
serverCapabilities.resources = {
|
|
201
316
|
listChanged: false
|
|
202
317
|
};
|
|
203
318
|
}
|
|
204
|
-
|
|
319
|
+
|
|
205
320
|
// If client supports logging, we also support it
|
|
206
321
|
if (params?.capabilities?.logging) {
|
|
207
322
|
serverCapabilities.logging = {
|
|
208
323
|
listChanged: false
|
|
209
324
|
};
|
|
210
325
|
}
|
|
211
|
-
|
|
326
|
+
|
|
212
327
|
// If client supports roots, we also support it
|
|
213
328
|
if (params?.capabilities?.roots) {
|
|
214
329
|
serverCapabilities.roots = {
|
|
215
330
|
listChanged: false
|
|
216
331
|
};
|
|
217
332
|
}
|
|
218
|
-
|
|
333
|
+
|
|
219
334
|
result = {
|
|
220
335
|
protocolVersion: params?.protocolVersion || '2025-06-18',
|
|
221
336
|
capabilities: serverCapabilities,
|
|
@@ -226,7 +341,7 @@ class ProjectStandardsMCPServer {
|
|
|
226
341
|
};
|
|
227
342
|
} else if (method === 'tools/list') {
|
|
228
343
|
const tools = [];
|
|
229
|
-
|
|
344
|
+
|
|
230
345
|
// Add all tools since config is always available now
|
|
231
346
|
tools.push({
|
|
232
347
|
name: 'project_info',
|
|
@@ -266,18 +381,18 @@ class ProjectStandardsMCPServer {
|
|
|
266
381
|
]
|
|
267
382
|
}
|
|
268
383
|
});
|
|
269
|
-
|
|
270
|
-
tools.push(
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
384
|
+
|
|
385
|
+
tools.push({
|
|
386
|
+
name: 'project_structure',
|
|
387
|
+
description: 'Get, set or delete project structure in configuration',
|
|
388
|
+
inputSchema: {
|
|
389
|
+
type: 'object',
|
|
390
|
+
properties: {
|
|
391
|
+
action: {
|
|
392
|
+
type: 'string',
|
|
393
|
+
enum: ['get', 'set', 'delete'],
|
|
394
|
+
description: 'Action to perform: "get" to retrieve structure, "set" to update structure, "delete" to delete structure item'
|
|
395
|
+
},
|
|
281
396
|
structure: {
|
|
282
397
|
type: 'array',
|
|
283
398
|
description: 'Array of structure items with path and description (required for "set" action)',
|
|
@@ -325,226 +440,300 @@ class ProjectStandardsMCPServer {
|
|
|
325
440
|
]
|
|
326
441
|
}
|
|
327
442
|
});
|
|
328
|
-
|
|
329
|
-
tools.push(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
required: ['action'],
|
|
366
|
-
anyOf: [
|
|
367
|
-
{
|
|
368
|
-
properties: {
|
|
369
|
-
action: { const: 'get' }
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
properties: {
|
|
374
|
-
action: { const: 'set' },
|
|
375
|
-
key: { type: 'string' },
|
|
376
|
-
value: {}
|
|
377
|
-
},
|
|
378
|
-
required: ['key', 'value']
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
properties: {
|
|
382
|
-
action: { const: 'delete' },
|
|
383
|
-
headerName: { type: 'string' }
|
|
384
|
-
},
|
|
385
|
-
required: ['headerName']
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
properties: {
|
|
389
|
-
action: { const: 'delete' },
|
|
390
|
-
requirement: { type: 'string' }
|
|
391
|
-
},
|
|
392
|
-
required: ['requirement']
|
|
393
|
-
}
|
|
394
|
-
]
|
|
443
|
+
|
|
444
|
+
tools.push({
|
|
445
|
+
name: 'api_standards',
|
|
446
|
+
description: 'Get, set or delete API interface standards and best practices',
|
|
447
|
+
inputSchema: {
|
|
448
|
+
type: 'object',
|
|
449
|
+
properties: {
|
|
450
|
+
action: {
|
|
451
|
+
type: 'string',
|
|
452
|
+
enum: ['get', 'set', 'delete'],
|
|
453
|
+
description: 'Action to perform: "get" to retrieve standards, "set" to update standards, "delete" to delete header'
|
|
454
|
+
},
|
|
455
|
+
key: {
|
|
456
|
+
type: 'string',
|
|
457
|
+
enum: ['interfaceType', 'successStructure', 'errorStructure', 'basicHeaders', 'requirements'],
|
|
458
|
+
description: 'Key to update when action is "set" (interfaceType|successStructure|errorStructure|basicHeaders|requirements)'
|
|
459
|
+
},
|
|
460
|
+
value: {
|
|
461
|
+
oneOf: [
|
|
462
|
+
{ type: 'string' },
|
|
463
|
+
{ type: 'array' }
|
|
464
|
+
],
|
|
465
|
+
description: 'Value to set when action is "set" (must be string or array)'
|
|
466
|
+
},
|
|
467
|
+
forceOverwrite: {
|
|
468
|
+
type: 'boolean',
|
|
469
|
+
description: 'Force overwrite array values when action is "set" and value is array (default: false)'
|
|
470
|
+
},
|
|
471
|
+
headerName: {
|
|
472
|
+
type: 'string',
|
|
473
|
+
description: 'Header name to delete when action is "delete"'
|
|
474
|
+
},
|
|
475
|
+
requirement: {
|
|
476
|
+
type: 'string',
|
|
477
|
+
description: 'Requirement content to delete when action is "delete"'
|
|
395
478
|
}
|
|
396
479
|
},
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
inputSchema: {
|
|
401
|
-
type: 'object',
|
|
480
|
+
required: ['action'],
|
|
481
|
+
anyOf: [
|
|
482
|
+
{
|
|
402
483
|
properties: {
|
|
403
|
-
action: {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
484
|
+
action: { const: 'get' }
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
properties: {
|
|
489
|
+
action: { const: 'set' },
|
|
490
|
+
key: { type: 'string' },
|
|
491
|
+
value: {}
|
|
492
|
+
},
|
|
493
|
+
required: ['key', 'value']
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
properties: {
|
|
497
|
+
action: { const: 'delete' },
|
|
498
|
+
headerName: { type: 'string' }
|
|
499
|
+
},
|
|
500
|
+
required: ['headerName']
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
properties: {
|
|
504
|
+
action: { const: 'delete' },
|
|
505
|
+
requirement: { type: 'string' }
|
|
506
|
+
},
|
|
507
|
+
required: ['requirement']
|
|
508
|
+
}
|
|
509
|
+
]
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
name: 'development_standards',
|
|
514
|
+
description: 'Get, set or delete development standards',
|
|
515
|
+
inputSchema: {
|
|
516
|
+
type: 'object',
|
|
517
|
+
properties: {
|
|
518
|
+
action: {
|
|
519
|
+
type: 'string',
|
|
520
|
+
enum: ['get', 'set', 'delete'],
|
|
521
|
+
description: 'Action to perform: "get" to retrieve standards, "set" to update standards, "delete" to delete standard'
|
|
522
|
+
},
|
|
523
|
+
standards: {
|
|
524
|
+
type: 'array',
|
|
525
|
+
description: 'Array of development standards (required for "set" action)',
|
|
526
|
+
items: {
|
|
527
|
+
type: 'string'
|
|
422
528
|
}
|
|
423
529
|
},
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
{
|
|
439
|
-
properties: {
|
|
440
|
-
action: { const: 'delete' },
|
|
441
|
-
standard: { type: 'string' }
|
|
442
|
-
},
|
|
443
|
-
required: ['standard']
|
|
530
|
+
forceOverwrite: {
|
|
531
|
+
type: 'boolean',
|
|
532
|
+
description: 'Force overwrite array values when action is "set" and value is array (default: false)'
|
|
533
|
+
},
|
|
534
|
+
standard: {
|
|
535
|
+
type: 'string',
|
|
536
|
+
description: 'Standard content to delete when action is "delete"'
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
required: ['action'],
|
|
540
|
+
anyOf: [
|
|
541
|
+
{
|
|
542
|
+
properties: {
|
|
543
|
+
action: { const: 'get' }
|
|
444
544
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
description: 'Get, set or delete database standards',
|
|
451
|
-
inputSchema: {
|
|
452
|
-
type: 'object',
|
|
453
|
-
properties: {
|
|
454
|
-
action: {
|
|
455
|
-
type: 'string',
|
|
456
|
-
enum: ['get', 'set', 'delete'],
|
|
457
|
-
description: 'Action to perform: "get" to retrieve standards, "set" to update standards, "delete" to delete standard'
|
|
458
|
-
},
|
|
459
|
-
standards: {
|
|
460
|
-
type: 'array',
|
|
461
|
-
description: 'Array of database standards (required for "set" action)',
|
|
462
|
-
items: {
|
|
463
|
-
type: 'string'
|
|
464
|
-
}
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
properties: {
|
|
548
|
+
action: { const: 'set' },
|
|
549
|
+
standards: { type: 'array' }
|
|
465
550
|
},
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
551
|
+
required: ['standards']
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
properties: {
|
|
555
|
+
action: { const: 'delete' },
|
|
556
|
+
standard: { type: 'string' }
|
|
469
557
|
},
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
558
|
+
required: ['standard']
|
|
559
|
+
}
|
|
560
|
+
]
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
name: 'database_standards',
|
|
565
|
+
description: 'Get, set or delete database standards',
|
|
566
|
+
inputSchema: {
|
|
567
|
+
type: 'object',
|
|
568
|
+
properties: {
|
|
569
|
+
action: {
|
|
570
|
+
type: 'string',
|
|
571
|
+
enum: ['get', 'set', 'delete'],
|
|
572
|
+
description: 'Action to perform: "get" to retrieve standards, "set" to update standards, "delete" to delete standard'
|
|
573
|
+
},
|
|
574
|
+
standards: {
|
|
575
|
+
type: 'array',
|
|
576
|
+
description: 'Array of database standards (required for "set" action)',
|
|
577
|
+
items: {
|
|
578
|
+
type: 'string'
|
|
473
579
|
}
|
|
474
580
|
},
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
581
|
+
forceOverwrite: {
|
|
582
|
+
type: 'boolean',
|
|
583
|
+
description: 'Force overwrite array values when action is "set" and value is array (default: false)'
|
|
584
|
+
},
|
|
585
|
+
standard: {
|
|
586
|
+
type: 'string',
|
|
587
|
+
description: 'Standard content to delete when action is "delete"'
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
required: ['action'],
|
|
591
|
+
anyOf: [
|
|
592
|
+
{
|
|
593
|
+
properties: {
|
|
594
|
+
action: { const: 'get' }
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
properties: {
|
|
599
|
+
action: { const: 'set' },
|
|
600
|
+
standards: { type: 'array' }
|
|
481
601
|
},
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
},
|
|
487
|
-
|
|
602
|
+
required: ['standards']
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
properties: {
|
|
606
|
+
action: { const: 'delete' },
|
|
607
|
+
standard: { type: 'string' }
|
|
488
608
|
},
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
standard: { type: 'string' }
|
|
493
|
-
},
|
|
494
|
-
required: ['standard']
|
|
495
|
-
}
|
|
496
|
-
]
|
|
497
|
-
}
|
|
609
|
+
required: ['standard']
|
|
610
|
+
}
|
|
611
|
+
]
|
|
498
612
|
}
|
|
499
|
-
);
|
|
500
|
-
|
|
501
|
-
// 构建 API 调试工具描述
|
|
502
|
-
let apiDebugDescription = 'API debugging tool for testing and executing API requests. You can directly execute any API URL without needing to add it to the configuration first. Use URL to identify APIs instead of index numbers.';
|
|
503
|
-
|
|
504
|
-
// 检查是否设置了登录接口环境变量
|
|
505
|
-
const loginUrl = process.env.API_DEBUG_LOGIN_URL;
|
|
506
|
-
const loginMethod = process.env.API_DEBUG_LOGIN_METHOD;
|
|
507
|
-
const loginDescription = process.env.API_DEBUG_LOGIN_DESCRIPTION;
|
|
508
|
-
const allowedMethods = process.env.API_DEBUG_ALLOWED_METHODS;
|
|
509
|
-
|
|
510
|
-
if (loginUrl || loginMethod || allowedMethods) {
|
|
511
|
-
apiDebugDescription += '\n\n🔐 Login Authentication Configuration:';
|
|
512
|
-
|
|
513
|
-
if (loginUrl) {
|
|
514
|
-
apiDebugDescription += `\n- Login URL: ${loginUrl}`;
|
|
515
|
-
}
|
|
516
|
-
if (loginMethod) {
|
|
517
|
-
apiDebugDescription += `\n- Login Method: ${loginMethod}`;
|
|
518
613
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
614
|
+
);
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
// API Login Tool
|
|
618
|
+
tools.push({
|
|
619
|
+
name: 'api_login',
|
|
620
|
+
description: 'API login authentication tool that uses environment variables for login credentials',
|
|
621
|
+
inputSchema: {
|
|
622
|
+
type: 'object',
|
|
623
|
+
properties: {
|
|
624
|
+
baseUrl: {
|
|
625
|
+
type: 'string',
|
|
626
|
+
description: 'Base URL for login request (optional, will override config baseUrl)'
|
|
627
|
+
}
|
|
628
|
+
}
|
|
524
629
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
apiDebugDescription += '\n- Use URL to identify APIs for execute and delete operations (not index numbers)';
|
|
529
|
-
apiDebugDescription += '\n- Login API automatically uses environment variable configuration';
|
|
530
|
-
apiDebugDescription += '\n- Non-login APIs must use allowed methods only';
|
|
531
|
-
apiDebugDescription += '\n- Common request headers are automatically updated after successful login';
|
|
532
|
-
}
|
|
533
|
-
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
// API Debug Tool
|
|
534
633
|
tools.push({
|
|
535
634
|
name: 'api_debug',
|
|
536
|
-
description:
|
|
635
|
+
description: 'API debugging tool for directly executing API requests with automatic content-type detection and flexible body format support',
|
|
537
636
|
inputSchema: {
|
|
538
637
|
type: 'object',
|
|
539
638
|
properties: {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
639
|
+
url: {
|
|
640
|
+
type: 'string',
|
|
641
|
+
description: 'API URL to execute (required)',
|
|
642
|
+
examples: ['/api/users', 'https://api.example.com/users', '/api/login']
|
|
643
|
+
},
|
|
644
|
+
method: {
|
|
645
|
+
type: 'string',
|
|
646
|
+
enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
|
|
647
|
+
description: 'HTTP method (optional, defaults to GET)',
|
|
648
|
+
examples: ['GET', 'POST', 'PUT']
|
|
649
|
+
},
|
|
650
|
+
headers: {
|
|
651
|
+
type: 'object',
|
|
652
|
+
description: 'Additional headers for the request (optional)',
|
|
653
|
+
examples: [
|
|
654
|
+
{'Authorization': 'Bearer token123'},
|
|
655
|
+
{'Content-Type': 'application/json'},
|
|
656
|
+
{'X-API-Key': 'your-api-key'}
|
|
657
|
+
]
|
|
658
|
+
},
|
|
659
|
+
query: {
|
|
660
|
+
type: 'object',
|
|
661
|
+
description: 'Query parameters (optional)',
|
|
662
|
+
examples: [
|
|
663
|
+
{'page': 1, 'limit': 10},
|
|
664
|
+
{'search': 'keyword', 'sort': 'name'},
|
|
665
|
+
{'id': 123, 'status': 'active'}
|
|
666
|
+
]
|
|
667
|
+
},
|
|
668
|
+
body: {
|
|
669
|
+
description: 'Request body (optional) - Supports multiple formats: JSON object, form data, or plain text',
|
|
670
|
+
examples: [
|
|
671
|
+
'JSON Object: {"username": "admin", "password": "123456"}',
|
|
672
|
+
'Form Data: "username=admin&password=123456"',
|
|
673
|
+
'Plain Text: "Hello World"',
|
|
674
|
+
'XML: "<user><name>John</name><email>john@example.com</email></user>"'
|
|
675
|
+
]
|
|
676
|
+
},
|
|
677
|
+
contentType: {
|
|
678
|
+
type: 'string',
|
|
679
|
+
description: 'Content-Type for request body (optional, will auto-detect if not specified)',
|
|
680
|
+
examples: [
|
|
681
|
+
'application/json',
|
|
682
|
+
'application/x-www-form-urlencoded',
|
|
683
|
+
'text/plain',
|
|
684
|
+
'application/xml',
|
|
685
|
+
'text/html'
|
|
686
|
+
]
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
required: ['url'],
|
|
690
|
+
examples: [
|
|
691
|
+
{
|
|
692
|
+
description: 'Simple GET request',
|
|
693
|
+
url: '/api/users',
|
|
694
|
+
method: 'GET',
|
|
695
|
+
query: {'page': 1, 'limit': 10}
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
description: 'POST request with JSON body',
|
|
699
|
+
url: '/api/login',
|
|
700
|
+
method: 'POST',
|
|
701
|
+
body: {'username': 'admin', 'password': '123456'},
|
|
702
|
+
headers: {'Content-Type': 'application/json'}
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
description: 'PUT request with form data',
|
|
706
|
+
url: '/api/users/123',
|
|
707
|
+
method: 'PUT',
|
|
708
|
+
body: 'name=John&email=john@example.com',
|
|
709
|
+
contentType: 'application/x-www-form-urlencoded'
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
description: 'POST request with XML body',
|
|
713
|
+
url: '/api/data',
|
|
714
|
+
method: 'POST',
|
|
715
|
+
body: '<data><item>value</item></data>',
|
|
716
|
+
contentType: 'application/xml'
|
|
717
|
+
}
|
|
718
|
+
]
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
// API Config Tool
|
|
723
|
+
tools.push({
|
|
724
|
+
name: 'api_config',
|
|
725
|
+
description: 'API configuration management tool for managing API settings, endpoints, and configurations',
|
|
726
|
+
inputSchema: {
|
|
727
|
+
type: 'object',
|
|
728
|
+
properties: {
|
|
729
|
+
action: {
|
|
730
|
+
type: 'string',
|
|
731
|
+
enum: ['get', 'set', 'updateBaseUrl', 'updateHeaders', 'deleteHeader', 'search', 'list'],
|
|
732
|
+
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'
|
|
733
|
+
},
|
|
545
734
|
config: {
|
|
546
735
|
type: 'object',
|
|
547
|
-
description: 'API
|
|
736
|
+
description: 'API configuration (required for "set" action)',
|
|
548
737
|
properties: {
|
|
549
738
|
baseUrl: {
|
|
550
739
|
type: 'string',
|
|
@@ -556,7 +745,7 @@ class ProjectStandardsMCPServer {
|
|
|
556
745
|
},
|
|
557
746
|
list: {
|
|
558
747
|
type: 'array',
|
|
559
|
-
description: 'List of API endpoints
|
|
748
|
+
description: 'List of API endpoints',
|
|
560
749
|
items: {
|
|
561
750
|
type: 'object',
|
|
562
751
|
properties: {
|
|
@@ -575,45 +764,41 @@ class ProjectStandardsMCPServer {
|
|
|
575
764
|
},
|
|
576
765
|
query: {
|
|
577
766
|
type: 'object',
|
|
578
|
-
description: 'Query parameters
|
|
767
|
+
description: 'Query parameters'
|
|
579
768
|
},
|
|
580
769
|
body: {
|
|
581
|
-
description: 'Request body
|
|
770
|
+
description: 'Request body'
|
|
582
771
|
},
|
|
583
772
|
contentType: {
|
|
584
773
|
type: 'string',
|
|
585
|
-
description: 'Content-Type for request body
|
|
774
|
+
description: 'Content-Type for request body'
|
|
586
775
|
},
|
|
587
776
|
header: {
|
|
588
777
|
type: 'object',
|
|
589
778
|
description: 'Additional headers for this specific request'
|
|
590
779
|
}
|
|
591
780
|
},
|
|
592
|
-
required: ['url'
|
|
781
|
+
required: ['url']
|
|
593
782
|
}
|
|
594
783
|
}
|
|
595
784
|
}
|
|
596
785
|
},
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
keyword: {
|
|
614
|
-
type: 'string',
|
|
615
|
-
description: 'Search keyword to match against URL or description (required for "search" action)'
|
|
616
|
-
}
|
|
786
|
+
baseUrl: {
|
|
787
|
+
type: 'string',
|
|
788
|
+
description: 'New base URL (required for "updateBaseUrl" action)'
|
|
789
|
+
},
|
|
790
|
+
headers: {
|
|
791
|
+
type: 'object',
|
|
792
|
+
description: 'New headers to add or update (required for "updateHeaders" action)'
|
|
793
|
+
},
|
|
794
|
+
headerName: {
|
|
795
|
+
type: 'string',
|
|
796
|
+
description: 'Name of header to delete (required for "deleteHeader" action)'
|
|
797
|
+
},
|
|
798
|
+
keyword: {
|
|
799
|
+
type: 'string',
|
|
800
|
+
description: 'Search keyword (required for "search" action)'
|
|
801
|
+
}
|
|
617
802
|
},
|
|
618
803
|
required: ['action'],
|
|
619
804
|
anyOf: [
|
|
@@ -624,24 +809,15 @@ class ProjectStandardsMCPServer {
|
|
|
624
809
|
},
|
|
625
810
|
{
|
|
626
811
|
properties: {
|
|
627
|
-
action: { const: '
|
|
628
|
-
|
|
629
|
-
},
|
|
630
|
-
required: ['config']
|
|
631
|
-
},
|
|
632
|
-
{
|
|
633
|
-
properties: {
|
|
634
|
-
action: { const: 'delete' },
|
|
635
|
-
url: { type: 'string' }
|
|
636
|
-
},
|
|
637
|
-
required: ['url']
|
|
812
|
+
action: { const: 'list' }
|
|
813
|
+
}
|
|
638
814
|
},
|
|
639
815
|
{
|
|
640
816
|
properties: {
|
|
641
|
-
action: { const: '
|
|
642
|
-
|
|
817
|
+
action: { const: 'set' },
|
|
818
|
+
config: { type: 'object' }
|
|
643
819
|
},
|
|
644
|
-
required: ['
|
|
820
|
+
required: ['config']
|
|
645
821
|
},
|
|
646
822
|
{
|
|
647
823
|
properties: {
|
|
@@ -674,7 +850,8 @@ class ProjectStandardsMCPServer {
|
|
|
674
850
|
]
|
|
675
851
|
}
|
|
676
852
|
});
|
|
677
|
-
|
|
853
|
+
|
|
854
|
+
|
|
678
855
|
result = {
|
|
679
856
|
tools: tools,
|
|
680
857
|
environment: {
|
|
@@ -793,7 +970,7 @@ class ProjectStandardsMCPServer {
|
|
|
793
970
|
if (method === 'notifications/initialized' || method === 'notifications/exit') {
|
|
794
971
|
return null;
|
|
795
972
|
}
|
|
796
|
-
|
|
973
|
+
|
|
797
974
|
// shutdown method needs to return response
|
|
798
975
|
if (method === 'shutdown') {
|
|
799
976
|
return {
|
|
@@ -812,12 +989,12 @@ class ProjectStandardsMCPServer {
|
|
|
812
989
|
// Use standard MCP error codes
|
|
813
990
|
let errorCode = -32603; // Internal error
|
|
814
991
|
let errorMessage = error.message;
|
|
815
|
-
|
|
992
|
+
|
|
816
993
|
if (error.message.includes('Server not initialized')) {
|
|
817
994
|
errorCode = -32002; // Server not initialized
|
|
818
995
|
} else if (error.message.includes('Unknown method')) {
|
|
819
996
|
errorCode = -32601; // Method not found
|
|
820
|
-
} else
|
|
997
|
+
} else if (error.message.includes('Unsupported JSON-RPC version')) {
|
|
821
998
|
errorCode = -32600; // Invalid Request
|
|
822
999
|
}
|
|
823
1000
|
return {
|