
MCP 服务器用于对文件进行基于行的编辑。
概览
基于TypeScript的MCP服务器,提供在允许目录内对文本文件进行精确行编辑的工具。 使用字符串或正则表达式模式匹配对文件进行基于行的编辑。每次编辑可以:- 替换整行行 - 替换特定文本匹配同时保持行格式 - 复杂匹配使用正则表达式模式 - 处理多行和多次编辑 - 通过预演模式预览更改 州ID:fcbf740a 使用此ID搭配approve_edit来应用更改。 2. 结构保持的多行内容 州ID:f2ce973f 使用此ID搭配approve_edit来应用更改。 输出:State ID:f1f1d27b 使用此ID与approve_edit进行更改。 4. 配置更新,保留空白空间 州ID:20e93c34 使用此ID搭配approve_edit来应用更改。
概述(AI 翻译)
基于TypeScript的MCP服务器,提供在允许目录内对文本文件进行精确行编辑的工具。
特色
主编辑工具
edit_file_lines
通过字符串或正则表达式模式匹配对文件进行基于行的编辑。每次编辑都可以:
- 更换整条线路
- 替换特定文本匹配,同时保持行格式
- 使用正则表达式模式处理复杂匹配
- 处理多行和多编辑
- 预演模式中的预览更改
示例文件([src/components/App.tsx):
示例用例
- 简单换弦
输出:
州编号:fcbf740a 使用该ID搭配approve_edit来应用更改。
- 结构保持的多行内容
输出:
州编号:f2ce973f 使用该ID搭配approve_edit来应用更改。
- 复杂JSX结构修改
输出:
州ID:f1f1d27b 使用该ID搭配approve_edit来应用更改。
- 配置更新,保留空白空间
输出:
州编号:20e93c34 使用该ID搭配approve_edit来应用更改。
- 灵活空白匹配
输出:
附加工具
approve_edit
应用之前edit_file_lines的预演更改。
本页由 AI 翻译,技术细节请以原文为准。
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 新手?先看 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)
}
}
}
}