Skip to main content
Glama
pnini7814

Error Analyzer MCP Server

by pnini7814

Error Analyzer MCP Server ๐Ÿ”ง

A specialized Model Context Protocol (MCP) server that analyzes errors in your projects, identifies root causes, and generates detailed fix plans with a built-in approval workflow before applying any changes.

๐ŸŒŸ Overview

When your project encounters errors, this MCP server helps you:

  • Read and analyze log files to understand what went wrong

  • Identify the affected files and their dependencies

  • Diagnose the root cause of errors

  • Create detailed fix plans with step-by-step solutions

  • Request your approval before making ANY file modifications

  • Apply approved fixes safely to your project

This server emphasizes safety and transparency: it never modifies your files without your explicit approval and clear understanding of what will change.

Related MCP server: Debugging MCP Server

๐Ÿ—๏ธ Architecture

  • Reads log files from a configurable logger directory

  • Analyzes error messages and stack traces

  • Identifies related files and dependencies

  • Generates fix plans with risk assessment

  • Implements a two-phase workflow:

    1. Analysis & Planning Phase: Creates fix plans

    2. Approval Phase: Waits for your explicit approval

    3. Application Phase: Applies approved changes

๐Ÿ› ๏ธ Available Tools

1. list_available_logs

List all log files in your logger directory.

  • Returns all .log files available for analysis

2. analyze_error

Analyze errors in a specific log file.

  • Input: project directory path, log file name

  • Returns: error location, root cause, affected files, severity level

  • Creates an analysis ID for further processing

3. create_fix_plan

Create a detailed work plan to fix identified errors.

  • Input: analysis ID from previous step

  • Returns: fix plan with proposed fixes, impact assessment, risk level

  • Status: Awaiting your approval

  • Creates a plan ID for tracking

4. approve_fix_plan

Approve a fix plan after reviewing the proposed changes.

  • Input: plan ID

  • Effect: Marks the plan as approved

  • Next step: Call apply_fix_plan to make the changes

5. reject_fix_plan

Reject a fix plan if you disagree with proposed solutions.

  • Input: plan ID, optional feedback

  • Effect: Cancels the plan

  • Next step: Can request new analysis with different parameters

6. apply_fix_plan

Apply the approved fixes to your project files.

  • Input: plan ID (must be approved first)

  • Effect: MODIFIES YOUR PROJECT FILES

  • Returns: List of changes applied

  • Safety: Only works if plan was explicitly approved

7. get_fix_plan_details

Retrieve detailed information about a specific fix plan.

  • Useful for reviewing plans before approval

8. list_pending_plans

See all fix plans created in this session with their statuses.

  • Helps track pending approvals and applied fixes

๐Ÿ“‹ Workflow Example

1. Error occurs in your project
   โ†“
2. Error is written to logger/error.log
   โ†“
3. Call analyze_error(project_dir="/path/to/project", log_file_name="error.log")
   โ†’ Returns: analysis_id = "abc123"
   โ†“
4. Call create_fix_plan(analysis_id="abc123")
   โ†’ Returns: plan_id = "xyz789"
   โ†’ Status: "AWAITING USER APPROVAL"
   โ†“
5. Review the proposed fixes in the plan
   โ†“
6. Either:
   a) Call approve_fix_plan(plan_id="xyz789") โ†’ then apply_fix_plan(plan_id="xyz789")
   b) Call reject_fix_plan(plan_id="xyz789", feedback="...")

๐Ÿš€ Setup

Installation

  1. Clone or extract the project to your workspace:

cd m:\mcp\mcp-read-log
  1. Install dependencies:

pip install -r requirements.txt
  1. Configure environment (optional):

# Copy the example file
cp .env.example .env

# Edit .env to customize:
# - LOG_DIR: Path to your logger directory (default: ./logger)
# - PROJECT_DIR: Default project to analyze
# - BACKUP_BEFORE_APPLY: Create backups before applying fixes
  1. Create logger directory if it doesn't exist:

mkdir logger

๐Ÿ“– Usage with Claude or Other AI Agents

In Claude or Cline:

You have access to the error-analyzer-mcp MCP server. When a user's project has errors:

1. First call: list_available_logs() to see what log files are available
2. Then call: analyze_error() with the project path and log file name
3. Review the analysis results
4. Call: create_fix_plan() with the analysis ID
5. Show the user the proposed fixes and ask for approval
6. Only after explicit approval, call: apply_fix_plan()

Example Session:

