@rsc-kit/mcp 0.32.0 → 0.34.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/guides/domains.md CHANGED
@@ -26,30 +26,71 @@ whole host. The site's own hosts — the one in the root layout's
26
26
  nothing, so the apex keeps path routing and an app adds tenants without moving
27
27
  a file. `localhost` and an ip address are always the site's own.
28
28
 
29
- Nothing to configure for that: `metadataBase` names the apex, and a
30
- directory does the rest. `hosts` is for a name that is neither the apex nor a
31
- subdomain of it and is still the site rather than a tenant — a staging or
32
- internal name, or a second brand domain:
33
-
34
- ```ts title="vite.config.ts"
35
- rscKit({ hosts: ['app.internal', 'example.co.uk'] })
36
- ```
37
-
38
- Listing a subdomain there makes it the site by path instead of a tenant —
29
+ Listing a subdomain in `hosts` makes it the site by path instead of a tenant —
39
30
  the "app on `app.example.com`, marketing on the apex" split — which is a
40
31
  choice, not a requirement.
41
32
 
42
33
  And only when a route could answer it: a `[domain]` (or `[host]`) directory at
43
34
  the top of `app/`, or a directory named for the host. Any other parameter
44
35
  name at the top of `app/` — `[collection]`, `[slug]` — is a path segment, as
45
- it is in Next. An app with a `metadataBase` and no tenant tree routes every
46
- host by path, and a proxy that forwards to the app by an internal name is not
36
+ it is in Next. An app with no tenant tree routes every host by path, and a proxy that forwards to the app by an internal name is not
47
37
  read as a tenant called `internal`.
48
38
 
39
+ A subdomain of the site with no directory of its name falls back the same
40
+ way: with no `app/merchant/`, `merchant.example.com/` serves the home page.
41
+ That keeps a preview deployment under the production domain working. The dev
42
+ server says so once per host, naming the directory to add:
43
+
44
+ ```
45
+ [rsc-kit] merchant.example.test has no app/merchant/ - served by path, as the site's own. Add app/merchant/ to route the subdomain there.
46
+ ```
47
+
49
48
  The visitor's url is untouched: `acme.example.com/settings` stays in the
50
49
  address bar, and a link to `/billing` on that page goes to
51
50
  `acme.example.com/billing`. Only the match changed.
52
51
 
52
+ ## The one step: name the site's host
53
+
54
+ The router has to know which host is the site, and it learns it from either
55
+ the root layout's `metadataBase` or `rscKit({ hosts })` — one is enough, and
56
+ neither is needed for anything else here. Name neither and no host is the
57
+ site's: `merchant.example.com` is then a foreign host whose segment is the
58
+ whole name, no directory matches it, and it is served by path — the home page,
59
+ with nothing said.
60
+
61
+ `hosts` is the one to reach for when the address is in the environment, as a
62
+ Laravel app's is in `APP_URL`. It is read by the build, so the address of the
63
+ machine running it — `example.test` under Herd, the real domain in
64
+ production — is the one named:
65
+
66
+ ```ts title="vite.config.ts"
67
+ import { defineConfig, loadEnv } from 'vite'
68
+
69
+ export default defineConfig(({ mode }) => {
70
+ const env = loadEnv(mode, process.cwd(), '')
71
+
72
+ return {
73
+ plugins: [rscKit({ hosts: [new URL(env.APP_URL).host] })],
74
+ }
75
+ })
76
+ ```
77
+
78
+ `metadataBase` does the same when it is written as a literal, but it is for
79
+ metadata — the base a relative Open Graph image or canonical url is made
80
+ absolute against — and a computed one is not read for routing. An app with no
81
+ such metadata needs none.
82
+
83
+ `hosts` also takes a name that is neither the apex nor a subdomain of it and
84
+ is still the site rather than a tenant — a staging or internal name, or a
85
+ second brand domain:
86
+
87
+ ```ts title="vite.config.ts"
88
+ rscKit({ hosts: ['app.internal', 'example.co.uk'] })
89
+ ```
90
+
91
+ A directory then does the rest: `app/merchant/` is all `merchant.example.com`
92
+ needs.
93
+
53
94
  ## A tenant tree
