شعار Drain MCP

Drain MCP

المجتمع
NickLennonLiu

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

الناشرNickLennonLiu
المستودعdrain_mcp
اللغةPython
التفريعات
0
النجوم
54
الأدوات المتاحة
0
نوع نقل البياناتstdio
الروابط
  • اربط الأدوات بسير عمل الذكاء الاصطناعي

    يتيح Drain MCP إمكانات MCP التي يمكن لتطبيقات الذكاء الاصطناعي العميلة ووكلاء الذكاء الاصطناعي المتوافقة استخدامها.

  • الأدوات المتاحة: 0

    تصفّح الإجراءات القابلة للاستدعاء أدناه، بما في ذلك أسماؤها وأوصافها عندما يوفّرها الخادم.

  • إعدادات جاهزة للنسخ

    استخدم أمثلة إعداد التثبيت لتهيئة هذا الخادم في تطبيق MCP العميل المفضّل لديك.

  • مؤشرات الاهتمام بالمصدر المفتوح

    النجوم: 54، والنسخ المتفرعة: 0 في المستودع المرتبط.

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.

استخدم MCP الخاص بـ Drain MCP مع نماذج ذكاء اصطناعي متعددة

يربط TypingMind أدوات MCP على مستوى مساحة العمل، لذا بمجرد توصيل Drain MCP، يمكنك استخدامه مع نماذج ذكاء اصطناعي مختلفة في TypingMind بدلًا من إعداده لكل نموذج على حدة. يعمل تكامل MCP هذا محليًا عبر موصل MCP الخاص بـ TypingMind على جهازك.

دليل الإعداد لاستخدام الموصل المحلي

استخدم هذا الخيار عندما يحتاج خادم MCP إلى الوصول إلى ملفات محلية أو تطبيقات أو موارد خاصة على جهاز الكمبيوتر لديك.

1

فتح إعدادات MCP

في TypingMind، انتقل إلى «الإعدادات»، ثم «الإعدادات المتقدمة»، ثم «بروتوكول سياق النموذج»، واختر «إعداد الموصل».

  1. افتح TypingMind في متصفحك.
  2. انقر على أيقونة الإعدادات.
  3. انتقل إلى الإعدادات المتقدمة.
  4. افتح قسم بروتوكول سياق النموذج.
  5. انقر على «إعداد الموصل» واختر «هذا الجهاز».
شاشة إعداد موصل MCP في TypingMind مع تحديد «هذا الجهاز»
2

تنفيذ أمر الموصل

اختر «هذا الجهاز»، وانسخ الأمر من TypingMind وشغّله في Terminal. أبقِ العملية قيد التشغيل أثناء استخدام MCP.

  1. انسخ أمر الإعداد الذي يعرضه TypingMind.
  2. افتح Terminal على macOS أو Windows Terminal على Windows.
  3. الصق الأمر ونفّذه.
  4. وافق على تثبيت الحزمة إذا طلب منك Terminal تأكيد المتابعة.
  5. أبقِ نافذة Terminal والعملية التي تعمل فيها قيد التشغيل أثناء استخدام أدوات MCP.
3

أضف Drain MCP كخادم

عندما تظهر حالة الموصل «جاهز»، انقر على «تعديل الخوادم» والصق إعدادات خادم MCP.

  1. انتظر حتى تظهر حالة الموصل «جاهز».
  2. انقر على «تعديل الخوادم».
  3. الصق إعدادات خادم MCP الخاص بـ Drain MCP.
  4. احفظ قائمة الخوادم.
  5. حدّث الحالة إذا أردت التأكد من أن الموصل لا يزال جاهزًا.
