Log-Analyzer-with-MCP

A Model Context Protocol (MCP) server that provides AI assistants access to AWS CloudWatch Logs for analysis, searching, and correlation

GitHub Stars

123

User Rating

Not Rated

Favorites

0

Views

23

Forks

18

Issues

5

Installation
Difficulty
Intermediate
Estimated Time
10-20 minutes
Requirements
uv: latest version
AWS account with CloudWatch Logs enabled
+1 more

Installation

Installation

Prerequisites

uv: Latest version
AWS Account: With CloudWatch Logs enabled
AWS Credentials: Configured

Installation Steps

1. Clone Repository

bash
git clone https://github.com/awslabs/Log-Analyzer-with-MCP.git
cd Log-Analyzer-with-MCP

2. Install Dependencies

``bash uv sync source .venv/bin/activate # On Windows, use .venv\Scripts\activate ``

Troubleshooting

Common Issues

Issue: Server won't start Solution: Check Node.js version and reinstall dependencies. Issue: Not recognized by Claude Desktop Solution: Verify configuration file path and syntax.

Configuration

Configuration

Basic Configuration

Claude Desktop Setup

Edit ~/.config/claude-desktop/claude_desktop_config.json (macOS/Linux) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
json
{
  "mcpServers": {
    "log-analyzer": {
      "command": "python",
      "args": ["-m", "server"],
      "env": {
        "API_KEY": "your-api-key"
      }
    }
  }
}

Environment Variables

Set the following environment variables as needed:
bash
export API_KEY="your-api-key"
export DEBUG="true"

Configuration Example

json
{
  "mcpServers": {
    "log-analyzer": {
      "command": "python",
      "args": ["-m", "server"],
      "env": {
        "PORT": "3000",
        "LOG_LEVEL": "info"
      }
    }
  }
}

Examples

Examples

Basic Usage

Using with Claude Desktop

1Verify MCP Server Startup
Open Claude Desktop and confirm that the configuration has been loaded correctly.
2Execute Basic Commands

   Available tools from this MCP server:
   - log-analyzer: Analyze logs from CloudWatch
   

Programmatic Usage

python
import requests
import json

def call_mcp_tool(tool_name, params):
    response = requests.post(
        'http://localhost:3000/mcp/call',
        json={
            'tool': tool_name,
            'parameters': params
        }
    )
    return response.json()

Usage example

result = call_mcp_tool('analyze', { 'input': 'sample data', 'options': {'format': 'json'} })

Use Cases

Search for specific error messages in AWS CloudWatch Logs to identify the root cause of issues.
Correlate logs from multiple AWS services to analyze overall system performance.
Utilize AI assistants to analyze trends from historical log data and predict future issues.
Automate regular log analysis to provide real-time insights to operational teams.

Additional Resources