moontide-mcp 0.0.0-stage → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +372 -2
  3. package/dist/ask.js +634 -0
  4. package/dist/build-id.js +85 -0
  5. package/dist/catalog.js +454 -0
  6. package/dist/drum-maps.js +119 -0
  7. package/dist/edit-code.js +237 -0
  8. package/dist/history.js +692 -0
  9. package/dist/import-midnam.js +185 -0
  10. package/dist/index.js +93 -0
  11. package/dist/instruments.js +1316 -0
  12. package/dist/listen.js +88 -0
  13. package/dist/mcp.js +787 -0
  14. package/dist/midi-state.js +270 -0
  15. package/dist/midnam.js +571 -0
  16. package/dist/open-browser.js +54 -0
  17. package/dist/protocol.js +341 -0
  18. package/dist/reference.js +102 -0
  19. package/dist/rig-util.js +79 -0
  20. package/dist/session-label.js +35 -0
  21. package/dist/session.js +2039 -0
  22. package/dist/start.js +192 -0
  23. package/dist/version.js +32 -0
  24. package/dist/web-server.js +353 -0
  25. package/instruments/mt32.json +208 -0
  26. package/instruments/sc55.json +441 -0
  27. package/package.json +64 -4
  28. package/page/ask-view.js +533 -0
  29. package/page/ask.js +697 -0
  30. package/page/bar-model.js +296 -0
  31. package/page/change-timing.js +204 -0
  32. package/page/drum-lane.js +61 -0
  33. package/page/evaluate-tag.js +38 -0
  34. package/page/harmony.js +191 -0
  35. package/page/history-view.js +849 -0
  36. package/page/history.js +543 -0
  37. package/page/index.html +121 -0
  38. package/page/instruments-model.js +793 -0
  39. package/page/instruments-view.js +894 -0
  40. package/page/jam-analysis.js +662 -0
  41. package/page/jam-model.js +585 -0
  42. package/page/jam-view.js +518 -0
  43. package/page/load-failure-view.js +142 -0
  44. package/page/load-failure.js +96 -0
  45. package/page/main.js +4402 -0
  46. package/page/midi-clock.js +621 -0
  47. package/page/midi-controls.js +678 -0
  48. package/page/midi-out.js +2612 -0
  49. package/page/midi-plan.js +1098 -0
  50. package/page/midi-rig.js +655 -0
  51. package/page/midi-view.js +298 -0
  52. package/page/mixer-gesture.js +208 -0
  53. package/page/mixer-model.js +1206 -0
  54. package/page/mixer-registry.js +493 -0
  55. package/page/mixer-rewrite.js +1563 -0
  56. package/page/mixer-view.js +2003 -0
  57. package/page/parts.js +652 -0
  58. package/page/problem-view.js +269 -0
  59. package/page/query-check.js +182 -0
  60. package/page/session-identity.js +58 -0
  61. package/page/session-view.js +208 -0
  62. package/page/split-model.js +97 -0
  63. package/page/split-view.js +157 -0
  64. package/page/style.css +5355 -0
  65. package/page/takeover.js +253 -0
  66. package/page/tempo-guard.js +87 -0
  67. package/page/timeline.js +561 -0
  68. package/page/top-bar-view.js +138 -0
  69. package/page/tracks.js +710 -0
  70. package/page/ui-state.js +273 -0
  71. package/page/views.js +265 -0
  72. package/reference/effects.md +119 -0
  73. package/reference/functions.md +167 -0
  74. package/reference/midi.md +111 -0
  75. package/reference/mini-notation.md +118 -0
  76. package/reference/sounds.md +202 -0
  77. package/reference/theory.md +407 -0
  78. package/reference/tidal-differences.md +106 -0
  79. package/reference/transitions.md +140 -0