54
95
 
55
96
  Whether the tenant exists is a guard, so it goes in `middleware.ts`. It runs
@@ -100,7 +141,7 @@ one's, and it is rendered again when one of its own values changes:
100
141
  tenant layout for globex, while the root layout above it stays mounted.
101
142
 
102
143
  `[domain]` is an ordinary dynamic segment: `params.domain` in every page and
103
- layout below it, `route('/[domain]/settings', { domain })` typed, `loading.tsx`
144
+ layout below it, `hostUrl(domain, '/settings')` to link to it (below), `loading.tsx`
104
145
  and `error.tsx` where you put them. A directory named for a host,
105
146
  `app/admin/`, wins over `[domain]` the way a static segment wins over a
106
147
  parameter anywhere else.
@@ -112,6 +153,46 @@ reached as `example.com/acme`. Next has no such guard — its `[domain]` folder
112
153
  matches any path once the rewrite is in place — which is why Next apps tuck
113
154
  the tenant tree under a route group.
114
155
 
156
+ ## Linking to another host
157
+
158
+ A typed `href` is a folder path: `/merchant/orders` is the page at
159
+ `app/merchant/orders`, and that is the url a link to it goes to — the site,
160
+ by path. Both addresses work, so nothing breaks; but when the page is meant
161
+ to be seen on `merchant.example.com`, say so with `hostUrl`:
162
+
163
+ ```tsx title="src/app/page.tsx"
164
+ import { Link } from '@rsc-kit/core/link';
165
+ import { hostUrl } from '@rsc-kit/core/routes';
166
+
167
+ <Link href={hostUrl('merchant', '/orders')}>Orders</Link> // //merchant.example.com/orders
168
+ <Link href={hostUrl(tenant.slug, '/settings')}>Settings</Link> // //testbrand.example.com/settings
169
+ <Link href={hostUrl('acme.com', '/settings')}>Settings</Link> // //acme.com/settings
170
+ <Link href={hostUrl('/pricing')}>Pricing</Link> // //example.com/pricing, from a subdomain
171
+ ```
172
+
173
+ - The first argument autocompletes to the top-level folders of `app/`, and
174
+ takes any other string too: a tenant's subdomain, read from the database
175
+ at request time. A name with a dot is a whole domain, used as written.
176
+ - The path is typed by what that host answers. For a folder it is the pages
177
+ under it, with the folder taken off — `hostUrl('merchant', '/orders')`, not
178
+ `'/merchant/orders'`. For any other name it is the tenant tree's paths.
179
+ - With one argument it is the site itself: the link back from a subdomain,
180
+ where a plain `/pricing` would stay on the subdomain.
181
+
182
+ The site's host is the first one `rscKit({ hosts })` names (a literal
183
+ `metadataBase` otherwise), port and all, so `hosts: [new URL(env.APP_URL).host]`
184
+ gives `merchant.example.test` under Herd and `merchant.example.com` in
185
+ production. With no host named, a folder's url is its path,
186
+ `/merchant/orders`, since every page is then reached by path.
187
+
188
+ It is the same string on the server and in the browser, so the link hydrates
189
+ as it was rendered, and it works in `visit()` and `redirect()` too. On the
190
+ host it names already, Link navigates without a reload; to another host it is
191
+ a full page load, as a link to another origin always is.
192
+
193
+ Nothing redirects between the two addresses. When one of them should not be
194
+ reachable, a `redirect()` in that folder's `middleware.ts` says which.
195
+
115
196
  ## Domains in a database
116
197
 
117
198
  `generateStaticParams` on the tenant route is the hook. The listed hosts are
@@ -132,9 +213,12 @@ for that tenant and stored for none, exactly as any page is.
132
213
 
133
214
  ## Locally
134
215
 
135
- Keep `metadataBase` as the production host. `localhost` and an ip address
136
- are always the site's own, so the dev server routes by path as it always
137
- did, and nothing changes until a `[domain]` directory exists. To try a tenant
216
+ `localhost` and an ip address are always the site's own, so a dev server
217
+ opened on one routes by path as it always did. A local name is not:
218
+ `example.test` under Herd or Valet is a host like any other, and
219
+ `merchant.example.test` reaches `app/merchant/` only when `example.test` is
220
+ named in `hosts` — which reading `APP_URL`, as above, does. A `metadataBase`
221
+ fixed to the production host names only that one. To try a tenant
138
222
  without DNS, send the host the router will see in production:
