Map a music library's analysis into a kglite knowledge graph for AI agents
Project description
sonagram
Ask your AI assistant for a playlist from your own music collection — and get a file any music app can play.
sonagram listens to every track you own (tempo, energy, mood, key, how songs feel), organizes what it learns into a fast, searchable map of your library, and hands that map to an AI agent. From there, playlists are a sentence:
"Make me a deep-focus work playlist." "A party mix for Saturday that builds." "Songs like Teardrop, but calmer."
Your music files are never modified, moved, or uploaded — everything happens on your machine.
For AI agents
You are an AI agent and a user asked you to work with their music library — start here:
- Install —
pip install sonagram. Prebuilt wheels cover macOS (Apple Silicon + Intel), Linux x86_64, and Windows x86_64 on Python ≥ 3.9 — no toolchain needed. Only on other platforms does pip fall back to the sdist, which compiles the native core and needs a Rust toolchain (rustup). - Install the skill —
sonagram skill install. This writes thesonagram-playlistskill to~/.claude/skills/(pass--dir <skills_root>for a non-default skills location). - Read the installed
SKILL.mdand follow it now. It covers library detection, scanning, the optional Last.fm walkthrough, and playlist delivery. A skill only auto-loads at the next session start, so act on it immediately in this one.
Use it through your agent (no code)
This is the main way to use sonagram. One-time setup:
- Install it —
pip install sonagram. That's it on Mac, Windows, and regular Linux — prebuilt packages, nothing to compile. (On unusual platforms pip builds from source, which needs the free Rust toolchain — your agent can sort that out.) - Point it at your music —
sonagram sources add ~/Music(repeat for other folders). - Give your agent the skill —
sonagram skill install.
That's it. From now on, just ask:
- "make me a deep-focus work playlist"
- "a party mix for Saturday that builds"
- "songs like Teardrop but calmer"
- "which songs do I have multiple versions of? pair them"
- "what's even in my library?"
The first request analyzes your whole collection (about an hour for ~10,000 songs — your agent will tell you and can let it run in the background). Every request after that takes seconds: sonagram notices what changed, re-reads only that, and keeps the map current — including songs you've added or deleted.
Each playlist is saved with its name, your original request, and the full track
list, so you can always ask for it again later (sonagram playlists). The
.m3u8 files point straight at your own music files and open in any player.
Optional: better picks with Last.fm. A free Last.fm API key adds richer genre info, song popularity, and "fans also like" connections. Your agent can walk you through getting one — just ask.
CLI (scriptable)
pip install sonagram also gives you the standalone sonagram command (the same
shared code path the agent uses, so the two can't drift). Once a source is
registered, commands need no path arguments:
sonagram sources add ~/Music # register a library folder (repeatable)
sonagram status # is everything up to date? (exit 0/1/2)
sonagram scan # analyze new/changed files → local cache
sonagram enrich # optional: fold in Last.fm metadata (needs a key)
sonagram build # merge all sources → the central graph
sonagram playlist --ids h1,h2,h3 \
--name "Deep Focus" --description "a calm work playlist"
sonagram playlists # list stored playlists (newest first)
sonagram config shows where everything lives (defaults under ~/.sonagram/)
and whether a Last.fm key is set up. Explicit-path forms
(sonagram scan ~/Music, sonagram status ~/Music --format json, …) still work
for scripting a single library without touching the config, and
sonagram playlist ... --copy-to <dir> produces a portable folder — the
tracks copied next to the playlist file, ready for a USB stick or another device.
Everything is incremental: a rescan of an unchanged library analyzes nothing and finishes in well under a second.
For building your own agents / integrations
Serve the graph to any MCP-speaking agent, or drive sonagram from Python:
kglite-mcp-server --graph ~/.sonagram/music.kgl # expose the graph over MCP
import sonagram
sonagram.scan("~/Music")
g = sonagram.build("~/Music", out_path="music.kgl") # a live kglite graph
sonagram.export_m3u("music.kgl", "~/Music", "set.m3u8",
cypher="MATCH (t:Track) RETURN t.content_hash ORDER BY t.energy")
Agents get a full manual (AGENT-GUIDE.md: the schema, a query cookbook, and a
curation quality bar) — it ships with the repo and powers the bundled skill.
How it works (the short version)
- sonara does the listening: tempo, key, energy, mood, loudness, structure, and an audio "fingerprint of feel" for every track.
- kglite stores the map: a graph database with search, similarity, and an agent-friendly query interface.
- sonagram is the part in between: it decides what the map contains — every song with all its signals, connected to artists, genres, decades, moods, detected styles, and its 10 most similar tracks — and keeps the map exactly reproducible, byte for byte, no matter how often you rescan.
Full documentation (CLI reference, Python API, the graph's schema, and the
engineering details) lives on Read the Docs — see docs/.
License: MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sonagram-0.2.0.tar.gz.
File metadata
- Download URL: sonagram-0.2.0.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
642c539c42ee17c1d08a621dbecf82e18fce8807e5c98666c7b22dcfa051dfb7
|
|
| MD5 |
4b1f4789d41948b5da739bcaa663374a
|
|
| BLAKE2b-256 |
d428956114b61c236c94e206d5c51fc44bec0aea180f7d13324efbbab20d649f
|
Provenance
The following attestation bundles were made for sonagram-0.2.0.tar.gz:
Publisher:
release.yml on kkollsga/sonagram
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sonagram-0.2.0.tar.gz -
Subject digest:
642c539c42ee17c1d08a621dbecf82e18fce8807e5c98666c7b22dcfa051dfb7 - Sigstore transparency entry: 2190257882
- Sigstore integration time:
-
Permalink:
kkollsga/sonagram@bf03af7ce23728fff3c4489a1d8ef6a91d8296b2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kkollsga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bf03af7ce23728fff3c4489a1d8ef6a91d8296b2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sonagram-0.2.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: sonagram-0.2.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 6.1 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0b64b0697398d33848ce4297e2f5bc9f028d28242ba1c5ebff3dfff2b7c49fb
|
|
| MD5 |
3de60fece3fb142f6c2aaca499f74850
|
|
| BLAKE2b-256 |
8faa6ee2e8c9bf46d950c8b159b4c9235ac5aef7a688ae48c42d9bcab625cfa2
|
Provenance
The following attestation bundles were made for sonagram-0.2.0-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on kkollsga/sonagram
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sonagram-0.2.0-cp39-abi3-win_amd64.whl -
Subject digest:
f0b64b0697398d33848ce4297e2f5bc9f028d28242ba1c5ebff3dfff2b7c49fb - Sigstore transparency entry: 2190259839
- Sigstore integration time:
-
Permalink:
kkollsga/sonagram@bf03af7ce23728fff3c4489a1d8ef6a91d8296b2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kkollsga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bf03af7ce23728fff3c4489a1d8ef6a91d8296b2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sonagram-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: sonagram-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 6.5 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b296c8896560cb0a1a89b8cccbe8a81dd87a420275f2fd1ca05bd696b79b9e4
|
|
| MD5 |
2d4ecddd42129491f2d98362b10a9def
|
|
| BLAKE2b-256 |
1bd1f0aae34357228978175e8e1c9c0c063d3ee18329ab00edc1026ec11839cd
|
Provenance
The following attestation bundles were made for sonagram-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on kkollsga/sonagram
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sonagram-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
0b296c8896560cb0a1a89b8cccbe8a81dd87a420275f2fd1ca05bd696b79b9e4 - Sigstore transparency entry: 2190259382
- Sigstore integration time:
-
Permalink:
kkollsga/sonagram@bf03af7ce23728fff3c4489a1d8ef6a91d8296b2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kkollsga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bf03af7ce23728fff3c4489a1d8ef6a91d8296b2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sonagram-0.2.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: sonagram-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a485696bd4d88dda3715cea15f0c83a0b22de9312d09e8eec3a87b95af15d2e
|
|
| MD5 |
1996230c2f1ef25359fbd5a5694ef001
|
|
| BLAKE2b-256 |
9f173dda0bb730d0a3162e56933037f232e571f983761e7ccd83a5d90cdf8335
|
Provenance
The following attestation bundles were made for sonagram-0.2.0-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on kkollsga/sonagram
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sonagram-0.2.0-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
5a485696bd4d88dda3715cea15f0c83a0b22de9312d09e8eec3a87b95af15d2e - Sigstore transparency entry: 2190258466
- Sigstore integration time:
-
Permalink:
kkollsga/sonagram@bf03af7ce23728fff3c4489a1d8ef6a91d8296b2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kkollsga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bf03af7ce23728fff3c4489a1d8ef6a91d8296b2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sonagram-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: sonagram-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 6.2 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
432418c524ef41ea0480fde113cb420cb4e75f29b73415edf1460e41ccfabf79
|
|
| MD5 |
16436f95d4a7bbc75ed675b88e1c5ecc
|
|
| BLAKE2b-256 |
b61c41bb6646ae6b9ed70f46e8b50c4e31e136e1d61d73f3a857a8f536c39578
|
Provenance
The following attestation bundles were made for sonagram-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on kkollsga/sonagram
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sonagram-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
432418c524ef41ea0480fde113cb420cb4e75f29b73415edf1460e41ccfabf79 - Sigstore transparency entry: 2190259107
- Sigstore integration time:
-
Permalink:
kkollsga/sonagram@bf03af7ce23728fff3c4489a1d8ef6a91d8296b2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kkollsga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bf03af7ce23728fff3c4489a1d8ef6a91d8296b2 -
Trigger Event:
push
-
Statement type: