Krep MCP Server

by bmorphism
Verified

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 服务器

一个集成了 MCP(模型上下文协议)的高性能字符串搜索实用程序,适用于 infinity-topos 环境。它是krep的包装器,krep 是一个超快速的模式匹配实用程序,其性能显著优于 grep 等传统工具。

THE KREP-MCP-SERVER ABSURDITY DIAGRAM ==================================== +-----------------------------------------------------+ | | | The KREP MCP Redundancy Zone | | | +-----^--------------------+------------------------+-+ | | | +-----------+----------+ +------+-------------+ +------+-------+ | | | | | | | M E T A D A T A | | F U N C T I O N | | B I N A R Y | | E X P L O S I O N | | N A M E C H A O S| | H U N T | | | | | | | +-----+----------+-----+ +---+-----------+----+ +------+-------+ | | | | | v v v v v +--------+--+ +----+-----+ +---+----+ +---+-----+ +----+------+ | | | | | | | | | | | "Unified" | | 37 Paths | | krep | |krepSearch| | 5 Error | | Function | | To Find | | | |krepMatch | | Handlers | | That Does | | The Same | | | |krepCount | | For | | 3 Things | | Binary | | | | | | 1 Error | | | | | | | | | | | +-----------+ +----------+ +--------+ +----------+ +-----------+ +-----------------------------------------------------+ | | | Configuration & Shell Script Hell | | | +-----^--------------------+------------------------+-+ | | | +-----------+----------+ +------+-------------+ +------+-------+ | | | | | | | 3 Scripts to | | Integer | | Test Mode | | Install 1 Thing | | Arithmetic in | | that Mocks | | | | Shell that says | | Success When| | | | 0 + 0 = Syntax | | Everything | | | | Error | | Fails | +----------------------+ +--------------------+ +--------------+ "It's not redundant if it's resilient!" - MCP Engineer, probably

概述

Krep MCP 服务器为 krep 二进制文件提供了统一的接口。krep 是一款高性能字符串搜索工具,类似于 grep,但算法经过优化,并具备多线程功能。它通过模型上下文协议 (MCP) 公开 krep 的功能,使 AI 助手能够在文件和字符串中执行高效的模式搜索。

特征

  • 高性能搜索:使用根据模式长度选择的优化算法(KMP、Boyer-Moore-Horspool、Rabin-Karp)
  • 硬件加速:利用可用的 SIMD 指令(x86/x64 上的 SSE4.2/AVX2、ARM 上的 NEON)
  • 优化的多线程:自动使用所有可用的 CPU 核心,以实现最大的并行搜索性能
  • 统一界面:单一功能,多种模式(文件搜索、字符串搜索、仅计数)
  • MCP 集成:通过模型上下文协议与 AI 助手无缝集成

为什么这个代码库是悲剧

该代码库演示了一个简单的工具(字符串搜索实用程序的包装器)如何因不必要的复杂性而变得臃肿:

  1. 核心简单,实现复杂:实际功能简单,但却被过度工程层层掩盖
  2. 文档过载:一个工具的文档文件有 15 个,而这些文档可以在一个结构良好的 README 文件中解释清楚
  3. 集成疯狂:3 个独立的集成系统(Cline、Claude Desktop、SDK),每个系统都有冗余的脚本和文档
  4. 安装脚本激增:一个可配置脚本就足够了,但实际却有 7 个安装脚本
  5. 错误处理重复:错误处理在多个级别重复,而不是采用统一的方法
  6. 测试碎片化:测试文件分散在代码库中,没有系统地组织起来
  7. 配置冗余:配置文件和环境变量在多个组件之间重复
  8. 二进制路径过度杀伤:搜索 37 条不同的路径,以找到应该位于一个可预测位置的单个二进制文件

它应该是这样的:

┌──────────────────────┐ │ krep-mcp-server │ │ ┌────────────────┐ │ │ │ index.js │ │ │ │ - one function│ │ │ └────────────────┘ │ │ ┌────────────────┐ │ │ │ README.md │ │ │ │ - clear docs │ │ │ └────────────────┘ │ │ ┌────────────────┐ │ │ │ install.sh │ │ │ │ - one script │ │ │ └────────────────┘ │ └──────────────────────┘

项目结构

这是实际的项目结构:

krep-mcp-server/ ├── CLINE_README.md ├── CLINE_SETUP.md ├── CLAUDE_DESKTOP_INTEGRATION.md ├── CLAUDE_DESKTOP_README.md ├── EXAMPLES.md ├── IMPLEMENTATION_SUMMARY.md ├── INSTALL_NOW.md ├── LIFECYCLE_DESIGN.md ├── MCP_COMPLIANCE.md ├── MCP_URIS.md ├── README.md ├── SETUP_CLAUDE_DESKTOP.md ├── TESTING_STRATEGY.md ├── THREAD_OPTIMIZATION.md ├── analysis/ │ └── index.tree.json ├── auto-install-claude.sh ├── cline-config.js ├── direct-install.sh ├── eslint.config.js ├── fix-claude-desktop.sh ├── go-integration/ │ ├── example/ │ └── krep.go ├── install-claude-desktop.sh ├── install-cline-integration.sh ├── install-sdk-integrations.sh ├── jest.config.js ├── just-krep.sh ├── mcp-config.json ├── package-lock.json ├── package.json ├── python-integration/ │ └── krep_mcp_client.py ├── run-claude-desktop.sh ├── run-claude-integration.sh ├── run-cline-mcp-server.sh ├── run-cline-test.sh ├── run-tests.sh ├── run.sh ├── sdk-integration.js ├── src/ │ ├── index.js │ ├── index.min.js │ ├── mcp_server.js │ └── mcp_server.min.js ├── Support/ │ └── Claude/ ├── test/ │ ├── benchmark.js │ ├── fixtures/ │ ├── integration/ │ ├── mcp_benchmark.js │ ├── mock-server.js │ ├── unit/ │ └── utils.js └── various test scripts...

