filesystem-mcp-ignore

filesystem-mcp-ignore

A Node.js MCP server for filesystem operations with support for custom ignore files (like .gitignore) to protect sensitive data from AI agents.

Category
访问服务器

README

Filesystem MCP Server with Ignore File Support

A Node.js MCP server for filesystem operations with support for custom ignore files (.gitignore, .cursorignore, .cascadeignore, .claudeignore, etc.).

Protect sensitive data by controlling which files AI agents can access using gitignore-style patterns.

Features

  • Ignore File Support: Filter files using .gitignore, .cursorignore, .cascadeignore, or any custom ignore file
  • Unified File Operations: Single endpoints for reading/writing/editing multiple files
  • Automatic Project Detection: Detects Laravel, Python, Node.js, and other project types
  • Token Optimization: Smart truncation and compact directory trees for large projects
  • MCP Resources: Exposes workspace info and project details as MCP resources
  • Dynamic Access Control: Via command-line args or MCP Roots protocol

Installation & Usage

Quick Start with NPX

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@a13-team/filesystem-mcp-ignore",
        "/path/to/your/project"
      ]
    }
  }
}

With Ignore Files

To enable ignore file filtering, use the --ignore-files or -i flag:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@a13-team/filesystem-mcp-ignore",
        "-i", ".gitignore,.cursorignore",
        "/path/to/your/project"
      ]
    }
  }
}

Supported Ignore Files

  • .gitignore - Standard Git ignore patterns
  • .cursorignore - Cursor AI editor ignore
  • .cascadeignore - Windsurf/Cascade ignore
  • .claudeignore - Claude AI ignore
  • .codeiumignore - Codeium ignore
  • Any custom file with gitignore-style patterns

Ignore Pattern Syntax

Patterns follow .gitignore syntax:

# Comments start with #
node_modules/       # Ignore directories
*.log               # Glob patterns
!important.log      # Negation (include)
/root-only.txt      # Root-relative patterns
**/*.test.ts        # Match in any directory

API

Tools (8 unified endpoints)

Tool Description Annotations
read_file Read single or multiple files (auto-detects text/binary) readOnly: true
write_file Write single or multiple files destructive: true
edit_file Edit single or multiple files with find/replace destructive: true
move_file Move/rename single or multiple files destructive: false
create_directory Create directories (recursive) idempotent: true
list_directory List directory contents with sizes readOnly: true
directory_tree Get JSON tree structure (compact mode) readOnly: true
search_files Search files by glob pattern readOnly: true

Tool Details

read_file (Universal Read)

Read one or more files with automatic type detection.

{
  paths: string | string[],  // Single path or array
  encoding?: 'text' | 'base64' | 'auto',  // Default: 'auto'
  head?: number,  // First N lines (text only)
  tail?: number,  // Last N lines (text only)
  maxTokens?: number  // Approx token limit for response size
}
  • Text files: Returns content as text (code, config, markdown, etc.)
  • SVG files: Returns as text (viewable XML code)
  • Binary files: Returns metadata only with message to use native tools
  • Large files: Automatically truncated with option to use head/tail

Binary files return metadata shaped like:

{
  "type": "binary_info",
  "path": "/path/to/image.png",
  "mimeType": "image/png",
  "size": 12345,
  "message": "Binary file. Use native tools or download to view."
}

write_file (Universal Write)

Write one or more files.

{
  files: { path: string, content: string } | Array<{ path: string, content: string }>
}
  • Creates parent directories automatically
  • Overwrites existing files (use with caution)

edit_file (Universal Edit)

Make text replacements in one or more files.

{
  edits: {
    path: string,
    changes: Array<{ oldText: string, newText: string }>
  } | Array<{ path: string, changes: Array<{ oldText: string, newText: string }> }>,
  dryRun?: boolean  // Preview without applying
}
  • Returns git-style diff showing changes
  • Supports whitespace-flexible matching
  • Use dryRun: true to preview changes

move_file (Universal Move)

Move or rename files/directories.

{
  operations: { source: string, destination: string } | Array<{ source: string, destination: string }>
}

list_directory

List directory contents with optional detail formatting.

{
  path: string,
  showSizes?: boolean,  // Default: false
  sortBy?: 'name' | 'size' | 'modified',
  format?: 'compact' | 'detailed' // Default: 'compact'
}
  • format: 'detailed' or showSizes: true includes size and mtime summaries.

directory_tree

Get recursive directory structure as JSON.

{
  path: string,
  maxDepth?: number,  // Default: 10
  excludePatterns?: string[],
  compact?: boolean,  // Default: true - collapses large dirs
  omitEmptyDirs?: boolean // Default: false
}

Compact mode automatically:

  • Collapses node_modules/, vendor/, .git/, etc.
  • Groups many similar files: *.svg (15 files)

MCP Resources

The server exposes these resources:

URI Description
workspace://allowed-directories List of allowed directories
workspace://project-info Detected project type and stack
workspace://tree/{path} Directory tree JSON for a path

Project Detection

The server automatically detects project types and exposes info via workspace://project-info resource:

  • Laravel/PHP: Detects Livewire, Inertia, Blade, Vue, React, Tailwind, Vite
  • Python: Django, Flask, FastAPI with database detection
  • Node.js: Next.js, Nuxt, Express, NestJS, React, Vue, Angular, Svelte
  • Other: Ruby/Rails, Go, Rust, Java (Maven/Gradle), .NET

Directory Access Control

Directories can be specified:

  1. Via command-line arguments (shown above)
  2. Via MCP Roots protocol (recommended for dynamic updates)

MCP clients supporting Roots can dynamically update allowed directories at runtime.

Token Optimization

  • Response truncation: Large files truncated at ~50k chars with message to use head/tail
  • Compact trees: Directory trees collapse node_modules/, vendor/, etc.
  • File grouping: Many similar files shown as *.svg (15 files)
  • Binary handling: Binary files return metadata only (no base64 bloat)

License

MIT License. See LICENSE.

Contributing

See CONTRIBUTING.md.

Security

See SECURITY.md.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选