Edit File Lines MCP Server
by oakenai
A TypeScript-based MCP server that provides tools for making precise line-based edits to text files within allowed directories. It offers functionalities for editing file lines using string or regex pattern matching.
Last updated: N/A
What is Edit File Lines MCP Server?
The Edit File Lines MCP Server is a tool designed to facilitate automated and precise modifications to text files. It allows users to make line-based edits using either simple string matching or more complex regular expressions, ensuring that changes are made accurately and efficiently.
How to use Edit File Lines MCP Server?
To use the server, you need to configure it within an MCP-compatible environment like Claude Desktop. This involves specifying the server's command and arguments, including the allowed directories for file operations. The server exposes several tools, including edit_file_lines
for making edits, approve_edit
for applying changes after a dry run, get_file_lines
for inspecting file content, and search_file
for locating specific lines. Example usage and configurations are provided in the README.
Key features of Edit File Lines MCP Server
Precise line-based editing
String and regex pattern matching
Dry run mode for previewing changes
Two-step editing process with approval
File content inspection tool
Text searching with context
Use cases of Edit File Lines MCP Server
Automated code refactoring
Configuration file updates
Batch modifications across multiple files
Updating JSX components
Flexible whitespace matching
FAQ from Edit File Lines MCP Server
How do I specify which files can be edited?
How do I specify which files can be edited?
You specify one or more allowed directories when starting the server. All file operations will be restricted to these directories for security.
What is a 'dry run' and why should I use it?
What is a 'dry run' and why should I use it?
A dry run allows you to preview the changes that will be made without actually modifying the file. It's highly recommended to use dry run first to verify changes before approving them.
What happens if my edit fails?
What happens if my edit fails?
The tool provides clear error messages for common issues, such as match not found, invalid regex, or multiple edits on the same line. Review the error message and adjust your input accordingly.
How does the tool handle whitespace?
How does the tool handle whitespace?
The tool intelligently handles whitespace in both string and regex matches. Original indentation is preserved in replacements, and multiple spaces between tokens are normalized for matching.
How long do edit states last?
How long do edit states last?
Edit states expire after a short time (default: 60 seconds, configurable via MCP_EDIT_STATE_TTL
) for security. Attempting to use an expired or invalid state ID will result in an error.