deoptkit
v0.3.0A V8 deoptimization toolkit for AI agents and dev workflows: MCP server, findings engine, benchmark harness, and fix-verify comparison for inline caches…
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
list_sessions Loaded sessions
List the V8 log sessions currently loaded in this server. Each session represents one parsed v8.log; use its id with the analysis tools.
load_log Load V8 log
Parse a V8 log file (v8.log, produced by `node --prof --log-deopt --log-ic --log-maps ...`) into a session for analysis. Returns the new session id, summary counts, and parser warnings.
| Parameter | Type | Description |
|---|---|---|
path * | string | Absolute path to the v8.log file to load |
workspaceRoot | string | Directory that reported paths are relative to (default: the server's working directory) |
load_manifest Load bench manifest
Load every V8 log listed in a deoptkit manifest (written by the deoptkit/vitest bench preset to <outDir>/manifest.json) as sessions. Bench cases wrapped with benchObserved expose <name>_start/<name>_end markers for the fromMark/toMark window filters. The response's sessionIds can be passed straight to get_findings.
| Parameter | Type | Description |
|---|---|---|
path * | string | Path to manifest.json, e.g. .deopt/manifest.json |
workspaceRoot | string | Directory that reported paths are relative to (default: the server's working directory) |
profile_run Profile a command
Run a command under V8 optimization logging and load the result as a session — no flag knowledge needed. The executable must be a V8 host that accepts V8 flags (node, or a path to one); run npm-script workloads as `node path/to/script.js`. Then call get_findings; pass compareTo after a fix to get the before/after comparison in the same call.
| Parameter | Type | Description |
|---|---|---|
command * | array | Executable and arguments, e.g. ["node", "bench/index.js", "--iterations", "100"] |
categories | array | Log categories to record (default: all of ics, deopts, maps, profile, sources) |
compareTo | string | A base session to compare the new session against; the response then includes `comparison`, the same payload compare_sessions returns |
cwd | string | Working directory for the command |
env | object | Extra environment variables (merged over the server's environment) |
timeoutMs | integer | Kill the process after this long (default 60000) |
get_findings Ranked findings
The primary analysis entry point: everything wrong in a session, ranked worst-first. Each finding has a severity (1-100), source location, and evidence; the explanation and suggested fix for each kind present are returned once under `kinds`. Start here, fix the top finding, re-profile, and compare. Pass sessionIds instead of sessionId to rank the findings of several sessions (every worker log of a vitest bench run) together; identical findings merge and list the sessions they appeared in.
| Parameter | Type | Description |
|---|---|---|
file | string | Only include items whose file path contains this substring |
fromMark | string | Window start: the first occurrence of this harness marker label (from deoptkit/harness mark/observed) |
kinds | array | Only include these finding kinds |
limit | integer | Maximum items to return (default 20) |
offset | integer | Items to skip, for paging |
sessionId | string | Session id returned by load_log (see list_sessions) |
sessionIds | array | Several session ids (for example from load_manifest); findings are merged by identity across them |
severityMin | integer | Only include findings at or above this severity |
toMark | string | Window end: the last occurrence of this harness marker label |
list_ics Inline cache sites
List inline cache sites, worst state first. Filter by state (megamorphic/polymorphic/...), IC type, or file substring. Transitions are omitted unless includeTransitions is set, and then bounded by maxTransitions.
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session id returned by load_log (see list_sessions) |
file | string | Only include items whose file path contains this substring |
fromMark | string | Window start: the first occurrence of this harness marker label (from deoptkit/harness mark/observed) |
includeTransitions | boolean | Include each site's recent state transitions (see maxTransitions) |
limit | integer | Maximum items to return (default 20) |
maxTransitions | integer | With includeTransitions: at most this many of the most recent transitions per site (default 20) |
offset | integer | Items to skip, for paging |
states | array | Only sites whose worst state is one of these |
toMark | string | Window end: the last occurrence of this harness marker label |
types | array | Only these IC kinds |
list_deopts Deopt sites
List deoptimization sites, most frequent first, with V8's bailout reasons. Eager deopts mean optimized code hit an unexpected type; repeated eager deopts at one site are a deopt loop.
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session id returned by load_log (see list_sessions) |
file | string | Only include items whose file path contains this substring |
fromMark | string | Window start: the first occurrence of this harness marker label (from deoptkit/harness mark/observed) |
kinds | array | Only these deopt kinds |
limit | integer | Maximum items to return (default 20) |
minCount | integer | Only sites with at least this many deopts |
offset | integer | Items to skip, for paging |
toMark | string | Window end: the last occurrence of this harness marker label |
list_functions CPU profile (flat)
List functions by CPU profile weight (a flat profile). selfTicks is time at the top of the stack; totalTicks counts any presence on the stack. Windows samples at ~15ms granularity.
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session id returned by load_log (see list_sessions) |
file | string | Only include items whose file path contains this substring |
fromMark | string | Window start: the first occurrence of this harness marker label (from deoptkit/harness mark/observed) |
limit | integer | Maximum items to return (default 20) |
offset | integer | Items to skip, for paging |
sortBy | string | Sort key (default selfTicks) |
toMark | string | Window end: the last occurrence of this harness marker label |
get_profile CPU call tree
Call tree from the profiler samples: top-down (who calls what, from the roots) or bottom-up (hot functions and their callers). Defaults to the user's own code with builtins and dependencies folded into their nearest user caller, whose `folded` list names the folded functions that were actually running; pruned by maxDepth, limit (children per node), and minPercent (share of attributed ticks). Window with fromMark/toMark like get_findings.
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session id returned by load_log (see list_sessions) |
fromMark | string | Window start: the first occurrence of this harness marker label (from deoptkit/harness mark/observed) |
justMyCode | boolean | Only show the user's own code; time in builtins and node_modules counts toward the nearest user caller (default true) |
limit | integer | Maximum children kept per node, heaviest first (default 10) |
maxDepth | integer | Maximum tree depth (default 8) |
minPercent | number | Drop nodes below this percentage of the attributed ticks (default 1) |
toMark | string | Window end: the last occurrence of this harness marker label |
view | string | top-down roots the tree at outermost callers; bottom-up roots it at the functions that ran, with their callers beneath (default top-down) |
get_map Hidden class details
Inspect one V8 object map (hidden class) by address: its parsed shape (properties in order, representation, flags), the transition chain that produced it, its sibling shapes from the same parent, and the IC sites that observed it. Map addresses appear in list_ics transitions (includeTransitions) and get_findings evidence (exampleMaps).
| Parameter | Type | Description |
|---|---|---|
address * | string | Map address, e.g. 0x03a2c272a931 |
sessionId * | string | Session id returned by load_log (see list_sessions) |
get_function Function deep dive
Deep-dive one function: an annotated source snippet (from the sources embedded in the log) plus every IC site, deopt, and profile tick attributed to it. Identify the function by file substring plus functionName, or file plus a line number.
| Parameter | Type | Description |
|---|---|---|
file * | string | Substring of the script path/URL, e.g. src/hot.js |
sessionId * | string | Session id returned by load_log (see list_sessions) |
contextLines | integer | Lines of source to include (default 30) |
functionName | string | Function to anchor the snippet on |
limit | integer | Maximum items to return (default 20) |
line | integer | 1-based line to anchor on when functionName is not given |
compare_sessions Compare before/after
Diff two sessions to verify a fix: findings resolved by the change, regressions it introduced, findings persisting (with severity movement), and per-function CPU deltas. Each finding kind's explanation and suggested fix are returned once under `kinds`. Profile before the change, apply it, profile again, then compare base vs head.
| Parameter | Type | Description |
|---|---|---|
baseSessionId * | string | The 'before' session |
headSessionId * | string | The 'after' session |