Skip to main content
Glama
BBashh

MCP Log Analyzer

by BBashh

📊 MCP Log Analyzer

An intelligent log file analyzer powered by Python and integrated with Cursor IDE through the Model Context Protocol (MCP).

🎯 What It Does

Analyzes log files instantly using AI-powered tools. Instead of manually searching through thousands of log lines, ask questions in natural language and get instant insights about errors, patterns, and anomalies.

Before vs After

Before (❌):

  • Manually open and search log files

  • Hours of tedious analysis

  • Error-prone manual work

After (✅):

  • Ask Claude in natural language

  • Get instant analysis in seconds

  • Automatic pattern detection

  • AI-powered insights

Related MCP server: Local Logs MCP Server

🛠️ Features

6 Analysis Tools

  1. read_logs - Fetch and display log content

  2. count_log_types - Count logs by severity (INFO, ERROR, WARNING, CRITICAL)

  3. generate_statistics - Analyze patterns and detect anomalies

  4. extract_critical_logs - Extract only critical issues

  5. detect_anomalies - Find unusual activity and spikes

  6. generate_report - Create formatted HTML/text reports

🚀 Quick Start

1. Clone Repository

git clone https://github.com/BBashh/log_file_mcp.git
cd log_file_mcp

2. Set Up Virtual Environment

# Windows
python -m venv venv
venv\Scripts\activate
# Mac/Linux
python3 -m venv venv
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Test Locally

python mcp_server.py
# Should show: "Log Analyzer MCP Server starting..."
# Press Ctrl+C to stop

5. Configure Cursor IDE

Update your mcp.json file:

Location: C:\Users\[YourUsername]\AppData\Roaming\Cursor\User\settings\mcp.json

{
  "mcpServers": {
    "log-analyzer": {
      "command": "[FULL_PATH_TO_VENV]\\venv\\Scripts\\python.exe",
      "args": ["[FULL_PATH_TO_PROJECT]\\mcp_server.py"]
    }
  }
}

6. Use in Cursor

  • Restart Cursor IDE

  • Look for green dot in Tools & MCP

  • Ask questions in Cursor chat:

    • "Read logs from sample_logs"

    • "How many errors are there?"

    • "Generate a report"

🔧 Configuration

Edit `config.py` to customize:

DEFAULT_LOG_DIR = "C:\\path\\to\\logs"  # Your log directory
LOG_LEVELS = ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"]
STATS_CONFIG = {
    "min_line_length": 5,
    "max_line_length": 1000,
    "rare_threshold": 0.01,
}

📝 Usage Examples

In Cursor Chat:

NOTE: If the chat is giving responses without using the mcp tool, then explicitly mention in the chat to use the xyz tool.

Ex:

Read logs:

Read the logs from sample_logs and show me the last 10 lines using the read_logs mcp tool

Count by type:

How many INFO, WARNING, and ERROR logs are there using `xyz` tool?

Get statistics:

Analyze the logs for patterns and anomalies using `xyz` tool

Extract critical:

Show me all critical logs only using `xyz` tool

Generate report:

Create a comprehensive analysis report of the logs using `xyz` tool.

Ex:

🏛️ Technical Details

Technologies

  • FastMCP - MCP server framework

  • Python 3.x - Programming language

  • Cursor IDE - IDE integration

  • JSON-RPC - Communication protocol

Design Patterns

  • MVC Pattern - Separation of concerns

  • Factory Pattern - Tool creation

  • Observer Pattern - Event handling

  • Singleton Pattern - Config management

Key Features

  • Modular architecture (easy to extend)

  • Error handling and validation

  • Configuration management

  • Report generation (HTML/Text)

  • Pattern detection

  • Anomaly detection

🔐 Security Notes

  • Server runs locally only (no internet exposure)

  • Log files processed in memory

  • No data stored externally

  • Compatible with confidential logs

🐛 Troubleshooting

Green dot not showing?

  • Check mcp.json has correct paths

  • Verify venv Python path is correct

  • Restart Cursor completely

"Module not found" error?

  • Make sure venv is activated

  • Run: pip install -r requirements.txt

Tools not responding?

  • Verify server running: python mcp_server.py

  • Check sample_logs/sample.log exists

  • Restart Cursor and try again

Related MCP Connectors

Related MCP Servers

  • -
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables AI-powered debugging through structured logging with pattern recognition and intelligent analysis. Allows applications to write structured logs and receive actionable debugging insights based on error patterns and frequency analysis.
    -
  • A
    license
    A
    quality
    D
    maintenance
    Enables monitoring and analysis of local application log files with real-time tailing, error tracking, and search capabilities. Perfect for debugging Node.js applications, web servers, or any application that writes to log files through natural language commands.
    6
    6
    MIT
  • F
    license
    B
    quality
    C
    maintenance
    Enables AI-assisted analysis of log files through advanced searching, filtering, and test execution capabilities. Supports time-based queries, pattern matching, test summarization, and code coverage reporting directly within compatible MCP clients.
    12
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that provides AI assistants with direct access to application logs for on-demand searching, filtering, and analysis. It enables tools like Cursor to summarize log entries and identify errors within the development environment to streamline debugging.
    8 npm
    6
    MIT