Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@j0hanz/fs-context-mcp

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@j0hanz/fs-context-mcp

MCP Server that enables LLMs to interact with the local filesystem.

latest
Source
npmnpm
Version
2.7.6
Version published
Maintainers
1
Created
Source

FS-Context MCP Server

npm version License: MIT Node.js TypeScript MCP SDK

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

Filesystem MCP Server that enables LLMs to interact with the local filesystem.

Overview

The fs-context-mcp server provides a secure interface for language models to perform filesystem operations. By defining a set of tools that map to common file and directory actions, it allows LLMs to read, write, search, and manipulate files within specified allowed directories. This can be used for tasks like code analysis, content generation, data processing, and more, all while ensuring that the model's access is safely confined.

Key Features

  • Filesystem Navigation: List directories (ls), visualize structures (tree), and list allowed roots (roots).
  • File Operations: Read (read, read_many), write (write), edit (edit), move (mv), and delete (rm) files.
  • Advanced Search: Find files by glob pattern (find) or search file contents (grep) with regex support.
  • Diff & Patch: Hash files (calculate_hash), generate unified diffs (diff_files), apply patches (apply_patch), and bulk replace (search_and_replace).
  • Batch Processing: Efficiently read or stat multiple files in a single request (read_many, stat_many).
  • Security: Operations are strictly confined to allowed directories specified at startup.

Tech Stack

  • Runtime: Node.js >=24
  • Language: TypeScript 5.9
  • MCP SDK: @modelcontextprotocol/sdk 1.26
  • Validation: Zod
  • Regex: re2 (safe regex execution)

Quickstart

To run the server with access to your current directory:

npx -y @j0hanz/fs-context-mcp .

Installation

npx -y @j0hanz/fs-context-mcp <allowed-directory>

From Source

  • Clone the repository:

    git clone https://github.com/j0hanz/fs-context-mcp-server.git
    cd fs-context-mcp-server
    
  • Install dependencies:

    npm ci
    
  • Build the server:

    npm run build
    
  • Run:

    node dist/index.js <allowed-directory>
    

Configuration

The server is configured primarily via command-line arguments.

CLI Arguments

ArgumentDescription
allowedDirsPositional arguments specifying which directories the server can access.
--allow-cwd, --allow_cwdFlag to automatically add the current working directory to the allowed list.
-h, --helpShow CLI usage and exit.
-v, --versionShow server version and exit.

Environment Variables

VariableDefaultDescription
MAX_SEARCH_SIZE1048576Max file size (bytes) for grep/search content. Min 100 KB, max 10 MB.
MAX_FILE_SIZE10485760Max file size (bytes) for read/read_many. Min 1 MB, max 100 MB.
MAX_READ_MANY_TOTAL_SIZE524288Max total bytes returned by read_many. Min 10 KB, max 100 MB.
DEFAULT_SEARCH_TIMEOUT5000Timeout (ms) for search operations. Min 100 ms, max 60 s.
FS_CONTEXT_ALLOW_SENSITIVEfalseAllow access to sensitive files (set to 1/true to allow).
FS_CONTEXT_DENYLIST(empty)Additional denylist patterns (comma or newline separated).
FS_CONTEXT_ALLOWLIST(empty)Allowlist patterns that override the denylist.
FS_CONTEXT_SEARCH_WORKERSmin(cores, 8)Worker threads for content search (0-16).
FS_CONTEXT_SEARCH_WORKERS_DEBUG0Log worker debug details when set to 1.
FS_CONTEXT_DIAGNOSTICS0Enable diagnostics channels when set to 1.
FS_CONTEXT_DIAGNOSTICS_DETAIL0Diagnostics detail level: 0=off, 1=hashed paths, 2=full paths.
FS_CONTEXT_TOOL_LOG_ERRORS0Emit tool error diagnostics when enabled.

MCP Surface

Tools

roots

List the workspace roots this server can access.

ParameterTypeRequiredDefaultDescription
(none)----

ls

List the immediate contents of a directory (non-recursive).

