mat icon indicating copy to clipboard operation
mat copied to clipboard

Add Model Context Protocol (MCP) Support to Eclipse Memory Analyzer

Open will-zdu opened this issue 11 months ago • 10 comments

Summary

This is a feature request to integrate the Model Context Protocol (MCP) into Eclipse Memory Analyzer (MAT). MCP would enable AI assistants (like Claude, ChatGPT, etc.) to interact directly with MAT for automated memory analysis, leak detection, and report generation through standardized tool calls.

Motivation

As memory analysis becomes increasingly complex, integrating AI capabilities could significantly enhance the productivity of developers and performance engineers. MCP would allow:

  1. Automated Analysis Pipeline: AI assistants could perform end-to-end memory analysis workflows
  2. Intelligent Insights: AI could correlate memory patterns with application code and provide actionable recommendations
  3. Natural Language Queries: Developers could ask questions about heap dumps in plain English
  4. Integration with Development Workflows: AI could automatically analyze heap dumps as part of CI/CD pipelines

Proposed Implementation

Core MCP Tools

The following MCP tools could be implemented:

  1. parse_heap_dump

    • Input: Path to heap dump file
    • Output: Basic statistics and parse status
    • Parameters: Optional filters, parsing preferences
  2. run_leak_detection

    • Input: Parsed heap dump reference
    • Output: Leak suspects, potential memory issues
    • Parameters: Analysis depth, report format
  3. query_objects

    • Input: OQL query or natural language description
    • Output: Query results in structured format
    • Parameters: Query type, result limit
  4. analyze_memory_patterns

    • Input: Specific classes, packages, or patterns
    • Output: Memory usage statistics, retention analysis
    • Parameters: Analysis scope, comparison baseline
  5. generate_report

    • Input: Analysis results, report template
    • Output: HTML/JSON report
    • Parameters: Report type, sections to include

will-zdu avatar Dec 12 '25 02:12 will-zdu

Generate PDF or Markdown report is good. Current report includes html/js/css/png, is tough to analyzer with LLM.

omegazeng avatar Jan 21 '26 03:01 omegazeng

@will-zdu @jasonk000 is this still needed? If yes, i can work on it

sachinkg12 avatar Sep 28 '26 07:09 sachinkg12

In principle, we would be open to this but we would like to first see a design proposal of how it might work. Contributions welcome. Note the Eclipse GenAI policy: https://www.eclipse.org/projects/handbook/#genai

kgibm avatar Oct 08 '26 20:10 kgibm

4. In principle, we would be open to this but we would like to first see a design proposal of how it might work. Contributions welcome. Note the Eclipse GenAI policy: https://www.eclipse.org/projects/handbook/#genai

Hi @kgibm , sure i will work on it, and provide the design proposal. You can assign this ticket to me, i don't have the access to assign it to myself.

sachinkg12 avatar Oct 12 '26 05:10 sachinkg12

i created an MCP server on top of MAT: https://github.com/Servoy/mat_mcp an update site is also created: https://servoy.github.io/mat_mcp/

This runs on top of jetty an mcp http server , hard coded for now on localhost:8923/mcp that exposes a number of tools that mat provides.

i didn't want to just do it fully headless, because i like that i can open it let it first parse and then the the AI through the MCP can interact with the open editor (this has now some reflection hacks because of the x-friends stuff)

You are free to copy the whole code, if you want i can based on that create a pull request?

jcompagner avatar Oct 13 '26 09:10 jcompagner

@sachinkg12 still need it

will-zdu avatar Oct 14 '26 07:10 will-zdu

i have to say that an mcp server like that is really working well. this morning i got an 19GB heapdump that somebody ask me to analyse i opened MAT, read in (let it parse) the whole thing, when it was done, i openend my AI tool with the mcp server enabled, and i just asked:

"What can you tell me about the current heapdump"

with in seconds it says "this is fishy" and i asked it to go deeper and a few seconds later it had exactly the cause, even comming up with something like this:

"Each tuple has 216 columns, and one cell [37] sits at a very different address (0x448718e7000) which suggests a large blob. Let me check that cell's size"

that "sits at a very different address" i wouldn't have noticed that quickly

jcompagner avatar Oct 15 '26 08:10 jcompagner

Hi @jcompagner Thanks for the prototype. There might be a lot of questions around security (and MAT is used by many security-conscious enterprises), whether it's on-by-default and how to configure it, etc. which will be a significant effort to review and integrate. So for now given that your prototype works in combination with MAT, I suggest we wait for feedback on it from the community. Thanks!

kgibm avatar Oct 20 '26 14:10 kgibm

Relatedly, I just merged into the main branch a rudimentary new "Export to Markdown for AI" feature: #193

Image

kgibm avatar Oct 20 '26 14:10 kgibm

11. Hi @jcompagner Thanks for the prototype. There might be a lot of questions around security (and MAT is used by many security-conscious enterprises), whether it's on-by-default and how to configure it, etc. which will be a significant effort to review and integrate. So for now given that your prototype works in combination with MAT, I suggest we wait for feedback on it from the community. Thanks!

If you want a preference page where you can enabled it , disabled by default (and choose the port) and having a bearer/auth token configuration so somehting like this:

Image

that is from the AssistAI (https://github.com/gradusnikov/eclipse-chatgpt-plugin) plugin. That would be really easy to make if needed....

jcompagner avatar Oct 20 '26 14:10 jcompagner