Sponsored by Deepsite.site

MCP Chunk Editor

Created By
dwymark10 months ago
An MCP server providing an efficient and safe text editor for LLMs
Content

MCP Chunk Editor

A Model Context Protocol server that provides chunk-oriented text file editing capabilities for LLMs. This server enables LLMs to edit files using semantically meaningful chunks instead of line numbers, resulting in more natural and efficient editing operations.

Key Features

  • Semantic Chunking: Uses Universal CTags to identify meaningful code structures like functions, classes, and methods
  • Immediate Application: Changes are applied immediately with preview generation for verification
  • Simple Undo: Supports reverting the most recent change for each file
  • Efficiency: Optimized for LLM token usage with incremental updates and lazy chunking

Available Tools

  • read_chunks - Retrieve chunks of a file, either all chunks or a specific range.

    • file_path (string, required): Path to the file to read
    • chunk_indices (array of integers, optional): List of chunk indices to retrieve
    • include_adjacent (boolean, optional): Include chunks before and after for context
    • encoding (string, optional): File encoding (default: utf-8)
  • replace_chunks - Replace the content of one or more chunks and immediately apply the changes.

    • file_path (string, required): Path to the file to modify
    • replacements (array, required): List of {index, new_content} objects
    • encoding (string, optional): File encoding (default: utf-8)
  • undo - Revert the last change made by a replace_chunks operation.

    • file_path (string, required): Path to the file to revert changes in
  • create_file - Create a new file with given content.

    • file_path (string, required): Path to the file to create
    • content (string, required): Content to write to the file
    • encoding (string, optional): File encoding (default: utf-8)
  • delete_file - Delete a file.

    • file_path (string, required): Path to the file to delete

Prerequisites

  • Python 3.10 or 3.11 (Python 3.12+ not supported yet due to python-ctags3 compatibility)
  • Universal CTags (apt-get install universal-ctags on Debian/Ubuntu)

Installation

When using uv no specific installation is needed. We will use uvx to directly run mcp-chunk-editor.

Using PIP

Alternatively you can install mcp-chunk-editor via pip:

pip install mcp-chunk-editor

After installation, you can run it as a script using:

python -m mcp_chunk_editor

Configuration

Configure for Claude.app

Add to your Claude settings:

Using uvx
"mcpServers": {
  "chunk-editor": {
    "command": "uvx",
    "args": ["mcp-chunk-editor"]
  }
}
Using docker
"mcpServers": {
  "chunk-editor": {
    "command": "docker",
    "args": ["run", "-i", "--rm", "mcp/chunk-editor"]
  }
}
Using pip installation
"mcpServers": {
  "chunk-editor": {
    "command": "python",
    "args": ["-m", "mcp_chunk_editor"]
  }
}

Customization - Maximum Chunk Size

By default, the server will use a maximum chunk size of 100 lines. This can be customized by adding the argument --max-chunk-size=200 (for example, to set 200 lines) to the args list in the configuration.

Debugging

You can use the MCP inspector to debug the server. For uvx installations:

npx @modelcontextprotocol/inspector uvx mcp-chunk-editor

Or if you've installed the package in a specific directory or are developing on it:

cd path/to/servers/src/chunk-editor
npx @modelcontextprotocol/inspector uv run mcp-chunk-editor

How It Works

The chunk editor works by first parsing files with Universal CTags to identify meaningful semantic units like functions, classes, and methods. These semantic units become the chunks that the LLM can operate on.

When editing a file:

  1. The LLM requests chunks from a file (read_chunks)
  2. The LLM makes changes to specific chunks (replace_chunks)
  3. Changes are immediately applied to the file
  4. A preview of the changes is returned for verification
  5. If needed, the LLM can undo the most recent change (undo)

This workflow is more efficient and natural for LLMs compared to traditional line-based editors, which require precise line numbers and content hashing.

Contributing

We encourage contributions to help expand and improve mcp-chunk-editor. Whether you want to add new tools, enhance existing functionality, or improve documentation, your input is valuable.

For examples of other MCP servers and implementation patterns, see: https://github.com/modelcontextprotocol/servers

Pull requests are welcome! Feel free to contribute new ideas, bug fixes, or enhancements to make mcp-chunk-editor even more powerful and useful.

License

mcp-chunk-editor is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
ChatWiseThe second fastest AI chatbot™
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Playwright McpPlaywright MCP server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Tavily Mcp
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
DeepChatYour AI Partner on Desktop
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
WindsurfThe new purpose-built IDE to harness magic
CursorThe AI Code Editor
Serper MCP ServerA Serper MCP Server
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
Amap Maps高德地图官方 MCP Server