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.
FS Context MCP Server
Read-only Model Context Protocol (MCP) server for secure filesystem exploration, searching, and analysis.
Overview
This server enables AI assistants to navigate your filesystem through a set of read-only tools. It provides capabilities to explore directory structures, find files using glob patterns, search file contents with grep, read files (including batch operations), and access file metadata—all restricted to explicitly approved directories.
Key Features
Read-Only Security: No write, delete, or modify permissions.
Allowed Roots: Access is strictly limited to configured directories.
Directory Exploration: List contents (
ls) and visualize structures (tree).File Search: Find files by name or pattern (
find) and search content (grep).File Reading: Read single (
read) or multiple (read_many) files with line-range support.Metadata: Retrieve file stats (
stat,stat_many) including size and timestamps.Large File Handling: Automatic truncation and pagination for large outputs.
Ignore Support: Respects
.gitignoreand common ignore patterns by default.
Tech Stack
Runtime: Node.js >= 22.19.8
Language: TypeScript 5.9.3
MCP SDK: @modelcontextprotocol/sdk 1.25.3
Libraries:
zod(validation),re2(safe regex),ignore(filtering)
Repository Structure
Requirements
Node.js >= 22.19.8
Quickstart
Use npx to run the server directly.
VS Code Configuration
Installation
NPX (Recommended)
Global Installation
From Source
Clone the repository:
git clone https://github.com/j0hanz/fs-context-mcp-server.git cd fs-context-mcp-serverInstall dependencies:
npm ciBuild the project:
npm run buildRun the server:
node dist/index.js /path/to/directory
Configuration
Runtime Modes
This server runs over stdio by default.
CLI Arguments
Argument | Description |
| List of allowed root directories. |
| Add the current working directory to allowed roots. |
Environment Variables
Variable | Default | Description |
| 10MB | Max file size for read operations. |
| 512KB | Max combined size for |
| 1MB | Max file size for |
| 30000 | Timeout (ms) for search/list operations. |
| min(cpu, 8) | Number of worker threads for search. |
| false | Allow reading sensitive files (disables denylist). |
| (empty) | Additional comma-separated glob patterns to block. |
| (empty) | Comma-separated globs to allow despite denylist. |
| false | Log tool failures to stderr. |
MCP Surface
Tools
roots
List the workspace roots this server can access.
Returns: List of allowed directory paths.
ls
List the immediate contents of a directory.
Parameter | Type | Required | Default | Description |
| string | No | (root) | Directory path to list. |
| boolean | No | false | Include hidden files. |
| boolean | No | false | Include ignored directories (node_modules, etc). |
find
Find files by glob pattern.
Parameter | Type | Required | Default | Description |
| string | Yes | - | Glob pattern (e.g., |
| string | No | (root) | Base directory to search from. |
| boolean | No | false | Include ignored directories. |
| number | No | 100 | Maximum matches to return. |
tree
Render a directory tree.
Parameter | Type | Required | Default | Description |
| string | No | (root) | Base directory to render. |
| number | No | 5 | Maximum recursion depth. |
| number | No | 1000 | Max entries before truncating. |
| boolean | No | false | Include hidden files. |
| boolean | No | false | Include ignored directories. |
read
Read the text contents of a file.
Parameter | Type | Required | Default | Description |
| string | Yes | - | Path to the file. |
| number | No | - | Read only first N lines. |
| number | No | - | 1-based start line. |
| number | No | - | 1-based end line. |
read_many
Read multiple text files in a single request.
Parameter | Type | Required | Default | Description |
| string[] | Yes | - | Array of file paths to read (max 100). |
| number | No | - | Read only first N lines of each file. |
| number | No | - | 1-based start line per file. |
| number | No | - | 1-based end line per file. |
stat
Get metadata for a file or directory.
Parameter | Type | Required | Default | Description |
| string | Yes | - | Path to file or directory. |
stat_many
Get metadata for multiple files/directories.
Parameter | Type | Required | Default | Description |
| string[] | Yes | - | Array of paths to query. |
grep
Search for text within file contents.
Parameter | Type | Required | Default | Description |
| string | Yes | - | Text pattern to search for. |
| string | No | (root) | Base directory or file to search. |
| boolean | No | false | Include hidden files. |
Resources
Pattern | Description |
| Usage guidance and server instructions. |
| Access to cached large tool outputs. |
Client Configuration Examples
Add to .vscode/mcp.json:
Add to claude_desktop_config.json:
Add to Cursor's MCP configuration:
Add to Windsurf's MCP configuration:
Security
Read-Only: This server is designed to be read-only. It provides no tools for writing or modifying files.
Path Validation: All file access is validated against the allowed root directories.
Path Traversal: Attempts to access files outside allowed roots using
..are blocked.Symlinks: Symlinks resolving outside allowed roots are blocked.
Sensitive Files: Common sensitive files (e.g.,
.env,.ssh/id_rsa) are denied by default unless explicitly allowed via configuration.Stdio: The server communicates via stdio. Ensure your client does not pipe untrusted data into the server's input.
Development Workflow
Install dependencies:
npm ciRun in dev mode:
npm run dev(watches for changes)Build:
npm run buildTest:
npm testLint:
npm run lint
Troubleshooting
Access Denied: Ensure the directory is included in the CLI arguments or client roots configuration.
File Too Large: Large files are truncated. Use the
headparameter orstartLine/endLineto read specific sections, or follow the resource URI provided in the tool output.Timeout: Complex searches (
greporfind) may timeout on large codebases. Try narrowing the search path.
License
This project is licensed under the MIT License - see the LICENSE file for details.