EM

erniebrodeur/mcp-grep

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

24 stars 4 forks 品質 52 トレンド 10GPL-3.0

単純 mcp サーバーで grep のローカルインスタンスをラップします.

概要

モデルコンテキストプロトコル(MCP)を介して grep 機能を公開する grep サーバの実装。 Smitheryによって自動的にClaudeデスクトップのためのGlipサーバーを取付けるため: MCP-Grep は、MCP 互換クライアントで使用できるサーバーとして動作します。 サーバは、次のMCP機能を公開します。 - grep://info - システム grep バイナリ - grep - システム grep バイナリを使用してファイル内のパターンを検索します - システム grep バイナリ(パス、バージョン、サポートされている機能)に関する情報 - 通常の式を使用してファイル内のパターンを検索 - 一般的な grep オプションのサポート: - ケースに敏感なマッチング - コンテキスト行(前後のマッチ) - 最大マッチ数 - 固定文字列マッチング(非正規表現) - 再帰的なディレクトリ検索 - LLM を使用してより簡単に使用するための自然な言語プロンプト理解 - MCP インスペクターによるインタラクティブなデバッグとテスト MCP-Grepは自然言語のプロンプトを理解し、LMsで使いやすいようにします.

概要(AI 翻訳)

モデルコンテキストプロトコル(MCP)を介して grep 機能を公開する grep サーバの実装。

インストール

##Smitheryでインストールする

Smitheryによって自動的にClaudeデスクトップのためのGlipサーバーを取付けるため:

手動インストール

使用法

MCP-Grep は、MCP 互換クライアントで使用できるサーバーとして動作します。

サーバは、次のMCP機能を公開します。

  • リソース: [grep://info] - システム grepバイナリに関する情報を返す
  • ツール: grep - システム grepバイナリを使用してファイル内のパターンを検索します

##特徴

  • システム grep バイナリ(パス、バージョン、サポート機能)に関する情報
  • 正規表現を使用してファイル内のパターンを検索する
  • 一般的な grep オプションのサポート:
  • ケースインセンティブマッチング
  • コンテキストライン(マッチ前後)
  • 最大マッチ数
  • 固定文字列マッチング(非正規)
  • 再帰ディレクトリ検索
  • LLMでより使いやすい自然な言語プロンプトの理解
  • MCPインスペクタによるインタラクティブなデバッグとテスト

API の使用例

MCP Python クライアントを使用する:

自然言語プロンプト

MCP-Grepは自然言語のプロンプトを理解し、LMsで使いやすいようにします。 例:

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

MCP-Grep

A grep server implementation that exposes grep functionality through the Model Context Protocol (MCP).

Installation

Installing via Smithery

To install Grep Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @erniebrodeur/mcp-grep --client claude

Manual Installation

pip install mcp-grep

Usage

MCP-Grep runs as a server that can be used by MCP-compatible clients:

# Start the MCP-Grep server
mcp-grep-server

# Or use the MCP Inspector for interactive debugging and testing
mcp-grep-inspector

The server exposes the following MCP functionality:

  • Resource: grep://info - Returns information about the system grep binary
  • Tool: grep - Searches for patterns in files using the system grep binary

Features

  • Information about the system grep binary (path, version, supported features)
  • Search for patterns in files using regular expressions
  • Support for common grep options:
    • Case-insensitive matching
    • Context lines (before and after matches)
    • Maximum match count
    • Fixed string matching (non-regex)
    • Recursive directory searching
  • Natural language prompt understanding for easier use with LLMs
  • Interactive debugging and testing through MCP Inspector

Example API Usage

Using the MCP Python client:

from mcp.client import MCPClient

# Connect to the MCP-Grep server
client = MCPClient()

# Get information about the grep binary
grep_info = client.get_resource("grep://info")
print(grep_info)

# Search for a pattern in files
result = client.use_tool("grep", {
    "pattern": "search_pattern",
    "paths": ["file.txt", "directory/"],
    "ignore_case": True,
    "recursive": True
})
print(result)

Natural Language Prompts

MCP-Grep understands natural language prompts, making it easier to use with LLMs. Examples:

# Basic search
Search for 'error' in log.txt

# Case-insensitive search
Find all instances of 'WARNING' regardless of case in system.log

# With context lines
Search for 'exception' in error.log and show 3 lines before and after each match

# Recursive search
Find all occurrences of 'deprecated' in the src directory and its subdirectories

# Fixed string search (non-regex)
Search for the exact string '.*' in config.js

# Limited results
Show me just the first 5 occurrences of 'TODO' in the project files

# Multiple options
Find 'password' case-insensitively in all .php files, show 2 lines of context, and limit to 10 results

MCP Inspector Integration

MCP-Grep includes an MCP Inspector integration for interactive debugging and testing:

# Start the MCP Inspector with MCP-Grep
mcp-grep-inspector

This opens a web-based UI where you can:

  • Explore available resources and tools
GitHub で README 全文を見る

インストール

npx -y @smithery/cli install @erniebrodeur/mcp-grep --client claude
MCP 初心者?mcpskill.org のガイドから始めましょう →