@liangshanli/mcp-server-project-standards 3.0.2 → 5.1.0

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,17 @@ A MCP (Model Context Protocol) server for project standards management, designed
4
4
 
5
5
  ## 📋 Version Updates
6
6
 
7
+ ### v5.1.0 (2025-12-22)
8
+ - **New Tool**: Added `download_file` tool to download files from URL to project path.
9
+ - **Version Sync**: Updated server and package versions to 5.1.0.
10
+
11
+ ### v5.0.0 (2025-12-19) - Major Release
12
+ - **Project Path Support**: Added `PROJECT_PATH` environment variable for resolving relative paths.
13
+ - **Cursor Detection**: Automatic identification of Cursor IDE for enhanced features.
14
+ - **New Tools**: Added `list_directory`, `generate_cursorrules`, and `generate_rules`.
15
+ - **AI Guidance**: Integrated AI Enforcement Rules into rule generation templates.
16
+ - **Security**: Added path validation for directory listing.
17
+
7
18
  ### v3.0.0 (2025-10-31) - Major Release
8
19
 
9
20
  #### 🚀 Breaking Changes
@@ -78,6 +89,10 @@ A MCP (Model Context Protocol) server for project standards management, designed
78
89
 
79
90
  ## 🚀 Core Advantages
80
91
 
92
+ ### 💰 Token Cost Optimization
93
+ - **Efficient Context Caching**: By using MCP tools to retrieve short, structured standard data instead of reading long documents, it triggers model Context Caching more effectively (e.g., Gemini 3 Flash), significantly reducing input costs (down to $0.05/1M).
94
+ - **Incremental Output**: Enforces minimal code diffs and precise tool responses, minimizing high-cost output token consumption.
95
+
81
96
  ### 🎯 Solving Multi-Machine Development Chaos
82
97
  - **Unified Standards**: AI assistants on multiple machines use the same project standards, avoiding inconsistent development styles
83
98
  - **Team Collaboration**: Eliminates code style differences caused by different developers using different AI configurations
@@ -104,6 +119,7 @@ A MCP (Model Context Protocol) server for project standards management, designed
104
119
  - ✅ **Configuration Management** - JSON-based configuration storage and management
105
120
  - ✅ **Auto-Restart** - Intelligent process management and fault recovery
106
121
  - ✅ **Health Checks** - Real-time service status and performance monitoring
122
+ - ✅ **File Downloader** - Download files from URLs directly to the project directory
107
123
 
108
124
  ## 🎯 Application Scenarios
109
125
 
@@ -149,7 +165,8 @@ The server uses the `./.setting/` directory to store configuration files by defa
149
165
 
150
166
  | Variable | Default | Description | Example |
