Agent guide¶
sonagram is built for AI agents: the graph is served over MCP by
kglite-mcp-server, and an agent curates playlists by querying it. The repo
ships the full agent-facing manual as AGENT-GUIDE.md at its root, plus an
invocable Claude Code skill at skills/sonagram-playlist/. This page is the
orientation; the manual is the reference.
The two tools¶
An agent works the graph through two MCP tools:
graph_overview— the node/edge inventory with live counts and sample ids. Call it first on an unfamiliar graph to see the library’s shape.cypher_query— run one openCypher query, get up to ~15 rows inline. It takes only aquerystring: there is no parameter binding over MCP, so inline every literal ({title:'Marry You'},[0.1, ...]). A$paramreference errors.
The graph schema is the node/edge/property reference those queries run against.
The four query archetypes¶
AGENT-GUIDE.md gives a copy-paste-runnable cookbook for each:
Filter + order — the graph’s bread and butter: every filterable signal is a flat scalar on
Track, soWHERE t.bpm >= 110 AND t.vocalness < 0.5 … ORDER BY t.energyneeds no joins.Discover / group — aggregate over the dimension nodes (
Genre,Decade,TempoBand) or read the detectedStylecommunities’ profiles to learn what’s in an unfamiliar library.Similarity — the
SIMILAR_TOhop (“like this, but calmer”) composes with anyWHERE; chain-[:SIMILAR_TO*1..2]->to reach beyond the top-10 horizon.Sequence — walk
CAMELOT_ADJACENTfor a harmonic step plus an energy ramp to build a DJ set.
Materializing the answer¶
A query answers which tracks, in what order; you turn that into a playable
.m3u8 outside the graph via sonagram playlist or
export_m3u, passing the content_hash values a
query returns. Order is preserved verbatim, so for any hand-built arc (a ramp, a
breather, a harmonic chain) the --ids / track_ids= path — export candidates,
order them client-side, feed the hash list — is the primary route, not one big
ORDER BY.
The quality bar¶
AGENT-GUIDE.md grades every playlist against four requirements before export —
treat them as requirements, not suggestions:
Duration-check every pick. Casual/mood playlists default to radio-length cuts (
duration_sec <= 330) unless the brief wants epics — alwaysRETURN t.duration_secin the candidate query.Audit
era_sourcefirst, then fall back to your own knowledge. Whenera_source = 'original_year'the decade is era-true; when'file_year'theyearis the file tag (often a reissue/compilation date), so validate era claims yourself.Critical slots need style-world cohesion, not just scalar fit. Finales, the seed side of a “like this” set, and genre-set peaks must belong to the brief’s musical world — scalars will happily pass a rap track into a disco set.
Sanity-read the final tracklist as a human would — artist/title, in order. If a pick needs a defensive explanation, swap it.
The manual also carries extensive pitfalls and field notes from live agent
validation (e.g. gate bpm on bpm_confidence; mood_aggressive inverts on
extreme material; SIMILAR_TO is directed; compilation folder names often beat
scalars for vibe grouping). Read
AGENT-GUIDE.md
in the repo before curating against a real library.