Add Model Context Protocol (MCP) Support to Eclipse Memory Analyzer
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:
- Automated Analysis Pipeline: AI assistants could perform end-to-end memory analysis workflows
- Intelligent Insights: AI could correlate memory patterns with application code and provide actionable recommendations
- Natural Language Queries: Developers could ask questions about heap dumps in plain English
- 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:
-
parse_heap_dump- Input: Path to heap dump file
- Output: Basic statistics and parse status
- Parameters: Optional filters, parsing preferences
-
run_leak_detection- Input: Parsed heap dump reference
- Output: Leak suspects, potential memory issues
- Parameters: Analysis depth, report format
-
query_objects- Input: OQL query or natural language description
- Output: Query results in structured format
- Parameters: Query type, result limit
-
analyze_memory_patterns- Input: Specific classes, packages, or patterns
- Output: Memory usage statistics, retention analysis
- Parameters: Analysis scope, comparison baseline
-
generate_report- Input: Analysis results, report template
- Output: HTML/JSON report
- Parameters: Report type, sections to include
Generate PDF or Markdown report is good. Current report includes html/js/css/png, is tough to analyzer with LLM.
@will-zdu @jasonk000 is this still needed? If yes, i can work on it
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
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.
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?
@sachinkg12 still need it
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
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!
Relatedly, I just merged into the main branch a rudimentary new "Export to Markdown for AI" feature: #193
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:
that is from the AssistAI (https://github.com/gradusnikov/eclipse-chatgpt-plugin) plugin. That would be really easy to make if needed....