MCP server providing log snippet and Python traceback extraction tools.
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.
Requires Python 3.11+.
pip install .
Or with uv:
uv pip install .
logdetective-mcp
Or directly:
python -m logdetective_mcp.main
claude mcp add logdetective -- logdetective-mcp
Add to your Claude Desktop configuration file:
{
"mcpServers": {
"logdetective": {
"command": "logdetective-mcp"
}
}
}
extract_log_snippetsExtracts 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 | list[str] | null | List of regex patterns. Chunks matching any pattern 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).
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.
Both tools transparently decompress archived log files. Supported formats:
.gz, .bz2, .xz, .lzma.zip, .tar, .tar.gz, .tar.bz2, .tar.xzFormat is detected from the file extension (or URL path). Archives must contain exactly one file.
Zip bomb protection is enforced via:
All changes to this repository must pass pre-commit checks and tests.
uv run pytest tests/
Source-derived launch command. Check the maintainer’s required arguments and credentials before running:
uvx logdetective-mcpMerge this template into ~/Library/Application Support/Claude/claude_desktop_config.json. Keep existing servers. Add any arguments, credentials, and permissions required by the maintainer; this template has not been install-tested.
{
"mcpServers": {
"io-github-fedora-copr-logdetective-mcp": {
"command": "uvx",
"args": [
"logdetective-mcp"
]
}
}
}Restart Claude Desktop completely for changes to take effect. Confirm the server appears connected in the client’s tool list, then try a read-only example from its documentation.
Claude Desktop setup referencelogdetective-mcppypiLog Detective MCP works with any MCP-compatible client. Copy the config snippet from the Configuration section above and add it to the file shown for your client, then restart the application.
~/Library/Application Support/Claude/claude_desktop_config.jsonRestart Claude Desktop completely for changes to take effect.~/.cursor/mcp.jsonRestart Cursor for changes to take effect..vscode/mcp.jsonReload VS Code window for changes to take effect.~/.codeium/windsurf/mcp_config.jsonRestart Windsurf for changes to take effect..mcp.jsonSave at the project root, then start Claude Code in that project and review the MCP server approval prompt. Keep real credentials out of shared files.