Log Detective MCP
OfficialAnalyze logs via two MCP tools: extract representative clustered log snippets and extract Python tracebacks, with filtering, context, compression support, and size limits.
Extract one representative snippet per Drain3 cluster from a log, returning
line_numberandtext.Provide log content exactly one way: raw
log_text, server-sidelog_path, or HTTP(S)log_url.Tune snippet extraction with
max_clusters,max_snippet_len,skip_patterns, andcontext(0–50 surrounding lines).Extract Python tracebacks, including chained exceptions, with optional truncation,
skip_patterns, andcontext.Transparently decompress
.gz,.bz2,.xz,.lzma,.zip,.tar,.tar.gz,.tar.bz2, and.tar.xzinputs; archives must contain exactly one file.Enforce 100 MB limits on downloads and decompressed archives, with zip-bomb protections and no recursive decompression.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Log Detective MCP extract representative snippets from /var/log/app.log"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 .Related MCP server: log-ai-optimizer
Usage
Running the server
logdetective-mcpOr directly:
python -m logdetective_mcp.mainMCP client configuration
Claude Code
claude mcp add logdetective -- logdetective-mcpClaude 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):
Parameter | Type | Description |
|
| Raw log text passed directly. |
|
| Path to a log file on the server's filesystem. |
|
| HTTP(S) URL to fetch log content from. |
The input schema for both tools uses oneOf to require exactly one nonempty
source field. Omitted source fields and fields set to "" do not count as a
source. This matches the rule checked when a tool runs. The advertised tool
definitions conform to the MCP 2025-11-25 Tool schema.
Optional parameters:
Parameter | Type | Default | Description |
|
| 8 | Maximum number of snippets to extract. |
|
| 2000 | Maximum character length per snippet. |
|
|
| List of regex patterns. Chunks matching any pattern are excluded before clustering. |
|
| 0 | Number 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). MCP structured output
wraps this list as {"result": [...]}; the advertised output schema describes
that object.
extract_python_tracebacks
Extracts Python tracebacks from the log, including chained exceptions.
Parameter | Type | Default | Description |
|
| 2000 | Maximum character length per extracted traceback. |
|
|
| List of regex patterns. Tracebacks matching any pattern are excluded. |
|
| 0 | Number 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,.lzmaArchives:
.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/To inspect the JSON schemas returned by the installed server, run the check
script with the project's virtual environment. It starts the server over MCP
stdio, validates both tool schemas and structured results, and compares the
returned tool definitions with the files in schemas/:
.venv/bin/python scripts/check_mcp_schemas.pyAfter an intentional schema change, regenerate those files with:
.venv/bin/python scripts/check_mcp_schemas.py --writeAvailable Tools
2 toolsextract_log_snippetsA
Extract representative log snippets using Drain3 clustering.
Analyzes log text by chunking it into logical messages, clustering
similar messages using the Drain algorithm, and returning one
representative snippet per cluster.
Exactly one of log_text, log_path, or log_url must be provided.
Downloaded inputs are limited to 100 MB.
Compressed files (.gz, .bz2, .xz, .zip, .tar, .tar.gz, .tar.bz2,
.tar.xz) are decompressed transparently. Archives must contain
exactly one file. Compression ratios above 100:1 are rejected.
Args:
log_text: Raw log text to analyze.
log_path: Path to a log file on disk.
log_url: HTTP(S) URL to fetch log content from.
max_clusters: Maximum number of clusters/snippets to extract.
max_snippet_len: Maximum character length per snippet chunk.
skip_patterns: Optional list of regex patterns.
Chunks matching any pattern are excluded before clustering.
context: Number of lines to include before and after each snippet (0-50).
These lines are additional to max_snippet_len. Split chunks retain
their extracted text instead of expanding to the whole source line.
Inputs: context, log_url, log_path, log_text, +3 more. Returns: result
extract_python_tracebacksA
Extract Python tracebacks using specialized heuristic.
Analyzes log text and extracts unbroken Python tracebacks.
Traces are truncated to `max_traceback_len` characters.
Exactly one of log_text, log_path, or log_url must be provided.
Downloaded inputs are limited to 100 MB.
Compressed files (.gz, .bz2, .xz, .zip, .tar, .tar.gz, .tar.bz2,
.tar.xz) are decompressed transparently. Archives must contain
exactly one file. Compression ratios above 100:1 are rejected.
Args:
log_text: Raw log text to analyze.
log_path: Path to a log file on disk.
log_url: HTTP(S) URL to fetch log content from.
max_traceback_len: Maximum character length per extracted traceback.
skip_patterns: Optional list of regex patterns.
Chunks matching any pattern are excluded.
context: Number of lines to include before and after each traceback (0-50).
These lines are additional to max_traceback_len. A truncated
traceback keeps its shortened text; following context begins after
the original traceback ends.
Inputs: context, log_url, log_path, log_text, +2 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools target different extraction strategies (Drain3 clustering vs Python traceback heuristics), so their core purposes are clearly distinct. However, they share identical input modes (log_text/log_path/log_url, skip_patterns, context), and a log containing tracebacks could plausibly be fed to either, leaving a small boundary ambiguity an agent must reason about.
Both names follow the same `extract_<thing>` snake_case convention with the same verb prefix and noun-phrase object. Parameter naming is also mirrored across the two tools (max_*_len, skip_patterns, context), reinforcing predictability.
Two tools is thin for a server branded as 'Log Detective' — the surface is essentially one extraction family with two strategies. It is not incoherent, but there is little room for an agent to do anything beyond pulling snippets or tracebacks.
Input handling is thorough (text/path/URL, transparent decompression, safety limits) and both tools mirror it consistently. But the lifecycle stops at extraction: there is no summarization, severity/error-level grouping, keyword or pattern-include extraction, or structured output option, which leaves gaps for a diagnostic-oriented server.
Maintenance
Related MCP Connectors
Ingest and search LogsLoom logs from coding agents.
Files to text for AI agents: audio/podcast transcription, OCR, video frames, screenshots, web to MD.
Structured analysis API and remote MCP tool for text, JSON records and numeric series.
Turn URLs, PDFs and DOCX into clean Markdown for agents, plus prompt-injection scanning
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceEnables LLMs to analyze logs by extracting patterns, redacting secrets, and providing token-efficient summaries from files, Docker containers, or journald.5MIT
- FlicenseNot gradedqualityDmaintenanceCompresses log files into templates and statistics using Drain3, and exposes them to AI assistants via an MCP server for efficient log monitoring and anomaly detection.-
- AlicenseAqualityDmaintenanceMCP server that wraps Drain3 for streaming log template mining, read-only matching, parameter extraction, and model persistence, exposing tools and resources to train on logs and query learned templates.8MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to analyze, cluster, compare, and export reports from local log files through seven read-only tools, returning compact evidence packs with line-number citations instead of raw log dumps. All processing happens on the local machine, so log data never leaves the environment.1,388 PyPI1MIT