PlayByKey Music Theory

Chords, scales, progressions, transposition, and MIDI tools for music theory AI agents.

AI & MLTypeScriptv1.6.0

Developer Tools

Packages for PlayByKey - see the table below for what's here.


Install

npm install @playbykey/theory
pnpm add @playbykey/theory
yarn add @playbykey/theory
bun add @playbykey/theory

Quickstart and API examples: packages/theory/README.md


Why @playbykey/theory

  • Foundation music theory engine: music theory as code. Modes, keys, intervals, and scale relationships resolved deterministically; one source of truth every app, notation tool, or AI agent can build on.
  • Zero dependencies: no transitive baggage; safe for agents, edge runtimes, and tight bundles
  • Strictly typed: every function's types exported alongside it, no any
  • Agent-ready: copy-paste LLM context prompt and interactive docs
  • Sharps-only notation: one canonical spelling per note (C#, not Db) keeps the Note type safe and unambiguous. Flats are fully supported for both input (parseNote/parseNoteToken accept Db, Eb, Gb, Ab, Bb) and output (getFlats/getEnharmonicLabels), without extending Note itself.

Packages

PackageDescriptionLinks
@playbykey/theoryZero-dependency music theory engine - scales, modes, intervals, chords, progressions, key relationshipsnpm · docs · changelog
@playbykey/theory-mcpMCP server that exposes the theory engine as AI-callable toolsnpm · README
theory-docsStarlight documentation site (private workspace package)live site · README

License

MIT for the repository tooling and @playbykey/theory. See LICENSE. Individual packages may declare their own license in their package.json.

Installation

Source-derived launch command. Check the maintainer’s required arguments and credentials before running:

bash
npx -y @playbykey/theory-mcp

Set up in your AI client

Merge this template into ~/Library/Application Support/Claude/claude_desktop_config.json. Keep existing servers. Add any arguments, credentials, and permissions required by the maintainer; this template has not been install-tested.

json
{
  "mcpServers": {
    "com-playbykey-theory-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@playbykey/theory-mcp"
      ]
    }
  }
}

Restart Claude Desktop completely for changes to take effect. Confirm the server appears connected in the client’s tool list, then try a read-only example from its documentation.

Claude Desktop setup reference

Package

@playbykey/theory-mcpnpm

Compatible MCP Clients

PlayByKey Music Theory works with any MCP-compatible client. Copy the config snippet from the Configuration section above and add it to the file shown for your client, then restart the application.

  • Claude Desktop~/Library/Application Support/Claude/claude_desktop_config.jsonRestart Claude Desktop completely for changes to take effect.
  • Cursor~/.cursor/mcp.jsonRestart Cursor for changes to take effect.
  • VS Code.vscode/mcp.jsonReload VS Code window for changes to take effect.
  • Windsurf~/.codeium/windsurf/mcp_config.jsonRestart Windsurf for changes to take effect.
  • Claude Code.mcp.jsonSave at the project root, then start Claude Code in that project and review the MCP server approval prompt. Keep real credentials out of shared files.

Learn More