FS Context MCP Server

FS Context MCP Server

A secure, read-only MCP server that enables filesystem scanning, searching with glob patterns and regex, file reading, and batch operations with comprehensive path validation and security protections.

Category
访问服务器

README

Filesystem MCP

npm version License Node.js Version Docker Image

Install in VS Code Install in VS Code Insiders Install in Claude Desktop Install in Cursor

MCP Server that enables LLMs to interact with the local filesystem. Provides tools for navigation, file management, searching, and analysis, all within a secure, allowed set of directories. Ideal for agents needing to read/write files, explore directory structures, or perform file operations as part of their tasks.

Key Features

  • Navigation: List directories (ls), view trees (tree), and discover workspace roots (roots).
  • File Management: Create (mkdir), write (write), edit (edit), move (mv), and delete (rm) files/directories.
  • Search: Find files by glob pattern (find) or search content using regex (grep).
  • Analysis: Inspect metadata (stat), calculate hashes (calculate_hash), and compare files (diff_files).
  • Batch Operations: Read multiple files (read_many) or replace text across many files (search_and_replace).
  • Security: Strictly scoped to allowed directories provided at startup.

Tech Stack

  • Runtime: Node.js >= 24
  • Language: TypeScript
  • SDK: @modelcontextprotocol/sdk
  • Libraries: zod, commander, re2, diff

Repository Structure

.
├── src/
│   ├── index.ts        # Entry point
│   ├── server.ts       # MCP Server implementation
│   ├── tools/          # Individual tool implementations
│   └── lib/            # Shared utilities
├── assets/             # Images and static resources
├── scripts/            # Build and maintenance scripts
└── package.json

Requirements

  • Node.js >= 24

Quickstart

Run directly with npx:

npx -y @j0hanz/filesystem-mcp@latest "C:\path\to\allowed\directory"

Installation

NPX (Recommended)

npx -y @j0hanz/filesystem-mcp@latest [options] [directories...]

Docker

docker run -i --rm \
  -v /path/to/your/project:/projects/workspace:ro \
  ghcr.io/j0hanz/filesystem-mcp:latest \
  /projects/workspace

Mount host directories as volumes to /projects/ and pass the container paths as arguments.

From Source

  1. Clone the repository

  2. Install dependencies:

    npm ci
    
  3. Build the project:

    npm run build
    
  4. Run:

    node dist/index.js [options] [directories...]
    

Configuration

The server requires specifying allowed directories via command-line arguments.

Arguments

Argument Description
[allowedDirs...] Positional arguments specifying the root directories the server can access.

Options

Option Description
--allow-cwd Allow the current working directory as an additional root.
-v, --version Display server version.
-h, --help Display command help.

Usage

Stdio Transport

The server communicates via stdio. Ensure your MCP client is configured to run the server command and capture standard input/output.

MCP Surface

Tools

Tool Description Key Parameters
roots List allowed workspace roots None
ls List directory contents path, includeHidden
find Find files by glob pattern pattern, path, maxDepth
tree Generate directory tree path, maxDepth
read Read file content path, head
read_many Read multiple files paths
grep Search file content (regex/literal) pattern, path, isRegex
stat Get file metadata path
stat_many Get metadata for multiple files paths
calculate_hash Calculate SHA-256 hash path
mkdir Create directory (recursive) path
write Write file (create/overwrite) path, content
edit Edit file (string replacement) path, edits
mv Move or rename file/directory source, destination
rm Delete file or directory path, recursive
diff_files Generate unified diff original, modified
apply_patch Apply unified patch path, patch
search_and_replace Search & replace across files filePattern, searchPattern, replacement

Resources

URI Pattern Description
internal://instructions Usage guidance and documentation
filesystem-mcp://result/{id} Ephemeral cached tool output (for large results)

Prompts

Prompt Description
get-help Returns usage instructions for the server

Client Configuration Examples

<details> <summary><strong>Claude Desktop</strong></summary>

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@j0hanz/filesystem-mcp@latest",
        "C:\\path\\to\\allowed\\directory"
      ]
    }
  }
}

</details>

<details> <summary><strong>Cursor</strong></summary>

Add to your .cursor/mcp.json or configure via UI:

{
  "id": "filesystem",
  "name": "filesystem",
  "command": "npx",
  "args": ["-y", "@j0hanz/filesystem-mcp@latest", "${workspaceFolder}"]
}

</details>

<details> <summary><strong>VS Code</strong></summary>

Add to your .vscode/mcp.json:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@j0hanz/filesystem-mcp@latest", "${workspaceFolder}"]
    }
  }
}

</details>

<details> <summary><strong>Docker (any MCP client)</strong></summary>

Use the Docker image with any MCP client that supports stdio transport:

{
  "mcpServers": {
    "filesystem": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/path/to/project:/projects/workspace:ro",
        "ghcr.io/j0hanz/filesystem-mcp:latest",
        "/projects/workspace"
      ]
    }
  }
}

</details>

<details> <summary><strong>Codex</strong></summary>

Add to your configuration:

[mcp_servers.filesystem-mcp]
command = "npx"
args = ["-y", "@j0hanz/filesystem-mcp@latest", "${workspaceFolder}"]

</details>

Security

  • Path Restrictions: All file operations are strictly validated against the allowed root directories provided at startup.
  • Path Validation: Uses isPathWithinDirectories to prevent path traversal attacks.
  • Hidden Files: Hidden files (starting with .) are excluded by default in listings and searches unless explicitly requested.

Development Workflow

  1. Install Dependencies:

    npm install
    
  2. Development Mode (watch):

    npm run dev
    
  3. Run Locally:

    npm start -- --allow-cwd
    
  4. Test:

    npm run test
    
  5. Lint & Format:

    npm run lint
    npm run format
    

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

官方
精选