Atomic Writer MCP Server

Atomic Writer MCP Server

🔒 原子写入器 MCP Server:一种通过原子事务防止数据丢失的安全文件操作服务。专为AI集成、协作编辑和关键数据管理而构建。

📋 简介

原子写入器是一个安全的文件操作服务,通过 MCP(模型上下文协议)提供事务性文件处理,防止意外数据丢失。特别适用于 AI 集成、协作编辑和关键数据管理场景。

🌟 核心特性

  • 安全优先: 原子操作,完整性验证,自动备份
  • 防误操作: 新内容只能追加,不能覆盖
  • 可回滚: 所有操作都可追踪和撤销
  • 自感知: 自动跟踪外部创建的文件

🚀 快速安装

# 1. 克隆仓库
git clone [仓库URL]

# 2. 安装依赖
npm install

# 3. 构建项目
npm run build

⚙️ MCP 配置

在 Claude 配置文件中添加:

{
  "mcpServers": {
    "atomic-writer": {
      "command": "node",
      "args": [
        "/absolute/path/to/atomic-writer/build/index.js",
        "/absolute/path/to/base/directory"
      ]
    }
  }
}

重要: 第二个参数指定文件存储位置,必须提供

配置文件位置:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

🛠️ 主要工具

文件操作

  • write-file: 创建新文件
  • read-file: 安全读取文件
  • delete-file: 移至回收站
  • append-content: 追加内容
  • prepend-content: 前置内容

文本操作

  • replace-content: 替换文本
  • insert-content-at-line: 在特定行插入
  • read-around: 读取关键词上下文

系统工具

  • verify-integrity: 检查文件完整性
  • recover-file: 从日志恢复
  • rollback-operation: 撤销操作

📁 目录结构

base/
  ├── files/    # 管理的文件
  ├── journal/  # 操作日志
  ├── locks/    # 文件锁
  ├── trash/    # 已删除的文件
  └── temp/     # 临时文件

🧪 开发与测试

npm run build  # 构建代码
npm run test   # 运行测试
npm run lint   # 代码检查

🔒 安全保障

  • 操作原子性,自动记录
  • 执行文件锁定机制
  • 采用校验和验证内容
  • 支持操作回滚
  • 回收站系统代替永久删除