A Model Context Protocol (MCP) server for profiling x86 CPU applications using AMD uProf. This package enables LLMs to analyze CPU performance hotspots through the AMD uProf profiler.
Tool for profiling x86 CPU executables to identify performance hotspots using AMD uProf.
Capabilities:
- Profile CPU applications for hotspot analysis
- Identify top functions consuming CPU time
- Generate detailed profiling reports
- Support for custom executable arguments
You can install the package directly using uv or pip.
# Using uv (recommended)
uv pip install .
# Using pip
pip install .uProf MCP needs to know where AMD uProf is installed. There are three ways to set this, in order of precedence:
-
Environment variable
INTELLIKIT_UPROF_CLI:export INTELLIKIT_UPROF_CLI=/opt/AMDuProf_5.3-521/bin/AMDuProfCLI -
Constructor argument (Python API only):
profiler = UProfProfiler(uprof="/opt/AMDuProf_5.3-521/bin/AMDuProfCLI")
-
Default path:
/opt/AMDuProf_5.1-701/bin/AMDuProfCLI
To use this server with an MCP client, add the following to your configuration file:
{
"mcpServers": {
"uprof-profiler-mcp": {
"command": "uv",
"args": ["run", "--directory", "/path/to/uprof_mcp", "uprof-profiler-mcp"],
"env": {
"INTELLIKIT_UPROF_CLI": "/opt/AMDuProf_5.3-521/bin/AMDuProfCLI"
}
}
}
}Note: Adjust /path/to/uprof_mcp to the actual path where you have cloned or installed the package, and update the uProf path to match your installation.
You can use the profiler directly without MCP:
import tempfile
from 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())See examples/uprof_profiler.py for a complete example using LangChain agents:
# 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 --classic- Python >= 3.10
- AMD uProf installed
- x86 CPU architecture
This project uses uv for dependency management.
-
Sync dependencies:
uv sync --dev
-
Run the server locally (for testing):
uv run uprof-profiler-mcp
-
Run tests:
pytest
from uprof_mcp.uprof_profiler import UProfProfiler
profiler = UProfProfiler(logger=None, uprof=None)Constructor parameters:
logger(logging.Logger | None): Logger instance. If None, a default logger is created.uprof(str | PathLike | None): Path to the uProf CLI executable. If None, uses theINTELLIKIT_UPROF_CLIenvironment variable, or falls back to the default path.
Methods:
find_hotspots(output_dir, executable, executable_args)→UProfProfilerResult- Profiles the executable and returns hotspot analysis
- Parameters:
output_dir(str | Path): Directory to store resultsexecutable(str | Path): Path to executableexecutable_args(list[str] | None): Arguments for the executable
- Returns:
UProfProfilerResultwithreport_pathattribute