@protobase/server 0.43.0 → 0.43.2
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,5 +1,5 @@
|
|
|
1
1
|
const shownResources = 20;
|
|
2
|
-
const
|
|
2
|
+
const valueLength = 80;
|
|
3
3
|
const nameLength = 60;
|
|
4
4
|
const unicodeEscape = (char) => {
|
|
5
5
|
const code = char.codePointAt(0);
|
|
@@ -9,10 +9,15 @@ const escaped = (json) => json.replace(/[\p{Cc}\p{Cf}\u2028\u2029`<>]/gu, unicod
|
|
|
9
9
|
const cut = (text, length) => text.length > length ? `${text.slice(0, length - 1)}…` : text;
|
|
10
10
|
const quoted = (value, length) => cut(escaped(JSON.stringify(value) ?? "null"), length);
|
|
11
11
|
const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
12
|
+
const counted = (value, length) => {
|
|
13
|
+
const text = escaped(JSON.stringify(value) ?? "null");
|
|
14
|
+
return text.length > length ? `${text.slice(0, length)}… (${plural(text.length - length, "more character")})` : text;
|
|
15
|
+
};
|
|
16
|
+
const fieldsOf = (data) => `{${Object.entries(data).map(([name, value]) => `${counted(name, nameLength)}:${counted(value, valueLength)}`).join(",")}}`;
|
|
12
17
|
const lineOf = (operation, index) => {
|
|
13
18
|
const target = operation.op === "create" ? quoted(operation.resource, nameLength) : `${quoted(operation.resource, nameLength)} ${quoted(operation.key, nameLength)}`;
|
|
14
|
-
const values = operation.op === "delete" ? "" : ` ${
|
|
15
|
-
return
|
|
19
|
+
const values = operation.op === "delete" ? "" : ` ${fieldsOf(operation.data)}`;
|
|
20
|
+
return `${index + 1}. ${operation.op} ${target}${values}`;
|
|
16
21
|
};
|
|
17
22
|
const countsOf = (operations) => {
|
|
18
23
|
const counts = /* @__PURE__ */ new Map();
|
package/dist/mcp/mcp-server.js
CHANGED
|
@@ -3,6 +3,14 @@ import { ApprovalNeeded, approvalAsked, approvedUnasked, mcpApproval, writesUnas
|
|
|
3
3
|
import { CLIENT_CAPABILITIES_META_KEY, McpServer, fromJsonSchema } from "@modelcontextprotocol/server";
|
|
4
4
|
//#region src/mcp/mcp-server.ts
|
|
5
5
|
const capabilitiesOf = (envelope) => envelope?.[CLIENT_CAPABILITIES_META_KEY];
|
|
6
|
+
const inputSchemas = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
const inputSchemaOf = (parameters) => {
|
|
8
|
+
const known = inputSchemas.get(parameters);
|
|
9
|
+
if (known) return known;
|
|
10
|
+
const schema = fromJsonSchema(parameters);
|
|
11
|
+
inputSchemas.set(parameters, schema);
|
|
12
|
+
return schema;
|
|
13
|
+
};
|
|
6
14
|
const failed = {
|
|
7
15
|
content: [{
|
|
8
16
|
type: "text",
|
|
@@ -21,7 +29,7 @@ const mcpServer = ({ info, tools, context, report, rolesWithoutApproval = [] })
|
|
|
21
29
|
for (const tool of checkedTools(tools)) {
|
|
22
30
|
const config = {
|
|
23
31
|
description: tool.description,
|
|
24
|
-
inputSchema:
|
|
32
|
+
inputSchema: inputSchemaOf(tool.parameters),
|
|
25
33
|
...tool.annotations && { annotations: tool.annotations }
|
|
26
34
|
};
|
|
27
35
|
server.registerTool(tool.name, config, async (args, ctx) => {
|
package/dist/mcp/mcp-tools.js
CHANGED
|
@@ -9,10 +9,15 @@ import { batchWriteTool } from "../assistant/batch-write-tool.js";
|
|
|
9
9
|
* is on and the caller sees the assistant.
|
|
10
10
|
*/
|
|
11
11
|
const writeTools = (input) => [...writeRecordTools(input), batchWriteTool(input)];
|
|
12
|
-
const mcpTools = ({ db, sql, writes }) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const mcpTools = ({ db, sql, writes }) => {
|
|
13
|
+
const read = readRecordTools();
|
|
14
|
+
const write = writes === false ? [] : writeTools(writes === true || !writes.resources ? {} : { resources: writes.resources });
|
|
15
|
+
const query = sql ? [readOnlyQueryTool(db)] : [];
|
|
16
|
+
return (session) => [
|
|
17
|
+
...read,
|
|
18
|
+
...write,
|
|
19
|
+
...seesAssistant(session.user.roles) ? query : []
|
|
20
|
+
];
|
|
21
|
+
};
|
|
17
22
|
//#endregion
|
|
18
23
|
export { mcpTools };
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/server",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.2",
|
|
4
4
|
"description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"@better-auth/passkey": "^1.7.12",
|
|
37
37
|
"@better-auth/sso": "^1.7.12",
|
|
38
38
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
39
|
-
"@protobase/layout": "0.43.
|
|
40
|
-
"@protobase/query": "0.43.
|
|
41
|
-
"@protobase/schema": "0.43.
|
|
39
|
+
"@protobase/layout": "0.43.2",
|
|
40
|
+
"@protobase/query": "0.43.2",
|
|
41
|
+
"@protobase/schema": "0.43.2",
|
|
42
42
|
"@react-email/render": "^2.1.0",
|
|
43
43
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
44
44
|
"@sentry/core": "^11.7.0",
|