The MCP surface

Every key operation is reachable over HTTP MCP, because the interface and the server are both thin adapters over the same OpDispatcher. There is no second implementation: an edit made here takes exactly the path the Turtle editor takes, including validation.

Running it

The server is off by default and binds to loopback only. Enable it from Settings → MCP Server inside the plugin. The toggle persists in plugin state, so a saved session reopens with the server in whatever state you left it.

Two environment variables configure it when Valis starts:

variable default meaning
VALIS_MCP_PORT 7676 port to bind on 127.0.0.1
VALIS_MCP_TOKEN none if set, requests need Authorization: Bearer <token>

Check it is up:

curl -s localhost:7676/health

The reply says which instance answered:

{ "status": "ok", "server": "valis", "port": 7676, "name": "Bass" }

Several instances

A host that has several Valis tracks loads several instances into one process, and each gets an MCP server of its own. An instance asks for the configured port (7676 unless VALIS_MCP_PORT says otherwise) and, if that is taken, tries the next one, and the next, up to 32 ports. The first instance is on 7676, the second on 7677, and so on. The Settings menu shows the port an instance got ("MCP Server (port 7677)"), and a saved session remembers it as a preference, not a promise: an instance that finds its saved port taken moves up.

name in the /health reply is the track name the host gives the instance, when it gives one, so a client can tell which instance is which. To find them all:

for p in $(seq 7676 7707); do curl -s -m 1 localhost:$p/health && echo; done

Register each one with the client under its own name, for example claude mcp add --transport http valis-bass http://localhost:7677/mcp. The port an instance gets depends on the order the host loads them, so check /health rather than assuming.

Before this, two servers asked for the same port could both bind it (the HTTP library sets SO_REUSEPORT), and the system then handed each request to either one. That is now refused.

Protocol

JSON-RPC 2.0 over POST /mcp. initialize, tools/list, tools/call, resources/list, and resources/read are supported.

curl -s localhost:7676/mcp -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Resources

These read-only resources let a client inspect the current state without picking a tool first.

resource contains
valis://turtle the circuit's current Turtle source
valis://graph the current circuit as JSON, including which elements a val:Subcircuit expanded to and which voice each belongs to
valis://diagnostics load state, size, latency, and any diagnostics
valis://element-types every declared element class with ports, ranges, units, and which ports carry events rather than signal
valis://params the circuit's current parameter bindings
valis://guide the guide for agents
valis://circuits an index of every circuit in circuits/ and what each is
valis://circuits/NAME one example's Turtle, such as valis://circuits/basic

Tools

tool does
get_turtle the circuit's Turtle source
set_turtle replace the circuit; rejected if it will not compile
validate check Turtle without installing it
list_element_types every class, with ports, ranges and units
describe_element one class in full: its description, every port with range, unit and choices, and the options it takes
get_graph the circuit as JSON
add_node / remove_node add an element, or remove it and its arcs
connect / disconnect join or separate two ports
history / undo / redo the versions the circuit has had (up to 100), and going back and forward over them; a batch is one version
diff what changed between two versions, in plain sentences
apply_edits several add_node, remove_node, connect and disconnect edits as one: all take effect or none do, and the result is installed once
list_params / get_param / set_param the bound parameter slots
get_sample / set_sample the sound file a val:SampleLoad or val:TimeStretch node plays, or the model a val:NamModel runs
morph move every parameter that has a val:valueA and val:valueB between them, 0 to 1
randomize give the parameters new random values within their ranges, from a seed
load_file / save_file read or write a Turtle file on the server machine
note_on / note_off / all_notes_off play the circuit, as the editor's keyboard does
get_profile what the circuit says it is: role, signals, genre, cautions
read_outputs every control output's live value, or one node's
check_stability run the circuit on a fresh engine with random settings of its bound parameters, all moving at once partway through, and report runs that blow up, go non-finite, clip or fall silent, with the settings that did it
lint static checks on the loaded circuit: values an arc overwrites, knobs that do nothing, parts that cannot be heard, effects with nothing connected, nothing wired to the output
measure level, clipping, DC, pitch with note name and cents, octave levels, brightness, onsets, level over time and plain notes on anything wrong (under signal), plus loudness to BS.1770 (integrated LUFS, range, true peak) and the envelope (attack, decay, noise floor)
compare the spectral distance in dB between two files (0 is the same), and the differences in loudness and length
sounds_like yes, maybe or no to "is this file a trumpet?", the share, the rank among twenty rivals and the three closest sentences; needs a build with VALIS_WITH_ONNX and the models from scripts/shot/fetch-models.sh
listen AudioSet labels for a file and a share for each sentence given; the same requirements as sounds_like
fit_modes fit a recording of a struck object to val:FreeModalBank modes (frequency, ring time, level) and report how near the bank is
fit_params search the circuit's val:Param settings for the render nearest a recording, by spectral distance; reports the values and changes nothing
render render the circuit offline to a wav and report peak and RMS, with the same analysis measure gives
get_diagnostics whether the circuit loaded, its size, latency, voices, and problems: what an element recovered from, such as a missing sound file
read_song read a val:Song file (tempo, sections, parts, returns and the mix settings) and list problems such as a missing circuit or MIDI file
render_song render a song's stems to wavs/: each part is its circuit played by its MIDI file at the song's tempo, each return is its source stem through the return's circuit. A failing stem is named and the others are still written
score_song play a song's score (val:score: step-string patterns, chords, feels and a plan) into a MIDI file for each part it plays
check_stems compare the rendered stems with their MIDI files bar by bar and name any that are silent where the score has notes, clipped, non-finite, or have an empty MIDI file
reaper_project write a Reaper project from a song file: a track per rendered stem, volume and pan from the song's mix, tempo and meter from the song
mix_song mix the stems to mixes/<title>-<version>.wav: levelled, panned, with optional per-section levels, a fade, a room, a soft clip and a loudness target. It never replaces an existing version unless asked
freesound_search / freesound_download search freesound.org (CC0 by default) and fetch a result into audio/freesound/ as an Ogg preview with a .json naming author and licence. Needs FREESOUND_API_KEY in .env

