API & MCP

Everything a person can do on Tonegrid Pattern Builder, a program or AI agent can do with the same inputs and get the identical result.

HTTP API

Tonegrid Pattern Builder

Write a melody and a beat as lines of x and dots, one line per note name or drum. The builder checks every note against the chosen key and scale, returns an editable Tonegrid project with a link that opens it in the app, and a Standard MIDI File with the melody and General MIDI drums.

Inputs of Tonegrid Pattern Builder
FieldTypeDefaultDescription
nametext"API melody"Project name
patterntextarea"# melody (note names) and drums: x = hit, . = rest\nG4 .... ..x. .... ..x.\nPattern lines. One line per note (C4, D#4, Eb4) or drum (kick, snare, closed-hat, open-hat, clap, tom, rim, shaker), then x for a hit and a dot for a rest. Spaces and | are ignored; lines starting with # are comments. All melody lines need the same length, and so do all drum lines (1–32 steps).
rootnumber48Key (root MIDI note). 48 is C3, 57 is A3, 60 is C4. The root is the lowest melody row.
scaleselect (pentatonic, minorPentatonic, major, minor, dorian, mixolydian, harmonicMinor, blues, chromatic)"pentatonic"Musical scale
rowsnumber16Melody rows. How many scale notes the melody grid has, counted up from the root.
voiceselect (bell, sine, triangle, pluck, pad)"bell"Melody sound
bpmnumber100Tempo (BPM)
swingnumber0Swing (%). Delays every second step by this share of a step.
repeatsnumber2Repeats in the MIDI file

Example request

Pentatonic melody with a simple beat

curl -X POST https://tonegridpatternbuilder.usefulweb.site/api/v1/calculate -H 'content-type: application/json' -d '{"name":"Ripple beat","pattern":"# melody (note names) and drums: x = hit, . = rest\nG4    .... ..x. .... ..x.\nE4    .... x... .... x...\nA3    ..x. .... ..x. ....\nE3    x... .... x... ....\nkick  x... .... x... ....\nsnare .... x... .... x...\nclosed-hat x.x. x.x. x.x. x.x."}'

Every result contains

inputs (normalised, defaults applied), summary, result (validated against the published schema), units, assumptions, sources, warnings, computedAt and links.

MCP (Model Context Protocol)

{
  "mcpServers": {
    "tonegrid-pattern-builder": { "type": "http", "url": "https://tonegridpatternbuilder.usefulweb.site/mcp" }
  }
}