# mus.io for AI agents

mus.io plays music with real recorded instruments (Musio) for the person you work for. You turn their idea into parts (notes in JSON); mus.io plays them in the cloud and sends back the mix (MP3 and WAV) and, when asked, the score (PDF, PNG pages, MusicXML). Musio plays exactly the notes it is given, so the musical choices are yours and the person's, and the music is theirs.

This guide is enough to finish a render with nothing but a shell or an HTTP client. Every address here is absolute. Service: `https://mus.io`.

## 1. Pick how to connect

| You are... | Do this |
|---|---|
| An agent with MCP that the person can set up once (Claude Code, Codex, Cursor, claude.ai, ChatGPT, Gemini, Grok, VS Code and other apps with custom connectors) | [Section 2](#2-mcp-set-up-once): add `https://mus.io/mcp`; sign-in happens in the browser |
| An agent with a shell or an HTTP client, and no MCP connection right now | [Section 3](#3-sign-in-with-a-device-code-no-mcp): device code sign-in, then [section 5](#5-make-a-piece-search-card-job-wait-download) |
| Given an agent key (`mk_...`) by the person | [Section 4](#4-an-agent-key): send it as a bearer token, then [section 5](#5-make-a-piece-search-card-job-wait-download) |
| Only able to read web pages (no POST requests) | Ask the person to add `https://mus.io/mcp` as a custom connector in their app's settings (section 2), then start a new chat |

A chat agent cannot add an MCP server to itself in the middle of a conversation. If you have no mus.io tools now, use the device code (section 3): it works today, in this conversation.

## 2. MCP, set up once

The MCP server is `https://mus.io/mcp` (Streamable HTTP). A request without a token gets 401 with OAuth metadata (POST; a plain GET answers 405), so the client opens the mus.io sign-in page, the person signs in and approves, and the client keeps the connection.

- **Claude Code:** `claude mcp add --transport http musio https://mus.io/mcp`, then run `/mcp` in Claude Code and choose musio to sign in.
- **Codex:** `codex mcp add musio --url https://mus.io/mcp`, then `codex mcp login musio`.
- **Cursor:** add to `~/.cursor/mcp.json`: `{"mcpServers": {"musio": {"url": "https://mus.io/mcp"}}}`, then sign in when Cursor asks.
- **claude.ai and other apps with custom connectors:** add a custom connector with the URL `https://mus.io/mcp`, sign in, then start a new chat.
- **ChatGPT (web):** Plugins, +, Add custom MCP server, URL `https://mus.io/mcp`, Authentication OAuth, then sign in and pick it with @ in a new chat. Pasting the URL or a key into a chat does not work.
- **ChatGPT plans:** Business, Enterprise and Edu can add it and render. Pro can search instruments but can't start a render. Plus, Go and Free can't add custom servers: use Codex (above), which comes with your ChatGPT plan.
- **VS Code (Copilot agent):** add to `mcp.json`: `{"servers": {"musio": {"type": "http", "url": "https://mus.io/mcp"}}}`, then sign in when VS Code asks.
- **Gemini app:** gemini.google.com, Settings, Connected Apps, Add a custom app, URL `https://mus.io/mcp` (personal Google accounts in the US for now).
- **Gemini CLI or Antigravity CLI:** in the MCP settings: `{"mcpServers": {"musio": {"httpUrl": "https://mus.io/mcp"}}}`.
- **Grok:** grok.com/connectors, New Connector, Custom, URL `https://mus.io/mcp`. Grok Bot: ask it to add a custom MCP server named mus.io at `https://mus.io/mcp`.
- **Windsurf:** `mcp_config.json`: `{"mcpServers": {"musio": {"serverUrl": "https://mus.io/mcp"}}}`.
- **Hermes Agent:** `~/.hermes/config.yaml`: `mcp_servers: {musio: {url: "https://mus.io/mcp", auth: oauth}}`.
- **OpenClaw:** `{"mcp": {"servers": {"musio": {"url": "https://mus.io/mcp", "transport": "streamable-http", "auth": "oauth"}}}}`, then `openclaw mcp login musio`.
- **Goose:** `extensions: {musio: {type: streamable_http, uri: "https://mus.io/mcp"}}`.
- **Zed:** `"context_servers": {"musio": {"url": "https://mus.io/mcp"}}`.
- **Cline:** `{"mcpServers": {"musio": {"type": "streamableHttp", "url": "https://mus.io/mcp"}}}`.
- **n8n:** MCP Client Tool, HTTP Streamable, `https://mus.io/mcp`, MCP OAuth2 with Dynamic Client Registration.
- **Zapier:** MCP Client, Server URL `https://mus.io/mcp`, Streamable HTTP, OAuth: Yes.
- **An MCP client with nobody at a browser** (a server, a nightly test): send an agent key as `Authorization: Bearer mk_...` to the same URL (section 4); any client above can send this header instead of signing in.

The tools, in the order you use them:

| MCP tool | Same thing over HTTP | What it does |
|---|---|---|
| `search_instruments` | `GET /v1/instruments` | Find instruments mus.io can play: each with its id, library, developer, range, sweet spot, articulations and mics. |
| `get_instrument_card` | `GET /v1/instruments/{instrument_id}` | One instrument's full card: playable range, sweet spot, articulations (and what each is for, with how to ask for it), mics and tips. |
| `get_playing_guide` | `GET /v1/guide` | How to get the best sound from mus.io. |
| `submit_job` | `POST /v1/jobs` | Queue a cloud render. |
| `get_job` | `GET /v1/jobs/{job_id}` | A job's state and phase. |
| `get_outputs` | `GET /v1/jobs/{job_id}/outputs` | Signed download links. |
| `cancel_job` | `POST /v1/jobs/{job_id}/cancel` | Cancel one of your jobs. |

## 3. Sign in with a device code (no MCP)

1. Ask for a code:

```sh
curl -s -X POST https://mus.io/oauth/device -d client_id=musio-device -d scope=render
```

   The reply has `device_code` (keep it to yourself), `user_code`, `verification_uri_complete`, `expires_in` (seconds; about 15 minutes) and `interval` (5 seconds).
2. Show the person the `verification_uri_complete` link and the `user_code`, and say: *open this link, sign in with your mus.io account, check the code matches, and click Allow.* Their password goes only to mus.io; you never see it.
3. Poll for the token every `interval` seconds:

```sh
curl -s -X POST https://mus.io/oauth/token -d grant_type=urn:ietf:params:oauth:grant-type:device_code \
     -d client_id=musio-device -d device_code="$DEVICE_CODE"
```

   - `{"error": "authorization_pending"}` (HTTP 400): the person has not approved yet. Keep polling.
   - `slow_down`: you polled too fast. Add 5 seconds to your interval.
   - `expired_token`: the code ran out. Start again at step 1 and show the new link.
   - `access_denied`: the person said no. Stop.
   - Success: `access_token` (`mat_...`, lasts 60 minutes), `refresh_token` (`mrt_...`, 30 days), `expires_in`.
4. Keep the tokens in a shell variable or a file only you read (`chmod 600`). Never print them in the chat.
5. When the access token expires (401), refresh it:

```sh
curl -s -X POST https://mus.io/oauth/token -d grant_type=refresh_token -d client_id=musio-device -d refresh_token="$REFRESH"
```

   Each refresh gives a new refresh token: save it and drop the old one. Using a refresh token twice ends the connection, in case it leaked.

What the token may do (scope `render`): Make music with your mus.io instruments: search instruments, read their cards, render audio and scores, and read the jobs this connection made. It cannot see the password, change the account or plan, buy anything, or make keys. The person sees it at https://mus.io/tokens and can revoke it there.

## 4. An agent key

If the person gave you a key (`mk_...`), send it as `Authorization: Bearer mk_...` on `https://mus.io/v1/...` or on `https://mus.io/mcp`. Treat it like a password: do not repeat it in the chat or write it to shared files. Send it from your own process: a request with an `Origin` header (a web page) is refused. A key has its own monthly limit and the person can revoke it at any time.

## 5. Make a piece: search, card, job, wait, download

Set your token once: `export MUSIO_TOKEN=...` (the `access_token`, or the agent key). Every call:
`-H "Authorization: Bearer $MUSIO_TOKEN"`. Use a client timeout of at least 90 seconds (the wait calls hold up to 60 s).

**From the playing guide:** Before writing any part: find instruments with search_instruments (the connector's tool; over plain HTTP: GET /v1/instruments?search=...; results are grouped by instrument, with FX patches listed after the main hits). Then read each one's card with get_instrument_card (GET /v1/instruments/<id>; this starts the render machine and preloads that instrument, so the first draft is not a cold load). Put the card's id (32 hex characters) in each part's "instrument". Keep every note inside the card's range.playable (notes outside it are refused, on both render and project jobs, with a suggestion; send "range": "warn" only to be warned and still queued), put melodies in range.sweet_spot, choose articulations by what the card says each is for, and shape dynamics on every phrase (CC1 on long notes, velocity on short ones: the card's dynamics.velocity line says, measured per patch, whether velocity does anything on that patch). Then submit_job (POST /v1/jobs) with "dry_run": true to see every error at once (free; the reply also has today's remaining job and minute caps; the worker preloads the instruments in the payload, not just the VM), submit for real, and call get_job or get_outputs with "wait_seconds": 60 (GET /v1/jobs/<id>?wait_seconds=60 or GET /v1/jobs/<id>/outputs?wait_seconds=60): each answers the moment the job finishes. get_outputs gives the download links (mix_mp3 is the small file). cancel_job (POST /v1/jobs/<id>/cancel or DELETE /v1/jobs/<id>) stops a queued or running job. Musio plays exactly the notes it is given, so the musical choices are yours; the service takes care of attack timing, library levels and loudness (section 0).

1. **Read the playing guide once:** `curl -s https://mus.io/v1/guide -H "Authorization: Bearer $MUSIO_TOKEN"`
2. **Find instruments:** `curl -s "https://mus.io/v1/instruments?search=cello&limit=10" -H "Authorization: Bearer $MUSIO_TOKEN"`
   Parameters: `search`, `developer`, `library`, `family`, `fx`, `limit`, `offset`. Each result has its `id` (32 hex characters), range, sweet spot and articulations; results are grouped by instrument.
3. **Read each card** before writing that instrument's part: `curl -s https://mus.io/v1/instruments/<id> -H "Authorization: Bearer $MUSIO_TOKEN"`
4. **Check the job for free** with a dry run. The smallest valid job, three notes on the Grand Piano (Session Piano - Grand):

```sh
curl -s -X POST https://mus.io/v1/jobs -H "Authorization: Bearer $MUSIO_TOKEN" -H 'Content-Type: application/json' \
     -d '{"type": "render", "phrase": {"tempo_bpm": 90, "parts": [{"instrument": "b598b67578a14239834c92e16b8f7b32", "notes": [{"t": 0, "dur": 1, "pitch": "C4", "vel": 80}, {"t": 1, "dur": 1, "pitch": "E4", "vel": 80}, {"t": 2, "dur": 2, "pitch": "G4", "vel": 90}]}]}, "dry_run": true}'
```

   The reply lists every error at once (`errors`), `warnings`, the estimated render time, the instruments' facts and what is left of today's limits. Nothing is queued or counted.
5. **Send it for real:** the same body without `dry_run`:

```sh
curl -s -X POST https://mus.io/v1/jobs -H "Authorization: Bearer $MUSIO_TOKEN" -H 'Content-Type: application/json' \
     -d '{"type": "render", "phrase": {"tempo_bpm": 90, "parts": [{"instrument": "b598b67578a14239834c92e16b8f7b32", "notes": [{"t": 0, "dur": 1, "pitch": "C4", "vel": 80}, {"t": 1, "dur": 1, "pitch": "E4", "vel": 80}, {"t": 2, "dur": 2, "pitch": "G4", "vel": 90}]}]}}'
```

   The reply has the job `id` (16 hex characters) and `state: "queued"`. For the score too, send the same notes as a project (one job gives the mix and the score; dry-run it first the same way):

```json
{"type": "project", "outputs": ["mix", "score"], "project_json": {"tempo_bpm": 90, "parts": [{"instrument": "b598b67578a14239834c92e16b8f7b32", "notes": [{"t": 0, "dur": 1, "pitch": "C4", "vel": 80}, {"t": 1, "dur": 1, "pitch": "E4", "vel": 80}, {"t": 2, "dur": 2, "pitch": "G4", "vel": 90}]}], "title": "My idea", "meter": "4/4", "key": "C major"}}
```

6. **Wait for it:** `curl -s --max-time 90 "https://mus.io/v1/jobs/<id>?wait_seconds=60" -H "Authorization: Bearer $MUSIO_TOKEN"`
   The call answers the moment the job finishes, or after 60 s. Repeat until `state` is `succeeded` (or `failed`, with why). A machine that was off takes about a minute to start; a short piece then takes well under a minute.
7. **Get the links:** `curl -s "https://mus.io/v1/jobs/<id>/outputs" -H "Authorization: Bearer $MUSIO_TOKEN"`
   `available` is a list of `{kind, name, url, bytes}`: `mix_mp3` (small), `mix` (WAV), and `score_pdf`, `score_png`, `score_musicxml` for a score. Links last 60 minutes.
8. **Download the mix:** `curl -sL -o mix.mp3 "<the mix_mp3 url>"` (no Authorization header on the link). Give the person the file, or the link while it lasts.

To stop a job: `POST https://mus.io/v1/jobs/<id>/cancel`. A queued job is not charged.

## 6. The job

A job has these fields: `type`, `phrase`, `project_json`, `outputs`, `range`, `mode`, `section`, `format`, `dry_run`, `auto_full`. `type` is `render` (a phrase, gives the mix) or `project` (`project_json` with `outputs` from `mix`, `score` and `project`: one job gives the audio and the score). The Musio Studio file (.musiostudio, opens in Musio Studio 2.1+) is available on request with Musio Complete: add `project` to `outputs` of a `project` job.

- A phrase: `tempo_bpm`, `parts`, `master`, `buses`, `title`, `meter`, `key`, `preset`, `target_lufs`, `attack_compensation`, `level_trims`, `tail_seconds`, `fade_seconds`, `part_levels`, `hide_warnings`.
- A part: `instrument`, `name`, `articulation`, `articulations`, `dynamics`, `notes`, `cc`, `mix`, `effects`, `attack_compensation`, `level_trim`.
- A note: `t`, `dur`, `pitch`, `vel`, `articulation`, `swell`. `t` and `dur` are in beats when `tempo_bpm` is set; `pitch` is `"C4"` or a MIDI number.
- Every field is checked: one the service does not use is refused with its name. Notes outside an instrument's playable range are refused, with a suggestion.
- For quick revisions: `"mode": "draft"` reuses parts that did not change; `"section": {"start", "end"}` plays one passage. Send the final with the default `"mode": "full"`.
- The full description of every field is in the playing guide (`GET https://mus.io/v1/guide`) and in https://mus.io/openapi.json.

## 7. Limits and errors

Your account has daily limits (jobs and rendered minutes; `GET https://mus.io/v1/status` shows them and what is used), and each connection or key has a monthly limit of rendered minutes the person chose. Renders are paid from the account's minutes (`minutes` in status): 5 trial minutes once, which play any instrument here, and with Musio Complete 30 minutes each month. The trial is used first. Every refusal has `ok: false`, `error` and, where it applies, `reason` and `hint`:

| reason | HTTP | What to do |
|---|---|---|
| `revoked` | 403 | The person revoked this key or connection. Ask them to connect again. |
| `leaked` | 403 | The key was seen from too many places, or a refresh token was used twice. Connect again. |
| `spend_capped` | 403 or 200 with ok false | A monthly or daily limit, or the account's minutes, are used up. Tell the person; do not retry. |
| `rate_limited` | 429 | Too many requests a minute. Wait for Retry-After (60 s), then go on. |
| `reauth_required` | 401 | The person's mus.io sign-in ended. Ask them to sign in again (a new device code). |
| `scope` | 403 | Tokens and keys only render. They cannot manage keys or the account. |
| `unavailable` | 503 | A check could not be done just now. Send the same request after retry_after seconds. |

An instrument the person's plan does not include is refused with a note saying which plan has it: pick another instrument with search, or tell the person.

## 8. Working with the person

- Start from their idea: a hum, a photo of sheet music, a chord chart or a description. Write the parts yourself; mus.io plays them.
- Tell them what you are doing in plain words, especially when you need them to open the sign-in link.
- Send a dry run before every real job, and keep pieces short while you try things (`mode: draft`).
- Share the result as a file or link. The music is theirs.
