Skip to main content
Glama
log-analyzer-mcp

log-analyzer-mcp

by yufeizhou666

log-analyzer-mcp

ログ分析およびシステムメトリクスツールを提供するMCP(Model Context Protocol)サーバーです。stdioトランスポート経由でClaude Codeに接続し、ローカルのログファイルを検索、カウント、分析するための5つのツールを公開します。

機能

ツール

説明

search_logs

キーワードまたは正規表現でログファイルを検索

count_by_level

重要度レベル(ERROR/WARN/INFO/DEBUG)ごとにログエントリをカウント

query_by_timerange

特定の時間範囲内のログをフィルタリング

get_system_metrics

CPU、メモリ、ディスク使用量のメトリクスを取得

explain_error

AIによる分析用にエラー内容をフォーマット

Related MCP server: ai-ssh-mcp

クイックスタート

# Install dependencies
npm install

# Build TypeScript
npm run build

# Run the server
npm start

開発

# Run with hot reload
npm run dev

Claude Codeとの統合

Claude Codeにサーバーを追加します:

# Project-level (only available in this directory)
claude mcp add log-analyzer -- node /path/to/log-analyzer-mcp/dist/index.js

# User-level (available globally)
claude mcp add log-analyzer --scope user -- node /path/to/log-analyzer-mcp/dist/index.js

接続を確認します:

claude mcp list

ツールの詳細

キーワードまたは正規表現でログファイルを検索します。単一の .log ファイルまたはディレクトリ全体の検索をサポートしています。

{
  "keywords": ["ERROR", "timeout"],
  "regex": "connection.*failed",
  "logPath": "/var/log",
  "limit": 100
}

count_by_level

重要度レベルごとにログエントリをカウントします。オプションで時間範囲によるフィルタリングも可能です。

{
  "logPath": "/var/log",
  "startTime": "2026-04-29T00:00:00Z",
  "endTime": "2026-04-30T00:00:00Z"
}

query_by_timerange

特定の時間範囲内のログをフィルタリングします。オプションでレベルによるフィルタリングも可能です。

{
  "startTime": "2026-04-29T00:00:00Z",
  "endTime": "2026-04-30T00:00:00Z",
  "logPath": "/var/log",
  "level": "ERROR",
  "limit": 100
}

get_system_metrics

CPU、メモリ、ディスクのメトリクスを取得します。WindowsおよびLinuxをサポートしています。

{
  "metrics": ["cpu", "memory", "disk"]
}

explain_error

AIによる根本原因分析のためにエラー内容をフォーマットします。

{
  "errorContent": "java.lang.NullPointerException\n  at com.example.Service.process(Service.java:42)",
  "contextLines": 10
}

アーキテクチャ

src/
├── index.ts           # MCP Server entry point
├── tools/             # Individual MCP tool implementations
├── utils/
│   ├── log_parser.ts  # Timestamp/level parsing, keyword/regex matching
│   └── metrics.ts     # Cross-platform CPU/memory/disk metrics
└── types/             # TypeScript type definitions

このサーバーは @modelcontextprotocol/sdk と StdioServerTransport を使用しています。ツールは CallToolRequestSchema ハンドラーを介して登録されます。

主要な設計上の決定

  • ストリーム処理: readline + createReadStream を使用して、大きなログファイルをメモリにすべて読み込まずに処理します

  • クロスプラットフォーム: Windows (WMIC) と Linux (top/free/df) のデュアルパス実装により、実行時にプラットフォームを自動検出します

  • 寛容な解析: 非標準のログ形式も破棄せずに保持します(レベルが不明な場合はINFO、タイムスタンプが不明な場合は現在時刻をデフォルトとします)

ライセンス

MIT

Available Tools

5 tools
count_by_levelB

Count log entries by severity level (ERROR, WARN, INFO, DEBUG)

Inputs: logPath, startTime, endTime.

explain_errorC

AI-assisted error analysis. Formats error content for AI analysis.

Inputs: errorContent (required), contextLines.

get_system_metricsB

Get CPU, memory, and disk metrics from the system

Inputs: metrics.

query_by_timerangeC

Query logs within a specific time range

Inputs: startTime (required), endTime (required), logPath, level, +1 more.

search_logsA

Search log files by keywords or regex patterns. Returns matching log entries with timestamps.

Inputs: keywords, regex, logPath, limit.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: counting by level, error explanation, system metrics, time-range queries, and keyword search. No overlap in functionality.

    Naming Consistency4/5

    Names follow a verb-oriented pattern (count, explain, get, query, search) but mix styles: some use 'by_' (count_by_level, query_by_timerange) while others are plain verb_noun (explain_error, get_system_metrics, search_logs). Mostly consistent but with minor deviations.

    Tool Count5/5

    5 tools is well-scoped for a log analysis server, covering essential operations without being too few or excessive.

    Completeness4/5

    Core log analysis tasks are covered: search, count by level, time-range queries, error explanation, and system metrics. Minor gaps exist, such as lacking a tool to list log sources or aggregate statistics beyond level counting.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      A Claude integration tool that enables users to query and analyze Aliyun (Alibaba Cloud) Simple Log Service logs through natural language commands.
      1
      21 npm
      2
      GPL 2.0
    • A
      license
      A
      quality
      D
      maintenance
      Enables natural language SSH server management via Claude Code, allowing users to read logs, check services, run commands, and transfer files across multiple servers.
      6
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables Claude to monitor CPU, memory, disk, processes, network connections, Docker containers, and system logs for system diagnostics and troubleshooting.
      5
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      Exposes homelab and IT-ops tools to Claude, including system health monitoring, Grafana alert states, Docker container status, Loki logs, SMART disk health, and more.
      8
      1
      -