fileditor-mcp 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 bluetooth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # FileEditor MCP Server
2
+
3
+ [πŸ“– English Interface Doc](docs/MCP-INTERFACE.en.md) | [πŸ“– δΈ­ζ–‡ζŽ₯口文摣](docs/MCP-INTERFACE.cn.md) | [πŸ“‹ δΈ­ζ–‡README](docs/README.cn.md)
4
+
5
+ **AI-Optimized File Operations Server** - Built on Model Context Protocol, specifically engineered for AI coding assistants to perform sophisticated code editing, refactoring, and batch modification tasks with precision and efficiency.
6
+
7
+ ## 🎯 Design Philosophy
8
+
9
+ **Built for AI Programming** - This project is specifically designed for AI models' code editing requirements, providing precise block-level operations, intelligent matching algorithms, and batch processing capabilities that enable AI to safely and efficiently execute complex code modification tasks.
10
+
11
+ ## πŸš€ Core Features
12
+
13
+ ### πŸ“ File Operation Tools (7 Tools)
14
+ - **`set_workspace`** - Workspace isolation (must be called first)
15
+ - **`read_files`** - Smart file reading (batch, line ranges, with line numbers)
16
+ - **`write_files`** - Batch file writing (single/multiple files, create/overwrite)
17
+ - **`list_files`** - Directory traversal (recursive support)
18
+ - **`insert_contents`** - Precise content insertion (multiple files, negative line numbers, end insertion)
19
+ - **`apply_diffs`** - **Advanced diff application** (batch operations, atomic mode, intelligent whitespace handling)
20
+ - **`search_and_replace`** - Pattern replacement (regex, line ranges, case-insensitive)
21
+
22
+ ### πŸ”’ Security Features
23
+ - **Workspace Isolation**: Strictly limit operation scope, prevent directory traversal attacks
24
+ - **Path Security**: Automatic validation and resolution of relative paths
25
+ - **Atomic Operations**: Batch modifications succeed completely or rollback entirely
26
+
27
+ ### ⚑ AI-Optimized Features
28
+ - **Batch Processing Engine**: Handle multiple file operations in a single API call
29
+ - **Intelligent Matching Algorithm**: `trim` mode handles code formatting differences with high tolerance
30
+ - **Detailed Operation Feedback**: Complete success/failure information for AI debugging and decision-making
31
+ - **Non-blocking Error Handling**: Partial failures don't prevent other operations from continuing
32
+
33
+ ## πŸ› οΈ Quick Start
34
+
35
+ ```bash
36
+ # Install dependencies
37
+ pnpm install
38
+
39
+ # Start server
40
+ pnpm start
41
+
42
+ # Development mode (auto-restart)
43
+ pnpm dev
44
+
45
+ # Run tests
46
+ pnpm test
47
+ ```
48
+
49
+ **Requirements**: Node.js β‰₯18, pnpm
50
+
51
+ ## πŸ’‘ Usage Examples
52
+
53
+ ```json
54
+ // Scenario 1: Workspace initialization (must be called first)
55
+ {
56
+ "name": "set_workspace",
57
+ "arguments": { "path": "/path/to/your/project" }
58
+ }
59
+
60
+ // Scenario 2: Batch code file analysis
61
+ {
62
+ "name": "read_files",
63
+ "arguments": {
64
+ "path": ["src/main.js", "src/utils.js", "package.json"],
65
+ "line_range": "1-50" // Optional: read only first 50 lines
66
+ }
67
+ }
68
+
69
+ // Scenario 3: Intelligent code refactoring (tolerates whitespace differences)
70
+ {
71
+ "name": "apply_diffs",
72
+ "arguments": {
73
+ "path": "src/config.js",
74
+ "search_content": [
75
+ "const API_URL = 'localhost';",
76
+ "const PORT = 3000;"
77
+ ],
78
+ "replace_content": [
79
+ "const API_URL = process.env.API_URL || 'localhost';",
80
+ "const PORT = process.env.PORT || 3000;"
81
+ ],
82
+ "start_line": [5, 7],
83
+ "atomic": true, // Atomic mode: all succeed or all rollback
84
+ "trim": true // Smart mode: ignore whitespace differences
85
+ }
86
+ }
87
+ ```
88
+
89
+ ## πŸ—οΈ Architecture Design
90
+
91
+ ```
92
+ src/
93
+ β”œβ”€β”€ index.js # Application entry
94
+ β”œβ”€β”€ server.js # MCP server main class
95
+ β”œβ”€β”€ tools/
96
+ β”‚ └── toolDefinitions.js # Tool definitions and schema
97
+ β”œβ”€β”€ handlers/ # Tool handlers
98
+ β”‚ β”œβ”€β”€ applyDiff.js # apply_diffs (batch + atomic support)
99
+ β”‚ β”œβ”€β”€ readFile.js # read_files
100
+ β”‚ β”œβ”€β”€ writeFile.js # write_files
101
+ β”‚ β”œβ”€β”€ listFiles.js # list_files
102
+ β”‚ β”œβ”€β”€ insertContent.js # insert_contents
103
+ β”‚ β”œβ”€β”€ searchAndReplace.js # search_and_replace
104
+ β”‚ └── setWorkspace.js # set_workspace
105
+ └── utils/
106
+ └── fileUtils.js # Common file operation utilities
107
+ ```
108
+
109
+ **Design Principles**: Modular architecture, single responsibility, easy to maintain and extend
110
+
111
+ ## πŸ“Š Test Coverage
112
+
113
+ - βœ… **7 Complete Handler Test Suites**
114
+ - βœ… **Edge Cases and Error Handling Tests**
115
+ - βœ… **Batch Operations and Atomic Mode Validation**
116
+ - βœ… **Security and Path Validation Tests**
117
+
118
+ ## πŸŽ‰ Why Choose FileEditor MCP
119
+
120
+ 1. **AI-Native Design** - Specifically optimized for AI programming assistants' workflow
121
+ 2. **High-Performance Batch Processing** - Reduce API calls, improve processing efficiency
122
+ 3. **Intelligent Error Tolerance** - Handle real-world code formatting and whitespace differences
123
+ 4. **Enterprise-Grade Security** - Strict workspace isolation and permission control
124
+ 5. **Complete Test Coverage** - Reliability and stability guarantee
125
+
126
+ ## πŸ“„ License
127
+
128
+ MIT License - See `package.json` for details