139
223
 
140
224
  ```bash
package/guides/go.md CHANGED
@@ -216,7 +216,9 @@ Caused in the backend by Backend panic(runtime.boundsError): …
216
216
  at backend/main.go:64 main.main.func3
217
217
  ```
218
218
 
219
- Never in production: a trace names your files.
219
+ A server action that fails this way opens Vite's error overlay on the page in
220
+ development, with the same type and frames; frames from the module cache are
221
+ counted rather than listed. Never in production: a trace names your files.
220
222
 
221
223
  ### Refusing
222
224
 
@@ -51,6 +51,15 @@ adds Tailwind, and when `components.json` is already there it asks only
51
51
  whether to set the flag. Running `shadcn init` yourself
52
52
  leaves it `false`; set it to `true` by hand.
53
53
 
54
+ shadcn writes its theme, the colours and the dark variant, to the stylesheet
55
+ `components.json` names, and `shadcn add` keeps writing there. That file must
56
+ be one the app loads: the root layout's `styles.css`, or a file it imports. In
57
+ a Laravel app, `init` makes `styles.css` import `resources/css/app.css` when
58
+ that file already imports Tailwind, so the theme there, and the one shadcn's
59
+ own `init` writes there, reaches the pages. A `components.json` that names a
60
+ file the app never loads is reported; Blade's `@vite` loaded it before, and
61
+ nothing does now.
62
+
54
63
  Use `--yes`, not `-y`, with `bun create`: Bun reads `-y` as its own flag and
55
64
  refuses it. `bunx create-rsc-kit my-app -y` accepts either.
56
65
 
package/guides/laravel.md CHANGED
@@ -41,6 +41,20 @@ php artisan rsc:install
41
41
  JavaScript half. Nothing you already have is overwritten: where a file exists,
42
42
  the exact edit is printed for you to make instead.
43
43
 
44
+ In a terminal, `init` asks the questions that are the app's to answer:
45
+
46
+ - the React Compiler;
47
+ - Tailwind CSS, unless it is already there;
48
+ - shadcn/ui, when Tailwind is there;
49
+ - oxlint, unless oxlint or ESLint already is.
50
+
51
+ It asks nothing about validation or typed environment variables, because
52
+ Laravel already does both: a FormRequest validates, and `.env` holds the
53
+ settings. `composer require` can't ask anything itself, since Composer never
54
+ runs a package's own scripts, so `rsc:install` is where the questions are
55
+ asked. Run without a terminal, as in CI, it takes the defaults and adds no
56
+ linter.
57
+
44
58
  What lands:
45
59
 
46
60
  | | |
@@ -115,6 +129,12 @@ Part of starting Vite rather than a step to remember: a stale manifest names a
115
129
  method that has since been renamed, and nothing fails until the browser calls
116
130
  it.
117
131
 
132
+ It is rewritten every time, so it is not committed: `init`, and
133
+ `create-rsc-kit` for an app with a backend, add `rsc-host.json` to
134
+ `.gitignore` beside the generated stubs. A CI step that
135
+ type-checks before building runs `php artisan rsc:host-manifest` first, or
136
+ `rpc()` has no names to check against.
137
+
118
138
  If you had customised `dev` or `build` yourself, `init` leaves them alone and
119
139
  puts the renderer's at `rsc:dev` and `rsc:build`, and says so.
120
140
 
@@ -288,6 +308,12 @@ class, message and trace, and the renderer shows them under its own stack as
288
308
  the error's cause - so a failed `rpc()` in development points at the line of
289
309
  PHP that threw.
290
310
 
311
+ A server action that fails the same way opens Vite's error overlay on the page,
312
+ in development only. It leads with the exception's class and message, then names the
313
+ first frame in your own code, such as `app/Rsc/Actions/Notification.php:20`.
314
+ Laravel's own frames are counted rather than listed. In production the page
315
+ gets a bare 500 and the trace stays in Laravel's log.
316
+
291
317
  ## Server actions
