Skip to main content
Glama

logcat-mcp

Android Studio が出力する JSON 形式の logcat ファイルを解析・フィルタリング・検索するための MCP サーバーです。

LLM がログファイルを効率的に分析し、デバッグ支援を行えるようにすることを目的としています。巨大なログファイル (数MB~) を直接 LLM に渡すのではなく、サーバー側でフィルタ・集計した結果のみを返します。

セットアップ

必要環境

  • Python 3.10+

  • uv

インストール

git clone <repository-url>
cd logcat-mcp
uv sync

ログファイルの配置

~/logcat-mcp/ ディレクトリに .logcat ファイルを配置してください。

mkdir -p ~/logcat-mcp
cp /path/to/your/exported.logcat ~/logcat-mcp/

Android Studio からの logcat エクスポート: Logcat ウィンドウ > 右クリック > Export to Text File で JSON 形式を選択

Related MCP server: Log MCP Server

MCP クライアントへの設定

Claude Desktop

claude_desktop_config.json に以下を追加:

{
  "mcpServers": {
    "logcat-mcp": {
      "command": "uv",
      "args": [
        "--directory", "/path/to/logcat-mcp",
        "run", "python", "-m", "logcat_mcp.server"
      ]
    }
  }
}

Claude Code

.mcp.json に以下を追加:

{
  "mcpServers": {
    "logcat-mcp": {
      "command": "uv",
      "args": [
        "--directory", "/path/to/logcat-mcp",
        "run", "python", "-m", "logcat_mcp.server"
      ]
    }
  }
}

/path/to/logcat-mcp は実際のクローン先パスに置き換えてください。

Tools

logcat_list_files

~/logcat-mcp/ 内の .logcat ファイル一覧を取得します。ファイル名、サイズ、更新日時を返します。

logcat_read

ログファイルを読み込み、フィルタを適用してエントリを返します。

パラメータ

型

必須

説明

filename

string

Yes

ファイル名

log_level

string

No

最低ログレベル (VERBOSE/DEBUG/INFO/WARN/ERROR)

tag

string

No

タグ名 (部分一致)

pid

int

No

プロセス ID

application_id

string

No

アプリケーション ID (部分一致)

start_time

string

No

開始時刻 (ISO 8601)

end_time

string

No

終了時刻 (ISO 8601)

limit

int

No

上限数 (default: 50, max: 200)

offset

int

No

オフセット (default: 0)

ログメッセージを正規表現で検索します。

パラメータ

型

必須

説明

filename

string

Yes

ファイル名

pattern

string

Yes

検索パターン (正規表現、大文字小文字区別なし)

log_level

string

No

最低ログレベル

tag

string

No

タグ名 (部分一致)

application_id

string

No

アプリケーション ID (部分一致)

start_time

string

No

開始時刻 (ISO 8601)

end_time

string

No

終了時刻 (ISO 8601)

limit

int

No

上限数 (default: 30, max: 100)

logcat_summary

ログファイル全体の統計サマリーを返します。ログレベル別件数、頻出タグ TOP 10、頻出 applicationId、時間範囲、エラー件数、デバイス情報を含みます。

パラメータ

型

必須

説明

filename

string

Yes

ファイル名

logcat_errors

ERROR レベルのログとスタックトレースを抽出します。

パラメータ

型

必須

説明

filename

string

Yes

ファイル名

tag

string

No

タグ名 (部分一致)

application_id

string

No

アプリケーション ID (部分一致)

limit

int

No

上限数 (default: 30, max: 100)

Resources

logcat://files

~/logcat-mcp/ 内の利用可能なファイル一覧とメタデータを JSON で返します。

Prompts

analyze-crash

クラッシュ解析プロンプト。ERROR ログとスタックトレースを抽出し、根本原因の分析を行うワークフローを生成します。

debug-performance

パフォーマンスデバッグプロンプト。特定アプリのログサマリーと警告/エラーを抽出し、ボトルネック分析を行うワークフローを生成します。

推奨ワークフロー

  1. logcat_list_files でファイル一覧を確認

  2. logcat_summary でファイルの概要を把握

  3. 目的に応じて以下を使い分け:

    • エラー調査: logcat_errors でスタックトレースを確認

    • キーワード検索: logcat_search で正規表現検索

    • ログ閲覧: logcat_read でフィルタ付きページネーション

開発

MCP Inspector でテスト

uv run mcp dev src/logcat_mcp/server.py

対応するログファイル形式

Android Studio が出力する JSON 形式の .logcat ファイルに対応しています。

{
  "metadata": {
    "device": { ... },
    "filter": "package:mine",
    "projectApplicationIds": ["com.example.app"]
  },
  "logcatMessages": [
    {
      "header": {
        "logLevel": "ERROR",
        "pid": 1000,
        "tid": 1001,
        "applicationId": "com.example.app",
        "processName": "com.example.app",
        "tag": "CrashHandler",
        "timestamp": { "seconds": 1766305183, "nanos": 400000000 }
      },
      "message": "java.lang.NullPointerException: ..."
    }
  ]
}

セキュリティ

  • ファイルアクセスは ~/logcat-mcp/ ディレクトリ内に限定 (.. によるパストラバーサル防止)

  • filename パラメータは相対パスのみ受け付け、resolve 後にベースディレクトリ内であることを検証

  • すべてのツールは読み取り専用 (readOnlyHint=True)

ライセンス

MIT License - 詳細は LICENSE を参照してください。

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • 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
      5
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to automatically inspect and analyze application runtime log files for debugging and troubleshooting. Supports monitoring multiple log directories simultaneously with tools for listing, reading, searching, and paginating through log files.
      8
      MIT
    • A
      license
      Not graded
      quality
      F
      maintenance
      Enables LLMs to analyze logs by extracting patterns, redacting secrets, and providing token-efficient summaries from files, Docker containers, or journald.
      5
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to read and analyze Linux system logs—including systemd journal, syslog, kernel, application, and Docker container logs—for diagnostics and predictive analysis.
      MIT