Drain3 MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Drain3 MCP ServerMatch this log: 'User 789 failed login from 10.0.0.1' and show parameters."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Drain3 MCP Server
基于 Drain3 的 Python MCP Server,把流式日志模板挖掘、只读匹配、参数提取和模型持久化封装成标准的 Model Context Protocol 工具。
功能
逐条或批量训练日志模板
在不修改模型的前提下匹配新日志
提取 IP、数字、UUID、URL、十六进制值及 Drain3 通配参数
查询、排序和分页浏览已学习的模板
原子化文件快照,服务重启后自动恢复
同时支持
stdio、Streamable HTTP 和旧版 SSE 传输返回结构化 MCP 输出,便于 Agent 稳定消费
Related MCP server: log-mcp
MCP 工具
工具 | 用途 | 是否修改模型 |
| 学习一条日志并返回模板、簇和参数 | 是 |
| 按顺序批量学习日志 | 是 |
| 匹配一条日志,不创建新模板 | 否 |
| 批量只读匹配 | 否 |
| 查询已学习模板,支持排序和分页 | 否 |
| 按指定模板提取动态参数 | 否 |
| 查看模板数、消息数和有效配置 | 否 |
| 立即将完整模型状态写入快照 | 写快照 |
服务还公开以下 MCP Resources:
drain3://statsdrain3://templatesdrain3://templates/{cluster_id}
安装与启动
需要 Python 3.10 或更高版本。
python -m venv .venv
# Linux / macOS
source .venv/bin/activate
# Windows PowerShell
.venv\Scripts\Activate.ps1
pip install -e .
drain3-mcp-server默认启动 stdio 传输,适合 Codex、Claude Desktop 等 MCP Host。也可以启动 Streamable HTTP:
drain3-mcp-server --transport streamable-http --host 127.0.0.1 --port 8000MCP 端点是 http://127.0.0.1:8000/mcp。
MCP Host 配置示例
仓库开发模式:
{
"mcpServers": {
"drain3": {
"command": "D:/code/Drain3MCPServer/.venv/Scripts/python.exe",
"args": ["-m", "drain3_mcp_server"],
"env": {
"DRAIN3_MCP_STATE_PATH": "D:/data/drain3/state.bin"
}
}
}
}安装为命令后,可将 command 改成 drain3-mcp-server,并移除 args。
配置
环境变量 | 默认值 | 说明 |
| 包内 | 自定义 Drain3 INI 配置路径 |
|
| 模型快照路径;设为 |
|
| 单次批量调用允许的最大日志条数 |
默认配置会掩码 IP、数字、UUID、URL 和十六进制值。生产环境通常应通过 DRAIN3_MCP_CONFIG_PATH 提供针对业务日志设计的 masking 规则。完整的 Drain3 参数定义请参考 Drain3 配置说明。
调用示例
先训练两条相似日志:
{
"log_messages": [
"User 123 logged in from 10.0.0.1",
"User 456 logged in from 10.0.0.2"
]
}train_logs 会学习到类似下面的模板:
User <NUM> logged in from <IP>之后使用 match_log 可以对新日志做只读推理,并取得 NUM、IP 对应的参数值。
Docker
docker build -t drain3-mcp-server .
docker run --rm -p 8000:8000 -v drain3-data:/data drain3-mcp-server容器默认监听 0.0.0.0:8000,模型写入 /data/drain3_state.bin。
开发与测试
pip install -e ".[dev]"
pytest
ruff check .核心代码位于:
src/drain3_mcp_server/service.py:线程安全的 Drain3 服务层src/drain3_mcp_server/server.py:MCP 工具、资源与启动入口src/drain3_mcp_server/default_drain3.ini:默认模板挖掘配置
设计说明
训练调用会沿用 Drain3 自身的快照策略;如需确保最新的簇计数立即落盘,请在训练批次结束后调用
save_state。HTTP 模式下,单进程内的调用共享同一个 Drain3 模型,并通过可重入锁串行化访问。
若部署多个副本,每个副本应使用独立状态文件,或扩展为 Redis/Kafka 等共享持久化方案;本项目当前默认实现面向单实例。
HTTP 传输本身未配置身份认证。默认只监听回环地址;对外暴露时应放在带认证和 TLS 的网关之后。
Drain3 使用
jsonpickle恢复快照,因此状态文件必须来自可信位置,不要加载第三方提供的快照。
License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
MCP server for progressive tool usage at any scale (see https://klavis.ai)
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
MCP server for AI dialogue using various LLM models via AceDataCloud
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server for intelligent log analysis providing semantic search, error pattern clustering, and smart error detection. It enables users to process, vectorize, and query local logs to efficiently identify issues and generate AI-powered summaries.MIT
- AlicenseAqualityDmaintenanceMCP server for log file analysis. Gives LLMs the ability to efficiently analyze large log files without loading them into context.799MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for collecting and analyzing CLI/web server error logs. Enables watching log files/directories, parsing common error patterns, and querying/analyzing logs through natural language.10MIT
- FlicenseNot gradedqualityCmaintenanceCompresses log files into templates and statistics using Drain3, and exposes them to AI assistants via an MCP server for efficient log monitoring and anomaly detection.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/xinqihuang/Drain3MCPServer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server