SuperAPIAI Directory

text_file_read_and_refactor_mcp

github.com · AI developer platforms

Token-efficient text-file search, reading and refactoring that detects each file's BOM and codepage and preserves them on save.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)

About this tool

Purpose

Text File Read And Refactor MCP is a Python-based stdio MCP server designed to provide MCP clients with secure, token-efficient text file search, read, and refactoring capabilities. Its core feature is automatically parsing a file's BOM and code page, and the editing tools preserve the original encoding and BOM when saving files, avoiding file corruption caused by encoding issues.

Main Capabilities

The server provides a series of read-only and editing tools, designed around the three concepts of Slice (character range), Boundary (boundary), and Span (span):

  • Slice: Similar to Python's slice(start, stop), stores the start and end indices of a range.
  • Boundary: Similar to Boundary(text, type), where type can be text, word, dev_word, or regex.
  • Span: Composed of left and right Boundaries, supports searching or replacing between specified boundaries, for example getting the text between "my_config_param:" and ";", or replacing the text between "%my_regex_1%" and "%my_regex_2%" with "my_text".

Read-only tools include:

  • text_file__list_allowed_directories: Lists the directories allowed for access.
  • text_file__file_content_length: Gets the number of characters in a file.
  • text_file__read_slice: Reads text by character range.
  • text_file__file_lines_num: Gets the number of lines in a file.
  • text_file__read_content_by_line_range: Reads content by line range.
  • text_file__find_text: Finds text, supporting text, word, dev_word, and regex types.
  • text_file__find_all_text_occurrences: Finds all matches, supporting a result index range.
  • text_file__expand_slice_to_lines: Expands a character range to a line range.
  • text_file__find_span_boundaries: Finds the positions of the left and right boundaries.
  • text_file__find_span_between_boundaries: Returns the text between two boundaries (excluding the boundaries).
  • text_file__find_span_with_boundaries: Returns the text including the boundaries.

Editing tools include:

  • text_file__replace_content_by_line_range: Replaces content by line range.
  • text_file__replace_slice: Replaces content by character range.
  • text_file__replace_text: Replaces specified text.
  • text_file__replace_span_between_boundaries: Replaces the text between two boundaries.
  • text_file__replace_span_with_boundaries: Replaces the text including the boundaries.
  • text_file__patch_spans_by_boundary_patterns: Batch patches spans according to a list of boundary patterns.

Usage

  1. Install uv: Refer to https://docs.astral.sh/uv/getting-started/installation/
  2. Configure the MCP client to run the server via uvx.

Applicable Scenarios

Suitable for MCP client scenarios that require precise and secure manipulation of text files, such as configuration file modification, code refactoring, log analysis, etc., and is especially suitable for file processing sensitive to encoding and BOM.

Limitations

  • The project is built on Cengal.
  • The GitHub repository is a public mirror of the project; active development (including experimental code and private research notes) takes place in a private repository, and selected snapshots are periodically released here.
  • Copyright belongs to ButenkoMS, licensed under the Apache License 2.0.
  • Other specific limitations are not provided for now.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools