Package Exports
- fileditor-mcp
- fileditor-mcp/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fileditor-mcp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
FileEditor MCP Server
π English Interface Doc | π δΈζζ₯ε£ζζ‘£ | π δΈζREADME
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.
π― Design Philosophy
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.
π Core Features
π File Operation Tools (7 Tools)
set_workspace
- Workspace isolation (must be called first)read_files
- Smart file reading (batch, line ranges, with line numbers)write_files
- Batch file writing (single/multiple files, create/overwrite)list_files
- Directory traversal (recursive support)insert_contents
- Precise content insertion (multiple files, negative line numbers, end insertion)apply_diffs
- Advanced diff application (batch operations, atomic mode, intelligent whitespace handling)search_and_replace
- Pattern replacement (regex, line ranges, case-insensitive)
π Security Features
- Workspace Isolation: Strictly limit operation scope, prevent directory traversal attacks
- Path Security: Automatic validation and resolution of relative paths
- Atomic Operations: Batch modifications succeed completely or rollback entirely
β‘ AI-Optimized Features
- Batch Processing Engine: Handle multiple file operations in a single API call
- Intelligent Matching Algorithm:
trim
mode handles code formatting differences with high tolerance - Detailed Operation Feedback: Complete success/failure information for AI debugging and decision-making
- Non-blocking Error Handling: Partial failures don't prevent other operations from continuing
π οΈ Quick Start
# Install dependencies
pnpm install
# Start server
pnpm start
# Development mode (auto-restart)
pnpm dev
# Run tests
pnpm test
Requirements: Node.js β₯18, pnpm
π‘ Usage Examples
// Scenario 1: Workspace initialization (must be called first)
{
"name": "set_workspace",
"arguments": { "path": "/path/to/your/project" }
}
// Scenario 2: Batch code file analysis
{
"name": "read_files",
"arguments": {
"path": ["src/main.js", "src/utils.js", "package.json"],
"line_range": "1-50" // Optional: read only first 50 lines
}
}
// Scenario 3: Intelligent code refactoring (tolerates whitespace differences)
{
"name": "apply_diffs",
"arguments": {
"path": "src/config.js",
"search_content": [
"const API_URL = 'localhost';",
"const PORT = 3000;"
],
"replace_content": [
"const API_URL = process.env.API_URL || 'localhost';",
"const PORT = process.env.PORT || 3000;"
],
"start_line": [5, 7],
"atomic": true, // Atomic mode: all succeed or all rollback
"trim": true // Smart mode: ignore whitespace differences
}
}
ποΈ Architecture Design
src/
βββ index.js # Application entry
βββ server.js # MCP server main class
βββ tools/
β βββ toolDefinitions.js # Tool definitions and schema
βββ handlers/ # Tool handlers
β βββ applyDiff.js # apply_diffs (batch + atomic support)
β βββ readFile.js # read_files
β βββ writeFile.js # write_files
β βββ listFiles.js # list_files
β βββ insertContent.js # insert_contents
β βββ searchAndReplace.js # search_and_replace
β βββ setWorkspace.js # set_workspace
βββ utils/
βββ fileUtils.js # Common file operation utilities
Design Principles: Modular architecture, single responsibility, easy to maintain and extend
π Test Coverage
- β 7 Complete Handler Test Suites
- β Edge Cases and Error Handling Tests
- β Batch Operations and Atomic Mode Validation
- β Security and Path Validation Tests
π Why Choose FileEditor MCP
- AI-Native Design - Specifically optimized for AI programming assistants' workflow
- High-Performance Batch Processing - Reduce API calls, improve processing efficiency
- Intelligent Error Tolerance - Handle real-world code formatting and whitespace differences
- Enterprise-Grade Security - Strict workspace isolation and permission control
- Complete Test Coverage - Reliability and stability guarantee
π License
MIT License - See package.json
for details