package/README.md CHANGED
@@ -1,3 +1,373 @@
1
- # Temporary Holding Version
1
+ # Moontide
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > The moon guides the tide.
4
+
5
+ **A hobby project: Claude plays live music for you. Describe a mood, a theme or an idea, and
6
+ Claude writes [Strudel](https://strudel.cc) code that plays in your browser and changes without
7
+ ever stopping.**
8
+
9
+ <!-- Demo media goes here, right under the pitch. -->
10
+
11
+ ## How this was made
12
+
13
+ Moontide is a personal project. Most of the code, research and documentation was
14
+ written by an AI coding assistant working under my direction. I set the goals, listened to
15
+ every change, tried it on my own instruments, judged the results by ear, and made the
16
+ decisions. I am responsible for what is here, errors included.
17
+
18
+ ## Why
19
+
20
+ Curiosity. I wanted to see how far an AI assistant can go at making real music, not a
21
+ technical demo, when it is given a good instrument. Strudel is that instrument: a live-coding
22
+ language where a change lands on the next cycle, with no cut, and where the music is plain text
23
+ that both of us can read.
24
+
25
+ So Claude writes the code, and the code stays on screen while it plays. You can watch it, edit
26
+ it by hand, go back to any earlier version, or point at something in the page and ask for a
27
+ change.
28
+
29
+ ## What it does
30
+
31
+ - You talk ("start something dreamy in D minor", "darker", "add a bass"). Claude writes
32
+ Strudel code, and a browser page plays it at once. Each change takes over within a fraction
33
+ of a second, without stopping the music.
34
+ - The code is always visible and editable. Every version that played is kept, and Claude can
35
+ bring any of them back.
36
+ - Around the code, the page shows the music in several views: the named tracks on a timeline,
37
+ the parts of a piece, the history as a list or a tree, a mixer whose moves rewrite the code,
38
+ and a jam view with the scale on a piano or a guitar.
39
+ - A right-click on anything in the page sends Claude a request with that context.
40
+ - The same code can play real MIDI instruments from the page, through Web MIDI.
41
+
42
+ Moontide does not start from scratch. The music engine is
43
+ **[Strudel](https://strudel.cc)**, the JavaScript port of TidalCycles by Felix Roos, Alex McLean and the
44
+ Strudel contributors. Moontide is the bridge between Claude and a Strudel page.
45
+
46
+ ## How it works
47
+
48
+ ```
49
+ you ──talk──► Claude ──MCP (stdio)──► Moontide ──WebSocket (localhost)──► browser page
50
+ │ Strudel plays
51
+ └─ history file on your disk the code, sound
52
+ and Web MIDI out
53
+ ```
54
+
55
+ 1. Moontide runs as an MCP server that Claude connects to. It starts nothing until you ask
56
+ for music or say "start Moontide".
57
+ 2. It then opens a page in your browser with a Strudel editor.
58
+ 3. Claude writes the code, the page plays it, and you watch the code come alive.
59
+ 4. Claude can stop the music at any point. The page has its own Play and Stop button too.
60
+ 5. Right-click anything in the page to ask Claude about it. A right-click on the Timeline also
61
+ sends the moment under the pointer: the cycle and the beat, the version that was playing, and
62
+ the notes sounding there or starting in the same sixteenth, with their velocities and, for a
63
+ MIDI track, its instrument and channel. The Session drawer (the Session button in the top
64
+ bar) says whether page requests are live (they reach Claude right away) or wait for Claude
65
+ (they reach it with its next action). Its (i) explains how to switch.
66
+
67
+ ## Install
68
+
69
+ The short version, for someone who already has Node 22 or later and Claude Code:
70
+
71
+ ```bash
72
+ claude mcp add --scope user moontide -- npx -y moontide-mcp
73
+ ```
74
+
75
+ Then start a new Claude session and ask for music. The steps below explain each part.
76
+
77
+ ### 1. What you need
78
+
79
+ - **Node 22 or later**, with npm and npx (they come with Node).
80
+ - **Claude Code or Claude Desktop.** Moontide is an MCP server: Claude talks to it.
81
+ - **Chrome**, the browser Moontide was tried with. For MIDI (Web MIDI), use Chrome or Edge.
82
+ - **Internet access**: Strudel and its sounds load from the web.
83
+ - **Speakers or headphones.**
84
+
85
+ ### 2. Check Node
86
+
87
+ In a terminal, run:
88
+
89
+ ```bash
90
+ node --version
91
+ ```
92
+
93
+ It must print `v22` or higher. If Node is missing or older, install the LTS version from
94
+ [nodejs.org](https://nodejs.org). On macOS with Homebrew, `brew install node` works too. Open a
95
+ new terminal afterwards and check again.
96
+
97
+ ### 3. Get Claude
98
+
99
+ Install Claude Code or Claude Desktop from [claude.com](https://claude.com/claude-code) and sign
100
+ in once. Moontide works with either; Claude Code is the one tried most.
101
+
102
+ ### 4. Add Moontide to Claude
103
+
104
+ <details open>
105
+ <summary>Claude Code (tested on macOS; Linux untested)</summary>
106
+
107
+ In a terminal, run:
108
+
109
+ ```bash
110
+ claude mcp add --scope user moontide -- npx -y moontide-mcp
111
+ ```
112
+
113
+ With `--scope user`, Moontide is available in every folder. The default scope (local) works
114
+ only in the folder where you ran the command, and the scope `project` shares it through a
115
+ `.mcp.json` file.
116
+
117
+ Keep the name `moontide`. The page-request commands below use it.
118
+
119
+ Check the install with:
120
+
121
+ ```bash
122
+ claude mcp get moontide
123
+ ```
124
+
125
+ The same line is meant for Linux. It is untested there.
126
+
127
+ </details>
128
+
129
+ <details>
130
+ <summary>Claude Desktop (tested on macOS; Windows untested)</summary>
131
+
132
+ Open Settings, then Developer, then Edit Config. The file is:
133
+
134
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
135
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
136
+
137
+ Add Moontide to it:
138
+
139
+ ```json
140
+ {
141
+ "mcpServers": {
142
+ "moontide": {
143
+ "command": "npx",
144
+ "args": ["-y", "moontide-mcp"]
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ If the file already has an `mcpServers` block, add the `moontide` entry inside it. Quit Claude
151
+ Desktop fully and start it again. Claude Desktop has no Linux version.
152
+
153
+ </details>
154
+
155
+ <details>
156
+ <summary>Windows with Claude Code (untested)</summary>
157
+
158
+ From PowerShell or Command Prompt (not Git Bash), run:
159
+
160
+ ```bash
161
+ claude mcp add --scope user moontide -- cmd /c npx -y moontide-mcp
162
+ ```
163
+
164
+ Check it with `claude mcp get moontide`. The command must read `cmd` with `/c npx -y moontide-mcp`. If it shows `C:/` instead of `/c`, edit the `moontide` entry in the `.claude.json` file of your user folder so it reads `"command": "cmd", "args": ["/c", "npx", "-y", "moontide-mcp"]`.
165
+
166
+ This form comes from community reports. It has not been tried here.
167
+
168
+ </details>
169
+
170
+ <details>
171
+ <summary>From the source code</summary>
172
+
173
+ To run Moontide from a copy of this repository instead of npm:
174
+
175
+ ```bash
176
+ git clone https://github.com/konni-arcadia/moontide.git
177
+ cd moontide
178
+ npm ci
179
+ npm run build
180
+ ```
181
+
182
+ Then add it with the full path of `dist/index.js`, written here as `<folder>`:
183
+
184
+ ```bash
185
+ claude mcp add --scope user moontide -- node <folder>/dist/index.js
186
+ ```
187
+
188
+ `npm test` runs the test suite. The real-browser checks (`npm run probe:page`) need Chrome.
189
+
190
+ </details>
191
+
192
+ ### 5. First music
193
+
194
+ 1. Start a new Claude session. Nothing opens yet: Moontide waits until you want it.
195
+ 2. Ask for music, for example "Play something calm to start the day" or "Give me a slow, warm
196
+ groove". Or say "start Moontide". In Claude Code, `/mcp__moontide__start` does the same.
197
+ 3. The page opens in a new tab at http://localhost:5757, or on another port when 5757 is busy.
198
+ Claude's replies name the address. The tab title names the folder Claude runs in and the
199
+ port, for example "Moontide · my-project · 5757".
200
+ 4. Click once anywhere in the page. Browsers start sound only after a click.
201
+ 5. Ask for changes: "darker", "add a bass", "slower".
202
+
203
+ Set `MOONTIDE_NO_BROWSER=1` in the environment and starting Moontide opens no tab. Open the
204
+ address from Claude's reply yourself.
205
+
206
+ ### Update
207
+
208
+ To see the version that runs, run `npx -y moontide-mcp --version`. Releases are listed in
209
+ [CHANGELOG.md](https://github.com/konni-arcadia/moontide/blob/main/CHANGELOG.md). npx can keep
210
+ using a copy it already downloaded; to move to the newest release, add Moontide again with
211
+ `@latest`:
212
+
213
+ ```bash
214
+ claude mcp remove moontide --scope user
215
+ claude mcp add --scope user moontide -- npx -y moontide-mcp@latest
216
+ ```
217
+
218
+ ### Uninstall
219
+
220
+ ```bash
221
+ claude mcp remove moontide --scope user
222
+ ```
223
+
224
+ In Claude Desktop, remove the `moontide` entry from the config file and restart it. Moontide
225
+ keeps its history and settings in your data folder (see History); delete that folder if you
226
+ want them gone too.
227
+
228
+ ### MIDI instruments (optional)
229
+
230
+ Moontide can play MIDI instruments from the code through Web MIDI. It ships ready models for the
231
+ Roland MT-32 and SC-55. You can describe your own instruments and models, add sound catalogs and
232
+ send MIDI clock. The setup is in
233
+ [docs/midi.md](https://github.com/konni-arcadia/moontide/blob/main/docs/midi.md).
234
+
235
+ ## Page requests without a permission prompt
236
+
237
+ In the Code tab of the Claude app, ask Claude to turn page requests on or off. Claude calls
238
+ Moontide's `set_page_requests` tool. In Claude Code in a terminal, type
239
+ `/mcp__moontide__page-requests-on` to make them live or `/mcp__moontide__page-requests-off` to
240
+ make them wait. Live, Claude starts a monitor, which lasts at most 30 minutes and is started
241
+ again when a tool reply asks. Waiting, tool replies stop offering to start it until page
242
+ requests are turned on again. Page requests need an open page, so start Moontide first. These
243
+ names assume the server was added as `moontide`.
244
+
245
+ Claude Code asks permission before it starts the monitor for page requests, because it runs a
246
+ command. You can approve it each time. If you want a narrower permission rule instead, see the
247
+ permissions section of the Claude Code documentation. Do not allow broad `node` commands.
248
+
249
+ ## Musical reference
250
+
251
+ Claude gets a factual reference of the exact Strudel version the page runs, through the
252
+ `get_strudel_reference` tool (also offered as MCP resources), covering eight topics: Strudel
253
+ vs TidalCycles, mini-notation, pattern functions, effects and sound controls, the sound
254
+ palette, music theory in Strudel, transitions, and MIDI output. It holds facts only: what
255
+ exists and how to write it. Moontide ships no mood vocabulary, no style material and no model
256
+ pieces; Claude translates your words with its own knowledge of music theory, then tells you in
257
+ one line what it chose. Ask for a surprise in your own words: there is no menu command for it.
258
+ Set a frame for the session, for example gradual changes, and Claude follows it for every
259
+ change until you lift it. Say what matters to you (a melody, a rhythm) and Claude keeps it,
260
+ and asks before a full rewrite.
261
+
262
+ ## Small edits and harmony
263
+
264
+ Claude can change a few lines of a long piece without sending it again, through the
265
+ `edit_code` tool; a change that waits for its bar is edited, and your hand edits are kept.
266
+
267
+ The code can say which harmony it means with one top-level line, for example
268
+ `const harmony = 'C:minor'`, placed above the patterns. It plays nothing and is never a
269
+ track. The Jam view then shows two lines, "Declared:" and "Heard:", side by side.
270
+
271
+ ## History
272
+
273
+ Every version that plays is kept: Claude's own changes and your Ctrl+Enter edits, each with
274
+ its time, who made it and a short label. Failed code and stops are not versions.
275
+
276
+ Ask Claude things like "go back to the previous version", "the one from 3 changes ago", "the
277
+ one with the bass", or "keep this one, call it Take two", and "list my favorites". The
278
+ Session drawer shows the number of the version that is playing, in its Last change card, for
279
+ example `v42`.
280
+
281
+ The history file lives in your OS's per-user data folder:
282
+
283
+ - macOS: `~/Library/Application Support/moontide/history.jsonl`
284
+ - Linux: `$XDG_DATA_HOME/moontide/history.jsonl`, or `~/.local/share/moontide/history.jsonl`
285
+ - Windows: `%APPDATA%\moontide\history.jsonl`
286
+
287
+ Set `MOONTIDE_DATA_DIR` to use another folder. The history is one text file with one entry
288
+ per line, and survives the end of the Claude session.
289
+
290
+ The history keeps the last 1000 versions; older ones are dropped in batches and Claude is
291
+ told. Favorites are never dropped.
292
+
293
+ If a line of the file cannot be read, Claude is told which lines; they stay in the file
294
+ untouched. If the file cannot be read or written at all, the music keeps working and Claude
295
+ is told.
296
+
297
+ Run one Moontide at a time with the same history file. Two at once can give two versions the
298
+ same number.
299
+
300
+ ## Troubleshooting
301
+
302
+ **"Failed to connect" right after installing.** The first start downloads the package, and Claude Code gives up after 30 seconds. Wait a little and check again with `claude mcp list`. If it keeps failing, start Claude Code with a longer limit: `MCP_TIMEOUT=60000 claude`. In PowerShell, use `$env:MCP_TIMEOUT = "60000"; claude`.
303
+
304
+ **Moontide is missing in another folder.** It was added without `--scope user`. Add it again with the Install line.
305
+
306
+ **The page did not open.** Claude's replies name its address. Open it yourself, or ask Claude to start Moontide again: it gives the address and opens a new tab when no page is connected.
307
+
308
+ **Several Moontide tabs.** Each Claude session that started Moontide has its own page and port. The tab title says "Moontide · <folder> · <port>", with the folder that session runs in, and the Session drawer shows the same. Ask Claude which tab is its own: it answers with the address, the port and the tab title.
309
+
310
+ **No sound.** Click once in the page. Check that the browser tab is not muted, and keep the page open.
311
+
312
+ **Claude Desktop does not find `npx`.** Put the full path in `"command"`: the path printed by `which npx` on macOS or `where npx` on Windows, written here as `<full path printed by which npx>`. This is common advice and has not been tried here. The Claude Desktop logs are in `~/Library/Logs/Claude` on macOS and `%APPDATA%\Claude\logs` on Windows.
313
+
314
+ **MIDI says to use Chrome or Edge.** Web MIDI is missing in that browser.
315
+
316
+ ## Status
317
+
318
+ Early and personal. It runs on one setup: a Mac, Chrome, Claude Code and Claude Desktop, and,
319
+ for MIDI, a Roland SC-55, the Munt MT-32 emulator and a Roland JUPITER-Xm. It has not been tried
320
+ anywhere else. The test suite runs on Windows, Linux and macOS in CI, but nobody has played
321
+ music on Windows or Linux yet. There are known bugs. Feedback is welcome, but support is not
322
+ something I can promise.
323
+
324
+ Known limits:
325
+
326
+ - Tried by hand only on macOS, with Chrome, Claude Code and Claude Desktop.
327
+ - Windows and Linux are untested by hand. Edge, Safari and Firefox are untested.
328
+ - Internet access is needed.
329
+ - MIDI needs Chrome or Edge.
330
+ - Run one Moontide at a time with the same history file.
331
+ - The first start through npx downloads the package and can be slow.
332
+
333
+ ## Network and privacy
334
+
335
+ - The server listens on 127.0.0.1 only and refuses requests for any other host name.
336
+ - Moontide's own server code makes no outbound request and sends no telemetry.
337
+ - The page loads `@strudel/repl` 1.3.0 and `acorn` 8.18.0 from unpkg, pinned to exact versions with integrity hashes.
338
+ - Strudel then fetches sound lists and samples from raw.githubusercontent.com and cdn.jsdelivr.net. No hash covers those.
339
+ - The code Claude writes runs in the page and may load samples from other addresses.
340
+ - The history stays in the local data folder described above.
341
+
342
+ ## Contributing and security
343
+
344
+ Bug reports and ideas are welcome as issues (use the bug form). How pull requests are handled is in
345
+ [CONTRIBUTING.md](https://github.com/konni-arcadia/moontide/blob/main/CONTRIBUTING.md).
346
+
347
+ Security problems go through a private report, never a public issue. See
348
+ https://github.com/konni-arcadia/moontide/security/policy.
349
+
350
+ ## Credits
351
+
352
+ This builds on other people's work:
353
+
354
+ - **Felix Roos, Alex McLean and the Strudel contributors**: [Strudel](https://strudel.cc)
355
+ (source: https://codeberg.org/uzu/strudel), the live-coding engine that plays every note.
356
+ - **Alex McLean and the TidalCycles community**: TidalCycles, the pattern language Strudel
357
+ ports to JavaScript.
358
+ - **The sample makers** whose sets Strudel loads by default, including the TidalCycles
359
+ Dirt-Samples and the Versilian Community Sample Library (VCSL).
360
+ - **Anthropic**: the Model Context Protocol and its TypeScript SDK, which let Claude talk to
361
+ Moontide.
362
+ - **The acorn authors**: the JavaScript parser the page uses to read the code.
363
+
364
+ ## License
365
+
366
+ Moontide plays Strudel, which is under AGPL-3.0-or-later. Moontide uses the same license. It
367
+ loads Strudel from unpkg at run time and does not ship it. The license text is in
368
+ [LICENSE](https://github.com/konni-arcadia/moontide/blob/main/LICENSE). Moontide is not
369
+ affiliated with, or endorsed by, the Strudel or TidalCycles projects, or Anthropic.
370
+
371
+ ---
372
+
373
+ *Konni — built with an AI coding assistant.*