# FI-Mihej/text_file_read_and_refactor_mcp [Health: Active]

**Category:** 📂 File Systems  
**Repository:** https://github.com/FI-Mihej/text_file_read_and_refactor_mcp  
**GitHub Stars:** 1  
**Views:** 2  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/fi-mihej-text-file-read-and-refactor-mcp

## Description
Token-efficient Python stdio MCP server exposing safe text-file search, reading, and refactoring tools. Tools automatically resolve the file BOM and codepage; edit tools save files with their original encoding and BOM. uvx text-file-read-and-refactor-mcp

## Tools
Capabilities this server exposes over MCP:

- **text_file__list_allowed_directories** — in pseudocode: "text_file__list_allowed_directories() -> List[directory_path]"
- **text_file__file_content_length** — in pseudocode: "text_file__file_content_length() -> integer_characters_num"
- **text_file__read_slice** — in pseudocode: "text_file__read_slice(characters_slice) -> text"
- **text_file__file_lines_num** — in pseudocode: "text_file__file_lines_num() -> integer_lines_num"
- **text_file__read_content_by_line_range** — in pseudocode: "text_file__read_content_by_line_range(lines_slice) -> text"
- **text_file__find_text** — in pseudocode: "text_file__find_text(text, type: Enum[text, word, dev_word, regex]) -> {found, result?: {slice, lines, text}}"
- **text_file__find_all_text_occurrences** — in pseudocode: "text_file__find_all_text_occurrences(text, type: Enum[text, word, dev_word, regex], result_index_start, result_index_stop) -> List[{found, result: {slice, lines, text}}]"
- **text_file__expand_slice_to_lines** — in pseudocode: "text_file__expand_slice_to_lines(characters_slice) -> lines_slice"
- **text_file__find_span_boundaries** — in pseudocode: "text_file__find_span_boundaries(left_boundary, right_boundary) -> Tuple[left_boundary_characters_slice, right_boundary_characters_slice]"
- **text_file__find_span_between_boundaries** — in pseudocode: "text_file__find_span_between_boundaries(left_boundary, right_boundary) -> text". Example: `text_file__find_span_between_boundaries("my_config_param:", ";")` will return string " my_value".
- **text_file__find_span_with_boundaries** — in pseudocode: "text_file__find_span_with_boundaries(left_boundary, right_boundary) -> text". Example: `text_file__find_span_with_boundaries("my_config_param:", ";")` will return string "my_config_param: my_value;".
- **text_file__replace_content_by_line_range** — in pseudocode: "text_file__replace_content_by_line_range(text, lines_slice)"
- **text_file__replace_slice** — in pseudocode: "text_file__replace_slice(text, characters_slice)"
- **text_file__replace_text** — in pseudocode: "text_file__replace_slice(old_text, new_text)"
- **text_file__replace_span_between_boundaries** — in pseudocode: "text_file__replace_span_between_boundaries(text, left_boundary, right_boundary)".
- **text_file__replace_span_with_boundaries** — in pseudocode: "text_file__replace_span_with_boundaries(text, left_boundary, right_boundary)".
- **text_file__patch_spans_by_boundary_patterns** — in pseudocode: "text_file__patch_spans_by_boundary_patterns(List[Tuple[text, left_boundary, right_boundary]])".

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "text-file-read-and-refactor-mcp": {
    "command": "uvx",
    "args": ["text-file-read-and-refactor-mcp"]
  }
}
```

## Documentation

## What FI-Mihej/text_file_read_and_refactor_mcp does

FI-Mihej/text_file_read_and_refactor_mcp gives an MCP client tools for inspecting and modifying text files. Its read operations can report file size in characters and line count, return selected character or line ranges, search for text, and identify the locations of matches. The server also exposes the directories it permits for file operations.

Search results can include character slices, line ranges, and matched text. Search modes are defined as `text`, `word`, `dev_word`, or `regex`, allowing callers to choose between literal and pattern-oriented matching.

Editing operations cover several levels of precision. An agent can replace a line range, replace a character slice, substitute text, or update content located between two boundaries. A batch patch operation accepts multiple boundary-based replacements.

## How it works

The server runs as a Python process using MCP's stdio transport. The client starts it and communicates with it over standard input and output. The documented launch command is the `uvx` entry point `text-file-read-and-refactor-mcp`.

The tool model uses three concepts. A slice represents a start and end character index. A boundary describes text to locate and includes a matching type such as literal text, a word, a development-style word, or a regular expression. A span combines a left and right boundary, so an operation can retrieve or replace the content between them, or include the boundaries themselves.

For example, span tools can locate the value between a configuration label and a terminator, or return the complete text including those surrounding markers. The server resolves a file's BOM and codepage when reading. Replacement tools write the result using the file's original encoding and BOM.

## Setup and configuration

Install `uv` using its official installation instructions, then add an MCP server entry to the client configuration:

```json
{
  "mcpServers": {
    "text-file-read-and-refactor": {
      "command": "uvx",
      "args": [
        "text-file-read-and-refactor-mcp"
      ]
    }
  }
}
```

No environment variables are documented for this setup. The README identifies Linux, Windows, and macOS support, with x86_64 and ARM64 wheels listed. The project is a stdio server rather than an HTTP service, so the MCP client is responsible for launching the command.

## Tools and capabilities

The read-only tool group includes:

- Listing allowed directories.
- Measuring character length and line count.
- Reading by character slice or line range.
- Finding one match or a selected range of all occurrences.
- Expanding a character slice to its containing line range.
- Finding boundary positions and retrieving spans with or without the boundary text.

The edit group includes line-range replacement, slice replacement, direct text replacement, replacement between boundaries, replacement including boundaries, and patching several boundary-defined spans in one call. These operations are suited to focused changes where the caller already knows the relevant offsets, lines, text, or boundary patterns.

## Limitations and notes

The repository is described as a curated public mirror, with active development and private research notes maintained elsewhere. Its stated license is Apache License 2.0.

FI-Mihej/text_file_read_and_refactor_mcp is appropriate when an MCP client needs structured reads and targeted text edits. Choose the slice, line, or boundary tool according to how stable the target location is, and use the search tools first when the location must be discovered from file content.

_Full upstream README: https://allmcps.com/mcp/fi-mihej-text-file-read-and-refactor-mcp/readme_

