gpu_metrics
Retrieve comprehensive GPU metrics including clocks, voltages, PCIe details, firmware, activity, throttle status, and energy counters using rocm-smi's native JSON output.
Instructions
Full rocm-smi -a --json output for every GPU (clocks, voltages, PCIe link width/speed, firmware versions, per-engine activity, throttle status, energy counters). Use when gpu_status is not enough. The shape is rocm-smi’s native JSON, unmodified.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.js:154-170 (handler)The main handler function for the gpu_metrics tool. It runs 'rocm-smi -a --json', parses the output, and returns the raw JSON data along with a timestamp.
async function gpuMetrics() { const missing = requireRocmSmi(); if (missing) return errorResult(missing); const r = await run(BIN.rocmSmi, ['-a', '--json']); if (r.code !== 0 && !r.stdout) { return errorResult(`rocm-smi failed (code ${r.code}): ${r.stderr || 'no output'}`); } const data = parseRocmJson(r.stdout); if (!data) return errorResult(`rocm-smi returned no parseable JSON. stderr: ${r.stderr || '<empty>'}`); return textResult({ timestamp: new Date().toISOString(), source: 'rocm-smi -a --json', data, }); } - server.js:362-367 (schema)Tool schema definition for gpu_metrics in the TOOLS array: name, description, annotations, and inputSchema (no parameters required, read-only hint).
{ name: 'gpu_metrics', description: 'Full rocm-smi -a --json output for every GPU (clocks, voltages, PCIe link width/speed, firmware versions, per-engine activity, throttle status, energy counters). Use when gpu_status is not enough. The shape is rocm-smi’s native JSON, unmodified.', annotations: { title: 'Full GPU metrics', readOnlyHint: true, destructiveHint: false, openWorldHint: false }, inputSchema: { type: 'object', properties: {}, additionalProperties: false }, }, - server.js:395-401 (registration)Handler registration: maps the 'gpu_metrics' tool name to the gpuMetrics function in the HANDLERS object.
const HANDLERS = { gpu_status: gpuStatus, gpu_metrics: gpuMetrics, gpu_processes: gpuProcesses, gpu_watch: gpuWatch, rocm_info: rocmInfo, }; - server.js:47-52 (helper)Helper function requireRocmSmi() used by gpuMetrics to verify rocm-smi is installed before proceeding.
function requireRocmSmi() { if (!BIN.rocmSmi) { return 'rocm-smi is not installed. Install with: sudo apt install rocm-smi (or a full ROCm stack). See https://rocm.docs.amd.com/ for installation options.'; } return null; } - server.js:39-44 (helper)Helper functions textResult() and errorResult() used by gpuMetrics to format JSON-RPC responses.
function textResult(obj) { return { content: [{ type: 'text', text: JSON.stringify(obj, null, 2) }] }; } function errorResult(message) { return { content: [{ type: 'text', text: message }], isError: true }; }