PlayByKey Theory Engine

PlayByKey Theory Engine

TypeScript music theory engine and MCP server for scales, modes, and intervals

Free
3.3 (7 reviews)

Gallery

About PlayByKey Theory Engine

PlayByKey Theory Engine is a TypeScript library that computes music theory in code. Published on npm as @playbykey/theory, it gives developers a typed API for scales, modes, keys, and intervals, so an application can work out these relationships programmatically instead of hard-coding note tables and hoping they are right. It is the theory core that powers PlayByKey, a free interactive music education platform built by DigitalBrew LLC.

The problem it addresses shows up in any project that touches music. Working out which notes belong to a given scale, resolving a mode against its parent key, finding the relative minor, ordering keys around the Circle of Fifths, or measuring the interval between two notes is fiddly, easy to get subtly wrong, and tedious to reimplement in every codebase. The engine packages that logic once, tested and typed, so the rest of an application can simply ask for an answer and trust it instead of maintaining its own note math. It also keeps the same rules in one place, so a fix to how a mode resolves benefits every screen or feature that leans on the engine rather than being patched in five separate spots.

On capability it covers a lot of ground for keys and modes. It resolves the seven diatonic modes, Ionian through Locrian, identifies the parent scale behind a mode, navigates between relative major and minor, orders keys around the Circle of Fifths, and calculates modal roots. That covers most of the relationships a learning tool or a composition helper needs to reason about when it moves between keys or explains why a particular mode sounds the way it does, which is exactly the kind of logic that is easy to fumble by hand. It can also chain those operations, so a tool can go from a key to its modes to the notes of a chosen mode without ever leaving the library.

Scales and intervals are handled with the same care. For scales it supports standard shapes such as blues, harmonic minor, and pentatonic, along with degree calculation, scale membership testing, and derived scale computation. Intervals come with a catalog of semitone lookups and endpoint resolution between note pairs, and the library is careful to keep a clear distinction between scale motion measured in half and whole steps and root-relative intervals, which are two things beginners often conflate. There are also smaller utilities for semitone distance and note display mapping. That mix of coverage and precision is what separates a real theory engine from a lookup table, since it can answer questions about relationships the author never enumerated ahead of time.

A handful of design choices make it easy to drop in. It ships with zero external dependencies and is written in strict TypeScript with fully typed exports, so types like Note and ModeName can be imported directly into your own code. Note parsing is case-insensitive, so it does not matter how a user capitalizes their input, and it uses a sharps-only internal notation, writing C sharp rather than D flat, so the internal model stays consistent and predictable no matter how a note was entered. For a library other developers build on, that kind of predictability matters more than clever shortcuts.

The part that stands out in 2026 is the companion MCP server, published separately as @playbykey/theory-mcp. It exposes the same theory functions as native tools to an AI assistant like Claude, so a model can compute scales, chords, and intervals directly instead of guessing at them or asking the user to paste in code. For anyone building music tooling around an assistant, that turns a plain library into something the AI can call on its own, which is a real upgrade over hoping a language model gets the theory right from memory. It also lets a chat-based practice tool hand the exact computation to the engine and keep the model focused on explanation, which tends to produce answers a music teacher would actually sign off on.

Access is straightforward. Both packages install from npm, and the docs also show pnpm, yarn, and bun as alternatives, so the engine slots into most JavaScript and TypeScript toolchains without fuss. The docs site is the main reference for the API surface, and the intended users are music education tools, composition software, interactive learning platforms, and AI assistants that need real theory computation rather than a rough approximation. Because it already powers a shipping education product, the logic has been exercised against actual lessons rather than living only in tests.

Key Features

  • Zero-dependency TypeScript library
  • Scale and mode computation
  • Diatonic mode resolution
  • Interval and semitone calculations
  • Circle of Fifths ordering
  • Companion MCP server for AI assistants

Pros & Cons

What we like

  • No external dependencies, fully typed
  • Ships an MCP server for AI assistants
  • Covers scales, modes, keys, and intervals
  • Free to install from npm

Room for improvement

  • Narrow focus on theory math, no audio playback
  • Small and young, limited community
  • License is not spelled out in the docs
  • Assumes some music theory knowledge

Frequently Asked Questions

What is PlayByKey Theory Engine?
It is a dependency-free TypeScript library, published on npm as @playbykey/theory, that computes music theory such as scales, modes, keys, and intervals. It gives developers a typed API so an app can resolve these relationships in code instead of hard-coding them.
How is it installed?
Both packages install from npm, and the docs also show pnpm, yarn, and bun as options. The core engine is @playbykey/theory and the MCP server is @playbykey/theory-mcp, so it fits most JavaScript and TypeScript toolchains.
What is the MCP server for?
The companion @playbykey/theory-mcp package exposes the engine's theory functions as native tools to an AI assistant like Claude. That lets a model compute scales, chords, and intervals directly rather than guessing at them or asking a user to paste in code.
Is it free?
Both packages are published publicly on npm and free to install. It comes from DigitalBrew LLC and powers PlayByKey, a free interactive music education platform, though the docs do not spell out a specific license.

Best For

Building music education toolsPowering composition software with theory logicLetting Claude compute scales and chordsAdding key and interval math to an app

Featured in

Alternatives to PlayByKey Theory Engine

View all

Reviews (7)

H
Hiroshi Zhang

Solid but not perfect

Started using PlayByKey Theory Engine casually, now it is pinned in my dock. Got real value out of companion mcp server for ai assistants. Found it works best for adding key and interval math to an app. My only gripe is assumes some music theory knowledge. Recommending it to people in a similar spot.

5/10/2026 12 found this helpful
A
Anders Ramos Verified

Worth a look

Have been running PlayByKey Theory Engine for a while, here is where I land. The interface stays out of my way, which I appreciate. It fits well for adding key and interval math to an app.

5/1/2026 11 found this helpful
E
Emerson Costa Verified

It just works

Three months of PlayByKey Theory Engine later, here is what holds up. What stands out is how it handles diatonic mode resolution. It slotted into my routine without much fuss. Recommending it to people in a similar spot.

4/14/2026 10 found this helpful
F
Freya Zhang Verified

Does the job, a few gripes

Came to PlayByKey Theory Engine after getting frustrated with what I had before. The defaults are sensible, so I was not fighting settings on day one. It would be a five if not for license is not spelled out in the docs. Worth it for what I get out of it.

3/21/2026 10 found this helpful
L
Lei Pereira Verified

Solid but not perfect

PlayByKey Theory Engine solves a real problem for me without making a fuss about it. The scale and mode computation is more useful than I expected. Performance has been steady even when I lean on it hard. One thing that bugs me is small and young, limited community. Worth it for what I get out of it.

3/24/2026 2 found this helpful
N
Nneka Kang Verified

Good, with a few caveats

Hadn't planned on switching, but PlayByKey Theory Engine was hard to ignore. The companion mcp server for ai assistants is more useful than I expected. The defaults are sensible, so I was not fighting settings on day one. The catch is assumes some music theory knowledge. Easy yes for anyone weighing the same trade offs.

6/24/2026 1 found this helpful
T
Tunde Okafor Verified

Solid but not perfect

Have been running PlayByKey Theory Engine for a while, here is where I land. What stands out is how it handles companion mcp server for ai assistants. Found it works best for adding key and interval math to an app. It would be a five if not for assumes some music theory knowledge. No regrets so far.

4/28/2026