Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@FS Context MCP Serverfind all TypeScript files in the src directory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Filesystem MCP Server
๐ npm version
๐ License: MIT
๐ Install in VS Code
๐ Install in VS Code Insiders
๐ Install in Visual Studio
๐ Add to LM Studio
๐ Install in Cursor
Secure filesystem MCP server for reading, writing, searching, diffing, and patching files.
Table of Contents
Quick Start โ Docker ยท CLI Usage
MCP Surface โ Tools ยท Resources ยท Prompts
Configuration โ HTTP & Auth ยท File Size Limits ยท Access Control ยท Output & Inline Limits ยท Tasks ยท Logging & Diagnostics ยท Performance
Overview
A secure, production-ready Model Context Protocol server that gives AI assistants controlled access to the local filesystem. All operations are sandboxed to explicitly allowed directories with path traversal prevention, sensitive file blocking, and optional Bearer token authentication.
Supports stdio (default) and Node Streamable HTTP transport. HTTP sessions are implemented with isolated per-session server state. The HTTP transport is stateful by default and currently non-resumable; it does not persist an event store for Last-Event-ID replay.
Key Features
18 filesystem tools โ read, write, search, diff, patch, hash, and bulk operations with structured output schemas
Security-first โ path validation, symlink escape prevention, sensitive file denylist, localhost-only CORS, Host header validation for loopback HTTP binds, optional API key auth
Dual transport โ stdio for local use, Node Streamable HTTP for networked/multi-session deployments
Structured output โ all tools return typed
outputSchema/structuredContentfor reliable LLM parsingSelf-documenting โ 6 built-in resources (
internal://instructions,internal://tool-catalog, etc.) and 4 built-in prompts (get-help,compare-files,analyze-path,get-tool-help)
Requirements
Node.js >= 24
Quick Start
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Docker
docker run -i --rm -v /path/to/project:/workspace:ro ghcr.io/j0hanz/filesystem-mcp /workspaceOr using Docker Compose:
services:
filesystem-mcp:
build: .
stdin_open: true
volumes:
- ./:/projects/workspace:ro
command: ['/projects/workspace']CLI Usage
filesystem-mcp [options] [allowedDirs...]
Arguments:
allowedDirs Directories the server can access
Options:
--allow-cwd Allow the current working directory as an additional root
--port <number> Enable HTTP transport on the given port
-v, --version Display server version
-h, --help Display help
Examples:
$ npx @j0hanz/filesystem-mcp@latest /path/to/project
$ npx @j0hanz/filesystem-mcp@latest --allow-cwd
$ npx @j0hanz/filesystem-mcp@latest --port 3000 /path/to/projectClient Configuration
Add to .vscode/mcp.json:
{
"servers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Or install via CLI:
code --add-mcp '{"name":"filesystem","command":"npx","args":["-y","@j0hanz/filesystem-mcp@latest"]}'๐ Install in VS Code Insiders
Add to .vscode/mcp.json:
{
"servers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Or install via CLI:
code-insiders --add-mcp '{"name":"filesystem","command":"npx","args":["-y","@j0hanz/filesystem-mcp@latest"]}'Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Add to <SOLUTIONDIR>.mcp.json or %USERPROFILE%\.mcp.json:
{
"servers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Add to ~/.config/goose/config.yaml:
extensions:
filesystem:
name: Filesystem MCP
cmd: npx
args:
- -y
- '@j0hanz/filesystem-mcp@latest'
enabled: true
type: stdio{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Add to claude_desktop_config.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}claude mcp add filesystem-mcp -- npx -y @j0hanz/filesystem-mcp@latestOr add a project-scoped .mcp.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}amp mcp add filesystem-mcp -- npx -y @j0hanz/filesystem-mcp@latestOr add to settings.json:
{
"amp.mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Add to cline_mcp_settings.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}codex mcp add filesystem -- npx -y @j0hanz/filesystem-mcp@latestOr add to ~/.codex/config.toml (or .codex/config.toml in a trusted project):
[mcp_servers.filesystem]
command = "npx"
args = ["-y", "@j0hanz/filesystem-mcp@latest"]Add this JSON in your repository's GitHub Copilot coding agent MCP configuration:
{
"mcpServers": {
"filesystem": {
"type": "local",
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"],
"tools": ["*"]
}
}
}{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Add to .kiro/settings/mcp.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Add to ~/.gemini/settings.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Add to ~/.config/zed/settings.json:
{
"context_servers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"],
"env": {}
}
}
}Add to VS Code settings.json under augment.advanced:
{
"augment.advanced": {
"mcpServers": [
{
"id": "filesystem",
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
]
}
}{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@j0hanz/filesystem-mcp@latest"]
}
}
}Use Cases
Explore and Understand a Codebase
Discover project structure and navigate unfamiliar repositories. Start with roots to see allowed directories, use tree for an overview, find to locate files by pattern, and read or read_many to inspect contents.
Relevant tools: roots, ls, find, tree, read, read_many, stat
Search Across Files
Locate specific code patterns, function definitions, or configuration values across a project. Use grep for content search with regex support and find for file name matching.
Edit and Refactor Code
Make precise, targeted edits to source files. Use edit for surgical replacements with dry-run preview, or search_and_replace for bulk changes across multiple files matching a glob pattern.
Relevant tools: edit, search_and_replace, write
Diff and Patch Workflow
Compare file versions and apply patches. Generate a unified diff with diff_files, preview with apply_patch(dryRun: true), then apply. Supports both single-file and multi-file patches (best-effort per file with per-file results[]).
Relevant tools: diff_files, apply_patch
File Management
Create directories, move/rename files, delete files, and verify file integrity via SHA-256 hashing.
Relevant tools: mkdir, mv, rm, calculate_hash, write
Architecture
[MCP Client]
|
| Transport: stdio (default) or Node Streamable HTTP (--port)
v
[MCP Server: filesystem-mcp]
| Entry: src/index.ts -> src/server/bootstrap.ts
|
+-- initialize / initialized
|
+-- tools/call โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| +-- [roots] โ List allowed workspace roots
| +-- [ls] โ List directory contents
| +-- [find] โ Find files by glob
| +-- [tree] โ Render directory tree
| +-- [read] โ Read file contents
| +-- [read_many] โ Read multiple files
| +-- [stat] โ Get file metadata
| +-- [stat_many] โ Get multiple file metadata
| +-- [grep] โ Search file contents
| +-- [mkdir] โ Create directory
| +-- [write] โ Write file
| +-- [edit] โ Edit file (string replacements)
| +-- [mv] โ Move/rename file
| +-- [rm] โ Delete file
| +-- [calculate_hash] โ SHA-256 hash
| +-- [diff_files] โ Unified diff
| +-- [apply_patch] โ Apply unified patch
| +-- [search_and_replace]โ Bulk search & replace
|
+-- resources/read โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| +-- internal://instructions
| +-- internal://tool-catalog
| +-- internal://workflows
| +-- internal://tool-info/{name}
| +-- filesystem-mcp://result/{id}
| +-- filesystem-mcp://metrics
|
+-- prompts/get โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| +-- get-help (optional topic argument)
| +-- compare-files (original, modified)
| +-- analyze-path (path)
| +-- get-tool-help (name)
|
+-- Capabilities: logging, resources, tools, prompts, completions, tasksRequest Lifecycle
[Client] -- initialize {protocolVersion, capabilities} --> [Server]
[Server] -- {protocolVersion, capabilities, serverInfo} --> [Client]
[Client] -- notifications/initialized --> [Server]
[Client] -- tools/call {name, arguments} --> [Server]
[Server] -- validate(inputSchema) --> [Handler]
[Handler] -- {content: [{type, text}], structuredContent?, isError?} --> [Client]MCP Surface
Tools
roots ยท ls ยท find ยท tree ยท read ยท read_many ยท stat ยท stat_many ยท grep ยท mkdir ยท write ยท edit ยท mv ยท rm ยท calculate_hash ยท diff_files ยท apply_patch ยท search_and_replace
roots
List allowed workspace roots. Call first โ all other tools are scoped to these directories.
No parameters.
ls
List immediate directory contents: name, path, type, size, modified date.
Parameter | Type | Required | Description |
| string | no | Base directory (default: root) |
| boolean | no | Include dotfiles. Default: |
| boolean | no | Include ignored items (node_modules, .git). Default: |
| integer | no | Max recursion depth (1-50) when pattern is provided |
| integer | no | Max entries before truncation. Default: 20000, Max: 20000 |
| enum | no |
|
| string | no | Relative glob filter (e.g. |
| boolean | no | Resolve symlink targets. Default: |
| string | no | Pagination cursor from a previous response |
find
Find files by glob pattern. Returns matching files with metadata.
Parameter | Type | Required | Description |
| string | no | Base directory (default: root) |
| string | yes | Relative glob pattern (e.g. |
| integer | no | Max results (1-10000). Default: 100 |
| boolean | no | Include ignored items. Default: |
| boolean | no | Include dotfiles. Default: |
| enum | no |
|
| integer | no | Max directory depth (0-100) |
| string | no | Pagination cursor |
tree
Render a directory tree with bounded recursion. Returns ASCII tree + structured JSON.
Parameter | Type | Required | Description |
| string | no | Base directory (default: root) |
| integer | no | Depth (0 = root node only). Default: 5, Max: 50 |
| integer | no | Max entries. Default: 1000, Max: 20000 |
| boolean | no | Include dotfiles. Default: |
| boolean | no | Include ignored items. Default: |
| boolean | no | Include file sizes in tree entries. Default: |
read
Read text file contents. Use head/tail to preview first/last N lines of large files.
Parameter | Type | Required | Description |
| string | yes | Absolute path to file |
| integer | no | Read first N lines (1-100000) |
| integer | no | Read last N lines (1-100000) |
| integer | no | Start line (1-based, inclusive) |
| integer | no | End line (1-based, inclusive). Requires |
| boolean | no | Include SHA-256 hash of full file content. Default: |
read_many
Read multiple text files in one request.
Parameter | Type | Required | Description |
| string[] | yes | Files to read (1-100 paths) |
| integer | no | Read first N lines of each file |
| integer | no | Read last N lines of each file |
| integer | no | Start line (1-based) per file |
| integer | no | End line (1-based) per file |
stat
Get file/directory metadata: size, modified, permissions, mime, tokenEstimate.
Parameter | Type | Required | Description |
| string | yes | Absolute path to file or directory |
stat_many
Get metadata for multiple files/directories in one request.
Parameter | Type | Required | Description |
| string[] | yes | File/directory paths (1-100) |
grep
Search file contents (grep-like). Returns matching lines with optional context.
Parameter | Type | Required | Description |
| string | no | Base directory (default: root) |
| string | yes | Search text or RE2 regex when |
| boolean | no | Treat pattern as RE2 regex. Default: |
| boolean | no | Case-sensitive matching. Default: |
| boolean | no | Match whole words only. Default: |
| integer | no | Lines of context before/after (0-50). Default: 0 |
| integer | no | Max match rows (0-10000). Default: 500 |
| string | no | Relative glob for candidate files (e.g. |
| boolean | no | Include dotfiles. Default: |
| boolean | no | Include ignored items. Default: |
mkdir
Create a new directory (recursive). Idempotent.
Parameter | Type | Required | Description |
| string | no | Absolute path to directory to create |
| string[] | no | Multiple directories to create. Either |
write
Write content to a file, overwriting all existing content. Creates parent directories if needed.
Parameter | Type | Required | Description |
| string | yes | Absolute path to file |
| string | yes | Content to write |
edit
Apply sequential literal string replacements (first occurrence per edit). Use dryRun to preview.
Parameter | Type | Required | Description |
| string | yes | Absolute path to file |
| array | yes | List of non-empty |
| boolean | no | Preview edits without writing. Default: |
| boolean | no | Treat whitespace sequences as equivalent. Default: |
mv
Move or rename a file or directory.
Parameter | Type | Required | Description |
| string | no | Single path to move (deprecated: use |
| string[] | no | Paths to move. Either |
| string | yes | Destination path |
rm
Permanently delete a file or directory. Irreversible.
Parameter | Type | Required | Description |
| string | yes | Absolute path to file or directory |
| boolean | no | Delete non-empty directories. Default: |
| boolean | no | No error if missing. Default: |
calculate_hash
Calculate SHA-256 hash of a file or directory.
Parameter | Type | Required | Description |
| string | yes | Absolute path to file or directory |
diff_files
Generate a unified diff between two files. Output feeds directly into apply_patch.
Parameter | Type | Required | Description |
| string | yes | Path to original file |
| string | yes | Path to modified file |
| integer | no | Lines of context in diff output |
| boolean | no | Ignore leading/trailing whitespace. Default: |
| boolean | no | Strip trailing carriage returns. Default: |
apply_patch
Apply a unified diff patch to one or more files. Single-file: throws on failure. Multi-file: best-effort per file with results[]. Workflow: diff_files -> apply_patch(dryRun) -> apply_patch.
Parameter | Type | Required | Description |
| string | yes | Path to file (single) or base directory (multi-file patch) |
| string | yes | Unified diff with |
| integer | no | Max fuzzy mismatches per hunk (0-20) |
| boolean | no | Auto-convert line endings. Default: |
| boolean | no | Validate without writing. Default: |
search_and_replace
Bulk search-and-replace across files matching a glob. Replaces all occurrences per file. Always dryRun: true first.
Parameter | Type | Required | Description |
| string | no | Base directory (default: root) |
| string | no | Relative glob pattern (e.g. |
| string | yes | Text to search. RE2 regex when |
| string | yes | Replacement text. Supports |
| boolean | no | Treat as RE2 regex. Default: |
| boolean | no | Preview matches with diff. Default: |
| boolean | no | Include dotfiles. Default: |
| boolean | no | Include ignored items. Default: |
| boolean | no | Return diff even when not dry-run. Default: |
| integer | no | Max files to process before stopping (1-10000) |
| boolean | no | Case-sensitive matching. Default: |
Resources
Resource | URI | MIME Type | Description |
Instructions |
| text/markdown | Comprehensive usage rules and guidelines |
Tool Catalog |
| text/markdown | Tool selection guide and data flow map |
Workflows |
| text/markdown | Standard operating procedures for exploration, search, edit, patch |
Tool Info |
| text/markdown | Per-tool contract details, nuances, gotchas |
Result Cache |
| text/plain | Ephemeral cached tool output (large results externalized here) |
Metrics |
| application/json | Live per-tool call/error/avgDurationMs snapshot |
Prompts
Prompt | Arguments | Description |
|
| Return usage instructions. Optionally filter by section heading prefix |
|
| Generate a workflow for comparing two files using |
|
| Generate a workflow for analyzing a file or directory |
|
| Return a prompt with the authoritative contract for a specific tool |
MCP Capabilities
Capability | Status | Evidence |
| confirmed |
|
| confirmed |
|
| confirmed |
|
| confirmed |
|
| confirmed |
|
| confirmed |
|
Tool Annotations
Annotation | Tools | Value |
|
| Read-only, idempotent, non-destructive |
|
| Destructive writes, not idempotent |
|
| Idempotent write, non-destructive |
Structured Output
All 18 tools define outputSchema (Zod -> JSON Schema) and return structuredContent alongside text content. Set FS_CONTEXT_STRIP_STRUCTURED=true to strip output schemas from tool definitions (reduces token usage for LLMs that don't use structured output).
Configuration
HTTP & Auth
Variable | Default | Description |
| (none) | Bearer token required when binding HTTP to a non-loopback host |
|
| Max concurrent HTTP sessions (1-10,000) |
|
| HTTP server bind address |
|
| Max HTTP request body size (1 KB - 256 MB) |
File Size Limits
Variable | Default | Description |
|
| Max file size for text read operations (1 MB - 100 MB) |
|
| Max file size for content search/grep (100 KB - 10 MB) |
|
| Max cumulative size for |
|
| Search operation timeout in ms (100 - 60,000) |
Access Control
Variable | Default | Description |
|
| Allow reading sensitive files (.env, .key, credentials, tokens) |
| (none) | CSV/newline-separated glob patterns to block (in addition to built-in denylist) |
| (none) | CSV/newline-separated glob patterns to permit (overrides denylist) |
Output & Inline Limits
Variable | Default | Description |
|
| Max inline result chars before externalizing to |
|
| Max inline search matches before truncation |
|
| Strip |
Tasks
Variable | Default | Description |
|
| Max task TTL before auto-eviction (1 s - 24 hr) |
|
| Max simultaneous task executions (1-10,000) |
Logging & Diagnostics
Variable | Default | Description |
|
| MCP log level: debug, info, notice, warning, error, critical, alert, emergency |
|
| Enable diagnostic logging |
|
| Enable detailed diagnostic output |
|
| Log tool errors to stderr |
|
| Debug logging for search worker pool |
Performance
Variable | Default | Description |
| CPU cores (โค 8) | Concurrent search worker threads (1-16) |
|
| Cursor TTL for |
HTTP Endpoints
When started with --port <number>, the server exposes a single MCP endpoint:
Method | Path | Purpose |
|
| Initialize session or send requests (Streamable HTTP) |
|
| HTTP streaming session endpoint |
|
| Terminate a session |
Required headers:
mcp-protocol-versionโ use the negotiated MCP protocol version on post-initialize HTTP requestsmcp-session-idโ required forGET/DELETE(returned byPOSTon initialize)
Authentication: Requests to non-loopback HTTP binds require FILESYSTEM_MCP_API_KEY; clients must then send Authorization: Bearer <key>. Loopback-only binds may omit auth for local use. Uses SHA-256 timing-safe comparison.
CORS: Only localhost origins allowed (127.0.0.1, ::1, localhost).
Host validation: Loopback HTTP binds validate the Host header (localhost, 127.0.0.1, [::1]) to reduce DNS rebinding risk. Non-loopback binds still require FILESYSTEM_MCP_API_KEY.
Security
Control | Status | Evidence |
Path sandboxing | confirmed |
|
Traversal prevention | confirmed |
|
Symlink escape prevention | confirmed |
|
Sensitive file denylist | confirmed |
|
Origin validation | confirmed |
|
Bearer auth | confirmed |
|
Input validation | confirmed |
|
Request body limit | confirmed |
|
Remote bind guard | confirmed |
|
Development
devโtsc --watch --preserveWatchOutputโ Watch mode TypeScript compilationdev:runโnode --env-file=.env --watch dist/index.jsโ Run server with auto-reloadstartโnode dist/index.jsโ Run production serverbuildโnode scripts/tasks.mjs buildโ Clean buildtestโnode scripts/tasks.mjs testโ Build + run all teststest:fastโnode --test --import tsx/esm src/__tests__/**/*.test.ts node-tests/**/*.test.tsโ Run tests without buildlintโeslint .โ Lint sourcetype-checkโnode scripts/tasks.mjs type-checkโ Type-check src + testsformatโprettier --write .โ Format codeinspectorโnpm run build && npx -y @modelcontextprotocol/inspector node dist/index.js ${workspaceFolder}โ Launch MCP Inspector
Build and Release
CI:
.github/workflows/release.ymlโ runs lint, type-check, test, build before tagging/publishing.Docker: Multi-stage build with
node:24-alpine. Builder compiles TypeScript + native modules (re2); release stage runs as non-rootmcpuser.npm:
npm run prepublishOnlyruns lint + type-check + build.
Troubleshooting
"No allowed directories" โ Pass at least one directory argument or use
--allow-cwd.Sensitive file blocked โ Files matching the denylist (
.env*,.git, SSH keys) are blocked by design. Checksrc/lib/constants.tsfor the full list.Large result externalized โ When tool output exceeds inline limits, it's cached as a resource at
filesystem-mcp://result/{id}. Read the resource URI to get the full content.Stdio: logs on stdout โ Keep logs on stderr only. The server uses
console.errorfor diagnostics.HTTP 413 โ Request body exceeds
FS_CONTEXT_MAX_REQUEST_BYTES. Increase the limit or reduce payload size.HTTP 401 โ
FILESYSTEM_MCP_API_KEYis set but the request is missing or has an incorrectAuthorization: Bearerheader.
Credits
Dependency | Description |
MCP server SDK package | |
MCP client SDK package | |
Node transport package for MCP runtime | |
CLI argument parsing | |
Unified diff generation and patch application | |
| |
Safe RE2 regex engine (no ReDoS) | |
Schema validation and JSON Schema generation |
License
MIT License. See LICENSE for details.
This server cannot be installed
Maintenance
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/j0hanz/fs-context-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
