Skip to main content
Glama

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
PERF_ENVNo`NAME=VALUE` pairs, separated by spaces, set for the recorded program.
KEEP_RUNSNoKeeps only the newest N recordings.
KEEP_TRACENo`1` keeps each recording's `.trace`, for `trace_tables`, `trace_query` or Instruments.
WINEPREFIXNoThe Wine prefix used when the call names none; `~/.wine` otherwise.
METAL_TRACE_LOGNo`off` silences the one-line stderr log per call.
METAL_TRACE_OUTNoWhere recordings go. Give an absolute path: the default, `./perf-runs`, depends on the client's working directory.
METAL_TRACE_READNoMore directories the tools may read, separated by `:`.
METAL_TRACE_WINENoThe Wine directory (holding `bin/wine`) that `perf_record` uses when the call names none.

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

Records GPU use on Apple silicon with Metal System Trace, and native Windows programs with PresentMon. A metal-gpu-trace.json in the repository gives each project its own recordings folder; project_info says which project is active. One recording runs at a time; keep other GPU work off the Mac while it records, and keep the program's window visible: a hidden window stops presenting, and the work after that is left out of the frames (gpu.unpresented; perf_gate fails such a run). Under Wine record 30 s or more: Wine's start-up takes part of the recording. A recording needs about 0.8 GB of free disk per second for Instruments' temporary files (26 GB for 30 s, 50 GB for 60 s); perf_record refuses to start without it. Reading a recording back takes 1 to 14 s per recorded second. Compare only recordings with 100 frames or more, and repeat a run before calling a change real. perf_baseline (or perf_baseline_record, which records them) saves several equal runs as a named reference and perf_check says whether a new run regressed against their range. perf_diagnose says whether a run splits its GPU work into too many short encoders, as translation layers do; perf_compare says how much two runs differ; skip_s on perf_compare and perf_gate leaves out the first seconds (start-up) of each run; perf_history follows FPS, hitches and memory across runs with one name prefix, oldest first; perf_gate says whether a run meets budgets you set (FPS floor, hitch or memory ceiling). trace_tables, trace_count and trace_query read the .trace when KEEP_TRACE=1 kept it, else the run's tables file (.tables.sqlite, written at every recording: perf_runs tables_kept); trace_query's where, columns, order_by, group_by and aggregates filter that file without SQL. When perf_record ends it stops every program of its Wine prefix, or the native program it launched and that program's children. To compare native Metal with a translation layer without a game of one's own: workload_list, workload_fetch, then perf_record with workload and api (and example, for a workload that lists examples), or the compare-layer prompt. The diagnose-stutter prompt tells first-seen shader stutter from steady stutter; bisect-regression finds the commit that slowed a program. perf_sweep records one run per value of dim, example, api or an environment variable and fits GPU ms per frame on the value. trace_query with window_ms sums a long table by time window instead of listing rows. memory_free_pct holds the whole Mac short of memory while recording (keep other work off it) and background throttles the program: repeat a run that uses either. Use tier light to iterate, standard to decide, deep for GPU counters and a kept .trace (METAL_TRACE_MAX_DISK_MB may drop it); compare recordings of the same tier. perf_diagnose and perf_compare return suggested_actions: when it is not empty, run the first one that fits. On a laptop set cooldown_s on perf_baseline_record, perf_ab and perf_sweep so the Mac cools between recordings; a run whose summary has noisy_environment (another process was loading the GPU) is repeated before it is trusted. A recording is refused before it starts when its program, xcrun, the disk or the lock is not ready, or when the screen is locked (METAL_TRACE_ALLOW_LOCKED=1 allows that). When memory spikes or a run stalls, perf_memory_breakdown says which resource types it allocates and drops. A program may write its own numbers to the CSV named in METAL_TRACE_APP_METRICS (first column t_ms, then numeric columns); they come back as the summary's app_metrics, never comparable between programs.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{}
prompts
{}
resources
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
perf_recordA

Records program (an .exe under Wine, or a macOS binary with wine="native") or a test workload for seconds with Metal System Trace and returns its summary: GPU ms per frame, frame intervals, FPS, Metal and resident memory. It then stops every program of that Wine prefix (wineserver -k), or with native the program it launched and its children. tier sets memory and counters together; compare recordings of the same tier.

perf_baseline_recordA

Records the same program count times with perf_record's arguments and saves the runs as the reference name for perf_check, returning the range each number spans. Runs are name-1, name-2, ... Each takes its seconds plus about a minute of read-back.

perf_sweepA

