@protobase/cli 0.45.22 → 0.46.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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.45.22";
2
+ var version = "0.46.0";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.45.22",
3
+ "version": "0.46.0",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -36,11 +36,11 @@
36
36
  "@better-auth/core": "^1.7.12",
37
37
  "@hono/node-server": "^2.1.3",
38
38
  "@hono/vite-dev-server": "^0.26.1",
39
- "@protobase/layout": "0.45.22",
40
- "@protobase/query": "0.45.22",
41
- "@protobase/schema": "0.45.22",
42
- "@protobase/server": "0.45.22",
43
- "@protobase/ui": "0.45.22",
39
+ "@protobase/layout": "0.46.0",
40
+ "@protobase/query": "0.46.0",
41
+ "@protobase/schema": "0.46.0",
42
+ "@protobase/server": "0.46.0",
43
+ "@protobase/ui": "0.46.0",
44
44
  "@react-email/render": "^2.1.0",
45
45
  "@scalar/hono-api-reference": "^0.12.10",
46
46
  "@tailwindcss/vite": "^4.3.3",
@@ -70,7 +70,9 @@ createAdmin({ ..., auth, options: { mcp: { writes: true } } })
70
70
 
71
71
  Each write goes through the REST API as the person: their role's access rules, `validate`, write hooks, events and webhooks apply, so the client can do only what the person may do in the app.
72
72
 
73
- Before each write the client asks the person to approve it, showing the resource and the data, or for a delete the resource, the key and whether the record can be restored, through MCP's form elicitation. For a resource without a soft delete, the approval says plainly that the delete cannot be undone. Nothing is written until they approve, and declining writes nothing. A client's own setting that always allows a tool is not this approval. A client that cannot ask, one without form elicitation or one on the 2025 protocol, gets each write refused with a message saying so.
73
+ Before each write the client asks the person to approve it, showing the resource and the data, or for a delete the resource, the key and whether the record can be restored, through MCP's form elicitation. For a resource without a soft delete, the approval says plainly that the delete cannot be undone. Nothing is written until they approve, and declining writes nothing. A client's own setting that always allows a tool is not this approval. An approval holds only for the call it was asked for, with the same arguments, by the same person in the same app, organization and client, and only once, within 10 minutes; any other call is asked again. A client that cannot ask, one without form elicitation or one on the 2025 protocol, gets each write refused with a message saying so.
74
+
75
+ <gap>An approval cannot be answered on another server instance or after a restart because a shared approval store is not implemented.</gap> Behind a load balancer, send an MCP client's calls to the same instance.
74
76
 
75
77
  To offer the writes on some resources only, list them:
76
78
 
@@ -124,7 +126,7 @@ The endpoint serves each request on its own, without an MCP session: a `GET` or
124
126
  `@protobase/server` exports the pieces the endpoint is made of, for an MCP server of your own with tools of your own:
125
127
 
126
128
  - `mcpHandler({ authenticate, resource, scope, server })`: the endpoint as a fetch handler. It checks the host, admits a valid token (`mcpGate`) and serves the request with the server that `server(session)` builds for its caller.
127
- - `mcpServer({ info, tools, context, report, rolesWithoutApproval })`: an MCP server offering [assistant tools](assistant.md#the-apps-own-tools), each with its JSON Schema and its `annotations`, MCP's tool hints. `context` is the tools' context without `approve`: each call gets its own, which asks the client's user, or approves at once when the session's user holds one of `rolesWithoutApproval`.
129
+ - `mcpServer({ info, tools, context, report, rolesWithoutApproval, approvals })`: an MCP server offering [assistant tools](assistant.md#the-apps-own-tools), each with its JSON Schema and its `annotations`, MCP's tool hints. `context` is the tools' context without `approve`: each call gets its own, which asks the client's user, or approves at once when the session's user holds one of `rolesWithoutApproval`. `approvals` is `mcpApprovals()`, built once and passed to every server the endpoint builds: it keeps the approvals asked for until they are answered or expire.
128
130
  - `mcpTools({ db, sql, writes })`: the default tools for a session; `writes` is `true`, `false` or `{ resources, rolesWithoutApproval }`.
129
131
  - `writeRecordTools({ resources })`, or `createRecordTool(...)`, `updateRecordTool(...)` and `deleteRecordTool(...)`: the single write tools alone, on the listed resources or, without `resources`, on any; `batchWriteTool({ resources })` is `batch_write` alone.
130
132
  - `mcpGate({ authenticate, resource, scope })`: the token check alone, answering 401 or 403 with a challenge that names the resource's metadata.
@@ -135,7 +137,7 @@ To serve your own endpoint at `mcp.path` instead, pass `createAdmin` `options: {
135
137
  A tool of your own goes on the server `server` returns, with the context its tools get:
136
138
 
137
139
  ```ts
138
- import { defineTool, mcpHandler, mcpServer, type Session, type ToolContext } from '@protobase/server'
140
+ import { defineTool, mcpApprovals, mcpHandler, mcpServer, type Session, type ToolContext } from '@protobase/server'
139
141
 
140
142
  const ping = defineTool({
141
143
  name: 'ping',
@@ -152,11 +154,13 @@ const context = (session: Session): Omit<ToolContext, 'approve'> => ({
152
154
  show: () => {},
153
155
  })
154
156
 
157
+ const approvals = mcpApprovals()
158
+
155
159
  const handler = mcpHandler({
156
160
  authenticate: authenticate.forAudience(auth.mcp.resource),
157
161
  resource: auth.mcp.resource,
158
162
  scope: auth.mcp.scope,
159
- server: (session) => mcpServer({ info: { name: 'My app', version: '1.0.0' }, tools: [ping], context: context(session), report: console.error }),
163
+ server: (session) => mcpServer({ info: { name: 'My app', version: '1.0.0' }, tools: [ping], context: context(session), report: console.error, approvals }),
160
164
  })
161
165
  ```
162
166