Skip to main content

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):

Parameter Type Description
log_text str Raw log text passed directly.
log_path str Path to a log file on the server's filesystem.
log_url str HTTP(S) URL to fetch log content from.

Optional parameters:

Parameter Type Default Description
max_clusters int 8 Maximum number of snippets to extract.
max_snippet_len int 2000 Maximum character length per snippet.
skip_patterns dict[str, str] null Map of names to regex patterns. Matching chunks are excluded before clustering.

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

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/

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logdetective_mcp-0.4.0.tar.gz (64.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logdetective_mcp-0.4.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file logdetective_mcp-0.4.0.tar.gz.

File metadata

  • Download URL: logdetective_mcp-0.4.0.tar.gz
  • Upload date:
  • Size: 64.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for logdetective_mcp-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3c6793f8f9280f4baad7505587554d92b8b5f0f55e6b261e5384e7e3c471b040
MD5 4b3a9a9c85f8baab473ca8898761f7f8
BLAKE2b-256 3007ddb0c9e990b116b9c47399fd1194d63c0c26721dfa08b32c54fd815ccaa1

See more details on using hashes here.

Provenance

The following attestation bundles were made for logdetective_mcp-0.4.0.tar.gz:

Publisher: publish.yml on fedora-copr/logdetective-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logdetective_mcp-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for logdetective_mcp-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7a5e31c98dd241717979662160c61f394123482dd8e313ce728b4dc588ef59f
MD5 bc1eab555b4e8c0f3ced01549b9563b1
BLAKE2b-256 7cee57c612f7186e8586b0c15c7ee9a12cdb60149950d50da5ddb85d58970cc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for logdetective_mcp-0.4.0-py3-none-any.whl:

Publisher: publish.yml on fedora-copr/logdetective-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page