User: "My Python project is broken with errors"
AI: Calling list_available_logs()... Found: error.log, debug.log
AI: Which log should I analyze? Let me check error.log.
AI: Calling analyze_error(project_dir=".", log_file_name="error.log")
AI: Analysis complete! Found SyntaxError on line 42, affects 3 files.
AI: Calling create_fix_plan()...
AI: Created fix plan. Here are the proposed changes:
   - Fix syntax error in main.py line 42
   - Update import in handler.py line 15
AI: This has LOW risk. Do you approve these changes?
User: "Yes, apply them"
AI: Calling approve_fix_plan()... then apply_fix_plan()
AI: Done! Applied 2 fixes to your project.

๐Ÿ”’ Safety Features

โœ… No file modifications without approval

  • Every fix plan requires explicit user approval before changes

โœ… Clear risk assessment

  • Each plan shows risk level, severity, and dependencies

โœ… Transparent change tracking

  • See exactly which files and lines will be modified

โœ… Reversible operations

  • Backup support (configurable in .env)

  • Can review changes before committing

๐Ÿ“ Log File Format

Place log files in the logger directory. Supported formats:

  • Standard error logs with file:line:column notation

  • Stack traces with file paths

  • IDE error output

  • Custom formatted logs with error messages

Example:

Error in /path/to/file.py on line 42:
  SyntaxError: invalid syntax
    x = y +
          ^
File "helper.py", line 15, in process()
  undefined_variable = 5

๐Ÿ”ง Configuration Files

pyproject.toml

Project metadata and Python dependencies. Uses PyPI packages for MCP, Pydantic, and python-dotenv.

requirements.txt

Direct pip requirements for easy installation.

settings.py

Configuration dataclass for runtime settings.

.env

Environment variables:

  • LOG_DIR: Custom logger directory path

  • PROJECT_DIR: Default project to analyze

  • BACKUP_BEFORE_APPLY: Whether to create backups (true/false)

๐Ÿ“‚ Project Structure

mcp-read-log/
โ”œโ”€โ”€ main.py                          # MCP server with all tools
โ”œโ”€โ”€ settings.py                      # Configuration management
โ”œโ”€โ”€ pyproject.toml                   # Project metadata
โ”œโ”€โ”€ requirements.txt                 # Python dependencies
โ”œโ”€โ”€ .env.example                     # Example configuration
โ”œโ”€โ”€ README.md                        # This file
โ”‚
โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ result.py                   # ToolResult, ErrorInfo, ErrorAnalysis models
โ”‚   โ””โ”€โ”€ error_analysis_models.py    # Input models for MCP tools
โ”‚
โ”œโ”€โ”€ services/
โ”‚   โ”œโ”€โ”€ log_reader.py               # Log file reading utilities
โ”‚   โ””โ”€โ”€ error_analysis_service.py   # Core error analysis logic
โ”‚
โ”œโ”€โ”€ utils/
โ”‚   โ””โ”€โ”€ (utilities for path, validation, errors)
โ”‚
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ (unit tests for services)
โ”‚
โ””โ”€โ”€ logger/                          # Log files (created on first use)
    โ”œโ”€โ”€ error.log
    โ””โ”€โ”€ debug.log

๐Ÿ› Debugging

If the MCP server doesn't start:

  1. Check Python version: Requires Python 3.12+

python --version
  1. Verify dependencies:

pip list | grep mcp
pip list | grep pydantic
  1. Test log reading:

python -c "from services.log_reader import list_log_files; print(list_log_files())"
  1. Check environment:

echo %LOG_DIR%  # Windows
echo $LOG_DIR   # Linux/Mac

๐Ÿ“„ License

Based on the git-mcp-server framework by the course instructor.

๐Ÿค Contributing

To extend this MCP server:

  • Add new error detection patterns in error_analysis_service.py

  • Add new analysis types by extending ErrorAnalysis model

  • Add new tool methods in main.py following the @mcp.tool() pattern


Remember: This server helps you understand and fix errors safely. Always review proposed changes before approval!

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    An intelligent debugging assistant that automates the debugging process by analyzing bugs, injecting HTTP-based debug logs into code across multiple environments (browser, Node.js, mobile, etc.), and iteratively fixing issues based on real-time feedback.
    8
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Enables LLMs to automatically diagnose coding errors through codebase search, test execution, and live debugger integration (DAP/V8 CDP). Provides a secure, policy-gated environment for investigating failures while preventing destructive operations.
    9
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Analyzes log files using AI-powered tools to detect errors, patterns, and anomalies through natural language queries in Cursor IDE.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI to automatically diagnose bugs by querying logs, tracing call chains, and analyzing code across multiple log platforms like Elasticsearch and Loki.
    MIT