@baasix/mcp 0.1.1 → 0.1.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.
- package/README.md +75 -387
- package/bin/baasix-mcp.js +21 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
# Baasix MCP Server
|
|
1
|
+
# Baasix Local MCP Server
|
|
2
2
|
|
|
3
|
-
A Model Context Protocol (MCP) server that provides Claude Desktop and other MCP clients with
|
|
3
|
+
A Model Context Protocol (MCP) server that provides Claude Desktop and other MCP clients with local access to Baasix Backend-as-a-Service operations.
|
|
4
|
+
|
|
5
|
+
> **Note:** This is the **Local MCP** package that runs on your machine. Baasix also has a **Remote MCP** built into the core server at `/mcp` endpoint. See [Choosing Local vs Remote MCP](#choosing-local-vs-remote-mcp) for guidance.
|
|
4
6
|
|
|
5
7
|
**Baasix** is an open-source BaaS that generates REST APIs from data models, featuring 50+ filter operators, visual workflows, multi-tenancy, and real-time subscriptions.
|
|
6
8
|
|
|
7
9
|
## Features
|
|
8
10
|
|
|
9
|
-
- **
|
|
11
|
+
- **57 MCP Tools** for comprehensive Baasix operations
|
|
10
12
|
- **Schema Management** - Create, update, delete collections and relationships
|
|
11
13
|
- **CRUD Operations** - Full item management with powerful query capabilities
|
|
12
14
|
- **50+ Filter Operators** - From basic comparison to geospatial and JSONB queries
|
|
@@ -18,24 +20,36 @@ A Model Context Protocol (MCP) server that provides Claude Desktop and other MCP
|
|
|
18
20
|
- **Multi-tenancy** - Tenant management and switching
|
|
19
21
|
- **Realtime** - Enable/disable WAL-based realtime per collection
|
|
20
22
|
|
|
23
|
+
## Choosing Local vs Remote MCP
|
|
24
|
+
|
|
25
|
+
| Feature | Local MCP (this package) | Remote MCP (built-in) |
|
|
26
|
+
|---------|--------------------------|----------------------|
|
|
27
|
+
| **Transport** | stdio | HTTP (Streamable HTTP) |
|
|
28
|
+
| **Setup** | Install `@baasix/mcp` | Enable `MCP_ENABLED=true` on server |
|
|
29
|
+
| **Authentication** | Environment variables | HTTP headers |
|
|
30
|
+
| **Best For** | Claude Desktop, local dev | Production, cloud, remote servers |
|
|
31
|
+
| **Process** | Runs locally | Runs on Baasix server |
|
|
32
|
+
| **Config File** | `.mcp.json` | `.mcp.json` or `.vscode/mcp.json` |
|
|
33
|
+
|
|
34
|
+
**Use Local MCP when:**
|
|
35
|
+
- Using Claude Desktop (requires stdio transport)
|
|
36
|
+
- Working offline with local Baasix server
|
|
37
|
+
- Need environment-based configuration
|
|
38
|
+
|
|
39
|
+
**Use Remote MCP when:**
|
|
40
|
+
- Connecting to remote/cloud Baasix servers
|
|
41
|
+
- Using VS Code with GitHub Copilot (supports HTTP)
|
|
42
|
+
- Want simpler setup without npm packages
|
|
43
|
+
|
|
21
44
|
## Quick Start
|
|
22
45
|
|
|
23
46
|
### 1. Install dependencies
|
|
24
47
|
```bash
|
|
25
|
-
|
|
26
|
-
npm install
|
|
48
|
+
npm install @baasix/mcp
|
|
27
49
|
```
|
|
28
50
|
|
|
29
|
-
### 2. Configure
|
|
30
|
-
|
|
31
|
-
cp .env.example .env
|
|
32
|
-
# Edit .env with your Baasix server details
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 3. Start the MCP server
|
|
36
|
-
```bash
|
|
37
|
-
npm start
|
|
38
|
-
```
|
|
51
|
+
### 2. Configure your AI tool
|
|
52
|
+
See [IDE Integration](#ide-integration) below.
|
|
39
53
|
|
|
40
54
|
## Configuration
|
|
41
55
|
|
|
@@ -50,34 +64,18 @@ npm start
|
|
|
50
64
|
|
|
51
65
|
*Either `BAASIX_AUTH_TOKEN` OR both `BAASIX_EMAIL` and `BAASIX_PASSWORD` must be provided.
|
|
52
66
|
|
|
53
|
-
### Environment Files
|
|
54
|
-
- `.env` - Development environment (default)
|
|
55
|
-
- `.env.production` - Production environment
|
|
56
|
-
|
|
57
|
-
### Available Scripts
|
|
58
|
-
- `npm run development` - Start with development environment
|
|
59
|
-
- `npm start` - Start with production environment
|
|
60
|
-
- `npm run dev` - Development mode with auto-restart
|
|
61
|
-
- `npm test` - Run tests
|
|
62
|
-
- `npm run debug` - Start with MCP inspector for debugging
|
|
63
|
-
|
|
64
67
|
## IDE Integration
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
### Claude Desktop
|
|
69
|
+
### Claude Code / Anthropic CLI
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
73
|
-
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
71
|
+
Create a `.mcp.json` file in your project root:
|
|
74
72
|
|
|
75
73
|
```json
|
|
76
74
|
{
|
|
77
75
|
"mcpServers": {
|
|
78
76
|
"baasix": {
|
|
79
|
-
"command": "
|
|
80
|
-
"args": ["
|
|
77
|
+
"command": "npx",
|
|
78
|
+
"args": ["@baasix/mcp"],
|
|
81
79
|
"env": {
|
|
82
80
|
"BAASIX_URL": "http://localhost:8056",
|
|
83
81
|
"BAASIX_EMAIL": "admin@baasix.com",
|
|
@@ -88,16 +86,24 @@ Add to your Claude Desktop configuration (`claude_desktop_config.json`):
|
|
|
88
86
|
}
|
|
89
87
|
```
|
|
90
88
|
|
|
91
|
-
|
|
89
|
+
Or add via CLI:
|
|
90
|
+
```bash
|
|
91
|
+
claude mcp add baasix -- npx @baasix/mcp
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Claude Desktop
|
|
92
95
|
|
|
93
|
-
|
|
96
|
+
Add to your Claude Desktop configuration:
|
|
97
|
+
|
|
98
|
+
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
99
|
+
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
94
100
|
|
|
95
101
|
```json
|
|
96
102
|
{
|
|
97
103
|
"mcpServers": {
|
|
98
104
|
"baasix": {
|
|
99
|
-
"command": "
|
|
100
|
-
"args": ["
|
|
105
|
+
"command": "npx",
|
|
106
|
+
"args": ["@baasix/mcp"],
|
|
101
107
|
"env": {
|
|
102
108
|
"BAASIX_URL": "http://localhost:8056",
|
|
103
109
|
"BAASIX_EMAIL": "admin@baasix.com",
|
|
@@ -108,56 +114,51 @@ For Claude Code CLI, create a `.mcp.json` file in your project root:
|
|
|
108
114
|
}
|
|
109
115
|
```
|
|
110
116
|
|
|
111
|
-
Or add via CLI:
|
|
112
|
-
```bash
|
|
113
|
-
claude mcp add baasix npm run start
|
|
114
|
-
```
|
|
115
|
-
|
|
116
117
|
### VS Code with GitHub Copilot
|
|
117
118
|
|
|
118
|
-
For VS Code
|
|
119
|
+
For VS Code, you can use either Local MCP (stdio) or Remote MCP (HTTP).
|
|
120
|
+
|
|
121
|
+
**Local MCP (stdio)** - Create `.vscode/mcp.json`:
|
|
119
122
|
|
|
120
123
|
```jsonc
|
|
121
124
|
{
|
|
122
125
|
"servers": {
|
|
123
126
|
"baasix": {
|
|
124
127
|
"type": "stdio",
|
|
125
|
-
"command": "
|
|
126
|
-
"args": ["
|
|
128
|
+
"command": "npx",
|
|
129
|
+
"args": ["@baasix/mcp"],
|
|
127
130
|
"env": {
|
|
128
131
|
"BAASIX_URL": "http://localhost:8056",
|
|
129
132
|
"BAASIX_EMAIL": "admin@baasix.com",
|
|
130
133
|
"BAASIX_PASSWORD": "admin@123"
|
|
131
134
|
}
|
|
132
135
|
}
|
|
133
|
-
}
|
|
134
|
-
"inputs": []
|
|
136
|
+
}
|
|
135
137
|
}
|
|
136
138
|
```
|
|
137
139
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
For Cursor, add to your Cursor settings or create a project-level configuration:
|
|
140
|
+
**Remote MCP (HTTP)** - Create `.vscode/mcp.json`:
|
|
141
141
|
|
|
142
|
-
```
|
|
142
|
+
```jsonc
|
|
143
143
|
{
|
|
144
|
-
"
|
|
144
|
+
"servers": {
|
|
145
145
|
"baasix": {
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
"BAASIX_PASSWORD": "admin@123"
|
|
146
|
+
"type": "http",
|
|
147
|
+
"url": "http://localhost:8056/mcp",
|
|
148
|
+
"headers": {
|
|
149
|
+
"X-MCP-Email": "${input:mcpEmail}",
|
|
150
|
+
"X-MCP-Password": "${input:mcpPassword}"
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
|
-
}
|
|
153
|
+
},
|
|
154
|
+
"inputs": [
|
|
155
|
+
{ "id": "mcpEmail", "type": "promptString", "description": "Baasix Email" },
|
|
156
|
+
{ "id": "mcpPassword", "type": "promptString", "description": "Password", "password": true }
|
|
157
|
+
]
|
|
155
158
|
}
|
|
156
159
|
```
|
|
157
160
|
|
|
158
|
-
###
|
|
159
|
-
|
|
160
|
-
If you're using the published npm package instead of the source:
|
|
161
|
+
### Cursor IDE
|
|
161
162
|
|
|
162
163
|
```json
|
|
163
164
|
{
|
|
@@ -187,7 +188,6 @@ If you're using the published npm package instead of the source:
|
|
|
187
188
|
| `baasix_delete_schema` | Delete a collection schema |
|
|
188
189
|
| `baasix_add_index` | Add index to collection |
|
|
189
190
|
| `baasix_remove_index` | Remove index from collection |
|
|
190
|
-
| `baasix_migrate_indexes` | Add missing FK indexes to all collections |
|
|
191
191
|
| `baasix_create_relationship` | Create M2O/O2M/M2M/M2A relationship |
|
|
192
192
|
| `baasix_update_relationship` | Update existing relationship |
|
|
193
193
|
| `baasix_delete_relationship` | Delete a relationship |
|
|
@@ -202,6 +202,7 @@ If you're using the published npm package instead of the source:
|
|
|
202
202
|
| `baasix_create_item` | Create new item |
|
|
203
203
|
| `baasix_update_item` | Update existing item |
|
|
204
204
|
| `baasix_delete_item` | Delete item |
|
|
205
|
+
| `baasix_sort_items` | Reorder items in collection |
|
|
205
206
|
|
|
206
207
|
### File Management (3 tools)
|
|
207
208
|
| Tool | Description |
|
|
@@ -251,11 +252,14 @@ If you're using the published npm package instead of the source:
|
|
|
251
252
|
| `baasix_send_notification` | Send notification to users |
|
|
252
253
|
| `baasix_mark_notification_seen` | Mark notification as seen |
|
|
253
254
|
|
|
254
|
-
### Settings (
|
|
255
|
+
### Settings & Templates (4 tools)
|
|
255
256
|
| Tool | Description |
|
|
256
257
|
|------|-------------|
|
|
257
258
|
| `baasix_get_settings` | Get application settings |
|
|
258
259
|
| `baasix_update_settings` | Update settings |
|
|
260
|
+
| `baasix_list_templates` | List email templates |
|
|
261
|
+
| `baasix_get_template` | Get email template |
|
|
262
|
+
| `baasix_update_template` | Update email template |
|
|
259
263
|
|
|
260
264
|
### Realtime (5 tools)
|
|
261
265
|
| Tool | Description |
|
|
@@ -270,7 +274,6 @@ If you're using the published npm package instead of the source:
|
|
|
270
274
|
| Tool | Description |
|
|
271
275
|
|------|-------------|
|
|
272
276
|
| `baasix_server_info` | Get server health/info |
|
|
273
|
-
| `baasix_sort_items` | Reorder items in collection |
|
|
274
277
|
|
|
275
278
|
## Filter Operators Reference
|
|
276
279
|
|
|
@@ -291,21 +294,8 @@ When using `baasix_list_items`, the `filter` parameter supports 50+ operators:
|
|
|
291
294
|
{"field": {"contains": "text"}} // Contains substring
|
|
292
295
|
{"field": {"icontains": "text"}} // Contains (case-insensitive)
|
|
293
296
|
{"field": {"startswith": "pre"}} // Starts with
|
|
294
|
-
{"field": {"istartswith": "pre"}} // Starts with (case-insensitive)
|
|
295
|
-
{"field": {"endswith": "fix"}} // Ends with
|
|
296
|
-
{"field": {"iendswith": "fix"}} // Ends with (case-insensitive)
|
|
297
297
|
{"field": {"like": "pat%tern"}} // SQL LIKE pattern
|
|
298
|
-
{"field": {"ilike": "pat%tern"}} // LIKE (case-insensitive)
|
|
299
298
|
{"field": {"regex": "^\\d+$"}} // Regular expression
|
|
300
|
-
{"field": {"iregex": "pattern"}} // Regex (case-insensitive)
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
### Null/Empty Operators
|
|
304
|
-
```json
|
|
305
|
-
{"field": {"isNull": true}} // IS NULL
|
|
306
|
-
{"field": {"isNull": false}} // IS NOT NULL
|
|
307
|
-
{"field": {"empty": true}} // Empty string or null
|
|
308
|
-
{"field": {"empty": false}} // Not empty
|
|
309
299
|
```
|
|
310
300
|
|
|
311
301
|
### List Operators
|
|
@@ -313,34 +303,6 @@ When using `baasix_list_items`, the `filter` parameter supports 50+ operators:
|
|
|
313
303
|
{"field": {"in": ["a", "b", "c"]}} // In list
|
|
314
304
|
{"field": {"nin": ["x", "y"]}} // Not in list
|
|
315
305
|
{"field": {"between": [10, 100]}} // Between range
|
|
316
|
-
{"field": {"nbetween": [10, 100]}} // Not between
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
### Array Operators
|
|
320
|
-
```json
|
|
321
|
-
{"tags": {"arraycontains": ["a", "b"]}} // Contains all elements
|
|
322
|
-
{"tags": {"arraycontainsany": ["a", "b"]}} // Contains any element
|
|
323
|
-
{"tags": {"arraylength": 3}} // Array has exact length
|
|
324
|
-
{"tags": {"arrayempty": true}} // Array is empty
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
### JSONB Operators (PostgreSQL)
|
|
328
|
-
```json
|
|
329
|
-
{"meta": {"jsoncontains": {"key": "val"}}} // JSON contains
|
|
330
|
-
{"meta": {"jsoncontainedby": {"a": 1}}} // JSON contained by
|
|
331
|
-
{"meta": {"jsonhaskey": "key"}} // Has key
|
|
332
|
-
{"meta": {"jsonhasanykeys": ["a", "b"]}} // Has any keys
|
|
333
|
-
{"meta": {"jsonhasallkeys": ["a", "b"]}} // Has all keys
|
|
334
|
-
{"meta": {"jsonpath": "$.store.book[0].title"}} // JSONPath query
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
### Geospatial Operators (PostGIS)
|
|
338
|
-
```json
|
|
339
|
-
{"location": {"dwithin": {"geometry": {"type": "Point", "coordinates": [-73.9, 40.7]}, "distance": 5000}}}
|
|
340
|
-
{"location": {"intersects": {"type": "Polygon", "coordinates": [...]}}}
|
|
341
|
-
{"location": {"contains": {"type": "Point", "coordinates": [...]}}}
|
|
342
|
-
{"location": {"within": {"type": "Polygon", "coordinates": [...]}}}
|
|
343
|
-
{"location": {"overlaps": {"type": "Polygon", "coordinates": [...]}}}
|
|
344
306
|
```
|
|
345
307
|
|
|
346
308
|
### Logical Operators
|
|
@@ -353,251 +315,10 @@ When using `baasix_list_items`, the `filter` parameter supports 50+ operators:
|
|
|
353
315
|
### Dynamic Variables
|
|
354
316
|
```json
|
|
355
317
|
{"author_Id": {"eq": "$CURRENT_USER"}} // Current user's ID
|
|
356
|
-
{"createdAt": {"gte": "$NOW"}} // Current timestamp
|
|
357
318
|
{"createdAt": {"gte": "$NOW-DAYS_7"}} // 7 days ago
|
|
358
|
-
{"dueDate": {"lte": "$NOW+MONTHS_1"}} // 1 month from now
|
|
359
319
|
```
|
|
360
320
|
|
|
361
|
-
|
|
362
|
-
```json
|
|
363
|
-
// Filter by related collection fields
|
|
364
|
-
{"category.name": {"eq": "Electronics"}}
|
|
365
|
-
{"author.role.name": {"eq": "admin"}}
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
## Query Parameters for baasix_list_items
|
|
369
|
-
|
|
370
|
-
```javascript
|
|
371
|
-
{
|
|
372
|
-
collection: "products", // Required: collection name
|
|
373
|
-
filter: {...}, // Filter object (see above)
|
|
374
|
-
sort: "createdAt:desc", // Sort: "field:asc" or "field:desc"
|
|
375
|
-
page: 1, // Page number
|
|
376
|
-
limit: 10, // Items per page (-1 for all)
|
|
377
|
-
fields: ["*", "category.*"], // Fields to include (* for all)
|
|
378
|
-
search: "keyword", // Full-text search
|
|
379
|
-
searchFields: ["name", "desc"], // Fields to search in
|
|
380
|
-
aggregate: { // Aggregation functions
|
|
381
|
-
total: {function: "sum", field: "price"},
|
|
382
|
-
count: {function: "count", field: "id"}
|
|
383
|
-
},
|
|
384
|
-
groupBy: ["category_Id"], // Group by fields
|
|
385
|
-
relConditions: { // Filter related records
|
|
386
|
-
"reviews": {"approved": {"eq": true}}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
## Schema Definition Example
|
|
392
|
-
|
|
393
|
-
When using `baasix_create_schema`:
|
|
394
|
-
|
|
395
|
-
```javascript
|
|
396
|
-
{
|
|
397
|
-
collection: "products",
|
|
398
|
-
schema: {
|
|
399
|
-
name: "Product",
|
|
400
|
-
timestamps: true, // Adds createdAt, updatedAt
|
|
401
|
-
paranoid: false, // Set true for soft deletes
|
|
402
|
-
fields: {
|
|
403
|
-
id: {
|
|
404
|
-
type: "UUID",
|
|
405
|
-
primaryKey: true,
|
|
406
|
-
defaultValue: {type: "UUIDV4"}
|
|
407
|
-
},
|
|
408
|
-
sku: {
|
|
409
|
-
type: "SUID",
|
|
410
|
-
unique: true,
|
|
411
|
-
defaultValue: {type: "SUID"}
|
|
412
|
-
},
|
|
413
|
-
name: {
|
|
414
|
-
type: "String",
|
|
415
|
-
allowNull: false,
|
|
416
|
-
values: {length: 255},
|
|
417
|
-
validate: {notEmpty: true, len: [3, 255]}
|
|
418
|
-
},
|
|
419
|
-
price: {
|
|
420
|
-
type: "Decimal",
|
|
421
|
-
values: {precision: 10, scale: 2},
|
|
422
|
-
defaultValue: 0.00,
|
|
423
|
-
validate: {min: 0, max: 999999.99}
|
|
424
|
-
},
|
|
425
|
-
quantity: {
|
|
426
|
-
type: "Integer",
|
|
427
|
-
defaultValue: 0,
|
|
428
|
-
validate: {isInt: true, min: 0}
|
|
429
|
-
},
|
|
430
|
-
email: {
|
|
431
|
-
type: "String",
|
|
432
|
-
validate: {isEmail: true}
|
|
433
|
-
},
|
|
434
|
-
tags: {
|
|
435
|
-
type: "Array",
|
|
436
|
-
values: {type: "String"},
|
|
437
|
-
defaultValue: []
|
|
438
|
-
},
|
|
439
|
-
metadata: {
|
|
440
|
-
type: "JSONB",
|
|
441
|
-
defaultValue: {}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
```
|
|
447
|
-
|
|
448
|
-
### Field Validation Rules
|
|
449
|
-
|
|
450
|
-
| Rule | Type | Description |
|
|
451
|
-
|------|------|-------------|
|
|
452
|
-
| `min` | number | Minimum value for numeric fields |
|
|
453
|
-
| `max` | number | Maximum value for numeric fields |
|
|
454
|
-
| `isInt` | boolean | Validate as integer |
|
|
455
|
-
| `notEmpty` | boolean | String cannot be empty |
|
|
456
|
-
| `isEmail` | boolean | Valid email format |
|
|
457
|
-
| `isUrl` | boolean | Valid URL format |
|
|
458
|
-
| `len` | [min, max] | String length range |
|
|
459
|
-
| `is` / `matches` | regex | Pattern matching |
|
|
460
|
-
|
|
461
|
-
```javascript
|
|
462
|
-
// Validation examples
|
|
463
|
-
{
|
|
464
|
-
"email": {
|
|
465
|
-
"type": "String",
|
|
466
|
-
"validate": {"isEmail": true, "notEmpty": true}
|
|
467
|
-
},
|
|
468
|
-
"age": {
|
|
469
|
-
"type": "Integer",
|
|
470
|
-
"validate": {"isInt": true, "min": 0, "max": 120}
|
|
471
|
-
},
|
|
472
|
-
"username": {
|
|
473
|
-
"type": "String",
|
|
474
|
-
"validate": {"notEmpty": true, "len": [3, 50]}
|
|
475
|
-
},
|
|
476
|
-
"phone": {
|
|
477
|
-
"type": "String",
|
|
478
|
-
"validate": {"matches": "^\\+?[1-9]\\d{1,14}$"}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
### Default Value Types
|
|
484
|
-
|
|
485
|
-
| Type | Description |
|
|
486
|
-
|------|-------------|
|
|
487
|
-
| `UUIDV4` | Random UUID v4 |
|
|
488
|
-
| `SUID` | Short unique ID (compact, URL-safe) |
|
|
489
|
-
| `NOW` | Current timestamp |
|
|
490
|
-
| `AUTOINCREMENT` | Auto-incrementing integer |
|
|
491
|
-
| `SQL` | Custom SQL expression |
|
|
492
|
-
| Static | Any constant value (`"active"`, `false`, `0`) |
|
|
493
|
-
|
|
494
|
-
```javascript
|
|
495
|
-
// Default value examples
|
|
496
|
-
{
|
|
497
|
-
"id": {"type": "UUID", "defaultValue": {"type": "UUIDV4"}},
|
|
498
|
-
"shortCode": {"type": "SUID", "defaultValue": {"type": "SUID"}},
|
|
499
|
-
"createdAt": {"type": "DateTime", "defaultValue": {"type": "NOW"}},
|
|
500
|
-
"orderNum": {"type": "Integer", "defaultValue": {"type": "AUTOINCREMENT"}},
|
|
501
|
-
"sortOrder": {"type": "Integer", "defaultValue": {"type": "SQL", "value": "(SELECT MAX(sort)+1 FROM items)"}},
|
|
502
|
-
"status": {"type": "String", "defaultValue": "pending"},
|
|
503
|
-
"isActive": {"type": "Boolean", "defaultValue": true}
|
|
504
|
-
}
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
### Supported Field Types
|
|
508
|
-
- **String**: `values: {length: 255}` for VARCHAR
|
|
509
|
-
- **Text**: Unlimited length text
|
|
510
|
-
- **Integer**, **BigInt**: Whole numbers
|
|
511
|
-
- **Decimal**: `values: {precision: 10, scale: 2}`
|
|
512
|
-
- **Float**, **Real**, **Double**: Floating point
|
|
513
|
-
- **Boolean**: true/false
|
|
514
|
-
- **Date**, **DateTime**, **Time**: Date/time values
|
|
515
|
-
- **UUID**: `defaultValue: {type: "UUIDV4"}`
|
|
516
|
-
- **SUID**: `defaultValue: {type: "SUID"}` - Short unique ID
|
|
517
|
-
- **JSONB**: JSON with indexing
|
|
518
|
-
- **Array**: `values: {type: "String|Integer|etc"}`
|
|
519
|
-
- **Geometry**, **Geography**: PostGIS spatial types
|
|
520
|
-
- **Enum**: `values: {values: ["A", "B", "C"]}`
|
|
521
|
-
|
|
522
|
-
## Relationship Types
|
|
523
|
-
|
|
524
|
-
When using `baasix_create_relationship`:
|
|
525
|
-
|
|
526
|
-
```javascript
|
|
527
|
-
// Many-to-One (products.category_Id → categories.id)
|
|
528
|
-
{
|
|
529
|
-
sourceCollection: "products",
|
|
530
|
-
relationshipData: {
|
|
531
|
-
type: "M2O",
|
|
532
|
-
name: "category", // Creates category_Id field
|
|
533
|
-
target: "categories",
|
|
534
|
-
alias: "products" // Reverse relation name
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// Many-to-Many (products ↔ tags)
|
|
539
|
-
// Auto-generates junction table: products_tags_tags_junction
|
|
540
|
-
{
|
|
541
|
-
sourceCollection: "products",
|
|
542
|
-
relationshipData: {
|
|
543
|
-
type: "M2M",
|
|
544
|
-
name: "tags",
|
|
545
|
-
target: "tags",
|
|
546
|
-
alias: "products"
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
// Many-to-Many with custom junction table name
|
|
551
|
-
// Useful when auto-generated name exceeds PostgreSQL's 63 char limit
|
|
552
|
-
{
|
|
553
|
-
sourceCollection: "products",
|
|
554
|
-
relationshipData: {
|
|
555
|
-
type: "M2M",
|
|
556
|
-
name: "tags",
|
|
557
|
-
target: "tags",
|
|
558
|
-
alias: "products",
|
|
559
|
-
through: "product_tags" // Custom junction table name (max 63 chars)
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// Many-to-Any (polymorphic - comments can belong to posts OR products)
|
|
564
|
-
{
|
|
565
|
-
sourceCollection: "comments",
|
|
566
|
-
relationshipData: {
|
|
567
|
-
type: "M2A",
|
|
568
|
-
name: "commentable",
|
|
569
|
-
tables: ["posts", "products"],
|
|
570
|
-
alias: "comments",
|
|
571
|
-
through: "comment_refs" // Optional custom junction table name
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
```
|
|
575
|
-
|
|
576
|
-
### Junction Tables (M2M/M2A)
|
|
577
|
-
|
|
578
|
-
- **Auto-generated name**: `{source}_{target}_{name}_junction`
|
|
579
|
-
- **Custom name**: Use `through` property (max 63 characters for PostgreSQL)
|
|
580
|
-
- **Schema property**: Junction tables have `isJunction: true` in their schema definition
|
|
581
|
-
- **Auto-indexed**: Foreign key columns are automatically indexed for better query performance
|
|
582
|
-
|
|
583
|
-
## Permission Structure
|
|
584
|
-
|
|
585
|
-
When using `baasix_create_permission`:
|
|
586
|
-
|
|
587
|
-
```javascript
|
|
588
|
-
{
|
|
589
|
-
role_Id: "uuid-of-role",
|
|
590
|
-
collection: "products",
|
|
591
|
-
action: "read", // read, create, update, delete
|
|
592
|
-
fields: ["*"], // Or specific: ["name", "price"]
|
|
593
|
-
conditions: { // Row-level security
|
|
594
|
-
"published": {"eq": true}
|
|
595
|
-
},
|
|
596
|
-
relConditions: { // Filter related data
|
|
597
|
-
"reviews": {"approved": {"eq": true}}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
```
|
|
321
|
+
For the complete list of 50+ operators, see the [Filter Reference](https://baasix.dev/docs/complete-filter-reference).
|
|
601
322
|
|
|
602
323
|
## Package Usage
|
|
603
324
|
|
|
@@ -606,7 +327,7 @@ When using `baasix_create_permission`:
|
|
|
606
327
|
npm install @baasix/mcp
|
|
607
328
|
```
|
|
608
329
|
|
|
609
|
-
### Usage
|
|
330
|
+
### Programmatic Usage
|
|
610
331
|
```javascript
|
|
611
332
|
import { startMCPServer } from '@baasix/mcp';
|
|
612
333
|
|
|
@@ -616,51 +337,18 @@ startMCPServer().catch((error) => {
|
|
|
616
337
|
});
|
|
617
338
|
```
|
|
618
339
|
|
|
619
|
-
### Custom Server Instance
|
|
620
|
-
```javascript
|
|
621
|
-
import { BaasixMCPServer } from '@baasix/mcp';
|
|
622
|
-
|
|
623
|
-
const server = new BaasixMCPServer();
|
|
624
|
-
server.run().catch(console.error);
|
|
625
|
-
```
|
|
626
|
-
|
|
627
|
-
## Claude Code CLI Commands
|
|
628
|
-
|
|
629
|
-
```bash
|
|
630
|
-
# Add MCP server
|
|
631
|
-
claude mcp add baasix npm run start
|
|
632
|
-
|
|
633
|
-
# Remove MCP server
|
|
634
|
-
claude mcp remove baasix
|
|
635
|
-
```
|
|
636
|
-
|
|
637
|
-
## File Structure
|
|
638
|
-
|
|
639
|
-
```
|
|
640
|
-
mcp/
|
|
641
|
-
├── server.js # Entry point
|
|
642
|
-
├── package.json # Dependencies and scripts
|
|
643
|
-
├── .env # Development config
|
|
644
|
-
├── .env.example # Template
|
|
645
|
-
├── .env.production # Production config
|
|
646
|
-
├── README.md # This file
|
|
647
|
-
└── baasix/
|
|
648
|
-
├── index.js # MCP server implementation
|
|
649
|
-
└── config.js # Configuration management
|
|
650
|
-
```
|
|
651
|
-
|
|
652
340
|
## Requirements
|
|
653
341
|
|
|
654
342
|
- Node.js 18+
|
|
655
|
-
- Baasix server running (v0.1.0
|
|
343
|
+
- Baasix server running (v0.1.0+)
|
|
656
344
|
- PostgreSQL 14+ (with PostGIS for geospatial)
|
|
657
345
|
|
|
658
346
|
## Links
|
|
659
347
|
|
|
660
348
|
- **Baasix Website**: https://baasix.dev
|
|
661
|
-
- **Documentation**: https://baasix.dev/docs
|
|
349
|
+
- **Documentation**: https://baasix.dev/docs/mcp-server-docs
|
|
662
350
|
- **GitHub**: https://github.com/baasix/baasix
|
|
663
|
-
- **npm Package**: https://www.npmjs.com/package/@baasix/
|
|
351
|
+
- **npm Package**: https://www.npmjs.com/package/@baasix/mcp
|
|
664
352
|
|
|
665
353
|
## License
|
|
666
354
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Baasix MCP Server CLI
|
|
5
|
+
*
|
|
6
|
+
* This is the entry point for running the MCP server via npx.
|
|
7
|
+
* Usage: npx @baasix/mcp
|
|
8
|
+
*
|
|
9
|
+
* Environment variables:
|
|
10
|
+
* BAASIX_URL - URL of your Baasix server (default: http://localhost:8056)
|
|
11
|
+
* BAASIX_AUTH_TOKEN - Static auth token (optional)
|
|
12
|
+
* BAASIX_EMAIL - Email for auto-login (optional)
|
|
13
|
+
* BAASIX_PASSWORD - Password for auto-login (optional)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { startMCPServer } from "../baasix/index.js";
|
|
17
|
+
|
|
18
|
+
startMCPServer().catch((error) => {
|
|
19
|
+
console.error("Failed to start MCP server:", error);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baasix/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Model Context Protocol (MCP) server for Baasix Backend-as-a-Service - provides 40+ tools for schema management, CRUD operations with 50+ filter operators, relationships, permissions, files, workflows, and more",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "baasix/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"baasix-mcp": "./bin/baasix-mcp.js"
|
|
9
|
+
},
|
|
7
10
|
"files": [
|
|
8
11
|
"baasix/",
|
|
12
|
+
"bin/",
|
|
9
13
|
"README.md"
|
|
10
14
|
],
|
|
11
15
|
"scripts": {
|