إعدادات MCP في TypingMind تعرض خادمًا نشطًا وزر «تعديل الخوادم»
{
  "mcpServers": {
    "drain-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

استخدام الاتصال مع نماذج مختلفة

احفظ قائمة الخوادم، وافتح «الإضافات»، وفعّل أدوات MCP الخاصة بـ Drain MCP، ثم اختر أي نموذج ذكاء اصطناعي مدعوم في TypingMind واستخدم الأدوات في المحادثة أو أسندها إلى وكيل ذكاء اصطناعي.

  1. افتح صفحة الإضافات في TypingMind.
  2. فعّل أدوات MCP الخاصة بـ Drain MCP.
  3. ابدأ محادثة واختر نموذج الذكاء الاصطناعي الذي تريد استخدامه.
  4. استخدم أدوات MCP في المحادثة أو عيّنها لوكيل ذكاء اصطناعي.
  5. انتقل إلى نموذج ذكاء اصطناعي آخر عند الحاجة دون إعادة الاتصال بـ MCP.
محادثة في TypingMind تستخدم أدوات MCP المفعّلة مع نموذج ذكاء اصطناعي محدّد
هل يمكنك استخدام Drain MCP لمساعدتي في هذه المهمة؟
Drain MCP
بالتأكيد. قرأته.
إليك ما وجدته باستخدام Drain MCP.

الأسئلة الشائعة

ما استخدامات خادم MCP Drain MCP؟

Drain MCP هو خادم MCP يتيح لتطبيقات الذكاء الاصطناعي المتوافقة الاتصال بأدوات ومصادر سياق خارجية. في TypingMind، يمكنك إضافة خادم MCP هذا مرة واحدة وإتاحة أدواته في مساحة عملك للذكاء الاصطناعي.

هل يمكنني استخدام خادم MCP Drain MCP مع نماذج ذكاء اصطناعي متعددة في TypingMind؟

نعم. يربط TypingMind أدوات MCP على مستوى مساحة العمل، لذا يمكنك استخدام Drain MCP مع نماذج ذكاء اصطناعي مختلفة مثل Claude أو ChatGPT أو Gemini أو غيرها من النماذج التي أعددتها في TypingMind، دون إعداد خادم MCP لكل نموذج على حدة.

لماذا تستخدم موصل MCP Drain MCP مع TypingMind؟

يُعد TypingMind من أفضل واجهات المحادثة مع النماذج اللغوية الكبيرة، إذ يجمع نماذج ذكاء اصطناعي متعددة ومطالبات وإضافات ووكلاء ذكاء اصطناعي ومفاتيح API وأدوات MCP في مساحة عمل واحدة. بعد توصيل Drain MCP، يمكنك استخدام أدوات MCP الخاصة به عبر نماذجك المفضلة مع الحفاظ على سير عمل محادثاتك منظمًا في TypingMind.

كيف أوصّل خادم MCP Drain MCP بـ TypingMind؟

يعمل Drain MCP عبر موصل MCP المحلي في TypingMind. هذا هو الخيار الأنسب عندما يحتاج خادم MCP إلى الوصول إلى ملفات محلية أو تطبيقات سطح المكتب أو أدوات سطر الأوامر أو موارد خاصة على حاسوبك.

ما الأدوات التي يوفّرها خادم MCP Drain MCP في TypingMind؟

يتيح Drain MCP إمكانات MCP يمكنك تفعيلها من صفحة الإضافات في TypingMind واستخدامها في المحادثات أو تعيينها لوكلاء ذكاء اصطناعي.

هل أحتاج إلى مشاركة مفاتيح API الخاصة بي مع TypingMind لاستخدام خادم MCP Drain MCP؟

لا. يعطي TypingMind الأولوية للعمل المحلي ويُبقي مزوّدي النماذج ومفاتيح API والمطالبات وإعدادات MCP تحت تحكمك. إذا كان Drain MCP يتطلب مصادقة، فأضف الترويسات أو إعدادات OAuth أو الإعدادات المحلية المطلوبة لخادم MCP هذا عند إنشاء الاتصال.

خوادم MCP ذات صلة

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا البريدية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