MCP Czkawka Server
by MitchellV3
README.md
# MCP Czkawka Server


An MCP (Model Context Protocol) server that provides tools to interact with the `czkawka_cli` command-line tool using FastMCP.
`czkawka` is a multi-functional app to find duplicates, empty folders, similar images/videos, broken files, etc. This server exposes its CLI functionality as MCP tools.
## 📋 Features
- Provides MCP tools corresponding to `czkawka_cli` subcommands:
- `find_duplicates` (`dup`)
- `find_empty_folders` (`empty-folders`)
- `find_big_files` (`big`)
- `find_empty_files` (`empty-files`)
- `find_temporary_files` (`temp`)
- `find_similar_images` (`image`)
- `find_similar_videos` (`video`)
- `find_duplicate_music` (`music`)
- `find_invalid_symlinks` (`symlinks`)
- `find_broken_files` (`broken`)
- `find_invalid_extension_files` (`ext`)
- Built using the FastMCP framework.
- Configurable path for the `czkawka_cli` executable via environment variable.
## 🚀 Getting Started
1. **Prerequisites**:
- Ensure you have `czkawka_cli` accessible on your system. Download it from the [Czkawka Releases page](https://github.com/qarmin/czkawka/releases).
- Ensure you have Node.js and npm installed (Download from [nodejs.org](https://nodejs.org/)).
2. **Install Dependencies**:
```bash
npm install
```
3. **Build the Server**:
```bash
npm run build
```
This creates the compiled JavaScript files in the `dist/` directory.
4. **Configure MCP Client**:
Add the server to your MCP client configuration (e.g., `mcp_settings.json` for Roo/VS Code or `.cursor/mcp.json`).
**Example `mcp_settings.json` entry:**
```json
{
"mcpServers": {
"czkawka-server": {
"command": "node",
"args": [
"c:/path/to/your/mcp-czkawka/dist/index.js" // Use absolute path to the compiled file in dist/
],
"env": {
"CZKAWKA_CLI_PATH": "c:/path/to/your/czkawka_cli.exe" // Use absolute path
}
}
// ... other servers
}
}
```
- Replace `"c:/path/to/your/mcp-czkawka/dist/index.js"` with the absolute path to the compiled server file in the `dist` directory.
- Replace `"c:/path/to/your/czkawka_cli.exe"` with the absolute path to your `czkawka_cli` executable.
5. **Restart MCP Client**: Restart your MCP client (e.g., VS Code) to load the new server configuration.
## 🛠️ Usage
Once configured, you can use the tools provided by this server (e.g., `find_duplicates`, `find_empty_folders`) through your MCP client. Refer to the tool descriptions provided by the server for specific parameters.
**Example Tool Call (Conceptual):**
```xml
<use_mcp_tool>
<server_name>czkawka-server</server_name>
<tool_name>find_duplicates</tool_name>
<arguments>
{
"directories": ["C:/Users/YourUser/Documents", "D:/Photos"],
"delete_method": "AEO",
"file_to_save": "C:/Users/YourUser/Desktop/duplicates_report.txt"
}
</arguments>
</use_mcp_tool>
```
## ⚙️ Configuration
- **`CZKAWKA_CLI_PATH` (Environment Variable)**: *Required*. Set this in the `env` section of your MCP server configuration to the absolute path of your `czkawka_cli` executable.
- **`CZKAWKA_TIMEOUT_MS` (Environment Variable)**: *Optional*. Maximum time in milliseconds to wait for a czkawka process to complete. Defaults to `600000` (10 minutes).
- **`CZKAWKA_MAX_CONCURRENT` (Environment Variable)**: *Optional*. Maximum number of czkawka processes to run concurrently. Defaults to `3`.
- **`CZKAWKA_MAX_OUTPUT_SIZE` (Environment Variable)**: *Optional*. Maximum combined stdout/stderr size in bytes to buffer in memory. If exceeded, the output is written to a temporary file and the result includes an `outputFile` path. Defaults to `10485760` (10 MB).
## 📚 Czkawka Documentation
For more details on `czkawka_cli` usage and options, refer to the official [Czkawka GitHub repository](https://github.com/qarmin/czkawka).
## 📦 Large Output Handling
For scans that produce very large result sets (e.g., millions of duplicate files), the MCP JSON response payload can become extremely large. The server provides two strategies to handle this:
1. **Automatic spillover to temp files**: If the combined stdout/stderr output exceeds `CZKAWKA_MAX_OUTPUT_SIZE` (default 10 MB), the result will include an `outputFile` field pointing to a temporary file on disk, and the `stdout`/`stderr` fields will be empty strings. The temp file is cleaned up on server shutdown.
2. **Direct file output (recommended for very large scans)**: Czkawka's built-in `file_to_save`, `compact_file_to_save`, and `pretty_file_to_save` parameters write results directly to a file on disk. This avoids transferring large payloads over MCP entirely. For example:
```json
{
"directories": ["C:/Users/YourUser/Documents"],
"file_to_save": "C:/Users/YourUser/Desktop/results.txt",
"compact_file_to_save": "C:/Users/YourUser/Desktop/results.json"
}
```
When using `file_to_save` or `compact_file_to_save`, czkawka writes results directly and outputs minimal status text to stdout, keeping the MCP response small.
## 🔒 Security Considerations
- **Network exposure**: This server is designed to run locally (stdio transport) or on a trusted network only. Do not expose the MCP endpoint to untrusted networks.
- **Binary execution**: This server executes the `czkawka_cli` binary tool and passes user-supplied directory paths directly to it. Ensure the server is only accessible to trusted clients.
- **Input validation**: The server validates that all directory paths are absolute and exist on disk before passing them to the CLI. Unknown fields are stripped by Zod schemas, preventing injection of unexpected CLI flags.
- **Access control**: Restrict access to the MCP endpoint using firewall rules or network segmentation. In HTTP/SSE mode, consider adding authentication or a reverse proxy.
## 📄 License
This project is licensed under the MIT License.
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues