@rsc-kit/mcp 0.34.0 → 0.36.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.
- package/dist/recipes.js +31 -2
- package/dist/recipes.js.map +1 -1
- package/guides/deployment.md +66 -0
- package/guides/go.md +5 -0
- package/guides/laravel.md +12 -0
- package/guides/static-generation.md +5 -0
- package/guides/where-it-runs.md +5 -0
- package/guides/your-own-backend.md +8 -0
- package/package.json +2 -2
package/guides/deployment.md
CHANGED
|
@@ -394,6 +394,72 @@ caching](/guides/edge-caching) covers what that buys. What rsc-kit puts in it:
|
|
|
394
394
|
the postponed state from its own build, so it never parses what a caller
|
|
395
395
|
wrote.
|
|
396
396
|
|
|
397
|
+
### The files: `.output/files.json`
|
|
398
|
+
|
|
399
|
+
A server in front of the app — nginx, a CDN, a PHP front controller — can
|
|
400
|
+
answer the app's files from disk without asking it. Everything in the public
|
|
401
|
+
directory is served before the renderer is reached, so nothing of the app runs
|
|
402
|
+
for a file: no `middleware.ts`, no `route.ts`, and `rscKit({ headers })` is a
|
|
403
|
+
page's, not a file's. Every server build says what that takes:
|
|
404
|
+
|
|
405
|
+
```json
|
|
406
|
+
{
|
|
407
|
+
"v": 1,
|
|
408
|
+
"root": "public",
|
|
409
|
+
"files": ["/assets/app-1a2b3c4d.js", "/favicon.ico", "/sw.js"],
|
|
410
|
+
"precompressed": ["br", "gzip", "zstd"],
|
|
411
|
+
"headers": [
|
|
412
|
+
{ "match": "/_app/**", "headers": { "cache-control": "public, max-age=0, must-revalidate" } },
|
|
413
|
+
{ "match": "/assets/**", "headers": { "cache-control": "public, max-age=31536000, immutable" } },
|
|
414
|
+
{ "match": "/sw.js", "headers": { "cache-control": "public, max-age=0, must-revalidate" } },
|
|
415
|
+
{ "match": "/sw-app.js", "headers": { "cache-control": "public, max-age=0, must-revalidate" } },
|
|
416
|
+
{ "match": "/manifest.webmanifest", "headers": { "cache-control": "public, max-age=0, must-revalidate" } }
|
|
417
|
+
],
|
|
418
|
+
"middleware": false
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
It is written to the build's output directory, beside `rsc-kit.json` and
|
|
423
|
+
`edge.json`: `.output/` for the `bun`, `node` and Cloudflare Workers presets,
|
|
424
|
+
`.vercel/output/` on Vercel - wherever Nitro's `output.dir` is.
|
|
425
|
+
|
|
426
|
+
- **`files`** is every file a request may be answered with, by url path,
|
|
427
|
+
relative to `root` (which is relative to `files.json`). A path is the file's
|
|
428
|
+
name as it is on disk, not percent-encoded: decode the request's path before
|
|
429
|
+
looking it up, as the app does. Under a `baseURL` the paths carry it. Nothing
|
|
430
|
+
else under `root` is public: the stored pages a Workers build copies there,
|
|
431
|
+
a platform's `_headers` and `_redirects`, and a server bundle built inside
|
|
432
|
+
the public directory are not in it.
|
|
433
|
+
- **`precompressed`** names the encodings a file may also exist in, as a
|
|
434
|
+
sibling with the suffix (`/sw.js.br`, `.gz`, `.zst`). Send it with
|
|
435
|
+
`Content-Encoding` and `Vary: Accept-Encoding` when the request accepts it.
|
|
436
|
+
- **`headers`** are what a file goes out with beyond its `Content-Type`: each
|
|
437
|
+
applies to an exact path, or, ending in `/**`, to every path under it.
|
|
438
|
+
Apply every entry that matches, in order; a later one replaces an earlier
|
|
439
|
+
one's header of the same name. They are the route rules the build's own
|
|
440
|
+
server uses, including any the app sets on `/**`, so a front that sends them
|
|
441
|
+
answers exactly as the app would. The files rsc-kit writes under a fixed
|
|
442
|
+
name - `/sw.js`, `/sw-app.js` (your `src/app/sw.js`), `/manifest.webmanifest`
|
|
443
|
+
and everything under `/_app/` - are `public, max-age=0, must-revalidate`, and
|
|
444
|
+
their ETag makes each check a 304: a service worker kept by a heuristic cache
|
|
445
|
+
installs the previous deploy's file list against the new server. A file no
|
|
446
|
+
entry matches, such as your own `public/favicon.ico`, gets no
|
|
447
|
+
`Cache-Control`; add a route rule if you want one.
|
|
448
|
+
- **`middleware`** is always `false`, and says so rather than leave a front
|
|
449
|
+
to wonder whether a guard is skipped.
|
|
450
|
+
|
|
451
|
+
The list fails closed. A route rule the manifest cannot state - a pattern
|
|
452
|
+
like `/:name.js`, a `redirect`, `cors` or `proxy` rule, a `headers: false`
|
|
453
|
+
reset - would make a front's answer differ from the app's with nobody seeing
|
|
454
|
+
it, so a file under one is left out of `files` and its request goes to the
|
|
455
|
+
app. The build checks each file against Nitro's own matcher, and says which
|
|
456
|
+
it left out and why.
|
|
457
|
+
|
|
458
|
+
A file from a previous deploy is not in the list and need not be kept: an
|
|
459
|
+
open tab that asks for a chunk the new server no longer has reloads the
|
|
460
|
+
document, and a page request from the old build is answered 409 and reloads
|
|
461
|
+
once.
|
|
462
|
+
|
|
397
463
|
Do not work the list out from the files in `.output/server/rsc-static/`. A
|
|
398
464
|
guarded page has a shell on disk too, `_team_` cannot say whether it was a
|
|
399
465
|
parameter or a folder of that name, and the folder's layout is not a contract.
|
package/guides/go.md
CHANGED
|
@@ -152,6 +152,11 @@ const orders = await rpc('Orders.recent', 5) // Order[]; rpc('Orders.recent',
|
|
|
152
152
|
unless it says what it writes with a `JSONSchema` method (below).
|
|
153
153
|
- **Empty, not null.** A nil slice or map in the result is sent as `[]` or
|
|
154
154
|
`{}`, as its type says; only a nil pointer is `null`.
|
|
155
|
+
- **Who is asking.** `rsckit.ClientIP(ctx)` and `rsckit.ClientUserAgent(ctx)`
|
|
156
|
+
are the visitor's address and browser, sent by the renderer and believed
|
|
157
|
+
because the call carried the secret. `r.RemoteAddr` and `r.UserAgent()`
|
|
158
|
+
would be the renderer's own, the same for every visitor. Both are empty
|
|
159
|
+
when there is no visitor: a build, or a page stored for everyone.
|
|
155
160
|
|
|
156
161
|
### A type that writes its own JSON
|
|
157
162
|
|
package/guides/laravel.md
CHANGED
|
@@ -589,6 +589,18 @@ and session. So the vocabulary means what it does in `routes/web.php`:
|
|
|
589
589
|
string.
|
|
590
590
|
- `request()` and the `Request` a middleware is handed are the page's, not the
|
|
591
591
|
host call's.
|
|
592
|
+
- `auth` sends a guest to `route('login')`, and the page redirects there. An
|
|
593
|
+
app with no route of that name fails with "Route [login] not defined", so
|
|
594
|
+
say where guests go in `bootstrap/app.php`. When the login page is on
|
|
595
|
+
another host (a `merchant.` subdomain signing in on the main site), give the
|
|
596
|
+
full url:
|
|
597
|
+
|
|
598
|
+
```php title="bootstrap/app.php"
|
|
599
|
+
->withMiddleware(function (Middleware $middleware): void {
|
|
600
|
+
$middleware->redirectGuestsTo('/login');
|
|
601
|
+
// or: fn () => config('app.url').'/login'
|
|
602
|
+
})
|
|
603
|
+
```
|
|
592
604
|
|
|
593
605
|
It fails
|
|
594
606
|
closed: anything that is not a literal `true` is a refusal, so a middleware
|
|
@@ -185,6 +185,11 @@ The generated server does this for you: the build freezes pages into
|
|
|
185
185
|
`.output/server/rsc-static`, and the entry reads them from beside itself.
|
|
186
186
|
Nothing found, and the request falls through to a live render.
|
|
187
187
|
|
|
188
|
+
On other presets they go wherever Nitro writes the server, since that is what the
|
|
189
|
+
platform deploys: inside the function on Vercel
|
|
190
|
+
(`.vercel/output/functions/__server.func/rsc-static`) and Netlify, and among
|
|
191
|
+
the static assets on Cloudflare, read back through the assets binding.
|
|
192
|
+
|
|
188
193
|
## A value that must not be frozen
|
|
189
194
|
|
|
190
195
|
A stored page keeps whatever it rendered, which includes whatever the clock
|
package/guides/where-it-runs.md
CHANGED
|
@@ -37,6 +37,11 @@ this package — a preset is a string, not an integration.
|
|
|
37
37
|
| `node` | `node` | `.output/server/index.mjs`, run with `node` |
|
|
38
38
|
| `worker` | `cloudflare_module` | a Worker, plus the `wrangler.json` and `_headers` Nitro generates |
|
|
39
39
|
|
|
40
|
+
On Cloudflare it is Workers, not Pages. Cloudflare is moving Pages projects to
|
|
41
|
+
Workers, and the `cloudflare_pages` preset's build does not run: every page
|
|
42
|
+
answers a bare 500. A Workers build serves its static files from the same
|
|
43
|
+
deploy, which is what Pages was for.
|
|
44
|
+
|
|
40
45
|
Everything else — Vercel, Netlify, Azure, Deno, AWS Amplify — is the same
|
|
41
46
|
change:
|
|
42
47
|
|
|
@@ -55,6 +55,7 @@ X-Rsc-Host-Secret: a-long-random-string
|
|
|
55
55
|
Cookie: <the visitor's, forwarded unchanged>
|
|
56
56
|
Authorization: <likewise, if the page request had one>
|
|
57
57
|
X-Rsc-Client-Ip: <the visitor's address, as the renderer's server saw it>
|
|
58
|
+
X-Rsc-Client-User-Agent: <the visitor's User-Agent>
|
|
58
59
|
|
|
59
60
|
{ "function": "Orders.recent", "args": [5] }
|
|
60
61
|
```
|
|
@@ -76,6 +77,13 @@ the renderer's and the same for every visitor. A throttle keyed on that puts
|
|
|
76
77
|
everyone in one bucket. Absent when there is no visitor: a build, or a page
|
|
77
78
|
stored for everyone.
|
|
78
79
|
|
|
80
|
+
**`X-Rsc-Client-User-Agent` is the visitor's browser**, for whatever you keep
|
|
81
|
+
about a request: a log, a list of signed-in devices, an audit entry. The
|
|
82
|
+
call's own `User-Agent` is the renderer's runtime, the same for everyone.
|
|
83
|
+
Believe it on the same terms as the address, and expect it absent on the same
|
|
84
|
+
occasions. Laravel puts it where `$request->userAgent()` reads; Go's is
|
|
85
|
+
`rsckit.ClientUserAgent(ctx)`.
|
|
86
|
+
|
|
79
87
|
**Arguments that do not fit the function are a failure, not a refusal.**
|
|
80
88
|
Too few, or a value your language cannot decode into the parameter's type:
|
|
81
89
|
answer 500 with `error`, as Go and Laravel do. The renderer's calls are typed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsc-kit/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
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.
|
|
37
|
+
"create-rsc-kit": "^0.36.0",
|
|
38
38
|
"zod": "^3.25"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|