@rsc-kit/mcp 0.30.52 → 0.30.54

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.
@@ -108,7 +108,11 @@ browser → renderer ──render──▶ React
108
108
  the React tree has it, React renders it; otherwise the backend does. Nothing
109
109
  is half-and-half on one url. A dynamic root route that would also match one
110
110
  of the backend's urls does not get it: name the backend's prefixes with
111
- `backendPaths` and they go first. A named prefix is also never a page to the
111
+ `backendPaths` and they go first. The build lists them in
112
+ `.output/rsc-kit.json`, so a proxy in front can send them straight to the
113
+ backend without going through the renderer
114
+ ([deployment](/hosts/deployment/#sending-the-backends-urls-past-the-renderer)).
115
+ A named prefix is also never a page to the
112
116
  browser: a `Link`, `visit()` or `redirect()` to it loads the document and is
113
117
  never prefetched, so it may bounce on to another site, as an OAuth start does
114
118
  ([redirects](/guides/redirects/#leaving-the-app)).
@@ -250,8 +250,14 @@ Three rules apply to all of them:
250
250
 
251
251
  **Rotating one** is a deploy, and each says so differently:
252
252
 
253
- - `RSC_HOST_CALL_SECRET` - the renderer and the backend must change together.
254
- Between the two, every `rpc()` is refused, so deploy both at once.
253
+ - `RSC_HOST_CALL_SECRET` - the renderer sends it and the backend checks it,
254
+ so the backend goes first. Give the backend the new value, with the old one
255
+ as `RSC_HOST_CALL_SECRET_PREVIOUS`: it answers either. Then give the
256
+ renderer the new value, and once every renderer has it, remove
257
+ `RSC_HOST_CALL_SECRET_PREVIOUS`. No call is refused along the way. The
258
+ renderer's own health probe takes either too. Read from `@rsc-kit/core`
259
+ 0.30.54, `rsc-kit/go` v0.17.0 and `rsc-kit/laravel` 0.21; before those, the
260
+ two must change together.
255
261
  - `RSC_SIGNING_SECRET` - pages already open hold names signed with the old
256
262
  key. Set the old value as `RSC_SIGNING_SECRET_PREVIOUS` for the deploy that
257
263
  rotates it: it is accepted when checking a signature and never used to make
@@ -293,9 +299,59 @@ code that decided; refuse a deploy where the two disagree:
293
299
  both.
294
300
  - **`output: "export"`** - `dir` is the static site; serve it as files.
295
301
 
296
- One field is only in the build's file, because only the build knows it:
297
- `commands`, the app's [commands](/guides/commands). Compare the rest with
298
- `info`.
302
+ Two fields are only in the build's file, because only the build knows them:
303
+ `commands`, the app's [commands](/guides/commands), and `backendPaths`. Compare
304
+ the rest with `info`.
305
+
306
+ ### Sending the backend's urls past the renderer
307
+
308
+ `backendPaths` is the app's
309
+ [`rscKit({ backendPaths })`](/hosts/backend-answered-pages/), normalised, and
310
+ `[]` when it names none, so a proxy can tell "none" from a build too old to say
311
+ (before 0.30.53). The renderer forwards those urls to the backend anyway, but
312
+ every request it forwards costs its CPU and memory and is cut off by its
313
+ timeouts. A proxy in front can send them straight to the backend:
314
+
315
+ ```json
316
+ { "version": "0.30.53", "output": "server", "backendPaths": ["/auth", "/github"] }
317
+ ```
318
+
319
+ - A path equal to a prefix, or under it (`/auth`, `/auth/callback`, but not
320
+ `/authors`), goes to the backend, for every method.
321
+ - Everything else goes to the renderer.
322
+ - The host-call endpoint (`/__rsc/host-call`, or `RSC_HOST_CALL_PATH`) is
323
+ refused from outside. Only the renderer calls it, straight to the backend.
324
+ The build refuses a `backendPaths` entry that would cover it, and the
325
+ renderer answers a browser's request for it with its not-found page instead
326
+ of forwarding it.
327
+
328
+ The same list is `build.backendPaths` in the `routes.json` beside the entries,
329
+ for a host that reads the route table.
330
+
331
+ ### A header on every request to the backend
332
+
333
+ When something in front of the backend admits the renderer only with a header
334
+ of its own, such as a private preview's access token, set
335
+ `RSC_BACKEND_HEADERS` on the renderer to a JSON object:
336
+
337
+ ```ini
338
+ RSC_BACKEND_HEADERS={"X-Preview-Token":"..."}
339
+ ```
340
+
341
+ - They go on every request the renderer makes to `RSC_BACKEND`: host calls,
342
+ and the urls it forwards. They go to no other origin.
343
+ - The renderer reads them once, when it starts, so a new value needs a
344
+ restart.
345
+ - A visitor's header with the same name is replaced, never passed through.
346
+ - Malformed JSON stops the server at startup, with an error that names the
347
+ variable but never its value.
348
+ - Names rsc-kit sets itself (`X-RSC-*`, `Cookie`, `Authorization`, `Host`,
349
+ `Content-Type`, the forwarding headers) are refused.
350
+ - `httpHostCalls({ headers })` takes the same, for a host that embeds the
351
+ engine itself.
352
+
353
+ Read from `@rsc-kit/core` 0.30.54. Production and a backend on loopback rarely
354
+ need it.
299
355
 
300
356
  ### Pages an edge may serve from its cache
301
357
 
@@ -211,11 +211,15 @@ vendors. A purge that fails is logged and never fails the change: the CDN
211
211
  still drops its copy at its `max-age` in `CDN-Cache-Control`. `purge({ tags, paths, all })` sends
212
212
  one yourself, from a deploy step or a webhook.
213
213
 
214
- On Homeport there is nothing to install. With `HOMEPORT_PURGE_URL` set, the
215
- hook is `homeportPurge()` unless you installed another. With a Laravel or Go
214
+ With `RSC_PURGE_URL` set, the hook is `homeportPurge()`, posting
215
+ `{"tags": [...]}` there, unless you installed another. On Homeport there is
216
+ nothing to set: it gives its apps `HOMEPORT_PURGE_URL`, which is read when
217
+ `RSC_PURGE_URL` is not. `RSC_PURGE_URL` is read from `@rsc-kit/core` 0.30.53,
218
+ `rsc-kit/go` v0.16.1 and `rsc-kit/laravel` 0.20.1; before those, only
219
+ `HOMEPORT_PURGE_URL` is. With a Laravel or Go
216
220
  backend, the change is made there - `Rsc::changed()`, `reg.Changed()` - and
217
221
  never passes through the engine, so the backend posts the purge itself; both
218
- do when `HOMEPORT_PURGE_URL` is set. A tag with a comma or a space cannot go in the header, and
222
+ do when `RSC_PURGE_URL` is set. A tag with a comma or a space cannot go in the header, and
219
223
  is left out with a warning.
220
224
 
221
225
  Homeport's edge is stricter about what it keeps than the page's headers alone
package/guides/go.md CHANGED
@@ -50,9 +50,21 @@ if err != nil {
50
50
 
51
51
  mux := http.NewServeMux()
52
52
  mux.Handle("POST /__rsc/host-call", callback)
53
- http.ListenAndServe("127.0.0.1:8080", mux)
53
+
54
+ // PORT when the platform names one, 8080 otherwise, on every address: a
55
+ // host that sends backend urls straight here (backendPaths) reaches it at
56
+ // the machine's own address, not loopback. RSC_BACKEND stays
57
+ // http://127.0.0.1:8080 - the renderer still calls over loopback.
58
+ http.ListenAndServe(":"+cmp.Or(os.Getenv("PORT"), "8080"), mux)
54
59
  ```
55
60
 
61
+ It listens on every address, not loopback alone. Once an app names
62
+ [`backendPaths`](/hosts/backend-answered-pages/), a proxy in front may send
63
+ those urls straight to the backend at the machine's own address, and a
64
+ backend bound to `127.0.0.1` can't be reached. The secret is what guards
65
+ the host-call endpoint, and the proxy refuses it from outside
66
+ ([deployment](/hosts/deployment/#sending-the-backends-urls-past-the-renderer)).
67
+
56
68
  The renderer forwards any url its route tree does not own to `RSC_BACKEND`,
57
69
  so a Go route on that mux — `/login`, a webhook, an upload — is reachable at
58
70
  the renderer's origin too.
@@ -102,6 +114,7 @@ Never set `RSC_DEBUG` in production: a trace names your files.
102
114
  | --- | --- | --- |
103
115
  | `RSC_BACKEND` | the renderer | Where the Go endpoint is, e.g. `http://127.0.0.1:8080`. Falls back to `APP_URL`. Read from `.env` by `vite`, and from the environment by the built server; the url forwarding is fixed at build time. |
104
116
  | `RSC_HOST_CALL_SECRET` | both | The shared secret. The renderer sends it; your Go code passes it to `NewCallbackHandler`. Without it neither side talks. |
117
+ | `RSC_HOST_CALL_SECRET_PREVIOUS` | Go | The secret being rotated away from, answered as well while set, so a rotation refuses no call. [Rotating one](/hosts/deployment/). |
105
118
  | `RSC_HOST_CALL_PATH` | the renderer | The endpoint's path. Default `/__rsc/host-call`. |
106
119
  | `RSC_DEBUG` | Go | `1` sends a failure's trace with its answer. Development only. |
107
120
  | `RSC_TRUST_FORWARDED` | the renderer | `1` passes the visitor's `X-Forwarded-For` through to Go. Only behind a proxy you control that writes it. |
@@ -428,7 +441,7 @@ has the whole picture.
428
441
  `export const revalidate = 60` keeps a page and refreshes it behind the visitor,
429
442
  and `reg.Changed(ctx, "posts")` renders it again at once on every instance, when
430
443
  it read that tag through `cache()`. A kept page calls Go as nobody: no `Cookie`,
431
- no `Authorization`. With `HOMEPORT_PURGE_URL` set, `Changed` purges the CDN as
444
+ no `Authorization`. With `RSC_PURGE_URL` set, `Changed` purges the CDN as
432
445
  well; `reg.SetPurger` replaces it. Call it after your transaction commits.
433
446
  [ISR](/guides/isr) has the whole of it.
434
447
 
package/guides/laravel.md CHANGED
@@ -423,7 +423,7 @@ sent after the transaction commits.
423
423
  `export const revalidate = 60` keeps a page and refreshes it behind the visitor,
424
424
  and `Rsc::changed('posts')` renders it again at once on every instance, when it
425
425
  read that tag through `cache()`. A kept page calls PHP as nobody, so
426
- `auth()->user()` is null there. With `HOMEPORT_PURGE_URL` set, `Rsc::changed()`
426
+ `auth()->user()` is null there. With `RSC_PURGE_URL` set, `Rsc::changed()`
427
427
  purges the CDN as well, after the transaction commits and the response has gone.
428
428
  [ISR](/guides/isr) has the whole of it.
429
429
 
@@ -577,7 +577,9 @@ the assets — which travels with the deployment; nothing in it is read from the
577
577
  source tree at runtime.
578
578
 
579
579
  Both processes read `RSC_HOST_CALL_SECRET`, and the renderer also needs
580
- `APP_URL` (or `RSC_BACKEND`) to know where Laravel is. Run it with the app's
580
+ `APP_URL` (or `RSC_BACKEND`) to know where Laravel is. To rotate the secret,
581
+ Laravel takes `RSC_HOST_CALL_SECRET_PREVIOUS` as well
582
+ ([rotating one](/hosts/deployment/)). Run it with the app's
581
583
  `.env` and it has both:
582
584
 
583
585
  ```ini title="/etc/systemd/system/rsc-renderer.service"
@@ -333,7 +333,7 @@ network. Off by default, and covered in [Offline](/guides/offline#surviving-with
333
333
  The generated `package.json` pins an exact version rather than a range:
334
334
 
335
335
  ```json
336
- "nitro": "3.0.260903-beta"
336
+ "nitro": "3.0.261103-rc"
337
337
  ```
338
338
 
339
339
  Nitro's own `latest` tag is a dated prerelease, and it sorts **above** the plain
@@ -92,6 +92,12 @@ unconfigured secret has to be rejected before the comparison rather than
92
92
  trusted to it. Better still, do not register the endpoint at all when no
93
93
  secret is configured — absent, not open.
94
94
 
95
+ **Answer the previous secret too, while `RSC_HOST_CALL_SECRET_PREVIOUS` is
96
+ set.** That is how the secret rotates without a refused call: the backend takes
97
+ the new one and the old, the renderers move to the new one, then the old is
98
+ removed ([rotating one](/hosts/deployment/)). Compare it the same way, unset
99
+ matching nothing, and never send it.
100
+
95
101
  ## The reply
96
102
 
97
103
  JSON, and the fields keep the outcomes apart so the renderer never reads a
@@ -314,7 +320,7 @@ so no authorization is needed here beyond the secret.
314
320
  **A purge, when a CDN keeps pages.** A `revalidate` page goes out with the
315
321
  `Cache-Tag` of every `cache()` answer it used, and the names you change are
316
322
  those tags. A change you make never passes through the renderer, so when
317
- `HOMEPORT_PURGE_URL` is set, your backend tells the CDN itself: after the
323
+ `RSC_PURGE_URL` is set, your backend tells the CDN itself: after the
318
324
  version has moved - after the transaction commits, and after the call has
319
325
  answered if you can - post
320
326
 
@@ -410,6 +416,12 @@ is the one it cannot.
410
416
  - **Answer within 30 seconds.** A render blocked on a host that never answers
411
417
  is a hung request, and the renderer gives up at 30s (`timeoutMs` on
412
418
  `httpHostCalls`, for a host that embeds the engine itself).
419
+ - **Starting after the renderer is fine.** A refused connection is tried again
420
+ for up to 2 seconds, because a refused connection means the call never
421
+ reached you, so nothing runs twice. This covers a backend started beside
422
+ the renderer in one container, still coming up when the first page renders.
423
+ Nothing else is retried: a timeout or a reset may have run the call
424
+ (`refusedRetryMs` on `httpHostCalls`; 0 turns it off).
413
425
  - **One process is not enough if you proxy.** A server that proxies a page
414
426
  to the renderer holds a worker for the whole render, and the render calls
415
427
  back to that same server for its data. With one worker, nobody is left to
@@ -461,13 +473,13 @@ visitor to `/conformance-login`, and `conformance-page`, which passes only when
461
473
  the page it is asked about is `/conformance/orders/7` with `{order}` bound to
462
474
  `"7"`. Then serve them and run:
463
475
 
464
- Start it with `HOMEPORT_PURGE_URL=http://127.0.0.1:8790/`, where the suite
465
- listens for its purges, then:
476
+ Start it with `RSC_PURGE_URL=http://127.0.0.1:8790/`, where the suite
477
+ listens for its purges, and `RSC_HOST_CALL_SECRET_PREVIOUS=old`, then:
466
478
 
467
479
  ```sh
468
480
  npx -y -p @rsc-kit/core rsc-kit-conformance \
469
481
  --endpoint http://127.0.0.1:8123/__rsc/host-call --secret test \
470
- --manifest rsc-host.json --purge-port 8790
482
+ --previous-secret old --manifest rsc-host.json --purge-port 8790
471
483
  ```
472
484
 
473
485
  It checks the whole contract on this page:
@@ -483,7 +495,9 @@ It checks the whole contract on this page:
483
495
  a browser can check, and a refusal landing on its field;
484
496
  - **the request** - `Cookie` and `Authorization` forwarded, the visitor's
485
497
  address in place of the renderer's, a cookie set by a
486
- call reaching the page, no secret or the wrong one refused with 403, an
498
+ call reaching the page, no secret or the wrong one refused with 403, the
499
+ previous one answered while `RSC_HOST_CALL_SECRET_PREVIOUS` names it (so a
500
+ rotation fails no call; without `--previous-secret` this fails), an
487
501
  unknown function 404, a malformed body 400;
488
502
  - **batches** - every call answered, a refusal only its own, and more than 50
489
503
  refused with 413 before any runs;
@@ -493,7 +507,7 @@ It checks the whole contract on this page:
493
507
  - **live data** - a name never changed at 0, a change moving it to a time in
494
508
  milliseconds that never comes round again, only the names that differ
495
509
  answered, and a held call bounded by `wait`;
496
- - **purges** - a change posted to `HOMEPORT_PURGE_URL` as its tag, as JSON,
510
+ - **purges** - a change posted to `RSC_PURGE_URL` as its tag, as JSON,
497
511
  only once the version has moved. Without `--purge-port` these fail: every
498
512
  adapter purges.
499
513
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsc-kit/mcp",
3
- "version": "0.30.52",
3
+ "version": "0.30.54",
4
4
  "description": "An MCP server over what an rsc-kit build decided: the routes, why each one is static or not, and what it costs the browser.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@modelcontextprotocol/sdk": "^1.30.0",
37
- "create-rsc-kit": "^0.30.52",
37
+ "create-rsc-kit": "^0.30.54",
38
38
  "zod": "^3.25"
39
39
  },
40
40
  "devDependencies": {