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

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.0.1",
3
+ "version": "2.0.2",
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": {
@@ -1,98 +1,3 @@
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
-
96
1
  const fs = require('fs-extra');
97
2
  const path = require('path');
98
3
 
@@ -105,6 +10,7 @@ const database_standards = require('./utils/database_standards');
105
10
  const api_login = require('./utils/api_login');
106
11
  const api_debug = require('./utils/api_debug');
107
12
  const api_config = require('./utils/api_config');
13
+ const api_help = require('./utils/api_help');
108
14
 
109
15
  // Get configuration from file or environment
110
16
  const getConfig = () => {
@@ -274,6 +180,12 @@ class ProjectStandardsMCPServer {
274
180
  return result;
275
181
  }
276
182
 
183
+ // API help tool
184
+ async api_help(params) {
185
+ const result = await api_help(params, this.config, saveConfig);
186
+ return result;
187
+ }
188
+
277
189
 
278
190
 
279
191
 
@@ -617,7 +529,7 @@ class ProjectStandardsMCPServer {
617
529
  // API Login Tool
618
530
  tools.push({
619
531
  name: 'api_login',
620
- description: 'API login authentication tool that uses environment variables for login credentials',
532
+ description: 'API login authentication tool that uses environment variables for login credentials. Automatically extracts token from response and updates Authorization headers. Example: Call with optional baseUrl parameter to override default base URL',
621
533
  inputSchema: {
622
534
  type: 'object',
623
535
  properties: {
@@ -632,7 +544,7 @@ class ProjectStandardsMCPServer {
632
544
  // API Debug Tool
633
545
  tools.push({
634
546
  name: 'api_debug',
635
- description: 'API debugging tool for directly executing API requests with automatic content-type detection and flexible body format support',
547
+ description: 'API debugging tool for directly executing API requests with automatic content-type detection and flexible body format support. Examples: GET /api/users with query params, POST /api/login with JSON body {"username":"admin","password":"123456"}, PUT /api/users/123 with form data "name=John&email=john@example.com"',
636
548
  inputSchema: {
637
549
  type: 'object',
638
550
  properties: {
@@ -719,10 +631,26 @@ class ProjectStandardsMCPServer {
719
631
  }
720
632
  });
721
633
 
634
+ // API Help Tool
635
+ tools.push({
636
+ name: 'api_help',
637
+ description: 'API help tool that provides detailed documentation and examples for all API debugging tools. Use this to understand how to use api_debug, api_login, and api_config tools effectively',
638
+ inputSchema: {
639
+ type: 'object',
640
+ properties: {
641
+ tool: {
642
+ type: 'string',
643
+ description: 'Specific tool name to get help for (optional: api_debug, api_login, api_config)',
644
+ examples: ['api_debug', 'api_login', 'api_config']
645
+ }
646
+ }
647
+ }
648
+ });
649
+
722
650
  // API Config Tool
723
651
  tools.push({
724
652
  name: 'api_config',
725
- description: 'API configuration management tool for managing API settings, endpoints, and configurations',
653
+ description: 'API configuration management tool for managing API settings, endpoints, and configurations. Examples: get config, set baseUrl to "https://api.example.com", updateHeaders with {"Authorization":"Bearer token"}, search APIs by keyword, list all configured APIs',
726
654
  inputSchema: {
727
655
  type: 'object',
728
656
  properties: {
@@ -0,0 +1,169 @@
1
+ /**
2
+ * API 帮助工具 - 返回API调试工具的详细说明和示例
3
+ * @param {Object} params - 参数
4
+ * @param {string} params.tool - 要查看的工具名称(可选,默认返回所有工具)
5
+ * @param {Object} config - 服务器配置
6
+ * @param {Function} saveConfig - 保存配置函数
7
+ * @returns {Object} 工具说明和示例
8
+ */
9
+ async function api_help(params, config, saveConfig) {
10
+ const { tool } = params || {};
11
+
12
+ const helpContent = {
13
+ api_debug: {
14
+ name: 'api_debug',
15
+ description: 'API调试工具 - 直接执行API请求',
16
+ usage: '直接传入URL和参数即可执行API请求,无需复杂的action参数',
17
+ supportedFormats: [
18
+ 'JSON对象: {"username": "admin", "password": "123456"}',
19
+ '表单数据: "username=admin&password=123456"',
20
+ '纯文本: "Hello World"',
21
+ 'XML: "<user><name>John</name><email>john@example.com</email></user>"',
22
+ 'HTML: "<html><body>Content</body></html>"'
23
+ ],
24
+ autoContentTypeDetection: {
25
+ 'JSON对象': 'application/json',
26
+ '表单数据': 'application/x-www-form-urlencoded',
27
+ 'XML': 'application/xml',
28
+ 'HTML': 'text/html',
29
+ '纯文本': 'text/plain'
30
+ },
31
+ examples: [
32
+ {
33
+ description: '简单GET请求',
34
+ request: {
35
+ url: '/api/users',
36
+ method: 'GET',
37
+ query: { page: 1, limit: 10 }
38
+ }
39
+ },
40
+ {
41
+ description: 'POST请求带JSON体',
42
+ request: {
43
+ url: '/api/login',
44
+ method: 'POST',
45
+ body: { username: 'admin', password: '123456' },
46
+ headers: { 'Content-Type': 'application/json' }
47
+ }
48
+ },
49
+ {
50
+ description: 'PUT请求带表单数据',
51
+ request: {
52
+ url: '/api/users/123',
53
+ method: 'PUT',
54
+ body: 'name=John&email=john@example.com',
55
+ contentType: 'application/x-www-form-urlencoded'
56
+ }
57
+ },
58
+ {
59
+ description: 'DELETE请求带认证',
60
+ request: {
61
+ url: '/api/users/123',
62
+ method: 'DELETE',
63
+ headers: { 'Authorization': 'Bearer token123' }
64
+ }
65
+ }
66
+ ],
67
+ bestPractices: [
68
+ '使用相对URL: /api/endpoint 而不是完整URL',
69
+ '通过api_config工具设置baseUrl',
70
+ '让工具自动检测内容类型,除非有特殊需求',
71
+ 'GET请求使用query参数而不是body',
72
+ '通过headers参数设置认证信息'
73
+ ]
74
+ },
75
+ api_login: {
76
+ name: 'api_login',
77
+ description: 'API登录工具 - 使用环境变量进行登录认证',
78
+ usage: '无需参数,直接从环境变量获取登录信息',
79
+ environmentVariables: {
80
+ 'API_DEBUG_LOGIN_URL': '登录接口URL(默认: /api/login)',
81
+ 'API_DEBUG_LOGIN_METHOD': '登录请求方法(默认: POST)',
82
+ 'API_DEBUG_LOGIN_BODY': '登录请求体模板(支持JSON和字符串格式)',
83
+ 'API_DEBUG_LOGIN_DESCRIPTION': '登录接口描述'
84
+ },
85
+ features: [
86
+ '自动从环境变量获取登录配置',
87
+ '支持JSON和字符串格式的登录体',
88
+ '自动提取token并更新Authorization头',
89
+ '支持自定义baseUrl参数'
90
+ ],
91
+ examples: [
92
+ {
93
+ description: '基本登录(使用环境变量配置)',
94
+ request: {}
95
+ },
96
+ {
97
+ description: '指定baseUrl的登录',
98
+ request: {
99
+ baseUrl: 'https://api.example.com'
100
+ }
101
+ }
102
+ ]
103
+ },
104
+ api_config: {
105
+ name: 'api_config',
106
+ description: 'API配置管理工具 - 管理全局API配置',
107
+ usage: '使用action参数指定操作类型',
108
+ actions: {
109
+ 'get': '获取当前配置',
110
+ 'set': '设置完整配置',
111
+ 'updateBaseUrl': '更新基础URL',
112
+ 'updateHeaders': '更新请求头',
113
+ 'deleteHeader': '删除指定请求头',
114
+ 'search': '搜索API',
115
+ 'list': '列出所有API'
116
+ },
117
+ examples: [
118
+ {
119
+ description: '获取配置',
120
+ request: { action: 'get' }
121
+ },
122
+ {
123
+ description: '更新基础URL',
124
+ request: {
125
+ action: 'updateBaseUrl',
126
+ baseUrl: 'https://api.example.com'
127
+ }
128
+ },
129
+ {
130
+ description: '更新请求头',
131
+ request: {
132
+ action: 'updateHeaders',
133
+ headers: { 'Authorization': 'Bearer token123' }
134
+ }
135
+ },
136
+ {
137
+ description: '搜索API',
138
+ request: {
139
+ action: 'search',
140
+ keyword: 'user'
141
+ }
142
+ }
143
+ ]
144
+ }
145
+ };
146
+
147
+ if (tool && helpContent[tool]) {
148
+ return {
149
+ success: true,
150
+ tool: helpContent[tool],
151
+ timestamp: new Date().toISOString()
152
+ };
153
+ } else {
154
+ return {
155
+ success: true,
156
+ message: 'API调试工具帮助文档',
157
+ tools: helpContent,
158
+ quickStart: {
159
+ '1. 设置配置': '使用 api_config 工具设置 baseUrl 和 headers',
160
+ '2. 登录认证': '使用 api_login 工具进行登录(如果需要)',
161
+ '3. 调试API': '使用 api_debug 工具执行API请求',
162
+ '4. 查看帮助': '使用 api_help 工具查看详细说明'
163
+ },
164
+ timestamp: new Date().toISOString()
165
+ };
166
+ }
167
+ }
168
+
169
+ module.exports = api_help;