Records the same program once per value of one variable and returns, per value, the median FPS, 1 % low, GPU ms per frame and stutter; with 3 or more numeric values also the line GPU ms follows (fixed ms plus ms per unit) with its r2. With rounds above 1 the values run in reverse every other round, so drift hits all alike. Runs are name--r; each takes its seconds plus about a minute of read-back. metric app_metrics. adds that telemetry column per value, with a fit.

perf_abA

Records the same program with two environments in the order A B B A (rounds times) and says per metric whether B is better, worse or the same as A, with every value behind it. Runs are name-a1, name-b1, ... Each takes its seconds plus about a minute of read-back. fingerprint_paths stops it before the next recording if one of those files changed.

perf_cold_warmB

Records the same program twice and says what the first run suffers that the second does not: shader-compile hitches (first minus second, never below 0), each run's hitch count and compiler time. macOS only. Runs are name-first and name-second.

perf_attachA

Records a program that is already running, by pid or by a name in its command line, for seconds, and returns perf_record's summary; the program keeps running. For games from Steam, CrossOver or any launcher: start the game first.

project_infoA

Says which project is active: its name, baseline and format, the folder its recordings go to and where that folder comes from (the project file, METAL_TRACE_OUT or the default ./perf-runs). Without a project file, project and baseline are null.

perf_runsB

Lists the saved recordings, newest first, with frames, FPS, GPU ms per frame, memory peaks and the translation layer each ran on; project names the project they belong to.

perf_compareA

Compares two saved recordings, a the reference and b the run after a change: headline numbers (FPS, GPU ms, frame pacing, memory), then the GPU work: encoders and command buffers per frame, share of short encoders, idle time, and each encoder label's change, largest first. layer says whether both ran on the same translation layer; measure marks Windows against Metal (use FPS, lows, stutter, jitter); runs under 100 frames are flagged. screen, noisy_environment flag runs that do not compare; suggested_actions says what to call next.

perf_baselineA

Names a reference for perf_check, or lists them. With name and runs (equal runs of one program) it saves their summaries as the reference, replacing a previous one, and returns each number's range and spread_pct: the noise a change must exceed. With name alone it shows that reference; with nothing it lists them.

perf_checkA

Judges a recording against a reference from perf_baseline: regressed when FPS falls under the reference's lowest, or GPU ms per frame rises over its highest, by more than margin_pct, or encoders or command buffers per frame exceed its highest; improved when a number leaves the range the other way and none regressed; same otherwise. Windows against Metal is judged on FPS alone. Returns the reasons and perf_compare's comparison.

perf_export_traceA

Writes a recording's GPU frames as <run>.chrome-trace in the runs directory, for ui.perfetto.dev and chrome://tracing: one slice per GPU frame. Returns the file name and the number of frames.

perf_gateA

Checks a recording against budgets and says pass or fail: FPS and 1% low floors, ceilings for stutter rate, p95 GPU ms per frame, hitches and peak Metal MiB. Give at least one. A number the recording lacks fails its budget (value null), and so does a run that stopped presenting (unpresented). Returns each budget with its limit, value and whether it held.

perf_historyA

Lists the recordings whose name starts with prefix, oldest first, with FPS, 1% low, GPU ms, stutter, hitches and peak Metal MiB, and the change from first to last. A trend is real only above the spread_pct of perf_baseline. Windows and Metal runs in one series are flagged.

perf_diagnoseA

Says whether a saved recording splits its GPU work into too many short encoders (the pattern of translation layers such as DXMT, Mullion or MoltenVK), with the numbers: encoders and command buffers per frame, share of short encoders, labels with the most GPU time, idle time (read with the FPS: vsync idles too). suggested_actions says what to call next.

perf_memory_breakdownA

Breaks down the Metal allocations of a saved recording by type (texture, buffer, heap...): allocated, still live and gone per type. A small live share of a large allocated size is churn, the pattern behind a memory spike or a stall. Also totals, live memory by mode, allocation rate and peak. Needs a Metal recording above tier light.

trace_tablesB

Lists the data tables of a recording: those of its .trace when kept, else those its tables file stored.

trace_countA

Counts the rows of tables of a recording, in all and per process: a table with 0 rows needs another instrument or Xcode, not a bigger page. Reads the .trace when kept, else the tables file.

trace_queryA

Returns one page of rows of one table of a recording as {column: value}, optionally one process's. With window_ms the page holds time windows instead ({start_ms, count}, plus duration_ms when the table has a duration column). Rows come from the .trace when kept, else from the tables file; where, columns, order_by with descending, and group_by with aggregates filter and summarize the tables file (never SQL) and need it.

capture_summaryA

Reads a Metal .gputrace capture without Xcode: command buffers, encoders, draws, debug groups, and the 100 most frequent call ids out of calls_total.

