
oakenai/mcp-edit-file-lines
Developer toolsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
MCP Server to make line-based edits to a file.
Обзор
A TypeScript-based MCP server that provides tools for making precise line-based edits to text files within allowed directories. Make line-based edits to a file using string or regex pattern matching. Each edit can: - Replace entire lines - Replace specific text matches while preserving line formatting - Use regex patterns for complex matches - Handle multiple lines and multiple edits - Preview changes with dry run mode State ID: fcbf740a Use this ID with approve_edit to apply the changes. 2. Multi-line Content with Preserved Structure State ID: f2ce973f Use this ID with approve_edit to apply the changes. Output: State ID: f1f1d27b Use this ID with approve_edit to apply the changes. 4. Configuration Update with Whitespace Preservation State ID: 20e93c34 Use this ID with approve_edit to apply the changes.
README
Показан фрагмент оригинального README. Открыть оригинал.
Edit File Lines MCP Server
A TypeScript-based MCP server that provides tools for making precise line-based edits to text files within allowed directories.
Features
Main Editing Tool
edit_file_lines
Make line-based edits to a file using string or regex pattern matching. Each edit can:
- Replace entire lines
- Replace specific text matches while preserving line formatting
- Use regex patterns for complex matches
- Handle multiple lines and multiple edits
- Preview changes with dry run mode
Example file (src/components/App.tsx):
// Basic component with props
const Button = ({ color = "blue", size = "md" }) => {
return Click me;
};
// Component with multiple props and nested structure
export const Card = ({
title,
subtitle = "Default subtitle",
theme = "light",
size = "lg",
}) => {
const cardClass = `card-${theme} size-${size}`;
return (
);
};
// Constants and configurations
const THEME = {
light: { bg: "#ffffff", text: "#000000" },
dark: { bg: "#000000", text: "#ffffff" },
};
const CONFIG = {
apiUrl: "https://api.example.com",
timeout: 5000,
retries: 3,
};
Example Use Cases
- Simple String Replacement
{
"p": "src/components/App.tsx",
"e": [{
"startLine": 2,
"endLine": 2,
"content": "primary",
"strMatch": "blue"
}],
"dryRun": true
}
Output:
Index: src/components/App.tsx
===================================================================
--- src/components/App.tsx original
+++ src/components/App.tsx modified
@@ -1,6 +1,6 @@
// Basic component with props
-const Button = ({ color = "blue", size = "md" }) => {
+const Button = ({ color = "primary", size = "md" }) => {
return Click me;
};
// Component with multiple props and nested structure
State ID: fcbf740a Use this ID with approve_edit to apply the changes.
- Multi-line Content with Preserved Structure
{
"p": "src/components/App.tsx",
"e": [{
"startLine": 16,
"endLine": 19,
"content": " ",
"regexMatch": ""
}],
"dryRun": true
}
Output:
Index: src/components/App.tsx
===================================================================
--- src/components/App.tsx original
+++ src/components/App.tsx modified
@@ -13,10 +13,10 @@
const cardClass = `card-${theme} size-${size}`;
return (
);
};
State ID: f2ce973f Use this ID with approve_edit to apply the changes.
- Complex JSX Structure Modification
Установка
This server does not publish a one-line install command.
Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →Конфигурация
{
"mcpServers": {
"edit-file-lines": {
"command": "node",
"args": [
"/path/to/edit-file-lines/build/index.js",
"<allowed-directory>"
],
"env": {
"MCP_EDIT_STATE_TTL": "300000" // Optional: Set custom TTL (in milliseconds)
}
}
}
}