Skip to content

lulkien/mcp-code-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mcp-code-tools

Rust-based MCP server implementing file operations.

Project Overview

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.

Architecture

Modules

  • file_ops/ - Core file operation implementations

    • common.rs - Path validation, traversal protection, workspace resolution
    • copy.rs - File/directory copy operations
    • delete.rs - File/directory deletion
    • list.rs - Directory listing with glob pattern support
    • move.rs - File/directory move operations
    • read.rs - File reading with binary/text detection and multiple file reading
    • replace.rs - Regex-based content replacement
    • search.rs - Regex-based file content search
  • server/ - MCP server implementation

    • handler.rs - Tool handlers with rmcp macros
    • requests.rs - Request/response structs with schemars
    • mod.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

Dependencies

  • rmcp - MCP server implementation
  • tokio - Async runtime
  • clap - CLI argument parsing
  • regex - Regex pattern matching
  • glob - Glob pattern matching
  • serde / schemars - Serialization
  • base64 - Binary file encoding

Features

8 File Operations

  1. file_read - Read file contents (text/base64 binary) with optional line range
  2. read_multiple_files - Read multiple files in single request
  3. list_directory - Single-level listing with glob pattern filtering
  4. search_files - Regex search with configurable timeout
  5. replace_in_files - Regex replacement with dry_run mode
  6. file_delete - Delete files/directories with dry_run mode
  7. file_move - Move/rename files with dry_run mode
  8. file_copy - Copy files/directories with dry_run mode

CLI Usage

# Start server with workspace
mcp-code-tools --workspace /path/to/workspace

Workspace Validation

  • Must be absolute path
  • Must exist and be directory
  • Root directory '/' rejected

Path Resolution

Relative Paths

Relative to workspace directory.

Example: src/main.rs/workspace/src/main.rs

Absolute Paths

Used directly (outside workspace allowed for read/search).

Security

  • Path traversal blocked (../ rejected)
  • Write/move/copy restricted to workspace
  • Read/search allow absolute paths (safe)

Test Results

Unit Tests: 56/56 PASS

All file operation logic tested.

MCP Tool Tests: 8 Tools

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

Known Issues

  1. search_files/replace_in_files timeout - Timeout detection works but may return partial results incorrectly
  2. list_directory empty - Empty directory listing returns empty array (expected behavior)

About

Just a dumb MCP server playground

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors