
文件系统
STDIO文件系统MCP服务器,提供安全精细权限控制
文件系统MCP服务器,提供安全精细权限控制
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.
Note: The server will only allow operations within directories specified via args
and according to the configured permissions.
curl -fsSL https://bun.sh/install | bash
bun install
bun run build
bun test
Paths may include environment variables like $HOME
, ${CUSTOM}
, or %USERPROFILE%
. Choose the modality that fits your setup:
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"] }
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"] }
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"] }
Isolated container environment.
{ "command": "docker", "args": ["run", "--rm", "-v", "$HOME/allowed-directory:/data", "mcp/filesystem", "/data"] }
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.
file://system
: File system operations interfaceAll 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
path
(string)maxBytes
(number): Maximum bytes to returnmaxBytes
bytes to protect downstream consumersread_multiple_files
paths
(string[])maxBytesPerFile
(number): Maximum bytes to return per filecreate_file
path
(string): File locationcontent
(string): File contentcreate
permissionmodify_file
path
(string): File locationcontent
(string): New file contentedit
permissionedit_file
path
(string): File to editedits
(array): List of edit operations
oldText
(string): Text to search for (exact match)newText
(string): Text to replace withdryRun
(boolean): Preview changes without applying (default: false)maxBytes
(number): Maximum bytes to read before editingedit
permissioncreate_directory
path
(string)create
permissionlist_directory
path
(string)directory_tree
path
(string)move_file
source
(string): Source pathdestination
(string): Destination pathmove
permissiondelete_file
path
(string)delete
permissiondelete_directory
path
(string): Directory to deleterecursive
(boolean): Whether to delete contents (default: false)delete
permissionsearch_files
path
(string): Starting directorypattern
(string): Search patternexcludePatterns
(string[]): Exclude patterns (glob format supported)find_files_by_extension
path
(string): Starting directoryextension
(string): File extension to findexcludePatterns
(string[]): Optional exclude patternsget_file_info
path
(string)get_permissions
list_allowed_directories
xml_to_json
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)read
permission for XML filecreate
or edit
permission for JSON filexml_to_json_string
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)read
permission for XML filexml_query
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 200KB
maxBytes
is still accepted and treated as response cap//tagname
//tagname[@attr="value"]
//tagname/text()
xml_structure
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 200KB
maxBytes
is still accepted and treated as response capregex_search_content
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)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.
The server implements a comprehensive security model with granular permission controls:
args
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.
See examples/mcp_permissions.json
for sample configurations using these flags.
To compile the project locally run:
bun run build
Run the test suite with:
bun test
Docker build:
docker build -t mcp/filesystem -f Dockerfile .
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.