diff --git a/app/internal/docs.build-assets.ts b/app/internal/docs.build-assets.ts
index 4a4db73..2bedbee 100644
--- a/app/internal/docs.build-assets.ts
+++ b/app/internal/docs.build-assets.ts
@@ -3,11 +3,14 @@ import { createApp } from "bknd/adapter/bun";
async function generate() {
console.info("Generating MCP documentation...");
const app = await createApp({
+ connection: {
+ url: ":memory:",
+ },
config: {
server: {
mcp: {
enabled: true,
- path: "/mcp",
+ path: "/mcp2",
},
},
auth: {
@@ -25,9 +28,9 @@ async function generate() {
},
});
await app.build();
+ await app.getMcpClient().ping();
- const res = await app.server.request("/mcp?explain=1");
- const { tools, resources } = await res.json();
+ const { tools, resources } = app.mcp!.toJSON();
await Bun.write("../docs/mcp.json", JSON.stringify({ tools, resources }, null, 2));
console.info("MCP documentation generated.");
diff --git a/app/src/App.ts b/app/src/App.ts
index 5658d90..633b9fa 100644
--- a/app/src/App.ts
+++ b/app/src/App.ts
@@ -311,8 +311,9 @@ export class App<
throw new Error("MCP is not enabled");
}
+ const url = new URL(config.path, "http://localhost").toString();
return new McpClient({
- url: "http://localhost" + config.path,
+ url,
fetch: this.server.request,
});
}
diff --git a/app/src/modules/server/SystemController.ts b/app/src/modules/server/SystemController.ts
index 9cdbd99..3ae6cd2 100644
--- a/app/src/modules/server/SystemController.ts
+++ b/app/src/modules/server/SystemController.ts
@@ -70,12 +70,13 @@ export class SystemController extends Controller {
if (!config.mcp.enabled) {
return;
}
- const { permission } = this.middlewares;
+ const { permission, auth } = this.middlewares;
this.registerMcp();
app.server.all(
config.mcp.path,
+ auth(),
permission(SystemPermissions.mcp, {}),
mcpMiddleware({
setup: async () => {
diff --git a/docs/content/docs/(documentation)/usage/mcp/tools-resources.mdx b/docs/content/docs/(documentation)/usage/mcp/tools-resources.mdx
index 78e1b45..40a7e97 100644
--- a/docs/content/docs/(documentation)/usage/mcp/tools-resources.mdx
+++ b/docs/content/docs/(documentation)/usage/mcp/tools-resources.mdx
@@ -24,7 +24,7 @@ Get the available authentication strategies
Create a new user
-
+
### `auth_user_password_change`
@@ -48,61 +48,61 @@ Get a user token
Delete many
-
+
### `data_entity_delete_one`
Delete one
-
+
### `data_entity_fn_count`
Count entities
-
+
### `data_entity_fn_exists`
Check if entity exists
-
+
### `data_entity_info`
Retrieve entity info
-
+
### `data_entity_insert`
Insert one or many
-
+
### `data_entity_read_many`
Query entities
-
+
### `data_entity_read_one`
Read one
-
+
### `data_entity_update_many`
Update many
-
+
### `data_entity_update_one`
Update one
-
+
### `data_sync`
@@ -110,6 +110,12 @@ Sync database schema
+### `data_types`
+
+Retrieve data typescript definitions
+
+
+
### `system_build`
Build the app
@@ -144,7 +150,7 @@ Ping the server
-
+
### `config_auth_roles_get`
@@ -162,7 +168,7 @@ Ping the server
-
+
### `config_auth_strategies_add`
@@ -192,7 +198,7 @@ Ping the server
-
+
### `config_data_entities_add`
@@ -306,7 +312,7 @@ Get Server configuration
Update Server configuration
-
+
## Resources
diff --git a/docs/mcp.json b/docs/mcp.json
index 7075b1e..afd9b12 100644
--- a/docs/mcp.json
+++ b/docs/mcp.json
@@ -612,6 +612,13 @@
"destructiveHint": true
}
},
+ {
+ "name": "data_types",
+ "description": "Retrieve data typescript definitions",
+ "inputSchema": {
+ "type": "object"
+ }
+ },
{
"name": "system_build",
"description": "Build the app",
@@ -714,10 +721,66 @@
"additionalProperties": false,
"properties": {
"permissions": {
- "type": "array",
- "items": {
- "type": "string"
- }
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "permission": {
+ "type": "string"
+ },
+ "effect": {
+ "type": "string",
+ "enum": [
+ "allow",
+ "deny"
+ ],
+ "default": "allow"
+ },
+ "policies": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "description": {
+ "type": "string"
+ },
+ "condition": {
+ "type": "object",
+ "properties": {}
+ },
+ "effect": {
+ "type": "string",
+ "enum": [
+ "allow",
+ "deny",
+ "filter"
+ ],
+ "default": "allow"
+ },
+ "filter": {
+ "type": "object",
+ "properties": {}
+ }
+ }
+ }
+ }
+ },
+ "required": [
+ "permission"
+ ]
+ }
+ }
+ ]
},
"is_default": {
"type": "boolean"
@@ -810,10 +873,66 @@
"additionalProperties": false,
"properties": {
"permissions": {
- "type": "array",
- "items": {
- "type": "string"
- }
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "permission"
+ ],
+ "properties": {
+ "permission": {
+ "type": "string"
+ },
+ "effect": {
+ "type": "string",
+ "enum": [
+ "allow",
+ "deny"
+ ],
+ "default": "allow"
+ },
+ "policies": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "description": {
+ "type": "string"
+ },
+ "condition": {
+ "type": "object",
+ "properties": {}
+ },
+ "effect": {
+ "type": "string",
+ "enum": [
+ "allow",
+ "deny",
+ "filter"
+ ],
+ "default": "allow"
+ },
+ "filter": {
+ "type": "object",
+ "properties": {}
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ ]
},
"is_default": {
"type": "boolean"
@@ -1062,6 +1181,9 @@
"type": "object",
"additionalProperties": false,
"properties": {
+ "domain": {
+ "type": "string"
+ },
"path": {
"type": "string",
"default": "/"
@@ -4067,6 +4189,20 @@
"path": {
"type": "string",
"default": "/api/system/mcp"
+ },
+ "logLevel": {
+ "type": "string",
+ "enum": [
+ "emergency",
+ "alert",
+ "critical",
+ "error",
+ "warning",
+ "notice",
+ "info",
+ "debug"
+ ],
+ "default": "warning"
}
}
}