kodegen-tools-filesystem
Memory-efficient, blazing-fast MCP (Model Context Protocol) filesystem tools for AI code generation agents.
Overview
kodegen-tools-filesystem provides a comprehensive suite of 14 filesystem and search tools exposed via the Model Context Protocol (MCP). Built on top of ripgrep's powerful search capabilities, it offers high-performance file operations, directory management, and advanced code search functionality for AI agents.
Features
File Operations
- Read Files: Single or batch file reading with offset/length support
- Write Files: Create or append with intelligent chunking
- Edit Files: Surgical text replacement with exact string matching
- Move/Delete: Rename, move, and delete file operations
- File Info: Retrieve comprehensive file metadata
Directory Management
- List Directories: Recursive listing with configurable depth
- Create Directories: Recursive directory creation
- Delete Directories: Safe recursive removal
Advanced Search (Powered by ripgrep)
- File Search: Find files by name pattern with glob support
- Content Search: Full-text search inside files with regex/PCRE2
- Streaming Results: Asynchronous search with pagination
- Session Management: Concurrent searches with cancellation support
Search Features
- Dual regex engines (Rust regex + PCRE2 fallback)
- Case-sensitive, case-insensitive, and smart-case modes
- Word and line boundary matching
- Binary file handling (auto-detect, skip, or force text)
- Multiline pattern support
- Search inside compressed files (.gz, .zip, .bz2, .xz)
- Sort by path, modification time, access time, or creation time
- Context lines (before/after match)
- Invert match (show non-matching results)
Installation
Prerequisites
- Rust nightly toolchain (edition 2024)
- Cargo
From Source
The compiled binary will be available at target/release/kodegen-filesystem.
Usage
Running the Server
# Run with default settings
# Run with custom allowed directories
KODEGEN_ALLOWED_DIRS="/path/to/workspace:/another/path"
# Run the release build
Configuration
The server respects the following environment variables:
| Variable | Description | Default |
|---|---|---|
KODEGEN_ALLOWED_DIRS |
Colon-separated list of allowed directories | Empty (all paths allowed) |
KODEGEN_DENIED_DIRS |
Colon-separated list of denied directories | Empty (no paths denied) |
Path Access Rules:
- Denied directories are checked first (blacklist takes precedence)
- If
KODEGEN_ALLOWED_DIRSis set, only those paths are accessible - If both are empty, all filesystem paths are accessible
Available Tools
The server exposes 14 MCP tools:
| Category | Tool | Description |
|---|---|---|
| File Ops | read_file |
Read file contents with offset/length support |
read_multiple_files |
Batch read multiple files | |
write_file |
Write or append to files | |
edit_block |
Replace text blocks surgically | |
move_file |
Move or rename files | |
delete_file |
Delete files | |
get_file_info |
Get file metadata | |
| Directory | create_directory |
Create directories recursively |
list_directory |
List directory contents with depth | |
delete_directory |
Delete directories recursively | |
| Search | start_search |
Start file or content search |
get_more_search_results |
Paginate search results | |
stop_search |
Cancel active search | |
list_searches |
List active search sessions |
Examples
Running Examples
# Comprehensive demo of all 14 tools
# Search examples
Search Example
use tools;
use json;
// Start a content search
let response = client.call_tool.await?;
let session_id = response.session_id;
// Get results
let results = client.call_tool.await?;
Development
Building
# Debug build
# Release build
Testing
# Run all tests
# Run with output
Code Quality
# Format code
# Run linter
# Auto-fix clippy warnings
Architecture
Core Components
- Tool Modules: Each tool (
read_file,write_file, etc.) is a self-contained module - Search Manager: Stateful coordinator for concurrent search sessions
- Ripgrep Integration: Full ripgrep implementation with dual regex engines
- Path Validation: Security layer for filesystem access control
- HTTP Server: MCP protocol server using
kodegen_server_http
Search Architecture
The search system uses a session-based model:
start_searchcreates a background search task and returns a session IDget_more_search_resultsretrieves paginated resultsstop_searchcancels the background task- Sessions auto-expire after inactivity
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Links
- Homepage: kodegen.ai
- Repository: github.com/cyrup-ai/kodegen-tools-filesystem
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Built with ❤️ by KODEGEN.ᴀɪ