You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/1.guide/14.security.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,7 @@ For your own auth UI, disable built-in handling with `otpParam: false`, then cal
75
75
76
76
-**Stay on loopback.** Bind to a routable address only intentionally, and require authentication when you do.
77
77
-**Keep `auth: false` local.** The hosted bridges (`devframeViteBridge`, `@devframes/next`'s handler) gate their side-car by default; opt out with an explicit `auth: false` only when the host framework owns the trust boundary another way.
78
-
-**The MCP route trusts same-machine callers, harden it when that's not your boundary.** The origin gate keeps browsers and remote hosts out (loopback-only, `Origin`-less rejected), so `mcp: true`is enough for a local dev tool. `Origin` proves nothing about *which* local process is calling, though, so when the route is reachable beyond loopback (a widened `allowedOrigins`, a hosted app) or exposes destructive tools, add an identity check with `mcp: { authorization }` (a bearer from an env var, or a callback). See [MCP](/adapters/mcp).
78
+
-**The MCP route trusts same-machine callers, harden it when that's not your boundary.** The origin gate keeps browsers and remote hosts out (loopback-only, `Origin`-less rejected), so the `'auto'` default - which mounts the route once agent tools exist - and `mcp: true`are enough for a local dev tool. `Origin` proves nothing about *which* local process is calling, though, so when the route is reachable beyond loopback (a widened `allowedOrigins`, a hosted app) or exposes destructive tools, add an identity check with `mcp: { authorization }` (a bearer from an env var, or a callback), or turn the route off with `mcp: false`. See [MCP](/adapters/mcp).
79
79
-**Treat tokens as secrets.** Never log the bearer token or the one-time code, or bake either into build output.
80
80
-**Authorize every handler.** Validate inputs, and mark state-changing functions `type: 'destructive'` so MCP and agent clients prompt before invoking them.
81
81
-**Origin-lock remote docks.** When a hub embeds a remote-UI dock, keep `originLock` on (the default) so its session token is only honored on a connection whose `Origin` matches the dock's own.
Copy file name to clipboardExpand all lines: docs/content/1.guide/15.agent-native.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,7 +100,9 @@ Every `ctx.rpc.sharedState` key is exposed as a `devframe://state/<key>` resourc
100
100
101
101
## Starting the MCP server
102
102
103
-
CLI:
103
+
The dev server serves the agent surface over HTTP on its own: the `mcp: 'auto'` default mounts the route at `/__mcp` once anything above exists (an `agent`-flagged RPC, a registered tool or resource) - one flagged function is the whole setup. See the [MCP adapter](/adapters/mcp#route-based-server) for forcing it on or off and hardening the route.
104
+
105
+
For a stdio server instead, via the CLI:
104
106
105
107
```sh
106
108
# Run your devtool with an MCP stdio server attached.
Copy file name to clipboardExpand all lines: docs/content/1.guide/18.hub-initiate.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ The advertised path is hub-base-absolute (`/__devframes/__ws`). Dev-reevaluated
33
33
34
34
## The namespace
35
35
36
-
The namespace serves the hub UI at `/` (the `ui.viewer` SPA, or an index document when headless) and each devframe's SPA at `<id>/` with its own `__connection.json` pointing at the shared socket. Hub-level endpoints sit alongside: `embedded.js` (the `ui.embedded` bootstrap), `__connection.json`, `__ws`, `__index.json`, `__client-imports.js`, and the opt-in `__mcp`. The route table is in the [Hub API reference](/references/hub-api#hub-namespace-routes).
36
+
The namespace serves the hub UI at `/` (the `ui.viewer` SPA, or an index document when headless) and each devframe's SPA at `<id>/` with its own `__connection.json` pointing at the shared socket. Hub-level endpoints sit alongside: `embedded.js` (the `ui.embedded` bootstrap), `__connection.json`, `__ws`, `__index.json`, `__client-imports.js`, and `__mcp` (mounted by the `'auto'` default once agent tools exist). The route table is in the [Hub API reference](/references/hub-api#hub-namespace-routes).
@@ -82,7 +82,7 @@ Registrations are validated fail-fast: one module per type (`DF8108`), an existi
82
82
83
83
The hub's **single Auth** is one gate at the shared transport for every mounted devframe, built-ins, and the MCP route; one handshake (OTP, magic link, or pre-shared token) unlocks the namespace; `auth: false` disables it for localhost.
84
84
85
-
The aggregate MCP route has its own origin gate, independent of this RPC Auth: `mcp: true`trusts same-machine callers, and `mcp: { authorization }` adds an identity check when the hub is reachable beyond loopback. A mounted devframe's own `mcp` setting is ignored: the hub exposes one aggregate route over them all, and warns ([`DF8005`](/errors/DF8005)) when a devframe asks for MCP while the hub's is off.
85
+
The aggregate MCP route mounts through the `'auto'` default once any mounted devframe (or an agent-flagged hub command) exposes agent tools; `mcp: true` forces it on, `mcp: false` off. It has its own origin gate, independent of this RPC Auth: the mounted route trusts same-machine callers, and `mcp: { authorization }` adds an identity check when the hub is reachable beyond loopback. A mounted devframe's own `mcp` setting is ignored: the hub exposes one aggregate route over them all, and warns ([`DF8005`](/errors/DF8005)) when a devframe asks for MCP while the hub set `mcp: false`.
Copy file name to clipboardExpand all lines: docs/content/1.guide/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,7 +114,7 @@ The mounted devframes share one RPC registry, state store, connection, auth gate
114
114
pnpm add devframe
115
115
```
116
116
117
-
`devframe` ships ESM-only, no Vite dependency. Adapters with optional peers (the MCP adapter needs `@modelcontextprotocol/server`) surface the requirement at import time.
117
+
`devframe` ships ESM-only, no Vite dependency. The CLI adapter's optional peer (`cac`) surfaces its requirement at import time.
`@modelcontextprotocol/server` is a peer dependency; `createMcpServer` serves `stdio` through the SDK's `serveStdio`, pinning one server instance per connection.
17
+
`createMcpServer` serves `stdio` through the MCP SDK's `serveStdio`, pinning one server instance per connection.
18
18
19
19
## Route-based server
20
20
21
-
The dev server exposes the same MCP API over HTTP, live. Whether to expose it is a hosting decision, so pass `mcp` to `createCac` when you assemble the CLI (or to `createDevServer` / `initDevframe` / `initHub` when you host it programmatically):
21
+
The dev server exposes the same MCP API over HTTP, live. The default setting is **`'auto'`**: the route mounts once the devframe exposes an agent surface (an `agent`-flagged RPC, a registered tool or resource) - flag your first function and the agent view is on. A devframe with nothing flagged mounts no route and loads no MCP code.
22
+
23
+
Pin the behavior where you host the tool - it's a hosting decision, so pass `mcp` to `createCac` when you assemble the CLI (or to `createDevServer` / `initDevframe` / `initHub` when you host it programmatically): `true` always mounts, `false` never mounts, an object customises the route:
22
24
23
25
```ts
24
26
import { createCac } from'devframe/adapters/cac'
25
27
importmyDevframefrom'./my-tool'
26
28
27
-
createCac(myDevframe, { mcp: true }).parse()
29
+
createCac(myDevframe, { mcp: true }).parse()// force on; `false` forces off; omit for 'auto'
28
30
```
29
31
30
-
The endpoint speaks Streamable-HTTP at `/__mcp` (`/__<id>/__mcp` under a host framework), sharing its origin/port. `--mcp` / `--no-mcp` override; `__connection.json` advertises it.
32
+
The endpoint speaks Streamable-HTTP at `/__mcp` (`/__<id>/__mcp` under a host framework), sharing its origin/port. `--mcp` / `--no-mcp` override per run; `__connection.json` advertises the mounted route.
31
33
32
34
The endpoint is **stateless**: it serves the [2026-07-28 revision](https://modelcontextprotocol.io/specification/2026-07-28) per request through the SDK's `createMcpHandler`, building a fresh MCP server for each request, so every HTTP request stands alone, with no `Mcp-Session-Id` to correlate. 2025-era clients are still served through the SDK's stateless legacy path.
33
35
34
36
### Origin gate, and opt-in identity
35
37
36
-
The **origin gate** guards every request: `Origin` must be loopback (or allow-listed), and `Origin`-less requests are rejected (a disallowed origin gets `403`). This is DNS-rebinding hardening that keeps browsers and remote hosts out, and it trusts same-machine callers, so `mcp: true`is all a local dev tool needs.
38
+
The **origin gate** guards every request: `Origin` must be loopback (or allow-listed), and `Origin`-less requests are rejected (a disallowed origin gets `403`). This is DNS-rebinding hardening that keeps browsers and remote hosts out, and it trusts same-machine callers - the `'auto'` default and `mcp: true`both mount origin-only, all a local dev tool needs.
37
39
38
40
`Origin` proves nothing about *who* is calling, though: a native process on the same box can send any `Origin`. When a same-machine process isn't your trust boundary (a LAN/tunnel origin, a shared/CI host, a destructive tool surface), layer on an **identity check** with `authorization`:
39
41
@@ -51,7 +53,7 @@ Never place the token in a URL, in `__connection.json`, in the instance registry
51
53
52
54
### Hosted bridges
53
55
54
-
Both bridges forward it to their side-car dev server, advertising the endpoint in `__connection.json`:
56
+
Both bridges forward the setting to their side-car dev server, advertising the mounted endpoint in `__connection.json`:
Copy file name to clipboardExpand all lines: docs/content/2.adapters/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ description: 'The lowest-level path is the standard handler, initDevframe(def, {
7
7
8
8
The lowest-level path is [the standard handler](/adapters/initiate), `initDevframe(def, { base })`: a Web Standard `(request: Request) => Promise<Response>` for any catch-all route. Every path below builds on it.
9
9
10
-
Adapters wrap it as `createXxx(def, options?)` at `devframe/adapters/<name>`. `cac`and `mcp` need an optional peer ([`cac`](https://github.com/cacjs/cac), [`@modelcontextprotocol/server`](https://github.com/modelcontextprotocol/typescript-sdk)).
10
+
Adapters wrap it as `createXxx(def, options?)` at `devframe/adapters/<name>`. `cac`needs an optional peer ([`cac`](https://github.com/cacjs/cac)).
Copy file name to clipboardExpand all lines: docs/content/3.frameworks/1.vite.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ Devframe spawns a separate RPC + WS server and registers Vite middleware at `<ba
42
42
|`host`|`def.cli?.host ?? 'localhost'`| Bind host for a pinned side-car. |
43
43
|`flags`| none | To `def.setup(ctx, { flags })`. |
44
44
|`auth`| gated (interactive OTP) |`false` to opt out, or a `DevframeAuthHandler` for a custom scheme. |
45
-
|`mcp`|`def.cli?.mcp`| Expose the MCP route at `<base>__mcp`. `true`is origin-only (trusts same-machine callers); `McpRouteOptions` can add an `authorization` identity check. |
45
+
|`mcp`|`'auto'`| Expose the MCP route at `<base>__mcp`. `'auto'` mounts once agent tools exist; `true`forces the origin-only route on (trusts same-machine callers); `McpRouteOptions` can add an `authorization` identity check. |
Copy file name to clipboardExpand all lines: docs/content/3.frameworks/3.next.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ export const GET = handler.fetch
48
48
|`port`| from `def.cli?.port`| Side-car port. |
49
49
|`flags`| none | Passed to `def.setup(ctx, { flags })`. |
50
50
|`auth`|`false`|`true` for the OTP gate, or a handler. |
51
-
|`mcp`|`def.cli?.mcp`| Expose the MCP route. `true`is origin-only (trusts same-machine callers); `McpRouteOptions` can add an `authorization` identity check. |
51
+
|`mcp`|`'auto'`| Expose the MCP route. `'auto'` mounts once agent tools exist; `true`forces the origin-only route on (trusts same-machine callers); `McpRouteOptions` can add an `authorization` identity check. |
The aggregate MCP route is off by default. Opt in with `mcp: true` (origin-only, trusting same-machine callers), or `mcp: { authorization }`to add an identity check when the app is reachable beyond localhost.
128
+
The aggregate MCP route mounts by default once any mounted devframe exposes agent tools (the `'auto'` setting). Force it on with `mcp: true` (origin-only, trusting same-machine callers), off with `mcp: false`, or add `mcp: { authorization }`for an identity check when the app is reachable beyond localhost.
129
129
130
130
No native hub UI provider here, so this scope stays quiet; `createDevframeNextHost()` is the low-level `DevframeHost`.
Copy file name to clipboardExpand all lines: docs/content/6.errors/DF0046.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
1
---
2
2
title: 'DF0046: Connector Requires the MCP SDK'
3
-
description: 'devframe connect requires the optional peer dependency @modelcontextprotocol/server: {reason}'
3
+
description: 'devframe connect requires the optional peer dependency @modelcontextprotocol/client: {reason}'
4
4
---
5
5
6
6
## Message
7
7
8
-
> `devframe connect` requires the optional peer dependency @modelcontextprotocol/server: `{reason}`
8
+
> `devframe connect` requires the optional peer dependency @modelcontextprotocol/client: `{reason}`
9
9
10
10
## Cause
11
11
12
-
`devframe connect` was started but `@modelcontextprotocol/server` could not be imported. The SDK is an optional peer dependency of `devframe`, keeping the MCP surface opt-in, so it only needs to be installed where MCP features are used.
12
+
`devframe connect` was started but `@modelcontextprotocol/client` could not be imported. The client SDK is an optional peer dependency of `devframe`: only the connector dials other instances, so only it needs the package installed.
13
13
14
14
## Fix
15
15
16
16
Install the SDK next to devframe and run the connector again:
0 commit comments