The song tools read and write files on the server machine, with relative paths resolved against the server's working directory. See songs as data.

Every tool is an adapter over the same Op the views use, so anything the UI can do is reachable here. Three of them are worth knowing about when building a circuit from outside:

note_on is what the editor's virtual keyboard does. Without it a caller can build an instrument and never hear it.

read_outputs returns the live value of every control output in the circuit. It is what the Controls view shows for val:Oscilloscope and val:FreqAnalyzer, so it is how a caller measures what it built rather than guessing.

render compiles the current circuit into a fresh engine, plays an optional note, writes a wav file and reports the peak, the RMS and whether every sample was finite. The fresh engine means rendering neither hears nor disturbs what the plugin is playing. This is the quickest way to tell whether a circuit actually sounds.

To render a whole part, pass midi (a standard MIDI file) and tempo: every note of the file plays at that tempo in place of note. Tempo changes in the file are ignored. rolling reports the transport as playing, for a circuit that takes its timing from the host.

Guarantees

Edits are atomic. A rejected edit leaves the source exactly as it was, so a failed call cannot corrupt the circuit for the next one.

A failed edit does not silence the plugin. Turtle that will not compile leaves the previous circuit playing.

Errors say what is wrong and where. Parse errors carry line and column; a structural error names the element or arc at fault.

4:0: missing ';' or '.'
Tanh has no port 'nosuch'
c: feedback loop with no val:UnitDelay to break it: g -> m

An example

Insert a saturator between two existing elements:

call() { curl -s localhost:7676/mcp \
  -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",
       \"params\":{\"name\":\"$1\",\"arguments\":$2}}"; }

call add_node   '{"id":"urn:valis:basic#growl","class":"val:Tanh"}'
call disconnect '{"from_node":"urn:valis:basic#drive","from_port":"out",
                  "to_node":"urn:valis:basic#out","to_port":"in"}'
call connect    '{"from_node":"urn:valis:basic#drive","from_port":"out",
                  "to_node":"urn:valis:basic#growl","to_port":"in"}'
call connect    '{"from_node":"urn:valis:basic#growl","from_port":"out",
                  "to_node":"urn:valis:basic#out","to_port":"in"}'

The graph view redraws with the new node in place, and the audio keeps running throughout.

Using with Claude Code

Start Valis with the server enabled, then register it as an MCP server. In the project or user settings file (.claude/settings.json or ~/.claude/settings.json):

{
  "mcpServers": {
    "valis": {
      "type": "http",
      "url": "http://localhost:7676/mcp"
    }
  }
}

Or add it from the command line:

claude mcp add --transport http valis http://localhost:7676/mcp

Once registered, Claude Code can call any tool in the table above directly. Describe the sound you want in plain English - the model can call get_graph to read what is there, then add_node, connect, and set_param to build or reshape the circuit while the audio keeps running.

A bearer token restricts access when the port is forwarded. Set it before launching, then reference it in the client config:

VALIS_MCP_TOKEN=secret ./valis
{
  "mcpServers": {
    "valis": {
      "type": "http",
      "url": "http://localhost:7676/mcp",
      "headers": { "Authorization": "Bearer secret" }
    }
  }
}

Using with OpenAI Codex

Codex CLI also supports MCP over HTTP. Add a server entry to your Codex configuration file (typically ~/.codex/config.toml):

[[mcp_servers]]
name    = "valis"
type    = "http"
url     = "http://localhost:7676/mcp"

The exact key names may vary with Codex version - check codex mcp --help or the Codex documentation if the above does not match. The Valis server speaks standard JSON-RPC 2.0 MCP, so any client that supports the HTTP transport will work.