Logotipo de Drain MCP

Drain MCP

Comunidad
NickLennonLiu

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

EditorNickLennonLiu
Repositoriodrain_mcp
IdiomaPython
Forks
0
Estrellas
54
Herramientas disponibles
0
Tipo de transportestdio
Enlaces
  • Conecta herramientas a flujos de trabajo con IA

    Drain MCP ofrece funciones MCP que pueden usar los clientes y agentes de IA compatibles.

  • 0 herramientas disponibles

    Explora a continuación las acciones que se pueden invocar, con sus nombres y descripciones cuando el servidor los proporcione.

  • Configuración lista para copiar

    Usa los ejemplos de instalación para configurar este servidor en tu cliente MCP preferido.

  • Indicadores de interés en el código abierto

    54 estrellas y 0 forks en el repositorio enlazado.

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.

Usa el MCP de Drain MCP con varios modelos de IA

TypingMind conecta las herramientas MCP a nivel del espacio de trabajo, por lo que, una vez conectado Drain MCP, puedes usarlo con distintos modelos de IA en TypingMind sin tener que configurarlo por separado para cada modelo. Esta integración MCP se ejecuta localmente en tu dispositivo a través del conector MCP de TypingMind.

Guía de configuración para usar el conector local

Usa esta opción si el servidor MCP necesita acceder a archivos locales, aplicaciones o recursos privados de tu ordenador.

1

Abre los ajustes de MCP

En TypingMind, ve a Ajustes, luego a Ajustes avanzados y a Model Context Protocol, y elige Configurar conector.

  1. Abre TypingMind en tu navegador.
  2. Haz clic en el icono de Ajustes.
  3. Ve a Ajustes avanzados.
  4. Abre la sección Model Context Protocol.
  5. Haz clic en Configurar conector y elige Este dispositivo.
Pantalla de configuración del conector MCP de TypingMind con «Este dispositivo» seleccionado
2

Ejecuta el comando del conector

Elige Este dispositivo, copia el comando de TypingMind y ejecútalo en Terminal. Mantén el proceso en ejecución mientras uses MCP.

  1. Copia el comando de configuración que muestra TypingMind.
  2. Abre Terminal en macOS o Windows Terminal en Windows.
  3. Pega y ejecuta el comando.
  4. Acepta la instalación del paquete si Terminal te pide confirmación para continuar.
  5. Mantén el proceso en ejecución en la ventana de Terminal mientras uses las herramientas MCP.
3

Añade Drain MCP como servidor

Cuando el estado del conector sea «Listo», haz clic en «Edita servidores» y pega la configuración del servidor MCP.

  1. Espera hasta que el estado del conector indique «Listo».
  2. Haz clic en Edita servidores.
  3. Pega la configuración del servidor MCP de Drain MCP.
  4. Guarda la lista de servidores.
  5. Actualiza para comprobar que el conector sigue listo.
Ajustes de MCP de TypingMind con un servidor activo y el botón «Edita servidores»
{
  "mcpServers": {
    "drain-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Úsala con distintos modelos

Guarda la lista de servidores, abre Plugins, activa las herramientas MCP de Drain MCP y selecciona cualquier modelo de IA compatible en TypingMind para usar las herramientas en el chat o asignárselas a un agente de IA.

  1. Abre la página Plugins en TypingMind.
  2. Activa las herramientas MCP de Drain MCP.
  3. Inicia un chat y elige el modelo de IA que quieras usar.
  4. Usa las herramientas MCP en el chat o asígnalas a un agente de IA.
  5. Cambia a otro modelo de IA cuando lo necesites sin volver a conectar MCP.
Chat de TypingMind que usa herramientas MCP activadas con un modelo de IA seleccionado
¿Puedes usar Drain MCP para ayudarme con esta tarea?
Drain MCP
Claro. Lo he leído.
Esto he encontrado usando Drain MCP.

Preguntas frecuentes

¿Para qué sirve el servidor MCP Drain MCP?

Drain MCP es un servidor MCP que permite a los clientes de IA compatibles conectarse a herramientas y contexto externos. En TypingMind, basta con añadir este servidor MCP una vez para que sus herramientas estén disponibles en tu espacio de trabajo de IA.

¿Puedo usar el servidor MCP Drain MCP con varios modelos de IA en TypingMind?

Sí. TypingMind conecta las herramientas MCP a nivel del espacio de trabajo, por lo que puedes usar Drain MCP con distintos modelos de IA, como Claude, ChatGPT, Gemini u otros que hayas configurado en TypingMind, sin configurar el servidor MCP por separado para cada modelo.

¿Por qué usar el conector MCP de Drain MCP con TypingMind?

TypingMind es una de las mejores interfaces de chat con LLM porque reúne varios modelos de IA, prompts, plugins, agentes de IA, claves de API y herramientas MCP en un solo espacio de trabajo. Con Drain MCP conectado, puedes usar sus herramientas MCP con tus modelos preferidos y mantener organizado tu flujo de trabajo de chat en TypingMind.

¿Cómo conecto el servidor MCP Drain MCP a TypingMind?

Drain MCP funciona a través del conector MCP local de TypingMind. Es la mejor opción cuando el servidor MCP necesita acceder a archivos locales, aplicaciones de escritorio, herramientas de línea de comandos o recursos privados de tu ordenador.

¿Qué herramientas ofrece el servidor MCP Drain MCP en TypingMind?

Drain MCP ofrece funciones MCP que puedes activar desde la página Plugins de TypingMind y usar en el chat o asignar a agentes de IA.

¿Tengo que compartir mis claves de API con TypingMind para usar el servidor MCP Drain MCP?

No. TypingMind prioriza el funcionamiento local y te permite mantener el control de tus proveedores de modelos, claves de API, prompts y configuración MCP. Si Drain MCP requiere autenticación, añade las cabeceras, los ajustes de OAuth o la configuración local necesarios para ese servidor MCP al crear la conexión.

Servidores MCP relacionados

Ver todos

Crea ya tu propio espacio de trabajo IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