Filesystem MCP Server
The Filesystem MCP Server provides secure, sandboxed filesystem operations with granular permission controls and advanced data processing capabilities.
Core Operations: Read, write, create, delete, move, and rename files and directories within explicitly allowed directories. Supports batch operations, recursive deletion, and metadata retrieval (size, timestamps, permissions).
Directory Management: List contents, generate recursive tree views with customizable depth and exclusion patterns, and perform directory-wide operations.
Search & Content: Recursively search files by name, pattern, or extension with depth/result limits. Search file contents using regular expressions across multiple files.
Data Processing: Convert XML to JSON, query XML with XPath expressions, and process JSON with JSONPath queries. Advanced JSON capabilities include filtering, transforming, validation against schemas, sampling, and key-value searching.
Advanced Editing: Pattern-matching file modifications with whitespace normalization and dry-run previews for change verification.
Security: Strict path validation, sandboxed operations within allowed directories, and granular permissions (read-only, create, edit, move, delete flags).
Deployment: Run locally, via Git, Docker, or hosted services with customizable directory access and permission configurations.
Enables running the filesystem MCP server in a containerized environment with volume mounting to control access to specific directories on the host system.
Allows running the filesystem MCP server directly with Node.js to provide file system operations with granular permission controls.
Provides specialized tools for XML processing including conversion to JSON, XPath querying, and structure analysis of XML files.
Click on "Deploy 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., "@Filesystem MCP Server read the contents of my notes.txt file"
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
Bun-based server implementing Model Context Protocol (MCP) for filesystem operations with comprehensive permission controls and enhanced functionality.
Development uses Bun and the server can run directly from TypeScript with bun, but most MCP clients execute Node-compatible JavaScript. Use node dist/index.js in configs unless you're intentionally running the TypeScript entry with Bun.
Features
Granular permission controls (read-only, full access, or specific operation permissions)
Secure file operations within allowed directories
File operations:
Read/write/modify files
Create/list/delete directories
Move files/directories
Search files by name or extension
Get file metadata
Directory operations:
Tree view of directory structures
Recursive operations with exclusion patterns
Utility functions:
XML to JSON conversion
Multiple file operations in one call
Advanced file editing with pattern matching
Security features:
Symlink control
Path validation
Sandboxed operations
Note: The server will only allow operations within directories specified via args and according to the configured permissions.
Related MCP server: MCP Filesystem Server
Installation
Install Bun (requires Bun v1.0 or later)
curl -fsSL https://bun.sh/install | bashInstall dependencies
bun installBuild the project (required for Node runtimes)
bun run buildRun tests
bun test
Configuration options
Paths may include environment variables like $HOME, ${CUSTOM}, or %USERPROFILE%. Choose the modality that fits your setup:
Local (Node or Bun)
Use Node for built JavaScript or Bun to run TypeScript directly.
{ "command": "node", "args": ["/path/to/mcp-filesystem/dist/index.js", "$HOME/allowed-directory"] }{ "command": "bun", "args": ["/path/to/mcp-filesystem/index.ts", "$HOME/allowed-directory"] }Git hosted
Run straight from the public repo without cloning.
{ "command": "bunx", "args": ["github:rawr-ai/mcp-filesystem", "$HOME/allowed-directory"] }{ "command": "npx", "args": ["github:rawr-ai/mcp-filesystem", "$HOME/allowed-directory"] }NPM package (coming soon)
Planned publication to rawr-ai/mcp-filesystem.
{ "command": "bunx", "args": ["rawr-ai/mcp-filesystem", "$HOME/allowed-directory"] }{ "command": "npx", "args": ["rawr-ai/mcp-filesystem", "$HOME/allowed-directory"] }Docker
Isolated container environment.
{ "command": "docker", "args": ["run", "--rm", "-v", "$HOME/allowed-directory:/data", "mcp/filesystem", "/data"] }Hosted service
For managed MCP hosts like glama.ai.
{ "mcpServers": { "filesystem": { "url": "https://glama.ai/rawr-ai/mcp-filesystem" } } }See the examples/ directory for platform-specific configs (Cursor, Roo, etc.) and additional path variants.
API
Resources
file://system: File system operations interface
Tools
All tool argument schemas are defined with TypeBox and registered via the toolSchemas map in src/schemas. This ensures every tool shares a consistent schema that handlers can reference.
read_file
Read contents of a file (response-capped)
Inputs:
path(string)maxBytes(number): Maximum bytes to return
Returns at most
maxBytesbytes to protect downstream consumers
read_multiple_files
Read multiple files simultaneously
Inputs:
paths(string[])maxBytesPerFile(number): Maximum bytes to return per file
Failed reads won't stop the entire operation
create_file
Create a new file with content
Inputs:
path(string): File locationcontent(string): File content
Fails if file already exists
Requires
createpermission
modify_file
Modify an existing file with new content
Inputs:
path(string): File locationcontent(string): New file content
Fails if file doesn't exist
Requires
editpermission
edit_file
Make selective edits using pattern matching and formatting
Features:
Line-based and multi-line content matching
Whitespace normalization with indentation preservation
Multiple simultaneous edits with correct positioning
Indentation style detection and preservation
Git-style diff output with context
Preview changes with dry run mode
Inputs:
path(string): File to editedits(array): List of edit operationsoldText(string): Text to search for (exact match)newText(string): Text to replace with
dryRun(boolean): Preview changes without applying (default: false)maxBytes(number): Maximum bytes to read before editing
Returns detailed diff for dry runs, otherwise applies changes
Requires
editpermissionBest Practice: Always use dryRun first to preview changes
create_directory
Create new directory or ensure it exists
Input:
path(string)Creates parent directories if needed
Succeeds silently if directory exists
Requires
createpermission
list_directory
List directory contents with [FILE] or [DIR] prefixes
Input:
path(string)Returns detailed listing of files and directories
directory_tree
Get recursive tree view of directory structure
Input:
path(string)Returns JSON structure with files and directories
Each entry includes name, type, and children (for directories)
move_file
Move or rename files and directories
Inputs:
source(string): Source pathdestination(string): Destination path
Fails if destination exists
Works for both files and directories
Requires
movepermission
delete_file
Delete a file
Input:
path(string)Fails if file doesn't exist
Requires
deletepermission
delete_directory
Delete a directory
Inputs:
path(string): Directory to deleterecursive(boolean): Whether to delete contents (default: false)
Fails if directory is not empty and recursive is false
Requires
deletepermission
search_files
Recursively search for files/directories
Inputs:
path(string): Starting directorypattern(string): Search patternexcludePatterns(string[]): Exclude patterns (glob format supported)
Case-insensitive matching
Returns full paths to matches
find_files_by_extension
Find all files with specific extension
Inputs:
path(string): Starting directoryextension(string): File extension to findexcludePatterns(string[]): Optional exclude patterns
Case-insensitive extension matching
Returns full paths to matching files
get_file_info
Get detailed file/directory metadata
Input:
path(string)Returns:
Size
Creation time
Modified time
Access time
Type (file/directory)
Permissions
get_permissions
Get current server permissions
No input required
Returns:
Permission flags (readonly, fullAccess, create, edit, move, delete)
Symlink following status
Number of allowed directories
list_allowed_directories
List all directories the server is allowed to access
No input required
Returns array of allowed directory paths
xml_to_json
Convert XML file to JSON format
Inputs:
xmlPath(string): Source XML filejsonPath(string): Destination JSON filemaxResponseBytes(number, optional): Maximum size of written JSON; large outputs are summarizedoptions(object, optional):ignoreAttributes(boolean): Skip XML attributes (default: false)preserveOrder(boolean): Maintain property order (default: true)format(boolean): Pretty print JSON (default: true)indentSize(number): JSON indentation (default: 2)
Requires
readpermission for XML fileRequires
createoreditpermission for JSON file
xml_to_json_string
Convert XML file to JSON string
Inputs:
xmlPath(string): Source XML filemaxResponseBytes(number, optional): Maximum size of returned JSON string; large outputs are summarizedoptions(object, optional):ignoreAttributes(boolean): Skip XML attributes (default: false)preserveOrder(boolean): Maintain property order (default: true)
Requires
readpermission for XML fileReturns JSON string representation (response-capped)
xml_query
Query XML file using XPath expressions
Inputs:
path(string): Path to the XML filequery(string, optional): XPath query to executestructureOnly(boolean, optional): Return only tag structureincludeAttributes(boolean, optional): Include attribute info (default: true)maxResponseBytes(number, optional): Maximum size of returned JSON; defaults to 200KBLegacy
maxBytesis still accepted and treated as response cap
XPath examples:
Get all elements:
//tagnameGet elements with specific attribute:
//tagname[@attr="value"]Get text content:
//tagname/text()
Parses full file; response is truncated to fit limits as needed
xml_structure
Analyze XML structure
Inputs:
path(string): Path to the XML filemaxDepth(number, optional): How deep to analyze (default: 2)includeAttributes(boolean, optional): Include attribute analysis (default: true)maxResponseBytes(number, optional): Maximum size of returned JSON; defaults to 200KBLegacy
maxBytesis still accepted and treated as response cap
Returns statistical information about elements, attributes, namespaces, and hierarchy
Parses full file; returns a summarized structure if response exceeds limit
regex_search_content
Search file contents with a regular expression
Inputs:
path(string): Root directory to searchregex(string): Regular expression patternfilePattern(string, optional): Glob to limit files (default:*)maxDepth(number, optional): Directory depth (default: 2)maxFileSize(number, optional): Maximum file size in bytes (default: 10MB)maxResults(number, optional): Maximum number of files with matches (default: 50)
Returns a human-readable summary of files and matching lines
Argument Validation
The server validates all tool inputs using the parseArgs helper. parseArgs parses incoming data against the appropriate TypeBox schema and throws an error when the arguments do not match the expected structure.
Permissions & Security
The server implements a comprehensive security model with granular permission controls:
Directory Access Control
Operations are strictly limited to directories specified during startup via
argsAll operations (including symlink targets) must remain within allowed directories
Path validation ensures no directory traversal or access outside allowed paths
Permission Flags
--readonly: Enforces read-only mode, overriding all other permission flags
--full-access: Enables all operations (create, edit, move, delete)
Individual permission flags (require explicit enabling unless --full-access is set):
--allow-create: Allow creation of new files and directories
--allow-edit: Allow modification of existing files
--allow-move: Allow moving/renaming files and directories
--allow-delete: Allow deletion of files and directories
Default Behavior: If no permission flags are specified, the server runs in read-only mode. To enable any write operations, you must use either --full-access or specific --allow-* flags.
Symlink Handling
By default, symlinks are followed when both the link and target are within allowed directories
--no-follow-symlinks: treat symlinks as regular files and refuse to traverse their targets, preventing escapes via linked paths
See examples/mcp_permissions.json for sample configurations using these flags.
Build
To compile the project locally run:
bun run buildRun the test suite with:
bun testDocker build:
docker build -t mcp/filesystem -f Dockerfile .License
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
Available Tools
21 toolsdirectory_treeA
Get a recursive tree view of files and directories as a JSON structure. Supports depth limiting to control traversal depth and exclusion patterns using glob syntax. Each entry includes 'name', 'type' (file/directory), and 'children' for directories. Files have no children array, while directories always have a children array (which may be empty). Requires maxDepth parameter (default 2) to limit recursion. Use excludePatterns to filter out unwanted files/directories. The output is formatted with 2-space indentation for readability. Only works within allowed directories.
Inputs: maxDepth (required), path (required), excludePatterns.
find_files_by_extensionA
Recursively find all files with a specific extension. Searches through all subdirectories from the starting path. Extension matching is case-insensitive. Returns full paths to all matching files. Requires maxDepth (default 2) and maxResults (default 10) parameters. Perfect for finding all XML, JSON, or other file types in a directory structure. Only searches within allowed directories.
Inputs: extension (required), maxDepth (required), maxResults (required), path (required), +1 more.
get_file_infoA
Retrieve detailed metadata about a file or directory. Returns comprehensive information including size, creation time, last modified time, permissions, and type. This tool is perfect for understanding file characteristics without reading the actual content. Only works within allowed directories.
Inputs: path (required).
get_permissionsA
Returns the current permission state of the server, including which operations are allowed (create, edit, move, delete) and whether the server is in read-only mode or has full access. Use this to understand what operations are permitted before attempting them.
Inputs: no named parameters.
json_filterA
Filter JSON array data using flexible conditions. Supports various comparison operators (equals, greater than, contains, etc.) and can combine multiple conditions with AND/OR logic. Requires maxBytes parameter (default 10KB). Perfect for filtering collections of objects based on their properties. The path must be within allowed directories.
Inputs: conditions (required), maxBytes (required), path (required), arrayPath, +1 more.
json_get_valueA
Get a specific value from a JSON file using a field path. Supports dot notation for accessing nested properties and array indices. Requires maxBytes parameter (default 10KB). Returns the value directly, properly formatted. The path must be within allowed directories.
Inputs: field (required), maxBytes (required), path (required).
json_queryC
Query JSON data using JSONPath expressions. Provides powerful search capabilities for selecting data within JSON structures. Supports standard JSONPath syntax for finding values, arrays, and nested structures. Requires maxBytes parameter (default 10KB). The path must be within allowed directories.
Inputs: maxBytes (required), path (required), query (required).
json_sampleA
Sample JSON data from a JSON file. Requires maxBytes parameter (default 10KB). Returns a random sample of data from the JSON file. The path must be within allowed directories.
Inputs: arrayPath (required), count (required), maxBytes (required), path (required), +1 more.
json_search_kvB
Search for key-value pairs in JSON files within a directory. Requires maxBytes (default 10KB), maxDepth (default 2), and maxResults (default 10) parameters. Returns all key-value pairs that match the search pattern. The path must be within allowed directories.
Inputs: directoryPath (required), key (required), maxBytes (required), maxDepth (required), +4 more.
json_structureA
Get the structure of a JSON file by analyzing its top-level keys and their types. Returns a mapping of key names to their corresponding data types (string, number, array, etc). For arrays, it also indicates the type of the first element if available. This is useful for understanding the shape of large JSON files without loading their entire content. Requires maxBytes (default 10KB) and maxDepth (default 2) parameters. The path must be within allowed directories.
Inputs: maxBytes (required), maxDepth (required), path (required), detailedArrayTypes.
json_transformB
Transform JSON data using a sequence of operations. Supports operations like mapping array elements, grouping by fields, sorting, flattening nested arrays, and picking/omitting fields. Requires maxBytes parameter (default 10KB). Operations are applied in sequence to transform the data structure. The path must be within allowed directories.
Inputs: maxBytes (required), operations (required), path (required).
json_validateA
Validate JSON data against a JSON schema. Requires maxBytes parameter (default 10KB) for the data file. Returns true if the JSON data is valid against the schema, or false if it is not. The path must be within allowed directories.
Inputs: maxBytes (required), path (required), schemaPath (required), allErrors, +1 more.
list_allowed_directoriesA
Returns the list of directories that this server is allowed to access. Use this to understand which directories are available before trying to access files.
Inputs: no named parameters.
list_directoryA
Get a detailed listing of all files and directories in a specified path. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is essential for understanding directory structure and finding specific files within a directory. Only works within allowed directories.
Inputs: path (required).
read_fileA
Read the complete contents of a file from the file system. Handles various text encodings and provides detailed error messages if the file cannot be read. Use this tool when you need to examine the contents of a single file. Requires maxBytes parameter. Only works within allowed directories.
Inputs: maxBytes (required), path (required).
read_multiple_filesA
Read the contents of multiple files simultaneously. This is more efficient than reading files one by one when you need to analyze or compare multiple files. Each file's content is returned with its path as a reference. Failed reads for individual files won't stop the entire operation. Requires maxBytesPerFile parameter. Only works within allowed directories.
Inputs: maxBytesPerFile (required), paths (required).
regex_search_contentA
Recursively search file content using a regex pattern. Searches through subdirectories from the starting path. Returns a list of files containing matches, including line numbers and matching lines. Requires regex pattern. Optional: path, filePattern, maxDepth, maxFileSize, maxResults. Only searches within allowed directories.
Inputs: path (required), regex (required), filePattern, maxDepth, +2 more.
search_filesA
Recursively search for files and directories matching a pattern. Searches through all subdirectories from the starting path. The search is case-insensitive and matches partial names. Returns full paths to all matching items. Requires maxDepth (default 2) and maxResults (default 10) parameters. Great for finding files when you don't know their exact location. Only searches within allowed directories.
Inputs: maxDepth (required), maxResults (required), path (required), pattern (required), +1 more.
xml_queryA
Query XML file using XPath expressions. Provides powerful search capabilities without reading the entire file into memory. Supports standard XPath 1.0 query syntax for finding elements, attributes, and text content. Requires maxBytes parameter (default 10KB). Can be used to extract specific data from large XML files with precise queries. The path must be within allowed directories.
Inputs: maxBytes (required), path (required), includeAttributes, query, +1 more.
xml_structureA
Analyze XML file structure without reading the entire file. Returns statistical information about element counts, attribute usage, namespaces, and hierarchical structure. Useful for understanding the structure of large XML files before performing detailed queries. Requires maxBytes (default 10KB) and maxDepth (default 2) parameters. The path must be within allowed directories.
Inputs: maxBytes (required), maxDepth (required), path (required), includeAttributes.
xml_to_json_stringA
Convert an XML file to a JSON string and return it directly. This is useful for quickly inspecting XML content as JSON without creating a new file. Requires maxBytes parameter (default 10KB). Uses fast-xml-parser for conversion. The input path must be within allowed directories. This tool is fully functional in both readonly and write modes (respecting maxBytes) since it only reads the XML file and returns the parsed data.
Inputs: maxBytes (required), xmlPath (required), options.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 21 tools
The tool set has clear functional groupings (filesystem navigation, JSON operations, XML operations, file reading/searching), but there is some overlap within groups. For example, directory_tree, list_directory, and search_files all provide directory listings with different formats and search capabilities, which could cause confusion. Similarly, json_query, json_filter, and json_search_kv offer overlapping JSON querying functionalities. Descriptions help differentiate, but an agent might struggle to choose the optimal tool for a given task.
Tool names follow a highly consistent snake_case pattern with clear verb_noun or noun_verb structures (e.g., directory_tree, find_files_by_extension, get_file_info). All tools adhere to this convention, making them predictable and easy to parse. There are no deviations in naming style, which enhances coherence across the set.
With 21 tools, this server feels overloaded for a filesystem domain. Many tools offer similar or overlapping functionalities (e.g., multiple JSON query tools, multiple directory listing tools), suggesting redundancy. A more streamlined set of 10-15 tools could cover the same scope without overwhelming agents, making the current count excessive and potentially confusing.
The server provides comprehensive coverage for filesystem operations, including navigation, metadata retrieval, content reading, and search (both file and content-based). It also includes specialized tools for JSON and XML processing. However, there are minor gaps: no tools for creating, editing, moving, or deleting files/directories (implied by get_permissions indicating possible write modes), which limits full lifecycle management. The allowed directories and permissions tools help agents work around this, but the surface is not fully complete for write operations.
Maintenance
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- FlicenseAqualityBmaintenanceNode.js server implementing Model Context Protocol (MCP) for filesystem operations.70141,222,611 npm92,139-
- AlicenseAqualityDmaintenanceA secure Model Context Protocol server that provides controlled filesystem access within predefined directories, enabling AI models to perform file and directory operations with strict path validation.1695 npm7MIT
- AlicenseNot gradedqualityCmaintenanceNode.js server implementing Model Context Protocol for secure read-only filesystem operations, allowing Claude to read files, list directories, search files, and get file metadata within specified directories.6MIT
- -licenseNot gradedqualityNot gradedmaintenanceNode.js server implementing Model Context Protocol (MCP) for filesystem operations, allowing AI systems to read, write, edit files and manage directories within specified allowed paths.1,222,611 npm-