MCP.so
登录
服务器

MCP Text Editor Server

@nathanonn

概览

What is MCP Text Editor Server?

An MCP server that implements Anthropic's text editor tool functionality, allowing Claude and other MCP clients to read and modify files within a specified directory. It provides commands for viewing, editing, creating, and undoing file changes, with automatic backups and path validation for security.

How to use MCP Text Editor Server?

Install Node.js 16+ and TypeScript, then set up a project with @modelcontextprotocol/sdk and zod. Compile the source code and run the server with node build/text-editor-server.js /path/to/working/directory. For Claude for Desktop integration, add the server to the mcpServers configuration in claude_desktop_config.json.

Key features of MCP Text Editor Server

  • View file contents or directory listings with line numbers
  • Make precise text replacements with str_replace
  • Edit blocks of code by line numbers with edit
  • Insert new content at specific line numbers
  • Create new files optionally overwriting existing ones
  • Undo edits by restoring files from automatic backups

Use cases of MCP Text Editor Server

  • Claude viewing and analyzing source code files in a project directory
  • Making targeted string replacements across code files
  • Editing entire code blocks or functions with before/after comparison
  • Creating new files (config files, scripts) from natural language instructions
  • Reverting accidental file modifications using the undo command

FAQ from MCP Text Editor Server

What commands does MCP Text Editor Server support?

It supports six commands: view, str_replace, edit, insert, create, and undo_edit. Each has specific parameters for controlling file operations.

What are the system requirements?

Node.js 16 or higher and TypeScript are required. The server uses the @modelcontextprotocol/sdk and zod libraries.

How does the server ensure security?

It validates paths to keep operations within the base directory, creates automatic backups before every modification, provides clear error messages, and automatically creates the base directory if missing.

Can I integrate this with Claude for Desktop?

Yes. Add the server to the mcpServers array in your claude_desktop_config.json file with the command and arguments pointing to your compiled server and working directory.

How do I undo a change?

Use the undo_edit command with the file path to restore the file to its state before the last modification. The server automatically creates a backup for every edit operation.

来自「其他」的更多内容