Skip to main content
Glama
rog0x

@rog0x/mcp-file-tools

by rog0x

@rog0x/mcp-file-tools

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

工具

工具

描述

dir_tree

生成可视化的目录树结构,支持配置深度和忽略模式

file_stats

分析目录:文件总数、按扩展名划分的大小分布、最大/最新/最旧的文件

duplicate_finder

通过大小 + MD5 哈希查找重复文件,报告浪费的空间

code_counter

按语言统计代码行数:代码、注释和空行(类似 cloc/scc)

file_search

按名称通配符、内容正则、大小范围和日期范围搜索文件

Related MCP server: Files MCP Server

安装

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

Available Tools

5 tools
code_counterA

Count lines of code by programming language: total lines, code lines, comment lines, blank lines (like cloc/scc).

ParametersJSON Schema
NameRequiredDescriptionDefault
dir_pathYesAbsolute path to the directory
max_depthNoMaximum depth to traverse (default: 10)

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It names the four line types and per-language grouping but does not mention recursion behavior, file inclusion/exclusion rules, binary file handling, or output format. These are significant behavioral details for a directory-traversing tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no wasted words. The 'like cloc/scc' parenthetical adds a compact orienting reference without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description names the output metrics and provides a known reference tool, which is helpful. However, it omits default traversal depth behavior, whether directories are recursed by default, and the shape of the returned result, leaving an agent with some open questions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so dir_path and max_depth are already documented in the schema. The tool description adds no parameter-level semantics, so the baseline of 3 applies—the schema does the work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource: 'Count lines of code by programming language' and enumerates the exact metrics (total, code, comment, blank lines). The cloc/scc reference further clarifies the intent and clearly separates this tool from sibling file tools like dir_tree and file_stats.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies when to use the tool—when line-count statistics are needed—but it does not explicitly contrast this with dir_tree, file_stats, or file_search. There is no when-not-to-use statement, so the agent must infer the appropriate context from the purpose alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

dir_treeB

Generate a visual directory tree structure (like the tree command). Shows files and folders with configurable depth and ignore patterns.

ParametersJSON Schema
NameRequiredDescriptionDefault
dir_pathYesAbsolute path to the directory
max_depthNoMaximum depth to traverse (default: 5, 0 = unlimited)
ignore_patternsNoPatterns to ignore (default: node_modules, .git, dist, __pycache__, .next, .cache, coverage)

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry the full burden of behavioral disclosure. It mentions the output format ('visual directory tree') and configurability, but does not state side effects, permissions, performance implications, or error handling. It does not clarify that this is a read-only operation, which is a notable omission without annotation support.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence. It front-loads the core purpose ('Generate a visual directory tree structure') and then immediately provides the key capabilities. There is zero unnecessary verbosity, making it easy for an agent to grasp quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read-only tool with full schema coverage and no output schema, the description is adequate but not complete. It explains what it does but omits details like the exact format of the output (e.g., ASCII art, indentation), whether it follows symlinks, or how it handles permission issues. These are minor for a tree tool, but with no annotations to fill the gaps, it remains at a middle score.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema covers all three parameters with descriptions (100% coverage), setting a baseline of 3. The description adds a little context by mentioning 'configurable depth and ignore patterns', which maps to max_depth and ignore_patterns, but it adds no extra meaning beyond the schema. It does not compensate for any gaps, so it stays at baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the function: generate a visual directory tree structure, and it names the analogous `tree` command. It specifies the verb ('Generate') and resource ('directory tree structure') and mentions configurable depth and ignore patterns. However, it does not explicitly differentiate from sibling tools, so it misses the top score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this tool versus alternatives like file_search or file_stats. The description only says what it does, not the context in which it is preferred or when it should be avoided. No exclusions or alternatives are mentioned, offering no decision support.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

duplicate_finderA

Find duplicate files by comparing size and MD5 hash. Returns groups of duplicates with paths and wasted space.

