Filesystem Tools
STDIOEmpower AI agents with secure, efficient, token-saving access to project files.
Empower AI agents with secure, efficient, token-saving access to project files.
Empower your AI agents (like Cline/Claude) with secure, efficient, and token-saving access to your project files. This Node.js server implements the Model Context Protocol (MCP) to provide a robust set of filesystem tools, operating safely within a defined project root directory.
There are several ways to use the Filesystem MCP Server:
1. Recommended: npx
(or bunx
) via MCP Host Configuration
The simplest way is via npx
or bunx
, configured directly in your MCP host environment (e.g., Roo/Cline's mcp_settings.json
). This ensures you always use the latest version from npm without needing local installation or Docker.
Example (npx
):
{ "mcpServers": { "filesystem-mcp": { "command": "npx", "args": ["@sylphlab/filesystem-mcp"], "name": "Filesystem (npx)" } } }
Example (bunx
):
{ "mcpServers": { "filesystem-mcp": { "command": "bunx", "args": ["@sylphlab/filesystem-mcp"], "name": "Filesystem (bunx)" } } }
Important: The server uses its own Current Working Directory (cwd
) as the project root. Ensure your MCP Host (e.g., Cline/VSCode) is configured to launch the command with the cwd
set to your active project's root directory.
2. Docker
Use the official Docker image for containerized environments.
Example MCP Host Configuration:
{ "mcpServers": { "filesystem-mcp": { "command": "docker", "args": [ "run", "-i", "--rm", "-v", "/path/to/your/project:/app", // Mount your project to /app "sylphlab/filesystem-mcp:latest" ], "name": "Filesystem (Docker)" } } }
Remember to replace /path/to/your/project
with the correct absolute path.
3. Local Build (For Development)
git clone https://github.com/sylphlab/filesystem-mcp.git
cd filesystem-mcp && pnpm install
(Using pnpm now)pnpm run build
Note: Launch the{ "mcpServers": { "filesystem-mcp": { "command": "node", "args": ["/path/to/cloned/repo/filesystem-mcp/dist/index.js"], // Updated build dir "name": "Filesystem (Local Build)" } } }
node
command from the directory you intend as the project root.Once the server is configured in your MCP host (see Installation), your AI agent can immediately start using the filesystem tools.
Example Agent Interaction (Conceptual):
Agent: <use_mcp_tool>
<server_name>filesystem-mcp</server_name>
<tool_name>read_content</tool_name>
<arguments>{"paths": ["src/index.ts"]}</arguments>
</use_mcp_tool>
Server Response: (Content of src/index.ts)
cwd
at launch).npx
/bunx
.(Placeholder: Add benchmark results and comparisons here, demonstrating advantages over alternative methods like individual shell commands.)
This server equips your AI agent with a powerful and efficient filesystem toolkit:
list_files
, stat_items
): List files/directories (recursive, stats), get detailed status for multiple items.read_content
, write_content
): Read/write/append multiple files, creates parent directories.edit_file
, search_files
, replace_content
): Surgical edits (insert, replace, delete) across multiple files with indentation preservation and diff output; regex search with context; multi-file search/replace.create_directories
): Create multiple directories including intermediate parents.delete_items
): Remove multiple files/directories recursively.move_items
, copy_items
): Move/rename/copy multiple files/directories.chmod_items
, chown_items
): Change POSIX permissions and ownership for multiple items.Key Benefit: All tools accepting multiple paths/operations process each item individually and return a detailed status report.
(Placeholder: Explain the core design principles.)
(Placeholder: Objectively compare with alternatives.)
Feature/Aspect | Filesystem MCP Server | Individual Shell Commands (via Agent) | Other Custom Scripts |
---|---|---|---|
Security | High (Root Confined) | Low (Agent needs shell access) | Variable |
Efficiency (Tokens) | High (Batching) | Low (One command per op) | Variable |
Latency | Low (Direct API) | High (Shell spawn overhead) | Variable |
Batch Operations | Yes (Most tools) | No | Maybe |
Error Reporting | Detailed (Per item) | Basic (stdout/stderr parsing) | Variable |
Setup | Easy (npx/Docker) | Requires secure shell setup | Custom |
(Placeholder: List upcoming features or improvements.)
list_files
.(Placeholder: Add link to the full documentation website once available.)
Full documentation, including detailed API references and examples, will be available at: [Link to Docs Site]
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
This project is released under the MIT License.
git clone https://github.com/sylphlab/filesystem-mcp.git
cd filesystem-mcp && pnpm install
pnpm run build
(compiles TypeScript to dist/
)pnpm run dev
(optional, recompiles on save)This repository uses GitHub Actions (.github/workflows/publish.yml
) to automatically publish the package to npm and build/push a Docker image to Docker Hub on pushes of version tags (v*.*.*
) to the main
branch. Requires NPM_TOKEN
, DOCKERHUB_USERNAME
, and DOCKERHUB_TOKEN
secrets configured in the GitHub repository settings.