@protobase/cli 0.40.5 → 0.40.6
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
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.6",
|
|
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.
|
|
40
|
-
"@protobase/query": "0.40.
|
|
41
|
-
"@protobase/schema": "0.40.
|
|
42
|
-
"@protobase/server": "0.40.
|
|
43
|
-
"@protobase/ui": "0.40.
|
|
39
|
+
"@protobase/layout": "0.40.6",
|
|
40
|
+
"@protobase/query": "0.40.6",
|
|
41
|
+
"@protobase/schema": "0.40.6",
|
|
42
|
+
"@protobase/server": "0.40.6",
|
|
43
|
+
"@protobase/ui": "0.40.6",
|
|
44
44
|
"@react-email/render": "^2.1.0",
|
|
45
45
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
46
46
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# MCP
|
|
4
4
|
|
|
5
|
-
The app's MCP endpoint, through which a person's AI client lists resources
|
|
5
|
+
The app's MCP endpoint, through which a person's AI client lists resources, finds and reads records, and, when turned on, creates and updates them with that person's access and approval.
|
|
6
6
|
|
|
7
7
|
An app can serve an MCP endpoint: a person adds its address to an AI client that speaks MCP, such as a chat assistant or a code editor, signs in on the app and allows the client. The client then works with that person's access: it lists the resources and fields they may read, finds records with the API's filters, sorting and pages, and reads one record.
|
|
8
8
|
|
|
@@ -51,6 +51,25 @@ createAdmin({ ..., auth, options: { mcp: { sql: true } } })
|
|
|
51
51
|
|
|
52
52
|
It runs one `SELECT` in a read-only transaction, as the app's database role, **outside the access rules and tenant scoping**: whoever has one of those roles reads the whole database through it. Give those roles only to people who may see all of the data.
|
|
53
53
|
|
|
54
|
+
### Writes
|
|
55
|
+
|
|
56
|
+
`createAdmin`'s `options.mcp.writes` also offers two tools that change records, to everyone signed in:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
createAdmin({ ..., auth, options: { mcp: { writes: true } } })
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
| Tool | What it does |
|
|
63
|
+
| --- | --- |
|
|
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. |
|
|
66
|
+
|
|
67
|
+
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
|
+
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
|
+
|
|
71
|
+
Nothing can be deleted over MCP, and there is no SQL that writes.
|
|
72
|
+
|
|
54
73
|
## Browsers and hosts
|
|
55
74
|
|
|
56
75
|
A client in a browser may call the endpoint from any origin: it sends its token, never cookies. A request addressed to another host than the app's `baseURL` is refused, against DNS rebinding.
|
|
@@ -62,8 +81,9 @@ The endpoint serves each request on its own, without an MCP session: a `GET` or
|
|
|
62
81
|
`@protobase/server` exports the pieces the endpoint is made of, for an MCP server of your own with tools of your own:
|
|
63
82
|
|
|
64
83
|
- `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.
|
|
65
|
-
- `mcpServer({ info, tools, context, report })`: an MCP server offering [assistant tools](assistant.md#the-apps-own-tools)), each with its JSON Schema and its `annotations`, MCP's tool hints.
|
|
66
|
-
- `mcpTools({ db, sql })`: the default tools for a session.
|
|
84
|
+
- `mcpServer({ info, tools, context, report })`: 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.
|
|
85
|
+
- `mcpTools({ db, sql, writes })`: the default tools for a session.
|
|
86
|
+
- `writeRecordTools()`, or `createRecordTool()` and `updateRecordTool()`: the write tools alone.
|
|
67
87
|
- `mcpGate({ authenticate, resource, scope })`: the token check alone, answering 401 or 403 with a challenge that names the resource's metadata.
|
|
68
88
|
- `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.
|
|
69
89
|
|
|
@@ -82,12 +102,11 @@ const ping = defineTool({
|
|
|
82
102
|
run: async () => 'pong',
|
|
83
103
|
})
|
|
84
104
|
|
|
85
|
-
const context = (session: Session): ToolContext => ({
|
|
105
|
+
const context = (session: Session): Omit<ToolContext, 'approve'> => ({
|
|
86
106
|
session,
|
|
87
107
|
records: myRecords(session),
|
|
88
108
|
resources: async () => ({ models: [], views: [] }),
|
|
89
109
|
show: () => {},
|
|
90
|
-
approve: () => Promise.reject(new Error('Not implemented: this server asks for no approval')),
|
|
91
110
|
})
|
|
92
111
|
|
|
93
112
|
const handler = mcpHandler({
|
|
@@ -98,4 +117,6 @@ const handler = mcpHandler({
|
|
|
98
117
|
})
|
|
99
118
|
```
|
|
100
119
|
|
|
120
|
+
A tool that changes something calls `context.approve(...)` before it changes anything, and only once: over MCP the client asks the person, then calls the tool again from the start with their answer, and `approve` then resolves with it.
|
|
121
|
+
|
|
101
122
|
`mcpServer` returns the SDK's `McpServer`, so `registerTool` on it adds a tool written against the SDK directly.
|