Krep MCP Server
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Integrations
Offers ESLint configuration integration for code quality enforcement within the krep MCP server environment
Provides testing infrastructure integration with Jest for unit and integration testing of the krep MCP server
Includes a Python integration client that allows Python applications to interact with the krep MCP server
Krep MCP Server
A high-performance string search utility with MCP (Model Context Protocol) integration for the infinity-topos environment. This is a wrapper around krep, an ultra-fast pattern matching utility that significantly outperforms traditional tools like grep.
Overview
Krep MCP Server provides a unified interface to the krep binary, a high-performance string search utility similar to grep but with optimized algorithms and multi-threading capabilities. It exposes krep's functionality through the Model Context Protocol, allowing AI assistants to perform efficient pattern searching in files and strings.
Features
- High-Performance Search: Uses optimized algorithms (KMP, Boyer-Moore-Horspool, Rabin-Karp) selected based on pattern length
- Hardware Acceleration: Leverages SIMD instructions (SSE4.2/AVX2 on x86/x64, NEON on ARM) when available
- Optimized Multi-Threading: Automatically uses all available CPU cores for maximum parallel search performance
- Unified Interface: Single function with multiple modes (file search, string search, count-only)
- MCP Integration: Seamless integration with AI assistants through the Model Context Protocol
Why This Codebase Is Tragic
This codebase demonstrates how a simple tool (a wrapper for a string search utility) became bloated with unnecessary complexity:
- Simple Core, Complex Implementation: The actual functionality is straightforward but buried under layers of over-engineering
- Documentation Overload: 15 documentation files for a tool that could be explained in a single well-structured README
- Integration Madness: 3 separate integration systems (Cline, Claude Desktop, SDK), each with redundant scripts and documentation
- Installation Script Proliferation: 7 installation scripts when one configurable script would suffice
- Error Handling Duplication: Error handling duplicated at multiple levels rather than having a unified approach
- Test Fragmentation: Test files scattered across the codebase rather than being organized systematically
- Configuration Redundancy: Configuration files and environment variables duplicated across multiple components
- Binary Path Overkill: Searches 37 different paths for a single binary that should be in one predictable location
What It Should Have Been:
Project Structure
Here's the actual project structure:
Installation
- Ensure you have the krep binary installed:Copy
- Configure the MCP server in your MCP settings file:Copy
Usage
The krep MCP server exposes a single unified function:
Parameters
- pattern (required): The pattern to search for
- target (required): File path or string to search in
- mode (optional): Search mode
file
(default): Search in a filestring
: Search in a stringcount
: Count occurrences only
- caseSensitive (optional): Whether the search is case-sensitive (default: true)
- threads (optional): Number of threads to use (default: auto-detected based on CPU cores)
Examples
See examples.md for detailed usage examples and patterns.
How It Works
The krep MCP server works by:
- Receiving requests through the Model Context Protocol
- Parsing the request parameters
- Building the appropriate krep command based on the mode and parameters
- Executing the command using the krep binary
- Parsing the results and returning them in a structured format
Performance
Krep is designed for high-performance pattern searching:
- Algorithm Selection: Automatically selects the optimal algorithm based on pattern length
- KMP (Knuth-Morris-Pratt) for very short patterns (< 3 characters)
- Boyer-Moore-Horspool for medium-length patterns (3-16 characters)
- Rabin-Karp for longer patterns (> 16 characters)
- Hardware Acceleration: Uses SIMD instructions when available
- Dynamic Multi-Threading: Automatically utilizes all available CPU cores for optimal parallel search performance
Cline VSCode Extension Integration
The krep-mcp-server can be integrated with the Cline VSCode extension, allowing you to use high-performance string search capabilities directly in your VSCode environment.
Installation with Cline
We provide an automatic installation script to set up the Cline integration:
Using krep in Cline
Once integrated, you can use krep directly in Cline conversations:
For detailed instructions and usage examples, see:
- CLINE_SETUP.md - Setup instructions
- CLINE_README.md - Usage guide
Integration with Infinity Topos
Krep MCP Server is designed to work seamlessly within the infinity-topos environment:
- Babashka Integration: Use Babashka to process search results
- Say Integration: Vocalize search results using the Say MCP server
- Coin-Flip Integration: Use randomization to determine search strategies
Development
Environment Variables
CLAUDE_MCP
: Set to "true" to run in MCP modeKREP_PATH
: Path to the krep binaryDEBUG
: Set to "true" for verbose loggingKREP_TEST_MODE
: Set to "true" to run in test mode with mock responsesKREP_SKIP_CHECK
: Set to "true" to skip checking if the krep binary exists
HTTP Server Mode
When not running in MCP mode, the server starts an HTTP server with the following endpoints:
GET /health
: Health check endpointGET /
: Server informationPOST /search
: Search for patterns in filesPOST /match
: Match patterns in stringsGET /performance
: Performance informationGET /algorithm-selection
: Algorithm selection guide
License
MIT
This server cannot be installed
A high-performance string search utility with Model Context Protocol integration that enables AI assistants to perform efficient pattern searching in files and strings.