An MCP (Model Context Protocol) server for analyzing MemPro memory profiling data and detecting memory errors using AI-powered analysis.
This server provides intelligent analysis of MemPro JSON exports, enabling AI assistants to quickly identify memory leaks, fragmentation issues, and large allocations in C++ applications.
-
analyze_leaks - Analyzes memory leaks and returns prioritized issues
- Input:
json_path(optional, defaults to test_memory_analysis.json) - Output: JSON array of memory leak issues with severity, descriptions, and suggestions
- Input:
-
get_summary - Provides comprehensive memory usage summary
- Input:
json_path(optional) - Output: Text summary with key metrics and critical findings
- Input:
-
get_top_leakers - Returns top N functions causing memory leaks
- Input:
json_path(optional),count(default: 10) - Output: Formatted list of top leakers with details
- Input:
-
analyze_fragmentation - Analyzes memory fragmentation
- Input:
json_path(optional) - Output: Fragmentation issues and recommendations
- Input:
-
find_large_allocations - Identifies unusually large allocations
- Input:
json_path(optional) - Output: List of large allocation issues
- Input:
-
get_all_issues - Comprehensive analysis of all issues
- Input:
json_path(optional) - Output: Complete analysis including summary, leaks, fragmentation, and large allocations
- Input:
- mempro://stats - Quick access to memory statistics in JSON format
-
Ensure Go 1.22+ is installed
-
Navigate to the MemProMCP directory:
cd "C:\Program Files\PureDevSoftware\MemPro\MemProReader\MemProMCP"
-
Download dependencies:
go mod tidy
-
Build the server:
go build -o mempro-mcp.exe
The server uses stdio transport for communication with MCP clients:
./mempro-mcp.exeAdd to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"mempro": {
"command": "C:\\Program Files\\PureDevSoftware\\MemPro\\MemProReader\\MemProMCP\\mempro-mcp.exe",
"env": {
"MEMPRO_JSON_PATH": "C:\\Program Files\\PureDevSoftware\\MemPro\\MemProReader\\test_memory_analysis.json"
}
}
}
}MEMPRO_JSON_PATH- Default path to MemPro JSON file (optional)
The analyzer identifies memory leaks based on:
- Leak size and count
- Leak score from MemPro
- Suspect flags
- Function context and call stacks
Severity levels:
- Critical: Suspect leaks > 100KB
- High: Suspect leaks or leaks > 50KB
- Medium: Leaks > 10KB or > 100 allocations
- Low: Other leaks
The analyzer provides context-aware suggestions:
- Unknown functions: Enable debug symbols
- STL containers: Check destructors and circular references
- Main function: Review allocation ownership, use RAII
- General: Use smart pointers (std::unique_ptr, std::shared_ptr)
Detects memory fragmentation issues:
- High (>80%): Severe fragmentation requiring immediate attention
- Medium (>50%): Moderate fragmentation to monitor
Recommendations include object pooling, memory arenas, and allocation pattern optimization.
Identifies allocations that may benefit from optimization:
- Average size > 10KB
- Maximum size > 50KB (Medium) or > 100KB (High)
Suggests chunking, streaming, or incremental allocation strategies.
When using this server with an AI assistant:
- "What are the most critical memory leaks in the application?"
- "Analyze memory fragmentation and provide recommendations"
- "Show me the top 5 functions causing memory leaks"
- "Give me a comprehensive analysis of all memory issues"
- "What large allocations should I optimize?"
The server parses MemPro JSON with the following key sections:
- CallTrees: Hierarchical allocation call trees
- Functions: Function-level allocation statistics
- Leaks: Detected memory leaks with suspect flags
- PageViews: Memory page usage information
- Types: Allocation type statistics
MemProMCP/
├── main.go # MCP server setup and tool handlers
├── analyzer.go # Memory analysis logic
├── types.go # Data structures for MemPro JSON
├── go.mod # Go module definition
└── README.md # This file
- Define tool in
setupTools()in main.go - Create handler function following the pattern
- Implement analysis logic in analyzer.go
- Update README with tool documentation
This tool is designed to work with PureDevSoftware's MemPro memory profiler.
For issues or questions about MemPro, visit: https://www.puredevsoftware.com/mempro/
For MCP protocol information: https://modelcontextprotocol.io/