远程文件监控服务

用于监控远程文件源、检测新文件并提取内容的MCP服务器,支持通过rclone或自定义命令与多种存储后端集成。

  • by eric-wien
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 vinerima/remote-files-mcp

使用说明

远程文件

MCP服务器,用于监控远程文件源、检测新文件和提取内容。通过rclone(70多个提供程序)或自定义命令与任何存储后端配合使用。

特性

  • 多源监测 --跟踪多个远程位置(Google Drive、S3、SFTP、本地目录等)
  • 新文件检测 --基于状态的差异检测新文件和更改的文件
  • 内容提取 --从DOCX、PDF和纯文本文件中提取文本
  • 自动清理 --内容提取后,下载的文件将被删除
  • 混合运输 --内置rclone支持+自定义shell命令

先决条件

  • Node.js>=18
  • npm
  • rclone (如果使用rclone传输,安装程序可以为您安装)

安装

交互式安装程序处理依赖关系、构建、配置和Claude代码注册:

cd remote-files
bash install.sh

安装程序将:

  1. 验证Node.js和npm是否可用
  2. 要求您选择运输方式(单独或自定义)
  3. 如果需要,安装rclone(通过brew、apt、pacman或官方安装脚本)
  4. 如果还没有遥控器,请引导您完成rclone远程配置
  5. 安装npm依赖项并构建项目
  6. 在以下位置创建配置文件 ~/.config/remote-files/config.json
  7. 使用Claude Code注册MCP服务器(如果CLI可用)

手动安装

如果你更喜欢自己设置:

cd remote-files
npm install
npm run build
claude mcp add --transport stdio remote-files -- node /absolute/path/to/remote-files/dist/index.js

然后创建 ~/.config/remote-files/config.json 手动(请参阅下面的配置)。

配置

创建 ~/.config/remote-files/config.json:

{
  "sources": {
    "my-drive": {
      "provider": "rclone",
      "remote": "gdrive:",
      "path": "Documents/Reports",
      "flags": ["--drive-shared-with-me"],
      "exclude": ["*.tmp"],
      "excludeFrom": "/path/to/exclude-patterns.txt"
    },
    "my-server": {
      "provider": "custom",
      "listCommand": "ssh server 'find /data -type f -printf \"%s %P\\n\"'",
      "downloadCommand": "scp server:/data/$FILE $DEST/"
    }
  },
  "settings": {
    "tempDir": "/tmp/remote-files",
    "stateDir": "~/.local/share/remote-files/state",
    "autoCleanup": true,
    "maxContentLength": 102400
  }
}

用覆盖配置路径 REMOTE_FILES_CONFIG 有人是。

rclone提供商

需要 rclone 安装和配置。领域:

字段 必填 描述
remote yes rclone远程名称(例如。 gdrive:, s3:)
path yes 远程路径
flags 否 额外的rclone标志
exclude 否 排除模式
excludeFrom no 排除文件的路径

自定义提供商

适用于rclone未涵盖的任何后端。领域:

字段 必填 描述
listCommand yes 输出的Shell命令 <size> <path> 线条
downloadCommand yes 带Shell命令 $FILE 和 $DEST 变量

MCP工具

check_来源

在不下载的情况下检查新的/更改的文件。

Parameters:
  source?          — specific source name (omit for all)
  include_pattern? — glob filter (e.g. "*.docx")

init_源

初始化源基线。所有当前文件都标记为已知。

Parameters:
  source — source name to initialize

fetch_file

下载文件,提取文本,并自动删除本地副本。

Parameters:
  source     — source name
  path       — file path (from check_sources)
  keep_local — if true, keep file on disk (default: false)

返回DOCX/PDF/TXT的提取文本。对于未知格式,返回 local_path 让克劳德直接阅读。

工作流程

  1. 第一次: 克劳德打电话来 init_source 创建基线
  2. 不间断的: 克劳德打电话来 check_sources 查找新文件
  3. 每个文件: 克劳德打电话来 fetch_file 获取内容并总结
  4. 提取后文件会自动删除

卸载

claude mcp remove remote-files
rm -rf ~/.config/remote-files
rm -rf ~/.local/share/remote-files