@protobase/cli 0.41.1 → 0.42.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/cli/package.js +1 -1
- package/package.json +6 -6
- package/skills/protobase/references/features/ai.md +1 -1
- package/skills/protobase/references/guides/api-functions.md +2 -1
- package/skills/protobase/references/reference/assistant.md +1 -1
- package/skills/protobase/references/reference/mcp.md +7 -6
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.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.
|
|
40
|
-
"@protobase/query": "0.
|
|
41
|
-
"@protobase/schema": "0.
|
|
42
|
-
"@protobase/server": "0.
|
|
43
|
-
"@protobase/ui": "0.
|
|
39
|
+
"@protobase/layout": "0.42.0",
|
|
40
|
+
"@protobase/query": "0.42.0",
|
|
41
|
+
"@protobase/schema": "0.42.0",
|
|
42
|
+
"@protobase/server": "0.42.0",
|
|
43
|
+
"@protobase/ui": "0.42.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",
|
|
@@ -10,6 +10,6 @@ Fields and actions filled by a model, the assistant beside the admin, and MCP.
|
|
|
10
10
|
- [Choice of model](../reference/assistant.md#which-backend): The assistant runs on OpenRouter or any OpenAI-compatible endpoint, also a local one.
|
|
11
11
|
- [Assistant tools](../reference/assistant.md#the-apps-own-tools): Your own tools for the assistant, acting on records as the user.
|
|
12
12
|
- [MCP server](../reference/mcp.md#the-tools): AI clients connect to the app over MCP as the signed-in person, and list, find and read records within that person's access.
|
|
13
|
-
- [MCP writes](../reference/mcp.md#writes): When turned on, for every resource or only those you list, AI clients create and
|
|
13
|
+
- [MCP writes](../reference/mcp.md#writes): When turned on, for every resource or only those you list, AI clients create, update and delete records after the person approves each write.
|
|
14
14
|
- [MCP writes without approval](../reference/mcp.md#writes-without-approval): Roles you name, such as service accounts, write over MCP without being asked to approve each write; everyone else is still asked.
|
|
15
15
|
- [Connected apps](../reference/auth.md#oauth-for-mcp-clients): People allow an AI client to sign in, and disconnect it later.
|
|
@@ -47,7 +47,7 @@ The second argument of a handler (`c.env` in a [Hono app](#hono-apps)):
|
|
|
47
47
|
| | |
|
|
48
48
|
| --- | --- |
|
|
49
49
|
| `session` | The caller: `{ user: { id, roles }, tenant? }`, from the app's `authenticate`. |
|
|
50
|
-
| `records` | The app's resources, acting as the caller: `list`, `get`, `create`, `update`, `delete`. |
|
|
50
|
+
| `records` | The app's resources, acting as the caller: `list`, `get`, `create`, `update`, `delete`, `softDeleteField`. |
|
|
51
51
|
| `db` | The Kysely instance itself. It skips every access rule, row filter and tenant scope. |
|
|
52
52
|
| `caller()` | Resolves to `{ session, records }`. Public functions use it to ask for a caller when they need one. |
|
|
53
53
|
| `acceptWebSocket(events)` | Answers a WebSocket upgrade with a socket; return its response. See [WebSockets](#websockets). |
|
|
@@ -88,6 +88,7 @@ export default defineFunction({ roles: ['mechanic', 'desk'] }, async (request, {
|
|
|
88
88
|
| `create(resource, data)` | `{ record, etag }` of the new record. |
|
|
89
89
|
| `update(resource, key, data, { etag }?)` | With `etag`, it fails with `412` when the record changed after it was read. |
|
|
90
90
|
| `delete(resource, key, { etag }?)` | `{ record, etag }` of the record as it was. It is a soft delete when the resource has one. |
|
|
91
|
+
| `softDeleteField(resource)` | The field a delete sets when the resource has a soft delete, or `undefined` when a delete removes the record. |
|
|
91
92
|
|
|
92
93
|
A refusal or a missing record rejects with the problem the REST API would answer, such as `403`, `404` or `412`. Left uncaught, that problem becomes the function's response. Each call is its own transaction. Use the [batch endpoint](../reference/api.md#batch-writes) when several writes must succeed or fail together.
|
|
93
94
|
|
|
@@ -68,7 +68,7 @@ Making the query role needs `CREATEROLE` once, for the role that applies the mig
|
|
|
68
68
|
|
|
69
69
|
`options.assistant.tools` adds tools of the app's own, which the built-in backend offers after its two. A tool is `defineTool({ name, description, parameters, run })` from `@protobase/server`: `parameters` is the JSON Schema of its arguments, and `run(args, context)` returns the text the model reads. A name must be 1 to 64 letters, digits, `_` or `-`, and a name taken twice stops the server at startup. A backend elsewhere has its own tools, so the option does nothing there. A tool's `annotations` are MCP's tool hints (`readOnlyHint`, `destructiveHint`, ...), which the dock ignores; the same tools can be offered over the app's [MCP endpoint](mcp.md#building-on-it).
|
|
70
70
|
|
|
71
|
-
`context` holds the user's `session`, `show(part)` to add a part to the answer, `approve(request)` for an approval card, `conversation` (the dock's, absent over MCP), `resources()` (the resources the user may read, restricted to their fields, with their views), and `records`: `list(resource, params)` with the REST API's list parameters, `get(resource, key)`, `create(resource, data)
|
|
71
|
+
`context` holds the user's `session`, `show(part)` to add a part to the answer, `approve(request)` for an approval card, `conversation` (the dock's, absent over MCP), `resources()` (the resources the user may read, restricted to their fields, with their views), and `records`: `list(resource, params)` with the REST API's list parameters, `get(resource, key)`, `create(resource, data)`, `update(resource, key, data, { etag? })` (without an ETag it updates any version), `delete(resource, key, { etag? })` (soft on a resource with `.softDelete()`) and `softDeleteField(resource)` (the field a delete sets, or `undefined` when a delete removes the record) on the app's resources **as the user**, through their access rules, tenant scope, validation and write hooks, as in the REST API. Each answers `{ record, etag }`; a refusal or a missing record rejects with an `HttpProblem`, whose `detail` a tool can return to the model as text.
|
|
72
72
|
|
|
73
73
|
A tool with a [widget](#widget-parts) creates or finds what it is about, shows a widget with its id, and returns the id and the state at that moment:
|
|
74
74
|
|
|
@@ -53,7 +53,7 @@ It runs one `SELECT` in a read-only transaction, as the app's database role, **o
|
|
|
53
53
|
|
|
54
54
|
### Writes
|
|
55
55
|
|
|
56
|
-
`createAdmin`'s `options.mcp.writes` also offers
|
|
56
|
+
`createAdmin`'s `options.mcp.writes` also offers three tools that change records, to everyone signed in:
|
|
57
57
|
|
|
58
58
|
```ts
|
|
59
59
|
createAdmin({ ..., auth, options: { mcp: { writes: true } } })
|
|
@@ -62,11 +62,12 @@ createAdmin({ ..., auth, options: { mcp: { writes: true } } })
|
|
|
62
62
|
| Tool | What it does |
|
|
63
63
|
| --- | --- |
|
|
64
64
|
| `create_record` | Creates a record of a resource from `data`, field names to values, and returns it with its ETag. |
|
|
65
|
-
| `update_record` | Changes the fields in `data` of one record by its key, and returns it with its new ETag. With the `etag` that `get_record` gave, it fails when someone changed the record since. |
|
|
65
|
+
| `update_record` | Changes the fields in `data` of one record by its key, and returns it with its new ETag. With the `etag` that `get_record` gave, it fails when someone changed the record since. It does not set the field a soft delete sets: a delete goes through `delete_record`. |
|
|
66
|
+
| `delete_record` | Deletes one record by its key and the `etag` that `get_record` gave, and fails when someone changed the record since. A resource with a [soft delete](data-config.md) keeps the record, deleted; any other loses it for good. |
|
|
66
67
|
|
|
67
68
|
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.
|
|
68
69
|
|
|
69
|
-
Before each write the client asks the person to approve it, showing the resource and the data, through MCP's form elicitation. 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.
|
|
70
|
+
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.
|
|
70
71
|
|
|
71
72
|
To offer the writes on some resources only, list them:
|
|
72
73
|
|
|
@@ -84,11 +85,11 @@ An app that runs service accounts over MCP, such as a backend job or an agent wi
|
|
|
84
85
|
createAdmin({ ..., auth, options: { mcp: { writes: { resources: ['tasks'], rolesWithoutApproval: ['service'] } } } })
|
|
85
86
|
```
|
|
86
87
|
|
|
87
|
-
A user with one of those roles creates and
|
|
88
|
+
A user with one of those roles creates, updates and deletes records over MCP without the approval step: the client is never asked, so a client that cannot ask writes too. Their role's access rules and the listed resources still limit every write as before, so a job with no person present can keep the app's data over MCP and do nothing there it could not do through the REST API. Everyone else is still asked before each write.
|
|
88
89
|
|
|
89
90
|
No role is exempt unless named. The roles are checked against the signed-in user, not against the client, and a user holding several is exempt when any of them is named. A name that is not one of the app's roles, or is `anonymous`, stops the server at startup. Naming a role a person signs in with lets any client that person allows write as them unasked.
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
A deleted record cannot be restored over MCP, and there is no SQL that writes.
|
|
92
93
|
|
|
93
94
|
## Browsers and hosts
|
|
94
95
|
|
|
@@ -103,7 +104,7 @@ The endpoint serves each request on its own, without an MCP session: a `GET` or
|
|
|
103
104
|
- `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.
|
|
104
105
|
- `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`.
|
|
105
106
|
- `mcpTools({ db, sql, writes })`: the default tools for a session; `writes` is `true`, `false` or `{ resources, rolesWithoutApproval }`.
|
|
106
|
-
- `writeRecordTools({ resources })`, or `createRecordTool(...)` and `
|
|
107
|
+
- `writeRecordTools({ resources })`, or `createRecordTool(...)`, `updateRecordTool(...)` and `deleteRecordTool(...)`: the write tools alone, on the listed resources or, without `resources`, on any.
|
|
107
108
|
- `mcpGate({ authenticate, resource, scope })`: the token check alone, answering 401 or 403 with a challenge that names the resource's metadata.
|
|
108
109
|
- `mcpToolContext(...)`, `mcpRoutes(app, { path, handler })` and `sessionOf(authInfo)`: the tools' context as the app builds it, the routes with open CORS, and the session a request was admitted with.
|
|
109
110
|
|