ParameterTypeRequiredDefaultDescription
pathstringNo(root)Base directory for the operation.
includeHiddenbooleanNofalseInclude hidden files and directories (starting with .).
includeIgnoredbooleanNofalseInclude normally ignored directories (node_modules, dist, etc).
sortBystringNonameSort by name, size, modified, or type.
maxDepthnumberNo-Max recursion depth when pattern is provided.
maxEntriesnumberNo-Max entries before truncation.
patternstringNo-Optional glob filter (for recursive listing).
includeSymlinkTargetsbooleanNofalseInclude resolved symlink targets in output.

find

Find files by glob pattern.

ParameterTypeRequiredDefaultDescription
patternstringYes-Glob pattern to match files (e.g., **/*.ts).
pathstringNo(root)Base directory for the operation.
maxResultsnumberNo100Maximum matches to return.
includeIgnoredbooleanNofalseInclude normally ignored directories.
includeHiddenbooleanNofalseInclude hidden files and directories.
sortBystringNopathSort by path, name, size, or modified.
maxDepthnumberNo-Maximum directory depth to scan.
maxFilesScannednumberNo-Hard cap on scanned files.

tree

Render a directory tree.

ParameterTypeRequiredDefaultDescription
pathstringNo(root)Base directory for the operation.
maxDepthnumberNo5Maximum depth to recurse.
maxEntriesnumberNo1000Maximum number of entries before truncating.
includeHiddenbooleanNofalseInclude hidden files.
includeIgnoredbooleanNofalseInclude ignored directories.

read

Read the text contents of a file.

ParameterTypeRequiredDefaultDescription
pathstringYes-Absolute path to file.
headnumberNo-Read only the first N lines.
startLinenumberNo-Start reading from this line (1-based).
endLinenumberNo-Stop reading at this line (inclusive).

read_many

Read multiple text files in a single request.

ParameterTypeRequiredDefaultDescription
pathsarrayYes-Array of file paths to read.
headnumberNo-Read only the first N lines of each file.
startLinenumberNo-Start line for each file.
endLinenumberNo-End line for each file.

stat

Get metadata for a file or directory.

ParameterTypeRequiredDefaultDescription
pathstringYes-Absolute path to file or directory.

stat_many

Get metadata for multiple files or directories.

ParameterTypeRequiredDefaultDescription
pathsarrayYes-Array of file or directory paths.

grep

Search for text within file contents.

ParameterTypeRequiredDefaultDescription
patternstringYes-Text to search for.
pathstringNo(root)Base directory or file for the search.
isRegexbooleanNofalseTreat pattern as a regular expression.
caseSensitivebooleanNofalseEnable case-sensitive matching.
wholeWordbooleanNofalseMatch whole words only.
contextLinesnumberNo0Include N lines before/after each match.
maxResultsnumberNo500Maximum match rows to return.
maxFilesScannednumberNo20000Hard cap on scanned files.
filePatternstringNo**/*Glob filter for candidate files.
includeHiddenbooleanNofalseInclude hidden files.
includeIgnoredbooleanNofalseInclude ignored directories.

calculate_hash

Compute a SHA-256 hash for a file.

ParameterTypeRequiredDefaultDescription
pathstringYes-Absolute path to file.

diff_files

Generate a unified diff between two files.

ParameterTypeRequiredDefaultDescription
originalstringYes-Path to original file.
modifiedstringYes-Path to modified file.
contextnumberNo-Lines of context to include in the diff.
ignoreWhitespacebooleanNofalseIgnore leading/trailing whitespace in comparisons.
stripTrailingCrbooleanNofalseStrip trailing carriage returns before diffing.

apply_patch

Apply a unified patch to a file.

ParameterTypeRequiredDefaultDescription
pathstringYes-Path to file to patch.
patchstringYes-Unified diff content.
fuzzybooleanNofalseAllow fuzzy patching (compatibility flag).
fuzzFactornumberNo-Maximum fuzzy mismatches per hunk.
autoConvertLineEndingsbooleanNotrueAuto-convert patch line endings to match file.
dryRunbooleanNofalseCheck only, no writes.

search_and_replace

Search and replace text across multiple files.

Response includes processedFiles, failedFiles, and a sample failures list when some files cannot be processed.

ParameterTypeRequiredDefaultDescription
pathstringNo(root)Base directory for the operation.
filePatternstringYes-Glob pattern (e.g., **/*.ts).
excludePatternsarrayNo[]Glob patterns to exclude.
searchPatternstringYes-Text or regex pattern to replace.
replacementstringYes-Replacement text.
isRegexbooleanNofalseTreat search pattern as regex.
dryRunbooleanNofalseCheck only, no writes.

mkdir

Create a new directory (recursive).

ParameterTypeRequiredDefaultDescription
pathstringYes-Path to create.

write

Write content to a file.

ParameterTypeRequiredDefaultDescription
pathstringYes-Path to file.
contentstringYes-Content to write.

edit

Edit a file by replacing text.

ParameterTypeRequiredDefaultDescription
pathstringYes-Path to file.
editsarrayYes-Array of objects with oldText and newText.
dryRunbooleanNofalseOnly check if edits would succeed.

mv

Move or rename a file or directory.

ParameterTypeRequiredDefaultDescription
sourcestringYes-Current path.
destinationstringYes-New path.

rm

Delete a file or directory.

ParameterTypeRequiredDefaultDescription
pathstringYes-Path to delete.
recursivebooleanNofalseAllow deleting non-empty directories.
ignoreIfNotExistsbooleanNofalseDo not fail if path missing.

Resources

PatternDescription
internal://instructionsServer Instructions
fs-context://result/{id}Cached Tool Result

Tool responses may include a resource_link or a resourceUri when output is too large to inline. Fetch the full payload with resources/read using the provided URI. Cached results are ephemeral and may not appear in resources/list.

Prompts

PromptDescription
get-helpReturns the server instructions for quick reference.

Tasks

Long-running tools (grep, find, search_and_replace, tree, read_many, stat_many) support task-augmented calls. When task is provided to tools/call, the server returns a task id that can be polled with tasks/get and resolved via tasks/result. Include _meta.progressToken on requests to receive notifications/progress updates. Task data is stored in memory and is cleared when the server restarts.

Client Configuration Examples

VS Code (Claude Dev / Cline)

Add to your ~/AppData/Roaming/Code/User/globalStorage/mcp-settings.json (Windows) or ~/Library/Application Support/Code/User/globalStorage/mcp-settings.json (macOS):

{
  "mcpServers": {
    "fs-context": {
      "command": "npx",
      "args": [
        "-y",
        "@j0hanz/fs-context-mcp",
        "c:\\path\\to\\allowed\\directory"
      ]
    }
  }
}
Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "fs-context": {
      "command": "npx",
      "args": [
        "-y",
        "@j0hanz/fs-context-mcp",
        "c:\\path\\to\\allowed\\directory"
      ]
    }
  }
}
Cursor

Configure via the MCP settings panel:

  • Name: fs-context
  • Type: command
  • Command: npx -y @j0hanz/fs-context-mcp c:\path\to\allowed\directory

Security

  • Path Scope: Operations are restricted to the directories specified in allowedDirs or the current working directory if --allow-cwd is used.
  • Path Validation:
    • Null bytes are rejected.
    • Windows drive-relative paths (e.g., C:path) are rejected.
    • Windows reserved device names are rejected.
  • Symlinks: Symlink targets are reported but not implicitly followed during recursion in some operations to prevent loops or escaping scope (specific behavior varies by tool).

Development Workflow

  • Install dependencies:

    npm ci
    
  • Run in development mode (rebuilds on change):

    npm run dev
    
  • Run tests:

    npm run test
    
  • Lint and Format:

    npm run lint
    npm run format
    

Contributing & License

This project is licensed under the MIT License.

Keywords

mcp

FAQs

Package last updated on 10 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts