File Tools MCP Server

File Tools MCP Server

An MCP server that provides file and directory tools for LLMs, including project structure analysis, file reading, and project context resources, with support for .gitignore patterns.

Category
访问服务器

README

File Tools MCP Server

An MCP (Model Context Protocol) server that provides file and directory tools for LLMs, with built-in support for respecting .gitignore patterns.

Features

Tools

  • project_structure: Generates a tree view of directory structures while respecting .gitignore patterns
  • read_multiple_files: Reads multiple files in a single request with clear content separation

Resources

  • project://info: Comprehensive project information (type, dependencies, scripts, git status)
  • git://status: Detailed git repository status with file changes and recent commits
  • dependencies://list: Lists all project dependencies by package manager
  • config://list: Finds and lists all configuration files in the project
  • files://recent: Shows the 20 most recently modified files
  • context://full: Complete project context with directory structure and all text files under 50KB

Additional Features

  • Handles circular symlinks and permission errors gracefully
  • Supports depth limiting and hidden file visibility options
  • Clear error messages with helpful context for path issues

Installation

For Claude Desktop

  1. Install the server to Claude Desktop:

    uv run mcp install main.py --name "File Tools"
    
  2. Restart Claude Desktop

For Development

  1. Clone the repository
  2. Install dependencies:
    uv sync
    

Usage

Development Mode (with Inspector)

uv run mcp dev main.py

This opens the MCP Inspector for debugging and testing.

Standalone Mode

uv run python main.py

Runs the server in stdio mode, waiting for MCP client connections.

Testing

uv run python test_client.py

Runs a test client to verify server functionality.

Available Tools

project_structure

Generates a tree view of a directory structure while respecting .gitignore patterns.

Parameters:

  • path (str, optional): Directory path to analyze (default: current working directory)
  • max_depth (int, optional): Maximum depth to traverse (default: None for unlimited)
  • show_hidden (bool, optional): Include hidden files and directories (default: False)

Example:

# Get structure of current directory
result = await session.call_tool("project_structure", {})

# Get structure with depth limit
result = await session.call_tool("project_structure", {
    "path": "/path/to/project",
    "max_depth": 3
})

# Include hidden files
result = await session.call_tool("project_structure", {
    "show_hidden": True
})

read_multiple_files

Reads multiple files and returns their contents in a single response.

Parameters:

  • paths (list[str], required): List of file paths to read

Features:

  • Clear separation between files with headers showing path and size
  • Graceful error handling for missing or inaccessible files
  • Efficient for reading multiple files in one request

Example:

# Read multiple files
result = await session.call_tool("read_multiple_files", {
    "paths": [
        "src/main.py",
        "config.json",
        "README.md"
    ]
})

Available Resources

project://info

Provides comprehensive project information in one request:

  • Project type detection (Node.js, Python, Rust, etc.)
  • Package metadata (name, version, description)
  • Available scripts/commands
  • Dependency counts
  • Git status summary
  • Recent commits

git://status

Detailed git repository status:

  • Current branch and tracking information
  • Ahead/behind status with remote
  • Staged, modified, and untracked files
  • Last 10 commits

dependencies://list

Lists all project dependencies:

  • Supports npm, yarn, pnpm, pip, poetry, uv
  • Shows production and development dependencies
  • Handles multiple package manager formats

config://list

Finds all configuration files:

  • Environment files (.env)
  • Language configs (tsconfig.json, pyproject.toml)
  • Linters and formatters
  • CI/CD configurations
  • Editor settings

files://recent

Shows recently modified files:

  • 20 most recently modified files
  • File modification timestamps
  • File sizes
  • Excludes common ignore patterns

context://full

Complete project context in one request:

  • Full directory structure
  • Contents of all text files under 50KB
  • Respects .gitignore patterns
  • Skips binary files automatically
  • Provides summary of files included/skipped
  • Perfect for giving LLMs complete project understanding

Configuration

Root Paths

When using the MCP Inspector or other MCP clients, you may need to configure root paths to allow the server to access your project directories. This is a security feature that prevents unauthorized file access.

In the MCP Inspector:

  1. Click on the server configuration
  2. Add root paths for directories you want to access
  3. Example: /home/user/projects/my-project

Without proper root paths configured, you may see "File not found" errors even for files that exist.

Security Considerations

When deploying this server:

  • Bind to localhost (127.0.0.1) only for local deployments
  • Use proper authentication if exposing to network
  • Consider path traversal risks - the server allows reading any accessible directory
  • Configure root paths to limit file access to specific directories

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选