292
318
 
293
319
  A class under `app/Rsc/Actions/` is a server action. `rsc:host-manifest`
@@ -371,6 +371,12 @@ with something you put in `public/` yourself. The favicon is the exception —
371
371
  it is served at `/favicon.ico`, because browsers ask for that url whatever the
372
372
  markup says.
373
373
 
374
+ A `public/favicon.ico` is answered at that url before the request reaches the
375
+ app, so it hides yours. Laravel's skeleton ships an empty one, which Herd
376
+ answers with a 404 — the console says the favicon is not found on an app that
377
+ has one. Dev start and the build warn when `public/` holds a file at a url the
378
+ app serves, and name both; delete the one in `public/`.
379
+
374
380
  :::note[Set `metadataBase`]
375
381
  The image is emitted as `/_app/opengraph-image.png`, which a scraper will not
376
382
  fetch. With `metadataBase` on the root layout it goes out absolute — see [the
package/guides/routing.md CHANGED
@@ -68,6 +68,12 @@ visitor. `searchParams` works the same way.
68
68
  Parenthesised directories like `(marketing)` group files without adding a URL
69
69
  segment. `app/(marketing)/pricing/page.tsx` serves `GET /pricing`.
70
70
 
71
+ Since a group adds nothing to the URL, two groups can put a page at the same
72
+ URL: `app/(home)/page.tsx` and `app/(preview)/(home)/page.tsx` are both `/`.
73
+ That stops the dev server and the build with an error naming both files, so
74
+ one of them can't silently go unreachable. Give one a directory that is part
75
+ of the URL, like `app/(preview)/home/page.tsx`.
76
+
71
77
  ## Fetching data
72
78
 
73
79
  A server component runs on the server, so it reads its data the way any
@@ -131,6 +131,12 @@ A hand-written file beside the root layout is served at the root as it is:
131
131
  copies them beside the client output. A file and a function for the same url
132
132
  is a build error naming both.
133
133
 
134
+ A file of the same name in `public/` wins over both: whatever serves
135
+ `public/` — Herd, nginx in front of Laravel, the server's static handler —
136
+ answers before the app is reached. Laravel's skeleton ships a
137
+ `public/robots.txt`, so a `robots.ts` beside the root layout is never seen
138
+ until it is deleted. Dev start and the build warn, naming both files.
139
+
134
140
  ## Coming from Next
135
141
 
136
142
  `app/robots.ts` and `app/sitemap.ts` carry across unchanged. `app/llms.txt`
@@ -166,6 +166,11 @@ development - Laravel's `app.debug`, Go's `CallbackHandler.Debug` - never in
166
166
  production, where it would name your files to whoever caused the error, and
167
167
  never with a refusal, which is an answer and not a bug.
168
168
 
169
+ In development, a server action that fails this way opens Vite's error overlay
170
+ in the browser: the `type` and `message` as its heading, the first frame not under
171
+ `vendor/`, `node_modules/` or `pkg/mod/` as its file, and the rest beneath. A
172
+ frame is easiest to read as `path:line` followed by what was running there.
173
+
169
174
  ## Batches
170
175
 
171
176
  Calls issued in the same tick of a render — sibling components each awaiting
@@ -510,6 +515,10 @@ It checks the whole contract on this page:
510
515
  - **purges** - a change posted to `RSC_PURGE_URL` as its tag, as JSON,
511
516
  only once the version has moved. Without `--purge-port` these fail: every
512
517
  adapter purges.
518
+ - **debug** - with `--debug`, for an adapter started with its debug on, a
519
+ failure carrying `debug` with a type, a message and at least one frame.
520
+ Without the flag it is not checked: a backend sends a trace only in
521
+ development.
513
522
 
514
523
  It exits non-zero on any failure, so it can gate your CI. The Go adapter's
515
524
  `cmd/conformance` and Laravel's `tests/Conformance` are working fixtures to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsc-kit/mcp",
3
- "version": "0.32.0",
3
+ "version": "0.34.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.32.0",
37
+ "create-rsc-kit": "^0.34.0",
38
38
  "zod": "^3.25"
39
39
  },
40
40
  "devDependencies": {