MCP Logback Analyzer

MCP Logback Analyzer

A FastMCP-based tool for analyzing logback log files to detect code defects and generate automated fix suggestions. It features intelligent stack trace filtering and token optimization to efficiently identify and resolve application errors.

Category
Visit Server

README

MCP 日志分析工具

一个基于 FastMCP 的 Model Context Protocol (MCP) 工具,用于分析 logback 配置的日志文件,检测代码缺陷并生成修复建议。

✨ 功能特性

  • 🔍 智能日志分析:自动提取异常信息,不限于预定义模式
  • 📊 堆栈跟踪过滤:保留应用包下的堆栈信息,过滤底层框架信息
  • 🎯 缺陷检测:自动识别异常类型并推断严重程度
  • 🔧 自动修复建议:生成代码修复建议
  • 🌐 跨平台支持:支持 Windows、Linux、Mac
  • ⚙️ 灵活配置:支持环境变量、配置文件、命令行参数多种配置方式
  • 🚀 Token 优化:智能提取关键信息,减少 token 消耗

📦 安装

从 PyPI 安装(推荐)

pip install mcp-logback-analyzer

使用国内镜像源(国内用户推荐)

如果无法访问 PyPI 或下载速度慢,可以使用国内镜像源:

# 清华大学镜像(推荐)
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple mcp-logback-analyzer

# 阿里云镜像
pip install -i https://mirrors.aliyun.com/pypi/simple/ mcp-logback-analyzer

# 腾讯云镜像
pip install -i https://mirrors.cloud.tencent.com/pypi/simple mcp-logback-analyzer

从私有 PyPI 安装

pip install -i http://your-server:8080/simple/ mcp-logback-analyzer

从源码安装

git clone https://github.com/mengbi-super/MCP-TOOLS.git
cd MCP-TOOLS
pip install -e .

🚀 快速开始

1. 安装依赖

pip install mcp-logback-analyzer

2. 配置 Cursor MCP

编辑 Cursor 的 MCP 配置文件(参考 cursor-mcp-config-example.json):

{
  "mcpServers": {
    "log-analyzer": {
      "command": "python",
      "args": ["-m", "tools.log_analyzer_tool"],
      "cwd": "${workspaceFolder}",
      "env": {
        "LOGBACK_CONFIG_PATH": "${workspaceFolder}/src/resource/logback-spring.xml",
        "SPRING_APPLICATION_NAME": "your-app-name",
        "APP_PACKAGE": "com.example.yourpackage"
      }
    }
  }
}

3. 使用工具

在 Cursor 中,你可以直接使用以下命令:

  • analyze_logs - 分析日志文件,检测代码缺陷
  • search_logs - 在日志中搜索关键词
  • get_logback_config - 获取 logback 配置信息
  • auto_fix_defect - 根据缺陷信息生成修复建议

📖 文档

详细文档请参考:使用指南.md

🔧 配置说明

环境变量

  • LOGBACK_CONFIG_PATH - logback 配置文件路径
  • SPRING_APPLICATION_NAME - 应用名称
  • APP_PACKAGE - 应用包名(用于过滤堆栈跟踪)
  • ERROR_LOG_PATH - 错误日志文件路径
  • WARN_LOG_PATH - 警告日志文件路径
  • ALL_LOG_PATH - 全部日志文件路径

配置优先级

  1. 方法参数
  2. 环境变量
  3. logback 配置
  4. 默认值

📝 使用示例

分析错误日志

from tools.log_analyzer_tool import LogAnalyzer

analyzer = LogAnalyzer()
result = analyzer.analyze_logs(log_level="error", max_lines=1000)

print(f"发现 {result['total_defects']} 个缺陷")
for defect in result['defects']:
    print(f"类型: {defect['defect_type']}, 严重程度: {defect['severity']}")

搜索日志

result = analyzer.search_logs(keyword="NullPointerException", log_level="error")
print(f"找到 {result['total_matches']} 个匹配结果")

🛠️ 开发

本地开发

# 克隆仓库
git clone https://github.com/mengbi-super/MCP-TOOLS.git
cd MCP-TOOLS

# 安装开发依赖
pip install -e ".[dev]"

# 运行测试
pytest

构建包

# 安装构建工具
pip install build twine

# 构建
python -m build

📄 许可证

MIT License

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📧 联系方式

如有问题,请提交 Issue 或联系:mengbi1014@gmail.com


更多信息请查看 使用指南.md

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured