Stop Reading Raw Stacktraces: AI-Powered Java Thread Dump Analysis with MCP

Published: (January 18, 2026 at 12:55 PM EST)
3 min read
Source: Dev.to

Source: Dev.to

Introduction

Let’s be honest: who actually enjoys digging through 500 MB log files to find a needle in a haystack? Production is down, alerts are popping up, and you’re scrolling through hundreds of lines of a thread dump, hunting for the monitor lock that’s holding everything up or trying to determine whether http-nio-8080-exec-1 was already stuck at the same line seconds ago. It’s tedious, error‑prone, and boring.

What if your debugging tools didn’t just display data but actually understood it? Imagine asking an AI agent (e.g., Claude, Cursor, or Junie):

“Hey, why is the database pool hanging?”

and having it run your trusted analysis tools in the background to give you an answer.

In this article I’ll show how I revitalized TDA (Thread Dump Analyzer)—a classic open‑source GUI for Java thread‑dump analysis—by integrating it with the new Model Context Protocol (MCP). An AI agent, powered by MCP, can directly access local log files, find deadlocks, and identify performance bottlenecks faster and more accurately than manual analysis.

Welcome to the era of agentic debugging.

Adding the TDA MCP Server

Create or update your mcp.json configuration with a TDA server entry:

{
  "mcpServers": {
    "tda": {
      "command": "java",
      "args": [
        "-Djava.awt.headless=true",
        "-jar", "path/to/tda.jar",
        "--mcp"
      ]
    }
  }
}

The --mcp flag tells TDA to start in MCP‑compatible mode.

Integrating with Junie (IntelliJ)

I integrated the MCP server into Junie, the AI assistant inside IntelliJ, by:

  1. Refactoring the TDA source to work with MCP.
  2. Adding the TDA server configuration to Junie’s settings.

After a successful integration, Junie’s settings panel lists the available commands for the TDA MCP server.

System Prompt for Log Handling

To ensure the agent uses the MCP server for log parsing (and avoids costly token usage), add the following system prompt to .junie/instructions.md (or to .cursorrules for Cursor users):

When you encounter a log file that appears to contain Java thread dumps:
1. DO NOT try to read or "cat" the entire file if it's large.
2. Use the `tda-analyzer` MCP toolset.
3. First, call `parse_log(path="...")` to initialize the analysis.
4. Use `get_summary()`, `check_deadlocks()`, and `find_long_running()` to perform the analysis.
5. Provide your insights based on the structured data returned by these tools rather than the raw log text.

Using the Integrated Analyzer

With the prompt in place, you can ask Junie (or any MCP‑compatible agent) to analyze a log:

Junie: "Please analyze the thread dump in /var/logs/app.log."

The agent will automatically:

  1. Call parse_log(path="/var/logs/app.log").
  2. Run check_deadlocks() and find_long_running().
  3. Summarize the findings with get_summary().

The output includes:

  • Whether deadlocks were detected.
  • Any long‑running threads.
  • A concise summary of each thread dump.

If the agent is running inside the same codebase that produced the thread dumps, it can even suggest concrete code changes to fix the identified issues.

Benefits of MCP‑Powered TDA

  • Speed – Temporal analysis across multiple snapshots that used to take minutes now completes in seconds.
  • Accuracy – Structured data from the MCP tools eliminates mis‑interpretation of raw logs.
  • Focus – Developers stay in their “flow” instead of grepping through massive files.

Future Work

  • Refine the TDA MCP toolset (e.g., add filter_by_thread_name).
  • Deepen IDE integrations (Cursor, IntelliJ via Junie).
  • Encourage community contributions to the open‑source MCP module.

Get Started

Stop reading raw stack traces and start chatting with your JVM!

Back to Blog

Related posts

Read more »

𝗗𝗲𝘀𝗶𝗴𝗻𝗲𝗱 𝗮 𝗣𝗿𝗼𝗱𝘂𝗰𝘁𝗶𝗼𝗻‑𝗥𝗲𝗮𝗱𝘆 𝗠𝘂𝗹𝘁𝗶‑𝗥𝗲𝗴𝗶𝗼𝗻 𝗔𝗪𝗦 𝗔𝗿𝗰𝗵𝗶𝘁𝗲𝗰𝘁𝘂𝗿𝗲 𝗘𝗞𝗦 | 𝗖𝗜/𝗖𝗗 | 𝗖𝗮𝗻𝗮𝗿𝘆 𝗗𝗲𝗽𝗹𝗼𝘆𝗺𝗲𝗻𝘁𝘀 | 𝗗𝗥 𝗙𝗮𝗶𝗹𝗼𝘃𝗲𝗿

!Architecture Diagramhttps://dev-to-uploads.s3.amazonaws.com/uploads/articles/p20jqk5gukphtqbsnftb.gif I designed a production‑grade multi‑region AWS architectu...