Logo vun Drain MCP

Drain MCP

Communautéit
NickLennonLiu

A FastMCP server for Drain3 log template mining, training, inference, and cluster inspection.

EditeurNickLennonLiu
Repositorydrain_mcp
SproochPython
Forks
0
Stären
54
Disponibel Tools
0
Transporttypstdio
Linken
  • Tools mat KI-Workflows verbannen

    Drain MCP stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 0 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    54 Stären an 0 Forks aus dem verlinkte Repository.

Drain MCP

Drain MCP is a FastMCP server that exposes Drain3 log template mining as MCP tools. It can learn templates from individual log lines or whole log files, run read-only inference against the trained model, inspect mined clusters, and manage Drain masking rules at runtime.

The server uses file persistence by default, so trained clusters survive process restarts in drain3_state.bin.

Features

  • Train a Drain3 model from a local UTF-8 log file or a directly reachable HTTP/HTTPS log file.
  • Train incrementally from one log line at a time.
  • Match log lines or files against the current model without changing state.
  • Inspect model statistics and page through mined clusters.
  • List, add, and remove masking rules used before template extraction.
  • Run as a Streamable HTTP MCP server on http://localhost:8101/mcp.

Requirements

  • Python 3.10 or newer
  • uv or another Python environment manager

Project dependencies are declared in pyproject.toml:

  • drain3
  • fastmcp

Quick Start

Install dependencies:

bash
uv sync

Start the MCP server:

bash
uv run python server.py

By default the server listens on:

text
http://0.0.0.0:8101/mcp

For local MCP clients, use:

text
http://localhost:8101/mcp

MCP Client Configuration

Configure your MCP client to use Streamable HTTP with the server URL:

json
{
  "mcpServers": {
    "drain-mcp": {
      "url": "http://localhost:8101/mcp"
    }
  }
}

If your client requires an explicit transport field, choose Streamable HTTP.

Tools

train_file

Train the Drain model from a local file path or HTTP/HTTPS URL.

Input:

  • file_url: absolute local path or directly reachable URL

Returns the number of processed lines, cluster counts before and after training, new cluster count, and message counts for clusters touched during the run.

train_line

Train the model with one log line.

Input:

  • line: a single log message without a newline

Returns the mined template, extracted parameters, cluster id, cluster size, and whether a cluster was created or its template changed.

inference_line

Match one log line against the trained model without updating model state.

Input:

  • line: a single log message without a newline

Returns whether the line matched, the cluster id, template, parameters, and cluster size.

inference_file

Run read-only inference over a local file path or HTTP/HTTPS URL.

Input:

  • file_url: absolute local path or directly reachable URL

Returns total line count, matched count, unmatched count, match rate, and the first 100 per-line inference results.

model_stats

Return aggregate model statistics:

  • total cluster count
  • total trained message count

list_clusters

List mined clusters with pagination.

Inputs:

  • page: 1-based page number, default 1
  • page_size: clusters per page, default 20

Returns cluster id, size, and template for each cluster on the page.

list_masking

List the currently configured Drain masking rules.

add_masking

Add a runtime masking rule.

Inputs:

  • regex_pattern: regular expression to mask before template mining
  • mask_with: placeholder name to use for matches

The model is saved and reinitialized so the new rule applies to future training and inference. Existing persisted clusters are preserved.

remove_masking

Remove a runtime masking rule by exact regex pattern.

Input:

  • regex_pattern: exact pattern to remove

The model is saved and reinitialized so the updated masking configuration applies to future training and inference. Existing persisted clusters are preserved.

Persistence and Configuration

The server loads Drain configuration from:

text
drain_demos/drain3.ini

The default configuration includes masking rules for common identifiers such as IP addresses, hexadecimal values, numeric values, and command strings. It also sets the Drain similarity threshold, tree depth, child limit, max cluster count, and extra delimiters.

Model state is stored at:

text
drain3_state.bin

This file is ignored by git because it is runtime state. Delete it if you want to start with a fresh model.

Runtime masking changes are kept in memory for the current server process and applied after the model is reinitialized. To make a masking rule permanent, add it to drain_demos/drain3.ini.

Demo Scripts

The drain_demos directory contains standalone Drain3 examples:

  • drain_stdin_demo.py: interactive training and inference from standard input
  • drain_bigfile_demo.py: batch processing demo using the public SSH log data set from Zenodo
  • drain3.ini: shared Drain3 configuration

Run a demo with:

bash
uv run python drain_demos/drain_stdin_demo.py

Development

Check that the Python files compile successfully:

bash
uv run python -m py_compile server.py main.py drain_demos/*.py

The repository currently has no automated test suite. For functional testing, start the server and call the MCP tools from a compatible MCP client.

Drain MCP MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal Drain MCP verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung fir de lokale Connector ze benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „Dësen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

Drain MCP als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu Drain MCP an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "drain-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vu Drain MCP. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu Drain MCP.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat Drain MCP?
Drain MCP
Jo. Ech hunn et gelies.
Dat hunn ech mat Drain MCP fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server Drain MCP benotzt?

Drain MCP ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech Drain MCP MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir Drain MCP mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat Drain MCP MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann Drain MCP verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech Drain MCP MCP mat TypingMind?

Drain MCP leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann de MCP-Server Zougrëff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

Wéi eng Tools stellt Drain MCP MCP an TypingMind zur Verfügung?

Drain MCP stellt MCP-Funktiounen zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir Drain MCP MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann Drain MCP eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