mcpField
F
file

file

本地服务
github.com/rog0x文件与存储032 周前更新

关于 file

为 AI Agent 提供文件与目录探索、搜索和分析工具的 MCP 服务,涵盖目录树、文件统计、重复文件检测、代码行计数及多条件搜索。

主要功能

  1. 01生成目录树
  2. 02分析文件数量与大小
  3. 03通过 MD5 查找重复文件
  4. 04统计代码、注释和空行
  5. 05按名称、内容、大小和日期搜索

适用场景

  1. 01查看目录结构与文件内容概况
  2. 02查找重复文件及空间浪费
  3. 03统计代码行与注释行
  4. 04按多个条件定位文件

MCP 相关

向兼容 MCP 的客户端提供文件系统探索、分析和搜索工具。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"rog0x-file": {
"command": "npx",
"args": [
"-y",
"@rog0x/mcp-file-tools"
]
}
}
}
启动命令npx -y @rog0x/mcp-file-tools

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@rog0x/mcp-file-tools1.0.1

工具

5

收录的工具列表 · 更新于 2 周前

参数类型必填说明
dir_pathstring是目录的绝对路径
max_depthnumber否遍历的最大深度(默认值:5,0 = 不限)
ignore_patternsarray否要忽略的模式(默认值:node_modules、.git、dist、__pycache__、.next、.cache、coverage)

详细介绍

@rog0x/mcp-file-tools

为 AI Agent 提供文件和目录分析工具的 MCP 服务。让 Claude(以及其他兼容 MCP 的 AI)能够浏览、分析和搜索文件系统。

工具

工具描述
dir_tree根据可配置的深度和忽略模式生成可视化目录树
file_stats分析目录:文件总数、按扩展名分类的大小明细,以及最大、最新和最旧的文件
duplicate_finder根据大小和 MD5 哈希查找重复文件,并报告浪费的空间
code_counter按语言统计代码行数:代码、注释和空行(类似 cloc/scc)
file_search按文件名 glob、内容正则表达式、大小范围和日期范围搜索文件

安装

git clone https://github.com/rog0x/mcp-file-tools.git
cd mcp-file-tools
npm install
npm run build

配置

Claude Code
claude mcp add mcp-file-tools node /absolute/path/to/mcp-file-tools/dist/index.js
Claude Desktop

将以下内容添加到 claude_desktop_config.json:

{
  "mcpServers": {
    "mcp-file-tools": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-file-tools/dist/index.js"]
    }
  }
}

工具详情

dir_tree

生成类似 tree 命令的可视化目录树。

Parameters:
  dir_path (required)     - Absolute path to the directory
  max_depth (optional)    - Max depth to traverse (default: 5, 0 = unlimited)
  ignore_patterns (optional) - Patterns to ignore (default: node_modules, .git, dist, etc.)
file_stats

全面分析目录内容。

Parameters:
  dir_path (required)     - Absolute path to the directory
  max_depth (optional)    - Max depth to traverse (default: 10)

返回:文件总数、总大小、按扩展名统计的文件数、最大的 10 个文件、最新和最旧的 10 个文件。

duplicate_finder

使用大小预筛选和 MD5 哈希查找重复文件。

Parameters:
  dir_path (required)     - Absolute path to the directory
  min_size (optional)     - Minimum file size in bytes (default: 1)
  max_depth (optional)    - Max depth to traverse (default: 10)

返回:重复文件组(包含文件路径和大小)以及总浪费空间。

code_counter

统计 20 多种语言的代码行数,并检测注释。

Parameters:
  dir_path (required)     - Absolute path to the directory
  max_depth (optional)    - Max depth to traverse (default: 10)

支持的语言:TypeScript、JavaScript、Python、Java、C/C++、C#、Go、Rust、Ruby、PHP、Swift、Kotlin、HTML、CSS、JSON、YAML、Markdown、Shell、SQL、Lua。

file_search

同时根据多个条件搜索文件。

Parameters:
  dir_path (required)        - Absolute path to the directory
  name_pattern (optional)    - Glob pattern (e.g. "**/*.ts")
  content_pattern (optional) - Regex to search file contents
  min_size (optional)        - Minimum file size in bytes
  max_size (optional)        - Maximum file size in bytes
  modified_after (optional)  - ISO date string
  modified_before (optional) - ISO date string
  max_results (optional)     - Max results (default: 100)

许可证

MIT

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。