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
POST https://tonegridpatternbuilder.usefulweb.site/api/v1/calculate– run Tonegrid Pattern BuilderGET https://tonegridpatternbuilder.usefulweb.site/api/v1/tool– inputs, output schema, examples- OpenAPI 3.1: /openapi.json · /openapi.yaml
- Errors:
application/problem+json;422includes per-fielderrors.
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.
| Field | Type | Default | Description |
|---|---|---|---|
name | text | "API melody" | Project name |
pattern | textarea | "# melody (note names) and drums: x = hit, . = rest\nG4 .... ..x. .... ..x.\n | Pattern 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). |
root | number | 48 | Key (root MIDI note). 48 is C3, 57 is A3, 60 is C4. The root is the lowest melody row. |
scale | select (pentatonic, minorPentatonic, major, minor, dorian, mixolydian, harmonicMinor, blues, chromatic) | "pentatonic" | Musical scale |
rows | number | 16 | Melody rows. How many scale notes the melody grid has, counted up from the root. |
voice | select (bell, sine, triangle, pluck, pad) | "bell" | Melody sound |
bpm | number | 100 | Tempo (BPM) |
swing | number | 0 | Swing (%). Delays every second step by this share of a step. |
repeats | number | 2 | Repeats 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)
- Streamable HTTP endpoint:
https://tonegridpatternbuilder.usefulweb.site/mcp– protocol revisions 2026-07-28 (stateless) and 2025-11-25 / 2025-06-18 / 2025-03-26 (initialize handshake). - Tools:
tonegrid_pattern_builder - Local stdio connector:
node src/mcp-stdio.ts --tool=tonegrid-pattern-builder
{
"mcpServers": {
"tonegrid-pattern-builder": { "type": "http", "url": "https://tonegridpatternbuilder.usefulweb.site/mcp" }
}
}