capture_diffB

Compares two .gputrace captures by their confirmed Metal calls: totals per call (a, b, delta) and the 100 debug groups with the largest change. Needs no Xcode.

capture_recordsB

Returns one page of the records of a .gputrace command stream, with their Metal call names when known.

screenshots_checkA

Flags screenshots that show nothing useful: black, uniform (one flat colour) and, with sequence (the folder's PNGs in name order are frames of one run), frozen (3 identical frames in a row) and flicker. ignore_rects leaves out areas that change alone, such as a clock. Returns {"frames", "ok", "findings": [{"file", "problem"}]}.

wine_log_censusA

Counts what a Wine debug log says is missing or wrong, by level, channel and message (numbers, paths and quoted text removed so repeats group), plus HRESULTs and the longest silence between +timestamp lines. No raw line leaves.

gpu_familyA

Apple's published facts for one GPU family ("Apple7") or chip ("M1 Pro"): its chips, what it adds, its limits, the limits shared by all families, footnotes and source URLs.

workload_listA

Lists the test programs workload_fetch can download, such as bgfx's drawstress: what each measures, its size, license and APIs, and whether it is already downloaded.

workload_fetchA

Downloads a test program from this project's GitHub releases once, checks its SHA-256 against the one this package pins, and keeps it in ~/Library/Caches/metal-gpu-trace; later calls reuse it. The programs are built from source by the project's workloads workflow. A workload with downloads (Godot) also fetches each of those zip files from its own publisher, checks its SHA-512 against the one data/workloads.json pins and unzips it into the workload's folder.

presentmon_installA

Windows only: downloads Intel's PresentMon console application (MIT) from its GitHub release, checks its SHA-256 against the one this package pins, and keeps it in %LOCALAPPDATA%\metal-gpu-trace, where perf_record and perf_attach find it; later calls reuse it. It needs administrator rights or the Performance Log Users group to run.

Prompts

Interactive templates invoked by user choice

NameDescription
compare-layerRecords a test program in native Metal and under a translation layer, then diagnoses and compares both runs
diagnose-stutterRecords a program twice to tell first-seen shader stutter from steady stutter, then diagnoses it
bisect-regressionFinds the commit that made a workload slower: git bisect, with a recording and a check at each step. The recordings use a workload, so a commit must change what the workload runs (its arguments or environment)

Resources

Contextual data attached and managed by the client

NameDescription
Apple GPU familiesApple silicon GPU families Apple7 to Apple10: chips, first family with each feature, and limits that differ. Facts restated from Apple's public documents, not Apple's text. Check a device with MTLDevice.supportsFamily; families nest, so an Apple9 GPU also supports Apple7 and Apple8.
Apple7 GPU familyApple's published facts for Apple7
Apple8 GPU familyApple's published facts for Apple8
Apple9 GPU familyApple's published facts for Apple9
Apple10 GPU familyApple's published facts for Apple10

TDQS

A3.6/5.0

Scored across 28 tools

Disambiguation3/5

Most tools cover distinct stages (record, compare, gate, trace query, capture analysis), but the set has genuine clusters of near-siblings: perf_record / perf_attach / perf_baseline_record / perf_sweep / perf_ab / perf_cold_warm all record, and perf_check / perf_gate / perf_compare all judge a run against something. perf_runs vs perf_history and perf_baseline vs perf_baseline_record are easy to confuse at a glance, though the long descriptions do spell out the distinctions.

Naming Consistency4/5

Everything is snake_case and grouped by domain prefix (perf_, trace_, capture_, workload_), which gives an agent a reliable mental map. Within perf_ most names are verb_noun (perf_record, perf_compare, perf_gate) with a few noun-only outliers (perf_runs, perf_history, perf_ab, perf_cold_warm), and singletons like project_info and gpu_family sit outside any prefix.

Tool Count3/5

28 tools is above the comfortable band for a single MCP server and pushes the agent's selection burden. Nearly every tool is substantive rather than filler, but a few (gpu_family, screenshots_check, wine_log_census, presentmon_install) are peripheral reference/setup helpers that could be folded into docs or a smaller surface.

Completeness4/5

The measurement lifecycle is unusually well covered: capture, attach, sweep, A/B, baseline, compare, gate, diagnose, memory breakdown, trace tables/query/export, plus workload and environment setup. The main gaps are lifecycle hygiene — no delete/cleanup for saved recordings, workloads, or cached downloads, and no tool to enumerate .gputrace captures, which every capture_* tool requires as input.

Maintenance

ActivityActive
ResponsivenessNo recent community issues