Claude文本编辑器MCP服务器
](https://www.npmjs.com/package/mcp-server-text-editor)  
Claude内置文本编辑器工具的开源实现 模型上下文协议 (MCP)服务器。此软件包提供的功能与 Claude的内置文本编辑器工具,允许您通过标准化的API查看、编辑和创建文本文件。
特性
- 与Claude的文本编辑器相同的API:实现与Claude的内置文本编辑器工具完全相同的接口
- MCP服务器实现:遵循AI工具集成的模型上下文协议标准
- 文件操作:
- 查看具有可选行范围规范的文件内容 - 创建新文件 - 替换现有文件中的文本 - 在特定行号处插入文本 - 撤消以前的编辑
支持的Claude文本编辑器版本
此包实现了一个等效的工具 内置的Claude文本编辑器工具 版本:
text_editor_20241022(克劳德3.5十四行诗)text_editor_20250124(克劳德3.7十四行诗)
但是使用工具名“text_editor”来避免与内置的Claude工具发生名称冲突。
安装
# Install from npm
npm install mcp-server-text-editor
# Or with pnpm
pnpm add mcp-server-text-editor用法
启动服务器
# Using npx
npx -y mcp-server-text-editor
# Or if installed globally
mcp-server-text-editor在Claude Desktop中配置
{
"mcpServers": {
"textEditor": {
"command": "npx",
"args": ["-y", "mcp-server-text-editor"]
}
}
}工具命令
视图
查看文件或目录的内容。
{
"command": "view",
"path": "/path/to/file.js",
"view_range": [1, 10] // Optional: Show lines 1-10 only
}创建
使用指定内容创建新文件。
{
"command": "create",
"path": "/path/to/file.js",
"file_text": "console.log('Hello, world!');"
}字符串替换
替换文件中的文本。
{
"command": "str_replace",
"path": "/path/to/file.js",
"old_str": "console.log('Hello, world!');",
"new_str": "console.log('Hello, Claude!');"
}插入
在特定行插入文本。
{
"command": "insert",
"path": "/path/to/file.js",
"insert_line": 5,
"new_str": "// This line was inserted by Claude"
}撤消编辑
还原上次对文件所做的编辑。
{
"command": "undo_edit",
"path": "/path/to/file.js"
}发展
先决条件
- Node.js 18+
- pnpm
设置
# Clone the repository
git clone https://github.com/bhouston/mcp-server-text-editor.git
cd mcp-server-text-editor
# Install dependencies
pnpm install
# Build the project
pnpm build脚本
pnpm build:构建TypeScript项目pnpm lint:运行ESLint并自动修复pnpm format:使用Prettier格式化代码pnpm clean:删除构建工件pnpm clean:all:删除构建工件和node_modulespnpm test:运行测试pnpm test:coverage:使用覆盖率报告运行测试
测试
该项目使用Vitest进行测试。
要运行测试,请执行以下操作:
# Run all tests
pnpm test
# Run tests with coverage report
pnpm test:coverage测试覆盖率报告将在 coverage 目录。
许可证
麻省理工学院
贡献
欢迎投稿!请随时提交拉取请求。
- 分叉存储库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交您的更改(
git commit -m 'Add some amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