151
167
  |----------|---------|-------------|---------|
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"` |
168
+ | PROJECT_PATH | . | Root path of the project. Supports both absolute (e.g., `/` or `C:\`) and relative paths. Used to resolve all relative paths. | `export PROJECT_PATH="/path/to/project"` |
169
+ | CONFIG_DIR | ./.setting or ./.setting.<TOOL_PREFIX> | Configuration directory. Resolved relative to PROJECT_PATH. | `export CONFIG_DIR="./config"` |
153
170
  | TOOL_PREFIX | | Optional tool prefix for tool names and config isolation | `export TOOL_PREFIX="projA"` |
154
171
  | PROJECT_NAME | | Optional project branding for tool descriptions | `export PROJECT_NAME="MyProject"` |
155
172
  | API_DEBUG_ALLOWED_METHODS | GET | Control allowed request methods (supports: GET,POST,PUT,DELETE,PATCH, etc.) | `export API_DEBUG_ALLOWED_METHODS="GET,POST"` |
@@ -247,6 +264,7 @@ npm run dev
247
264
  "command": "npx",
248
265
  "args": ["@liangshanli/mcp-server-project-standards"],
249
266
  "env": {
267
+ "PROJECT_PATH": ".",
250
268
  "CONFIG_DIR": "./.setting",
251
269
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
252
270
  "API_DEBUG_LOGIN_URL": "/api/login",
@@ -268,6 +286,7 @@ npm run dev
268
286
  "command": "npx",
269
287
  "args": ["@liangshanli/mcp-server-project-standards"],
270
288
  "env": {
289
+ "PROJECT_PATH": ".",
271
290
  "TOOL_PREFIX": "projA",
272
291
  "PROJECT_NAME": "Project A",
273
292
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
@@ -280,6 +299,7 @@ npm run dev
280
299
  "command": "npx",
281
300
  "args": ["@liangshanli/mcp-server-project-standards"],
282
301
  "env": {
302
+ "PROJECT_PATH": ".",
283
303
  "TOOL_PREFIX": "projB",
284
304
  "PROJECT_NAME": "Project B",
285
305
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
@@ -303,6 +323,7 @@ npm run dev
303
323
  "command": "npx",
304
324
  "args": ["@liangshanli/mcp-server-project-standards"],
305
325
  "env": {
326
+ "PROJECT_PATH": ".",
306
327
  "CONFIG_DIR": "./.setting",
307
328
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
308
329
  "API_DEBUG_LOGIN_URL": "/api/login",
@@ -323,6 +344,7 @@ npm run dev
323
344
  "command": "npx",
324
345
  "args": ["@liangshanli/mcp-server-project-standards"],
325
346
  "env": {
347
+ "PROJECT_PATH": ".",
326
348
  "TOOL_PREFIX": "projA",
327
349
  "PROJECT_NAME": "Project A",
328
350
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
@@ -335,6 +357,7 @@ npm run dev
335
357
  "command": "npx",
336
358
  "args": ["@liangshanli/mcp-server-project-standards"],
337
359
  "env": {
360
+ "PROJECT_PATH": ".",
338
361
  "TOOL_PREFIX": "projB",
339
362
  "PROJECT_NAME": "Project B",
340
363
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
@@ -544,6 +567,72 @@ The API debugging tool supports a complete login authentication flow, making it
544
567
 
545
568
  This design eliminates the need for manual authentication state management, as the tool automatically handles login and token updates, greatly simplifying the API debugging process!
546
569
 
570
+ ### 7. Directory Listing (list_directory)
571
+ Recursively explores the directory structure relative to the project root.
572
+
573
+ **Parameters:**
574
+ - `path` (optional): Subdirectory path to list.
575
+ - `depth` (optional): Max recursion depth (default: 2).
576
+
577
+ **Example:**
578
+ ```json
579
+ {
580
+ "jsonrpc": "2.0",
581
+ "id": 10,
582
+ "method": "tools/call",
583
+ "params": {
584
+ "name": "list_directory",
585
+ "arguments": {
586
+ "depth": 3
587
+ }
588
+ }
589
+ }
590
+ ```
591
+
592
+ ### 8. Rule Generation (generate_cursorrules / generate_rules)
593
+ Generates AI project guidance files (`.cursorrules` for Cursor, `PROJECT_RULES.md` for others) based on your standards.
594
+
595
+ **Parameters:**
596
+ - `save` (optional): Whether to save content to disk (default: false).
597
+
598
+ **Example:**
599
+ ```json
600
+ {
601
+ "jsonrpc": "2.0",
602
+ "id": 11,
603
+ "method": "tools/call",
604
+ "params": {
605
+ "name": "generate_cursorrules",
606
+ "arguments": {
607
+ "save": true
608
+ }
609
+ }
610
+ }
611
+ ```
612
+
613
+ ### 9. File Download Tool (download_file)
614
+ Download a file from a URL and save it to a specified path within the project.
615
+
616
+ **Parameters:**
617
+ - `url` (required): The URL of the file to download.
618
+ - `savePath` (required): The path where the file should be saved (relative to project path or absolute).
619
+
620
+ **Example:**
621
+ ```json
622
+ {
623
+ "jsonrpc": "2.0",
624
+ "id": 12,
625
+ "method": "tools/call",
626
+ "params": {
627
+ "name": "download_file",
628
+ "arguments": {
629
+ "url": "https://example.com/logo.png",
630
+ "savePath": "assets/logo.png"
631
+ }
632
+ }
633
+ }
634
+ ```
635
+
547
636
  ## 🔗 Related Tools for Collaborative Use
548
637
 
549
638
  To provide a more complete development experience, we recommend using the following MCP tools in collaboration:
package/README.zh-CN.md CHANGED
@@ -4,6 +4,17 @@
4
4
 
5
5
  ## 📋 版本更新说明
6
6
 
7
+ ### v5.1.0 (2025-12-22)
8
+ - **新增工具**:新增 `download_file` 工具,支持从 URL 下载文件到项目目录。
9
+ - **版本同步**:服务器和包版本更新至 5.1.0。
10
+
11
+ ### v5.0.0 (2025-12-19) - 重大更新
12
+ - **项目路径支持**:新增 `PROJECT_PATH` 环境变量,支持相对于项目根目录解析路径。
13
+ - **Cursor 自动识别**:初始化时自动识别 Cursor 编辑器,开启环境特有的增强模式。
14
+ - **新增工具**:新增 `list_directory`、`generate_cursorrules` 及 `generate_rules` 工具。
15
+ - **AI 行为准则**:在规则生成模板中集成了完善的 AI 行为准则与强制执行逻辑。
16
+ - **安全性增强**:为目录扫描工具增加了路径越界校验。
17
+
7
18
  ### v3.0.0 (2025-10-31) - 重大更新
8
19
 
9
20
  #### 🚀 破坏性变更
@@ -62,6 +73,10 @@
62
73
 
63
74
  ## 🚀 核心优势
64
75
 
76
+ ### 💰 Token 成本优化
77
+ - **高效 Context Caching**:通过 MCP 工具获取短小、结构化的标准数据而非读取冗长文档,能更有效地触发模型的 Context Caching(上下文缓存,如 Gemini 3 Flash),将输入成本降低至极低水平(约 $0.05/1M)。
78
+ - **增量式输出**:强制执行最小化代码 Diff 和精简的工具响应,最大限度减少高昂的输出 Token 消耗。
79
+
65
80
  ### 🎯 解决多机器开发混乱问题
66
81
  - **统一标准**:多台机器上的 AI 助手使用相同的项目标准,避免开发风格不一致
67
82
  - **团队协作**:消除因不同开发者使用不同 AI 配置导致的代码风格差异
@@ -88,6 +103,7 @@
88
103
  - ✅ **配置管理** - 基于 JSON 文件的配置存储和管理
89
104
  - ✅ **自动重启** - 智能的进程管理和故障恢复
90
105
  - ✅ **健康检查** - 实时监控服务状态和性能
106
+ - ✅ **文件下载** - 支持从 URL 直接下载文件到项目目录
91
107
 
92
108
  ## 🎯 应用场景
93
109
 
@@ -133,7 +149,8 @@ npm install
133
149
 
134
150
  | 变量名 | 默认值 | 描述 | 示例 |
135
151
  |--------|--------|------|------|
136
- | CONFIG_DIR | ./.setting 或 ./.setting.<TOOL_PREFIX> | 配置目录。若设置则直接使用;否则若设置了 TOOL_PREFIX 则使用 ./.setting.<TOOL_PREFIX>;否则 ./.setting | `export CONFIG_DIR="./config"` |
152
+ | PROJECT_PATH | . | 项目根路径。支持绝对路径(如 `/` `C:\`)和相对路径。用于解析所有相对路径。 | `export PROJECT_PATH="/path/to/project"` |
153
+ | CONFIG_DIR | ./.setting 或 ./.setting.<TOOL_PREFIX> | 配置目录。相对于 PROJECT_PATH 解析。 | `export CONFIG_DIR="./config"` |
137
154
  | TOOL_PREFIX | | 工具名前缀,同时用于多项目配置隔离 | `export TOOL_PREFIX="projA"` |
138
155
  | PROJECT_NAME | | 工具描述前添加项目名称用于标识 | `export PROJECT_NAME="MyProject"` |
139
156
  | API_DEBUG_ALLOWED_METHODS | GET | 控制允许的请求方法(支持:GET,POST,PUT,DELETE,PATCH等) | `export API_DEBUG_ALLOWED_METHODS="GET,POST"` |
@@ -231,6 +248,7 @@ npm run dev
231
248
  "command": "npx",
232
249
  "args": ["@liangshanli/mcp-server-project-standards"],
233
250
  "env": {
251
+ "PROJECT_PATH": ".",
234
252
  "CONFIG_DIR": "./.setting",
235
253
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
236
254
  "API_DEBUG_LOGIN_URL": "/api/login",
@@ -252,6 +270,7 @@ npm run dev
252
270
  "command": "npx",
253
271
  "args": ["@liangshanli/mcp-server-project-standards"],
254
272
  "env": {
273
+ "PROJECT_PATH": ".",
255
274
  "TOOL_PREFIX": "projA",
256
275
  "PROJECT_NAME": "项目A",
257
276
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
@@ -264,6 +283,7 @@ npm run dev
264
283
  "command": "npx",
265
284
  "args": ["@liangshanli/mcp-server-project-standards"],
266
285
  "env": {
286
+ "PROJECT_PATH": ".",
267
287
  "TOOL_PREFIX": "projB",
268
288
  "PROJECT_NAME": "项目B",
269
289
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
@@ -287,6 +307,7 @@ npm run dev
287
307
  "command": "npx",
288
308
  "args": ["@liangshanli/mcp-server-project-standards"],
289
309
  "env": {
310
+ "PROJECT_PATH": ".",
290
311
  "CONFIG_DIR": "./.setting",
291
312
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
292
313
  "API_DEBUG_LOGIN_URL": "/api/login",
@@ -307,6 +328,7 @@ npm run dev
307
328
  "command": "npx",
308
329
  "args": ["@liangshanli/mcp-server-project-standards"],
309
330
  "env": {
331
+ "PROJECT_PATH": ".",
310
332
  "TOOL_PREFIX": "projA",
311
333
  "PROJECT_NAME": "项目A",
312
334
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
@@ -319,6 +341,7 @@ npm run dev
319
341
  "command": "npx",
320
342
  "args": ["@liangshanli/mcp-server-project-standards"],
321
343
  "env": {
344
+ "PROJECT_PATH": ".",
322
345
  "TOOL_PREFIX": "projB",
323
346
  "PROJECT_NAME": "项目B",
324
347
  "API_DEBUG_ALLOWED_METHODS": "GET,POST,PUT,DELETE",
@@ -532,6 +555,72 @@ API 调试工具支持完整的登录认证流程,让您轻松管理 API 访
532
555
 
533
556
  这样设计让您无需手动管理认证状态,工具会自动处理登录和 token 更新,大大简化了 API 调试流程!
534
557
 
558
+ ### 7. 目录列表工具 (list_directory)
559
+ 递归地探索相对于项目根目录的目录结构。
560
+
561
+ **参数:**
562
+ - `path` (可选): 要列出的子目录路径。
563
+ - `depth` (可选): 最大递归深度(默认:2)。
564
+
565
+ **使用示例:**
566
+ ```json
567
+ {
568
+ "jsonrpc": "2.0",
569
+ "id": 10,
570
+ "method": "tools/call",
571
+ "params": {
572
+ "name": "list_directory",
573
+ "arguments": {
574
+ "depth": 3
575
+ }
576
+ }
577
+ }
578
+ ```
579
+
580
+ ### 8. 规则生成工具 (generate_cursorrules / generate_rules)
581
+ 根据您的标准生成 AI 项目指导文件(Cursor 使用 `.cursorrules`,其他客户端使用 `PROJECT_RULES.md`)。
582
+
583
+ **参数:**
584
+ - `save` (可选): 是否将内容保存到磁盘(默认:false)。
585
+
586
+ **使用示例:**
587
+ ```json
588
+ {
589
+ "jsonrpc": "2.0",
590
+ "id": 11,
591
+ "method": "tools/call",
592
+ "params": {
593
+ "name": "generate_cursorrules",
594
+ "arguments": {
595
+ "save": true
596
+ }
597
+ }
598
+ }
599
+ ```
600
+
601
+ ### 9. 文件下载工具 (download_file)
602
+ 从指定的 URL 下载文件并保存到项目路径中的指定位置。
603
+
604
+ **参数:**
605
+ - `url` (必需): 要下载的文件的 URL。
606
+ - `savePath` (必需): 文件保存路径(相对于项目路径或绝对路径)。
607
+
608
+ **使用示例:**
609
+ ```json
610
+ {
611
+ "jsonrpc": "2.0",
612
+ "id": 12,
613
+ "method": "tools/call",
614
+ "params": {
615
+ "name": "download_file",
616
+ "arguments": {
617
+ "url": "https://example.com/logo.png",
618
+ "savePath": "assets/logo.png"
619
+ }
620
+ }
621
+ }
622
+ ```
623
+
535
624
  ## 🔗 相关工具协同使用
536
625
 
537
626
  为了提供更完整的开发体验,推荐与以下 MCP 工具协同使用:
package/bin/cli.js CHANGED
@@ -3,7 +3,7 @@ const { spawn } = require('child_process');
3
3
  const path = require('path');
4
4
  const fs = require('fs');
5
5
 
6
- // 简单日志输出
6
+ // Simple log output
7
7
  const writeLog = (level, message, data = null) => {
8
8
  console.error(`[${level}] ${message}`);
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liangshanli/mcp-server-project-standards",
3
- "version": "3.0.2",
3
+ "version": "5.1.0",
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": {
@@ -12,16 +12,29 @@ const api_debug = require('./utils/api_debug');
12
12
  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
+ const list_directory = require('./utils/list_directory');
16
+ const generate_cursorrules = require('./utils/generate_cursorrules');
17
+ const download_file = require('./utils/download_file');
15
18
 
16
19
  // Get config directory based on CONFIG_DIR and TOOL_PREFIX
17
20
  const getConfigDir = () => {
18
21
  let configDir = process.env.CONFIG_DIR;
22
+ // If PROJECT_PATH is null and client is Cursor, default to '.', otherwise null
23
+ const projectPath = process.env.PROJECT_PATH || (global.isCursor ? '.' : null);
24
+
19
25
  if (!configDir) {
20
26
  const toolPrefix = process.env.TOOL_PREFIX || '';
27
+ // Configuration location: under project path if available, otherwise current directory
28
+ const baseDir = projectPath || '.';
21
29
  if (toolPrefix) {
22
- configDir = `./.setting.${toolPrefix}`;
30
+ configDir = path.resolve(baseDir, `.setting.${toolPrefix}`);
23
31
  } else {
24
- configDir = './.setting';
32
+ configDir = path.resolve(baseDir, '.setting');
33
+ }
34
+ } else if (projectPath) {
35
+ // If CONFIG_DIR is set, make it absolute or relative to projectPath if not already absolute
36
+ if (!path.isAbsolute(configDir)) {
37
+ configDir = path.resolve(projectPath, configDir);
25
38
  }
26
39
  }
27
40
  return configDir;
@@ -62,40 +75,44 @@ const saveConfig = (config) => {
62
75
  }
63
76
  };
64
77
 
65
- // 启动日志
78
+ // Startup logs
66
79
  console.error('=== MCP Project Standards Server Starting ===');
67
80
  console.error(`Time: ${new Date().toISOString()}`);
81
+ console.error(`Project Path: ${process.env.PROJECT_PATH || '.'}`);
68
82
  console.error(`Config Dir: ${getConfigDir()}`);
69
83
  console.error('==============================================');
70
84
 
85
+ // Global state
86
+ global.isCursor = false;
87
+
71
88
  // Final MCP Server
72
89
  class ProjectStandardsMCPServer {
73
90
  constructor() {
74
91
  this.name = 'project-standards-mcp-server';
75
- this.version = '1.2.2';
92
+ this.version = '5.1.0';
76
93
  this.initialized = false;
77
94
  this.config = getConfig();
78
95
  this.needsProjectFolder = this.config === null;
79
96
 
80
- // 如果配置文件不存在,创建默认配置
97
+ // Create default config if config file doesn't exist
81
98
  if (this.needsProjectFolder) {
82
99
  this.createDefaultConfig();
83
100
  }
84
101
  }
85
102
 
86
- // 创建默认配置文件
103
+ // Create default config file
87
104
  createDefaultConfig() {
88
105
  const configDir = getConfigDir();
89
106
  const configPath = path.join(configDir, 'config.json');
90
107
 
91
108
  try {
92
- // 创建配置目录
109
+ // Create config directory
93
110
  if (!fs.existsSync(configDir)) {
94
111
  fs.mkdirSync(configDir, { recursive: true });
95
112
  console.error(`Created config directory: ${configDir}`);
96
113
  }
97
114
 
98
- // 创建默认配置文件
115
+ // Create default config file
99
116
  const defaultConfig = {
100
117
  project_info: {},
101
118
  project_structure: [],
@@ -107,12 +124,12 @@ class ProjectStandardsMCPServer {
107
124
  fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), 'utf8');
108
125
  console.error(`Created default config file: ${configPath}`);
109
126
 
110
- // 更新配置和状态
127
+ // Update config and state
111
128
  this.config = defaultConfig;
112
129
  this.needsProjectFolder = false;
113
130
  } catch (err) {
114
131
  console.error('Failed to create default config:', err.message);
115
- // 保持 needsProjectFolder = true 状态
132
+ // Keep needsProjectFolder = true state
116
133
  }
117
134
  }
118
135
 
@@ -197,8 +214,29 @@ class ProjectStandardsMCPServer {
197
214
  return result;
198
215
  }
199
216
 
217
+ // List directory tool
218
+ async list_directory(params) {
219
+ const result = await list_directory(params);
220
+ return result;
221
+ }
222
+
223
+ // Generate cursorrules tool
224
+ async generate_cursorrules(params) {
225
+ const result = await generate_cursorrules(params, this.config);
226
+ return result;
227
+ }
200
228
 
229
+ // Generate rules tool (for non-cursor)
230
+ async generate_rules(params) {
231
+ const result = await generate_cursorrules(params, this.config);
232
+ return result;
233
+ }
201
234
 
235
+ // Download file tool
236
+ async download_file(params) {
237
+ const result = await download_file(params);
238
+ return result;
239
+ }
202
240
 
203
241
  // Handle JSON-RPC requests
204
242
  async handleRequest(request) {
@@ -214,6 +252,11 @@ class ProjectStandardsMCPServer {
214
252
 
215
253
  try {
216
254
  if (method === 'initialize') {
255
+ // Detect Cursor client
256
+ const clientName = params?.clientInfo?.name || '';
257
+ global.isCursor = clientName.toLowerCase().includes('cursor');
258
+ console.error(`Client identified: ${clientName} (isCursor: ${global.isCursor})`);
259
+
217
260
  // If already initialized, return success but don't re-initialize
218
261
  if (!this.initialized) {
219
262
  this.initialized = true;
@@ -704,6 +747,26 @@ class ProjectStandardsMCPServer {
704
747
  }
705
748
  });
706
749
 
750
+ // Download File Tool
751
+ tools.push({
752
+ name: 'download_file',
753
+ description: 'Download a file from a URL and save it to a specified path. Supported schemes: http, https.',
754
+ inputSchema: {
755
+ type: 'object',
756
+ properties: {
757
+ url: {
758
+ type: 'string',
759
+ description: 'The URL of the file to download (required)'
760
+ },
761
+ savePath: {
762
+ type: 'string',
763
+ description: 'The path where the file should be saved (relative to project path or absolute, required)'
764
+ }
765
+ },
766
+ required: ['url', 'savePath']
767
+ }
768
+ });
769
+
707
770
  // API Config Tool
708
771
  tools.push({
709
772
  name: 'api_config',
@@ -878,6 +941,63 @@ class ProjectStandardsMCPServer {
878
941
  }
879
942
  });
880
943
 
944
+ // Check whether to show project structure related tools
945
+ const projectPath = process.env.PROJECT_PATH || (global.isCursor ? '.' : null);
946
+ const showStructureTools = !!projectPath;
947
+
948
+ if (showStructureTools) {
949
+ // List Directory Tool
950
+ tools.push({
951
+ name: 'list_directory',
952
+ description: 'List directory structure relative to the project path. Returns a tree of files and directories.',
953
+ inputSchema: {
954
+ type: 'object',
955
+ properties: {
956
+ path: {
957
+ type: 'string',
958
+ description: 'Subdirectory path to list (relative to project path, optional)'
959
+ },
960
+ depth: {
961
+ type: 'number',
962
+ description: 'Max depth to traverse (default: 2, optional)'
963
+ }
964
+ }
965
+ }
966
+ });
967
+
968
+ if (global.isCursor) {
969
+ // Generate Cursor Rules Tool
970
+ tools.push({
971
+ name: 'generate_cursorrules',
972
+ description: 'Generate .cursorrules content based on project standards. Returns content and save path for user confirmation.',
973
+ inputSchema: {
974
+ type: 'object',
975
+ properties: {
976
+ save: {
977
+ type: 'boolean',
978
+ description: 'Whether to save to .cursorrules file (default: false)'
979
+ }
980
+ }
981
+ }
982
+ });
983
+ } else {
984
+ // Generate General Rules Tool
985
+ tools.push({
986
+ name: 'generate_rules',
987
+ description: 'Generate project rules content based on standards. Returns content and suggested save path for user confirmation.',
988
+ inputSchema: {
989
+ type: 'object',
990
+ properties: {
991
+ save: {
992
+ type: 'boolean',
993
+ description: 'Whether to save to rules file (default: false)'
994
+ }
995
+ }
996
+ }
997
+ });
998
+ }
999
+ }
1000
+
881
1001
  // Apply tool prefix and project name if both provided
882
1002
  const toolPrefix = process.env.TOOL_PREFIX || '';
883
1003
  const projectName = process.env.PROJECT_NAME || '';
@@ -79,16 +79,16 @@ const getLoginMethod = () => {
79
79
  const getLoginBody = () => {
80
80
  const envBody = process.env.API_DEBUG_LOGIN_BODY || '{"username":"","password":""}';
81
81
 
82
- // 如果是字符串格式,直接返回
82
+ // If it is a string format, return it directly
83
83
  if (typeof envBody === 'string' && !envBody.startsWith('{')) {
84
84
  return envBody;
85
85
  }
86
86
 
87
- // 如果是JSON格式,解析后返回
87
+ // If it is JSON format, parse and return it
88
88
  try {
89
89
  return JSON.parse(envBody);
90
90
  } catch {
91
- // 如果解析失败,返回原始字符串
91
+ // If parsing fails, return the original string
92
92
  return envBody;
93
93
  }
94
94
  };