安装

  1. 确保已安装 krep 二进制文件:
    cd /path/to/krep-native make
  2. 在您的 MCP 设置文件中配置 MCP 服务器:
    { "mcpServers": { "krep": { "command": "node", "args": [ "/path/to/krep-mcp-server/src/index.js" ], "env": { "CLAUDE_MCP": "true", "KREP_PATH": "/path/to/krep-native/krep", "DEBUG": "true" }, "description": "High-performance string search utility with unified interface", "disabled": false, "autoApprove": [ "krep" ] } } }

用法

krep MCP 服务器公开单一统一的功能:

<use_mcp_tool> <server_name>krep</server_name> <tool_name>krep</tool_name> <arguments> { "pattern": "search pattern", "target": "file path or string to search", "mode": "file|string|count", "caseSensitive": true|false, "threads": null // Automatically uses all CPU cores if not specified } </arguments> </use_mcp_tool>

参数

  • 模式(必需):要搜索的模式
  • 目标(必需):要搜索的文件路径或字符串
  • 模式(可选):搜索模式
    • file (默认):在文件中搜索
    • string :在字符串中搜索
    • count :仅统计出现次数
  • caseSensitive (可选):搜索是否区分大小写(默认值:true)
  • 线程(可选):要使用的线程数(默认值:根据 CPU 核心自动检测)

示例

有关详细使用示例和模式,请参阅examples.md

工作原理

krep MCP 服务器的工作原理如下:

  1. 通过模型上下文协议接收请求
  2. 解析请求参数
  3. 根据模式和参数构建适当的krep命令
  4. 使用 krep 二进制文件执行命令
  5. 解析结果并以结构化格式返回

表现

Krep 专为高性能模式搜索而设计:

  • 算法选择:根据模式长度自动选择最佳算法
    • KMP(Knuth-Morris-Pratt)适用于非常短的模式(<3 个字符)
    • Boyer-Moore-Horspool 适用于中等长度模式(3-16 个字符)
    • Rabin-Karp 用于较长的模式(> 16 个字符)
  • 硬件加速:使用可用的 SIMD 指令
  • 动态多线程:自动利用所有可用的 CPU 核心,实现最佳并行搜索性能

Cline VSCode 扩展集成

krep-mcp-server 可以与 Cline VSCode 扩展集成,让您直接在 VSCode 环境中使用高性能字符串搜索功能。

使用 Cline 安装

我们提供了一个自动安装脚本来设置 Cline 集成:

# Install the integration ./install-cline-integration.sh # Test the integration before installing ./run-cline-test.sh # Uninstall the integration ./uninstall-cline-integration.sh

在 Cline 中使用 krep

一旦集成,您就可以在 Cline 对话中直接使用 krep:

/krep krep pattern="function" target="/path/to/search" mode="file"

有关详细说明和使用示例,请参阅:

与 Infinity Topos 集成

Krep MCP 服务器旨在与 infinity-topos 环境无缝协作:

  • Babashka 集成:使用 Babashka 处理搜索结果
  • Say Integration :使用 Say MCP 服务器将搜索结果语音化
  • 抛硬币积分:使用随机化来确定搜索策略

发展

环境变量

  • CLAUDE_MCP :设置为“true”以在 MCP 模式下运行
  • KREP_PATH :krep 二进制文件的路径
  • DEBUG :设置为“true”以进行详细日志记录
  • KREP_TEST_MODE :设置为“true”以在模拟响应的测试模式下运行
  • KREP_SKIP_CHECK :设置为“true”以跳过检查 krep 二进制文件是否存在

HTTP 服务器模式

当不在 MCP 模式下运行时,服务器将启动具有以下端点的 HTTP 服务器:

  • GET /health :健康检查端点
  • GET / :服务器信息
  • POST /search :在文件中搜索模式
  • POST /match :匹配字符串中的模式
  • GET /performance :性能信息
  • GET /algorithm-selection :算法选择指南

执照

麻省理工学院

-
security - not tested
F
license - not found
-
quality - not tested

具有模型上下文协议集成的高性能字符串搜索实用程序,使 AI 助手能够在文件和字符串中执行高效的模式搜索。

  1. Overview
    1. Features
      1. Why This Codebase Is Tragic
        1. Project Structure
          1. Installation
            1. Usage
              1. Parameters
              2. Examples
            2. How It Works
              1. Performance
                1. Cline VSCode Extension Integration
                  1. Installation with Cline
                  2. Using krep in Cline
                2. Integration with Infinity Topos
                  1. Development
                    1. Environment Variables
                    2. HTTP Server Mode
                  2. License
                    ID: 9e91igo4ox