mcp-server-text-editor

mcp-server-text-editor

Claude 内置文本编辑器工具版本的开源实现: text\_editor\_20241022 (Claude 3.5 Sonnet) text\_editor\_20250124 (Claude 3.7 Sonnet)

数字笔记管理
访问服务器

README

Claude 文本编辑器 MCP 服务器

npm version CI Status Test Coverage

<p align="center"> <img src="https://mintlify.s3.us-west-1.amazonaws.com/mcp/logo/dark.svg" alt="Model Context Protocol Logo" width="200"/> </p>

一个 Claude 内置文本编辑器工具的开源实现,作为 模型上下文协议 (MCP) 服务器。 此软件包提供与 Claude 的内置文本编辑器工具 相同的功能,允许您通过标准化的 API 查看、编辑和创建文本文件。

特性

  • 与 Claude 文本编辑器相同的 API: 实现与 Claude 内置文本编辑器工具完全相同的接口
  • MCP 服务器实现: 遵循模型上下文协议标准,用于 AI 工具集成
  • 文件操作:
    • 查看文件内容,可选择指定行范围
    • 创建新文件
    • 替换现有文件中的文本
    • 在特定行号插入文本
    • 撤销之前的编辑

支持的 Claude 文本编辑器版本

此软件包实现了与 内置 Claude 文本编辑器工具 等效的工具版本:

  • text_editor_20241022 (Claude 3.5 Sonnet)
  • text_editor_20250124 (Claude 3.7 Sonnet)

但使用工具名称 'text_editor' 以避免与内置 Claude 工具的名称冲突。

安装

# 从 npm 安装
npm install mcp-server-text-editor

# 或者使用 pnpm
pnpm add mcp-server-text-editor

用法

启动服务器

# 使用 npx
npx -y mcp-server-text-editor

# 或者如果全局安装
mcp-server-text-editor

在 Claude Desktop 中配置

{
  "mcpServers": {
    "textEditor": {
      "command": "npx",
      "args": ["-y", "mcp-server-text-editor"]
    }
  }
}

工具命令

View (查看)

查看文件或目录的内容。

{
  "command": "view",
  "path": "/path/to/file.js",
  "view_range": [1, 10] // 可选:仅显示第 1-10 行
}

Create (创建)

创建具有指定内容的新文件。

{
  "command": "create",
  "path": "/path/to/file.js",
  "file_text": "console.log('Hello, world!');"
}

String Replace (字符串替换)

替换文件中的文本。

{
  "command": "str_replace",
  "path": "/path/to/file.js",
  "old_str": "console.log('Hello, world!');",
  "new_str": "console.log('Hello, Claude!');"
}

Insert (插入)

在特定行插入文本。

{
  "command": "insert",
  "path": "/path/to/file.js",
  "insert_line": 5,
  "new_str": "// This line was inserted by Claude"
}

Undo Edit (撤销编辑)

还原对文件所做的最后一次编辑。

{
  "command": "undo_edit",
  "path": "/path/to/file.js"
}

开发

前提条件

  • Node.js 18+
  • pnpm

设置

# 克隆仓库
git clone https://github.com/bhouston/mcp-server-text-editor.git
cd mcp-server-text-editor

# 安装依赖
pnpm install

# 构建项目
pnpm build

脚本

  • pnpm build: 构建 TypeScript 项目
  • pnpm lint: 运行 ESLint 并自动修复
  • pnpm format: 使用 Prettier 格式化代码
  • pnpm clean: 移除构建产物
  • pnpm clean:all: 移除构建产物和 node_modules
  • pnpm test: 运行测试
  • pnpm test:coverage: 运行测试并生成覆盖率报告

测试

本项目使用 Vitest 进行测试。

要运行测试:

# 运行所有测试
pnpm test

# 运行测试并生成覆盖率报告
pnpm test:coverage

测试覆盖率报告将在 coverage 目录中生成。

许可证

MIT

贡献

欢迎贡献! 请随时提交 Pull Request。

  1. Fork 仓库
  2. 创建您的特性分支 (git checkout -b feature/amazing-feature)
  3. 提交您的更改 (git commit -m 'Add some amazing feature')
  4. 推送到分支 (git push origin feature/amazing-feature)
  5. 打开一个 Pull Request

推荐服务器

mult-fetch-mcp-server

mult-fetch-mcp-server

一个多功能的、符合 MCP 规范的网页内容抓取工具,支持多种模式(浏览器/Node)、格式(HTML/JSON/Markdown/文本)和智能代理检测,并提供双语界面(英语/中文)。

精选
本地
YouTube Translate MCP

YouTube Translate MCP

一个模型上下文协议服务器,可以通过文字稿、翻译、摘要和各种语言的字幕生成来访问 YouTube 视频内容。

精选
mcp-codex-keeper

mcp-codex-keeper

作为开发知识的守护者,为 AI 助手提供精心策划的最新文档和最佳实践访问权限。

精选
Doc/docx-MCP

Doc/docx-MCP

一个基于 FastMCP 的强大 Word 文档处理服务,使 AI 助手能够创建、编辑和管理 docx 文件,并提供完整的格式支持。在编辑内容时保留原始样式。

精选
Fetch MCP Server

Fetch MCP Server

提供以各种格式(包括 HTML、JSON、纯文本和 Markdown)获取 Web 内容的功能。

精选
Jina AI

Jina AI

Contribute to JoeBuildsStuff/mcp-jina-ai development by creating an account on GitHub.

精选
mcp-text-editor

mcp-text-editor

一个面向行的文本文件编辑器。针对 LLM 工具进行了优化,具有高效的局部文件访问能力,以最大限度地减少 token 使用量。

本地
Mcp Server Chatsum

Mcp Server Chatsum

Please provide me with the chat message you want me to summarize and translate into Chinese. I need the text of the message to be able to help you.

本地
OSP Marketing Tools MCP Server

OSP Marketing Tools MCP Server

支持与任何支持 MCP 的 LLM 客户端无缝集成,以使用 Open Strategy Partners 的方法论创建和优化技术内容和产品定位。

本地
MCP Server Neurolorap

MCP Server Neurolorap

将文件和目录中的代码收集到一个 Markdown 文档中的 MCP 服务器。

本地