Log Detective MCP

السجل الرسمي أخرى

MCP server providing log snippet and Python traceback extraction tools.

التثبيت

أضف هذا إلى إعدادات MCP في عميلك (Claude Desktop: claude_desktop_config.json، وCursor: ‏.cursor/mcp.json، ويستخدم VS Code وغيره الصيغة نفسها «mcpServers»).

PYPI package logdetective-mcp
Claude Code
claude mcp add log-detective-mcp -- uvx logdetective-mcp==0.6.1
إعداد JSON (Claude Desktop وCursor وVS Code)
{
    "mcpServers": {
        "log-detective-mcp": {
            "command": "uvx",
            "args": [
                "logdetective-mcp==0.6.1"
            ]
        }
    }
}

التوثيق

مأخوذ من ملف README للمشروع على GitHub ويُحدَّث أسبوعيًا. تفتح الروابط على GitHub.

المحتويات
  1. Log Detective MCP
  2. Installation
  3. Usage
  4. Tools
  5. Contributing

Log Detective MCP

MCP server implementing core log analysis tools of Log Detective for use by other agents.

The server uses the Drain3 algorithm to cluster log messages into templates and extract a representative subset of snippets, reducing large logs to a manageable size for downstream analysis.

Installation

Requires Python 3.11+.

pip install .

Or with uv:

uv pip install .

Usage

Running the server
logdetective-mcp

Or directly:

python -m logdetective_mcp.main
MCP client configuration
Claude Code
claude mcp add logdetective -- logdetective-mcp
Claude Desktop

Add to your Claude Desktop configuration file:

{
  "mcpServers": {
    "logdetective": {
      "command": "logdetective-mcp"
    }
  }
}

Tools

extract_log_snippets

Extracts representative log snippets using Drain3 clustering. The tool chunks the log into logical messages, clusters similar messages, and returns one representative snippet per cluster.

Log content can be provided in three ways (exactly one must be used):

ParameterTypeDescription
log_textstrRaw log text passed directly.
log_pathstrPath to a log file on the server's filesystem.
log_urlstrHTTP(S) URL to fetch log content from.

Optional parameters:

ParameterTypeDefaultDescription
max_clustersint8Maximum number of snippets to extract.
max_snippet_lenint2000Maximum character length per snippet.
skip_patternslist[str]nullList of regex patterns. Chunks matching any pattern are excluded before clustering.
contextint0Number of lines to include before and after each snippet (0-50).

Returns a list of Snippet objects, each with line_number (position in the original log) and text (the extracted snippet content).

extract_python_tracebacks

Extracts Python tracebacks from the log, including chained exceptions.

ParameterTypeDefaultDescription
max_traceback_lenint2000Maximum character length per extracted traceback.
skip_patternslist[str]nullList of regex patterns. Tracebacks matching any pattern are excluded.
contextint0Number of lines to include before and after each traceback (0-50).

For both extractor tools, context follows grep's -C behavior: the requested number of surrounding log lines is included on each side when available. The length limit applies to the extracted snippet or traceback; context lines are additional, so the returned text can be longer than the limit. With context enabled, line_number points to the first returned line. Values outside 0-50 are rejected.

If a traceback is truncated, the extractor keeps its beginning and end with a marker when max_traceback_len permits; smaller limits keep only a prefix. Following context starts after the original traceback, without restoring its omitted middle. If a log line is split into chunks by max_snippet_len, each selected chunk keeps its own text when context is added. Neighboring lines do not replace it with the complete long line. Context boundaries follow the chunk's original source lines, including blank lines omitted from the rendered chunk.

Size limits

All downloaded inputs (via log_url) are limited to 100 MB regardless of format. Downloads are streamed in chunks and aborted as soon as the limit is exceeded.

Archives read via log_path are also checked against the 100 MB limit during decompression.

Compressed file support

Both tools transparently decompress archived log files. Supported formats:

  • Single-file compression: .gz, .bz2, .xz, .lzma
  • Archives: .zip, .tar, .tar.gz, .tar.bz2, .tar.xz

Format is detected from the file extension (or URL path). Archives must contain exactly one file.

Zip bomb protection is enforced via:

  • Maximum decompressed size of 100 MB
  • Maximum compression ratio of 100:1
  • Pre-check of declared sizes in zip/tar headers
  • No recursive decompression (nested archives are not unpacked)

Contributing

All changes to this repository must pass pre-commit checks and tests.

uv run pytest tests/

الأسئلة الشائعة

ما هو Log Detective MCP؟

MCP server providing log snippet and Python traceback extraction tools.

كيف أثبّت Log Detective MCP؟

يعمل على جهازك. في Claude Code: claude mcp add log-detective-mcp -- uvx logdetective-mcp==0.6.1. وفي العملاء الآخرين، الصق إعداد JSON من هذه الصفحة في إعدادات MCP الخاصة بهم.

هل يحتاج Log Detective MCP إلى مفتاح API؟

لا يذكر إدراجه في السجل أي مفتاح أو سر إلزامي. قد تتطلب بعض الميزات حسابًا لدى الخدمة التي يتصل بها.

هل Log Detective MCP مفتوح المصدر؟

نعم. شيفرته متاحة على GitHub بترخيص Apache-2.0.

من يصون Log Detective MCP؟

ينشره fedora-copr. يدرجه AI.tn لكنه لا يصونه ولا يوصي به.

من سجل MCP الرسمي. الإدراج ليس توصية: راجع شيفرة الخادم وصلاحياته قبل منحه الوصول إلى بياناتك.