ParametersJSON Schema
NameRequiredDescriptionDefault
dir_pathYesAbsolute path to the directory
min_sizeNoMinimum file size in bytes to consider (default: 1)
max_depthNoMaximum depth to traverse (default: 10)

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It does disclose the algorithm (size + MD5 comparison) and the return structure (groups of duplicates with paths and wasted space). However, it does not state that the operation is read-only/safe, mention recursion or symlink behavior beyond the max_depth default, or warn about the performance cost of hashing many files. Meaningful disclosure, but with zero annotation coverage, these gaps matter.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with zero filler. The first sentence front-loads purpose and method; the second discloses the return format. Every clause earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 3-param tool with full schema coverage and clear purpose, the description covers the core needs: what it does, how, and what it returns. The gaps are the missing safety declaration (read-only is implied but not stated, and there are no annotations), absence of performance/limitation warnings, and no explicit sibling differentiation. Adequate but with clear gaps relative to its complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents dir_path, min_size, and max_depth. The description references the 'size' comparison, which loosely contextualizes min_size as a pre-hash filter, but adds little beyond what the schema already states. Baseline 3 applies when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('Find'), a resource ('duplicate files'), and the exact method used ('comparing size and MD5 hash'). This clearly distinguishes it from siblings like file_search (searching files) and code_counter (counting code), so an agent can tell them apart without opening schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The purpose implies the use case (identify duplicates in a directory), and the scope is directional rather than explicit. It does not name alternatives or state when not to use this tool vs file_stats or file_search, leaving the routing decision to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

file_statsA

Analyze a directory: total files, total size, file count by extension, largest files, newest/oldest files.

ParametersJSON Schema
NameRequiredDescriptionDefault
dir_pathYesAbsolute path to the directory
max_depthNoMaximum depth to traverse (default: 10, 0 = unlimited)

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description lists the statistics produced and implies a read-only analysis, but with no annotations it does not disclose traversal behavior, handling of permission errors, or whether the analysis is recursive. The max_depth parameter hints at recursion, but the description itself leaves that implicit.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single compact sentence with a colon-separated list. The action and target are front-loaded, and every listed item adds useful information without filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is low-complexity and the schema covers both parameters, so the listed output types are helpful. However, with no annotations and no output schema, the description could still say more about return shape, recursion behavior, or failure conditions to be fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both dir_path and max_depth. The description does not add extra parameter meaning beyond what the schema provides, which meets the baseline for a well-covered schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a clear action ('Analyze a directory') and enumerates concrete outputs: total files, total size, file count by extension, largest files, and newest/oldest files. This distinguishes it from sibling tools like dir_tree or file_search, which serve different structural or search purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance about when to use this tool versus its siblings, nor are any alternatives mentioned. The only implied usage is analyzing a directory, but no exclusions or selection conditions are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv1.0.0
    • First observedcode_counter
    • First observeddir_tree
    • First observedduplicate_finder
    • First observedfile_search
    • First observedfile_stats

TDQS

A3.6/5.0

Scored across 5 tools

Disambiguation5/5

Each tool has a distinct purpose: generating a directory tree, computing stats, finding duplicates, counting code lines, and searching files. No overlapping responsibilities, so an agent can unambiguously choose the right tool for a task.

Naming Consistency5/5

All tool names follow a consistent pattern of lowercase snake_case, with each name being a noun phrase describing its function (e.g., dir_tree, file_stats). This is uniform and predictable, making it easy to infer tool behavior from the name alone.

Tool Count5/5

With exactly 5 tools, the surface is well-scoped for a file analysis and search utility. Each tool addresses a core aspect of file management without redundancy, and the count is within the ideal range of 3-15 tools.

Completeness4/5

The server covers major file inspection and analysis needs: structural views, statistics, duplicate detection, code metrics, and flexible searching. A minor gap is the lack of a direct file content read tool, but the search tool's regex content matching partially covers that, so agents can work around it.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables AI assistants to intelligently search and explore local file systems using native Unix commands (ripgrep, find, ls) with token-optimized output, automatic pagination, and multi-layer security validation.
    164 npm
    2
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to safely explore directories, read files, search content by pattern or filename, and edit files with checksum verification and dry-run preview within sandboxed filesystem access.
    13 npm
    75
    ISC
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to read, search, and analyze local file systems with tools for reading file contents, listing directories, searching by patterns, and analyzing folder structures for context-aware queries.
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides secure and efficient tools for codebase analysis, including file management, metadata retrieval, and dependency tree traversal. It allows LLMs to explore project structures and search for configuration files within a restricted root directory.
    22 npm
    3
    MIT