uProf MCP
A Model Context Protocol (MCP) server for profiling x86 CPU applications using AMD uProf. Enables LLMs to analyze CPU performance hotspots through the AMD uProf profiler.
Features
- Profile CPU applications for hotspot analysis
- Identify top functions consuming CPU time
- Generate detailed profiling reports
- Support for custom executable arguments
Installation
# Using uv (recommended)uv pip install .
# Using pippip install .Configuration
Add the following to your MCP client configuration:
{ "mcpServers": { "uprof-profiler-mcp": { "command": "uv", "args": ["run", "--directory", "/path/to/uprof_mcp", "uprof-profiler-mcp"] } }}Adjust /path/to/uprof_mcp to where you have cloned or installed the package.
Python API (non-agentic)
Use the profiler directly without MCP:
import tempfilefrom uprof_mcp.uprof_profiler import UProfProfiler
profiler = UProfProfiler()
with tempfile.TemporaryDirectory() as tmpdir: result = profiler.find_hotspots( output_dir=tmpdir, executable="./my_app", executable_args=["arg1", "arg2"], )
with result.report_path.open() as report: print(report.read())LangChain example
# Agentic mode (with LLM)python examples/uprof_profiler.py --executable ./my_app --args arg1 arg2
# Non-agentic mode (direct profiling)python examples/uprof_profiler.py --executable ./my_app --args arg1 arg2 --classicAPI reference
UProfProfiler class
from uprof_mcp.uprof_profiler import UProfProfiler
profiler = UProfProfiler(logger=None)Methods:
find_hotspots(output_dir, executable, executable_args)→UProfProfilerResultoutput_dir(str | Path) — directory to store resultsexecutable(str | Path) — path to executableexecutable_args(list[str] | None) — arguments for the executable- Returns
UProfProfilerResultwithreport_pathattribute
Requirements
- Python >= 3.10
- AMD uProf installed
- x86 CPU architecture
Development
# Sync dependenciesuv sync --dev
# Run the server locallyuv run uprof-profiler-mcp
# Run testspytest