MCP ExplorerExplorer

Mcp Simple Textedit

@andybrandton 2 days ago
0 MIT
FreeCommunity
AI Systems

Overview

What is Mcp Simple Textedit

MCP Simple TextEdit is a specialized text editing server designed for AI usage. It focuses on pattern-based editing rather than traditional line-numbering or visual editing, enabling AIs to work more effectively with text by understanding patterns and context.

Use cases

The tool is ideal for tasks such as code updates, text modifications, and data processing where precision and context understanding are crucial. It’s particularly useful for AIs performing systematic text editing, ensuring safe and reliable operations.

How to use

To use MCP Simple TextEdit, install it via pip, configure it in the Claude desktop app by specifying the command and base path for file editing. Upon setup, AIs can perform operations like replace, delete, and insert using patterns to ensure accuracy and safety.

Key features

Key features include pattern-based text block identification, content verification for safety, context-aware operations, and support for regular expression matching. The server enforces security by confining file access to a specified base directory and validating operations.

Where to use

This text editing server can be used in various environments where AI-driven text editing is needed, such as software development, automated documentation updates, and real-time content generation, specifically within the designated directory structure.

Content

MCP Simple TextEdit

An MCP server providing AI-optimized text editing capabilities.

This is an experimental server, backup files you intend AI to edit using it. Only appending function can be considered reliable

Why Pattern-Based Editing?

While this text editor might seem unusual to humans who are comfortable with line numbers and visual editing, it’s specifically designed for AI use. Here’s why:

  1. AI Perception vs Human Perception:

    • Humans naturally work with visual positions and line numbers
    • AIs perceive text through patterns, context, and content
    • AIs don’t “see” the file but understand its structure
  2. Safety First:

    • Line numbers can change when files are modified
    • Content-based identification is more robust
    • Pattern matching with verification prevents unintended changes
  3. Natural AI Workflow:

    • AIs identify code sections by their meaning and context
    • AIs can verify they’re modifying exactly what they intend to
    • Pattern matching aligns with how AIs process and understand text

This is why the editor supports:

  • Pattern-based text block identification
  • Content verification for safety
  • Context-aware operations
  • Regular expression matching

Installation

First install the module using:

pip install mcp-simple-textedit

Then configure in the Claude desktop app.

Under macOS, add this to ~/Library/Application Support/Claude/claude_desktop_config.json:

Under Windows, first check your Python path using where python in cmd. Then add this to %APPDATA%\Claude\claude_desktop_config.json:

Replace YOUR_USERNAME with your actual username and adjust the base-path to the directory where you want to allow file editing. The server will only be able to edit files within this directory and its subdirectories.

Security Features

The server enforces several security measures:

  • Can only access files within the specified base directory
  • Validates file paths to prevent directory traversal attacks
  • Checks file permissions before attempting modifications
  • Verifies content before making changes
  • All file operations are logged for auditing purposes

Text Encoding

All files are read and written using UTF-8 encoding. This ensures proper handling of:

  • International characters
  • Special symbols
  • Emoji and other Unicode characters

If a file cannot be read or written using UTF-8, an appropriate error message will be provided.

Pattern Matching Guidelines

For AIs using this tool, here are some guidelines for effective and safe text editing:

  1. Pattern Uniqueness:

    # Bad - ambiguous pattern
    {"start_pattern": "print(\"Done\")"}
    
    # Good - unique pattern with context
    {"start_pattern": "def process_data\\(\\):[\\s\\S]*?print\\(\"Done\"\\)"}
    
  2. Content Verification:

    # Good - verifies exact content being modified
    {
      "type": "replace",
      "start_pattern": "MAX_RETRIES = ",
      "expected_content": "MAX_RETRIES = 3",
      "content": ["MAX_RETRIES = 5"]
    }
    
  3. Block Operations:

    # Good - clear block identification
    {
      "type": "delete",
      "start_pattern": "# Old implementation",
      "end_pattern": "# End of old implementation",
      "expected_content": "# Old implementation\n    print(\"Processing...\")\n    # End of old implementation"
    }
    
  4. Context Awareness:

    # Good - uses surrounding context
    {
      "type": "insert",
      "after_pattern": "import logging\n",
      "content": ["import time", "from typing import List"]
    }
    

Remember: Always use expected_content when possible to verify you’re modifying exactly what you intend to change.

Tools

No tools

Comments