moontide-mcp 0.0.0-stage → 2.0.1

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