Rust-based MCP server implementing file operations.
mcp-code-tools is a Rust-based Model Context Protocol (MCP) server implementing 8 file operation tools. Built with rmcp crate, it provides secure file manipulation within workspace boundaries.
-
file_ops/ - Core file operation implementations
common.rs- Path validation, traversal protection, workspace resolutioncopy.rs- File/directory copy operationsdelete.rs- File/directory deletionlist.rs- Directory listing with glob pattern supportmove.rs- File/directory move operationsread.rs- File reading with binary/text detection and multiple file readingreplace.rs- Regex-based content replacementsearch.rs- Regex-based file content search
-
server/ - MCP server implementation
handler.rs- Tool handlers with rmcp macrosrequests.rs- Request/response structs with schemarsmod.rs- Server struct definition
-
cli.rs - Command-line interface with Clap argument parsing
-
tests/ - Integration tests
- Python test scripts for each tool (8 test files)
- Full MCP protocol testing via subprocess
rmcp- MCP server implementationtokio- Async runtimeclap- CLI argument parsingregex- Regex pattern matchingglob- Glob pattern matchingserde/schemars- Serializationbase64- Binary file encoding
- file_read - Read file contents (text/base64 binary) with optional line range
- read_multiple_files - Read multiple files in single request
- list_directory - Single-level listing with glob pattern filtering
- search_files - Regex search with configurable timeout
- replace_in_files - Regex replacement with dry_run mode
- file_delete - Delete files/directories with dry_run mode
- file_move - Move/rename files with dry_run mode
- file_copy - Copy files/directories with dry_run mode
# Start server with workspace
mcp-code-tools --workspace /path/to/workspace- Must be absolute path
- Must exist and be directory
- Root directory '/' rejected
Relative to workspace directory.
Example: src/main.rs → /workspace/src/main.rs
Used directly (outside workspace allowed for read/search).
- Path traversal blocked (
../rejected) - Write/move/copy restricted to workspace
- Read/search allow absolute paths (safe)
All file operation logic tested.
| Tool | Status | Tests |
|---|---|---|
| file_read | ✅ | 15/15 pass |
| read_multiple_files | ✅ | 8/8 pass |
| list_directory | ✅ | 17/17 pass |
| search_files | ✅ | 9/9 pass |
| replace_in_files | ✅ | 8/8 pass |
| file_delete | ✅ | 7/7 pass |
| file_move | ✅ | 7/7 pass |
| file_copy | ✅ | 7/7 pass |
- search_files/replace_in_files timeout - Timeout detection works but may return partial results incorrectly
- list_directory empty - Empty directory listing returns empty array (expected behavior)