suppa-mcp-2 1.0.0 → 1.1.1
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 +310 -27
- package/dist/bin.js +1 -1
- package/dist/server.js +114 -2
- package/dist/tools/automation.js +360 -2
- package/package.json +28 -4
package/README.md
CHANGED
|
@@ -1,23 +1,62 @@
|
|
|
1
1
|
# suppa-mcp-2
|
|
2
2
|
|
|
3
|
-
MCP (Model Context Protocol) server for the
|
|
4
|
-
|
|
5
|
-
attachments, with multi-tenant Google authentication.
|
|
3
|
+
MCP (Model Context Protocol) server for the **Suppa 2.0** platform ([modern.suppa.me](https://modern.suppa.me)).
|
|
4
|
+
Allows LLMs (Claude, GPT, Copilot, Cursor, etc.) to manage Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments through standardised MCP tools — with multi-tenant Google authentication.
|
|
6
5
|
|
|
7
|
-
This is the Node.js/TypeScript port of the Python [`suppa-mcp`](https://pypi.org/project/suppa-mcp/)
|
|
8
|
-
package, published to npm as **`suppa-mcp-2`**.
|
|
6
|
+
This is the Node.js/TypeScript port of the Python [`suppa-mcp`](https://pypi.org/project/suppa-mcp/) package, published to npm as **`suppa-mcp-2`**.
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
[](https://www.npmjs.com/package/suppa-mcp-2)
|
|
9
|
+
[](LICENSE)
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
### Run directly with npx
|
|
13
16
|
|
|
14
17
|
```bash
|
|
15
18
|
npx suppa-mcp-2
|
|
16
19
|
```
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
### Or install from npm
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g suppa-mcp-2
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
No API key needed to start — the server authenticates interactively via the `suppa_login` tool (see [Authentication](#authentication)).
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Authentication
|
|
32
|
+
|
|
33
|
+
There is **no API key to paste**. Run the **`suppa_login`** tool from your MCP client — it opens a browser for Google sign-in, then stores the resulting tokens in the OS keychain (Windows Credential Manager / macOS Keychain / libsecret). The server is **multi-tenant**: log in to more than one Suppa tenant and switch with `suppa_use_tenant`.
|
|
34
|
+
|
|
35
|
+
Credentials stay on your machine, are sent only in the `Authorization` header to your configured `SUPPA_BASE_URL`, and are **never** exposed to the AI agent. A `SUPPA_API_KEY` env var is an optional CI-only alternative.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
19
40
|
|
|
20
|
-
|
|
41
|
+
All variables are optional — the server works out of the box and authenticates via `suppa_login`.
|
|
42
|
+
|
|
43
|
+
| Variable | Default | Description |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| `SUPPA_BASE_URL` | `https://modern.suppa.me` | Platform base URL (the active tenant) |
|
|
46
|
+
| `SUPPA_API_KEY` | (none) | JWT / API key; skips interactive login when set (CI) |
|
|
47
|
+
| `SUPPA_REFRESH_TOKEN` | (none) | Refresh token; paired with `SUPPA_API_KEY` for long-lived CI sessions |
|
|
48
|
+
| `SUPPA_LANG` | `en` | Language (`en` / `uk`) |
|
|
49
|
+
| `SUPPA_TZ` | `Europe/Kyiv` | Timezone |
|
|
50
|
+
| `SUPPA_MCP_LOGIN_PORT` | `8080` | Local loopback port for the browser login callback |
|
|
51
|
+
| `SUPPA_MCP_HOME` | `~/.suppa-mcp` | Directory for the tenant registry |
|
|
52
|
+
| `SUPPA_HTTP_TIMEOUT` | `60` | Per-request timeout, seconds |
|
|
53
|
+
| `SUPPA_MCP_DEBUG` | (off) | `1` logs each request line to stderr |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Use with Claude Desktop
|
|
58
|
+
|
|
59
|
+
Add to your `claude_desktop_config.json`:
|
|
21
60
|
|
|
22
61
|
```json
|
|
23
62
|
{
|
|
@@ -30,29 +69,273 @@ Point any MCP client at `npx`:
|
|
|
30
69
|
}
|
|
31
70
|
```
|
|
32
71
|
|
|
33
|
-
##
|
|
72
|
+
## Use with Cursor
|
|
73
|
+
|
|
74
|
+
Add to `.cursor/mcp.json` in your project:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"mcpServers": {
|
|
79
|
+
"suppa-2.0": {
|
|
80
|
+
"command": "npx",
|
|
81
|
+
"args": ["-y", "suppa-mcp-2"]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
34
86
|
|
|
35
|
-
|
|
36
|
-
for Google sign-in, then stores the resulting credentials locally (in the OS keychain). The
|
|
37
|
-
server is multi-tenant, so you can log in to more than one Suppa tenant and switch between them.
|
|
87
|
+
## Use with VS Code (Copilot)
|
|
38
88
|
|
|
39
|
-
|
|
40
|
-
configured `SUPPA_BASE_URL`; they are **never** exposed to the AI agent.
|
|
89
|
+
Add to `.vscode/mcp.json`:
|
|
41
90
|
|
|
42
|
-
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"servers": {
|
|
94
|
+
"suppa-2.0": {
|
|
95
|
+
"command": "npx",
|
|
96
|
+
"args": ["-y", "suppa-mcp-2"]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
43
101
|
|
|
44
|
-
|
|
102
|
+
Then run **`suppa_login`** once per tenant to authenticate.
|
|
45
103
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Agent workflow
|
|
107
|
+
|
|
108
|
+
When an AI agent connects, the server provides built-in instructions describing the correct workflow. Auth first, then discover schema before reading or writing data:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
┌─────────────────────────────────────────────────────────┐
|
|
112
|
+
│ 0. AUTHENTICATE (once per tenant) │
|
|
113
|
+
│ suppa_login — Google browser sign-in │
|
|
114
|
+
│ suppa_use_tenant — switch active tenant │
|
|
115
|
+
├─────────────────────────────────────────────────────────┤
|
|
116
|
+
│ 1. DISCOVER ENTITIES │
|
|
117
|
+
│ suppa_list_entities(search?: "task") │
|
|
118
|
+
│ suppa_search_entities — fuzzy-find + record count │
|
|
119
|
+
├─────────────────────────────────────────────────────────┤
|
|
120
|
+
│ 2. DISCOVER FIELDS │
|
|
121
|
+
│ suppa_describe_entity(entity_name) │
|
|
122
|
+
│ suppa_list_field_types / suppa_list_tabular_parts │
|
|
123
|
+
├─────────────────────────────────────────────────────────┤
|
|
124
|
+
│ 3. READ DATA │
|
|
125
|
+
│ suppa_search_records / suppa_get_record │
|
|
126
|
+
│ suppa_search_tasks / suppa_get_task / … │
|
|
127
|
+
│ suppa_list_docs / suppa_read_page / suppa_get_blocks │
|
|
128
|
+
│ suppa_list_automations / suppa_get_automation │
|
|
129
|
+
├─────────────────────────────────────────────────────────┤
|
|
130
|
+
│ 4. WRITE DATA (destructive/edit tools are confirm-gated)│
|
|
131
|
+
│ suppa_create_record / suppa_update_record │
|
|
132
|
+
│ suppa_create_entity / suppa_add_field │
|
|
133
|
+
│ suppa_create_automation / suppa_publish_automation │
|
|
134
|
+
└─────────────────────────────────────────────────────────┘
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
> **Important:** discover with `suppa_list_entities` → `suppa_describe_entity` before reading or writing — field names, types, and filters vary between entities. Edit/delete tools return a **confirmation preview** first and only apply when re-called with `confirm=true`.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Available tools
|
|
142
|
+
|
|
143
|
+
79 tools across the areas below.
|
|
144
|
+
|
|
145
|
+
### Session & identity
|
|
146
|
+
|
|
147
|
+
| Tool | Description |
|
|
148
|
+
|---|---|
|
|
149
|
+
| `suppa_get_me` | Current authenticated user's profile |
|
|
150
|
+
| `suppa_login` | Google browser sign-in for a tenant (stores tokens in OS keychain) |
|
|
151
|
+
| `suppa_use_tenant` | Switch the active tenant (alias / host / URL) |
|
|
152
|
+
| `suppa_list_tenants` | List known tenants + which is active / authenticated |
|
|
153
|
+
| `suppa_logout` | Remove stored credentials for a tenant |
|
|
154
|
+
| `suppa_diagnostics` | Validate the whole multi-tenant setup |
|
|
155
|
+
| `suppa_health_check` | Config + upstream connectivity check |
|
|
156
|
+
|
|
157
|
+
### Tasks
|
|
158
|
+
|
|
159
|
+
| Tool | Description |
|
|
160
|
+
|---|---|
|
|
161
|
+
| `suppa_search_tasks` | Search tasks (my / active / overdue / due-today filters, paginated) |
|
|
162
|
+
| `suppa_count_tasks` | Count tasks matching filters |
|
|
163
|
+
| `suppa_get_task` | Get a single task |
|
|
164
|
+
| `suppa_create_task` | Create a task |
|
|
165
|
+
| `suppa_update_task` | Update a task (confirm-gated) |
|
|
166
|
+
| `suppa_delete_task` | Delete a task (confirm-gated) |
|
|
167
|
+
| `suppa_move_task` | Move a task to another stage (confirm-gated) |
|
|
168
|
+
| `suppa_close_task` | Close a task (confirm-gated) |
|
|
169
|
+
| `suppa_add_comment` | Add a comment (supports @mentions) |
|
|
170
|
+
| `suppa_get_comments` | Get comments on a task |
|
|
171
|
+
| `suppa_attach_file` | Attach a local file to a task |
|
|
172
|
+
| `suppa_list_workflows` | List Task workflows |
|
|
173
|
+
| `suppa_list_stages` | List stages of a workflow |
|
|
174
|
+
| `suppa_list_task_types` | List task types |
|
|
175
|
+
| `suppa_search_users` | Search users (feeds assignee / mentions) |
|
|
176
|
+
|
|
177
|
+
### Docs & pages
|
|
178
|
+
|
|
179
|
+
| Tool | Description |
|
|
180
|
+
|---|---|
|
|
181
|
+
| `suppa_list_docs` | List docs |
|
|
182
|
+
| `suppa_get_doc` | Get a doc |
|
|
183
|
+
| `suppa_create_doc` | Create a doc |
|
|
184
|
+
| `suppa_update_doc` | Update a doc (confirm-gated) |
|
|
185
|
+
| `suppa_delete_doc` | Delete a doc (confirm-gated) |
|
|
186
|
+
| `suppa_list_pages` | List pages of a doc |
|
|
187
|
+
| `suppa_get_page` | Get a page |
|
|
188
|
+
| `suppa_create_page` | Create a page |
|
|
189
|
+
| `suppa_update_page` | Update a page (confirm-gated) |
|
|
190
|
+
| `suppa_delete_page` | Delete a page (confirm-gated) |
|
|
191
|
+
| `suppa_get_blocks` | Get raw blocks of a page |
|
|
192
|
+
| `suppa_read_page` | Read a page rendered to text |
|
|
193
|
+
| `suppa_create_blocks` | Create blocks from a JSON array (11 block types) |
|
|
194
|
+
| `suppa_insert_block` | Insert a block at a position |
|
|
195
|
+
| `suppa_update_block` | Update a block (confirm-gated) |
|
|
196
|
+
| `suppa_delete_block` | Delete a block (confirm-gated) |
|
|
197
|
+
| `suppa_reorder_blocks` | Reorder blocks on a page |
|
|
198
|
+
|
|
199
|
+
### Entities & records
|
|
200
|
+
|
|
201
|
+
| Tool | Description |
|
|
202
|
+
|---|---|
|
|
203
|
+
| `suppa_list_entities` | List entities (tables) |
|
|
204
|
+
| `suppa_describe_entity` | Field definitions + types for an entity |
|
|
205
|
+
| `suppa_list_tabular_parts` | List tabular parts (ТЧ) of an entity |
|
|
206
|
+
| `suppa_search_records` | Search / filter records in any entity |
|
|
207
|
+
| `suppa_get_record` | Get a single record |
|
|
208
|
+
| `suppa_create_entity` | Create a new entity |
|
|
209
|
+
| `suppa_create_tabular_part` | Create a tabular part (owned rows) of a parent |
|
|
210
|
+
| `suppa_add_field` | Add a field to an entity |
|
|
211
|
+
| `suppa_add_enum_values` | Add values to an enum field |
|
|
212
|
+
| `suppa_set_title_field` | Set the representative/title field |
|
|
213
|
+
| `suppa_list_field_types` | List supported field types |
|
|
214
|
+
| `suppa_create_record` | Create a record |
|
|
215
|
+
| `suppa_update_record` | Update a record (confirm-gated) |
|
|
216
|
+
| `suppa_delete_record` | Delete a record (confirm-gated) |
|
|
217
|
+
| `suppa_attach_file_to_record` | Attach a local file to any record |
|
|
218
|
+
|
|
219
|
+
### Automations
|
|
220
|
+
|
|
221
|
+
| Tool | Description |
|
|
222
|
+
|---|---|
|
|
223
|
+
| `suppa_list_automations` | List automation workflows |
|
|
224
|
+
| `suppa_get_automation` | Get one automation as a normalized graph (nodes + edges) |
|
|
225
|
+
| `suppa_list_automation_runs` | List runs (executions) of an automation |
|
|
226
|
+
| `suppa_get_automation_run` | Get one run with per-node steps + trigger payload |
|
|
227
|
+
| `suppa_list_automation_node_types` | Node-type catalog (authoritative + fallback) |
|
|
228
|
+
| `suppa_get_automation_node_schema` | Parameter schema for one node type |
|
|
229
|
+
| `suppa_search_entities` | Fuzzy-find an entity by name/title (+ record count) |
|
|
230
|
+
| `suppa_create_automation` | Create an automation (pre-flight validated; draft) |
|
|
231
|
+
| `suppa_update_automation` | Update an automation (read-modify-write; confirm-gated) |
|
|
232
|
+
| `suppa_delete_automation` | Delete an automation (confirm-gated) |
|
|
233
|
+
| `suppa_publish_automation` | Publish the draft snapshot (confirm-gated) |
|
|
234
|
+
| `suppa_unpublish_automation` | Deactivate an automation (confirm-gated) |
|
|
235
|
+
|
|
236
|
+
### Forms
|
|
237
|
+
|
|
238
|
+
| Tool | Description |
|
|
239
|
+
|---|---|
|
|
240
|
+
| `suppa_list_forms` | List forms |
|
|
241
|
+
| `suppa_get_form` | Get a form |
|
|
242
|
+
| `suppa_create_form` | Create a form (optionally generated from an entity) |
|
|
243
|
+
| `suppa_update_form` | Update a form (confirm-gated) |
|
|
244
|
+
| `suppa_generate_form_schema` | Generate a grid form schema from an entity |
|
|
245
|
+
| `suppa_add_field_to_form` | Add a field element to a form (confirm-gated) |
|
|
246
|
+
| `suppa_list_form_field_types` | List form element types |
|
|
247
|
+
|
|
248
|
+
### Migration (Suppa 1.0 → 2.0) & workspace
|
|
249
|
+
|
|
250
|
+
| Tool | Description |
|
|
251
|
+
|---|---|
|
|
252
|
+
| `suppa_migrate_entities_from_v1` | Migrate 1.0 entities → 2.0 (dry-run / create / gap-fill / reconcile) |
|
|
253
|
+
| `suppa_read_v1_entities` | Read entity list from a Suppa 1.0 tenant |
|
|
254
|
+
| `suppa_read_v1_entity_props` | Read 1.0 entity field definitions |
|
|
255
|
+
| `suppa_read_v1_enum` | Read 1.0 enum values |
|
|
256
|
+
| `suppa_create_workspace` | Create a workspace + nav item |
|
|
257
|
+
| `suppa_add_menu_item` | Add a navigation-menu item |
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Prompts
|
|
262
|
+
|
|
263
|
+
Guided workflows clients can expose as slash commands:
|
|
264
|
+
|
|
265
|
+
| Prompt | Arguments | Description |
|
|
266
|
+
|---|---|---|
|
|
267
|
+
| `plan_my_day` | — | Triage my Suppa tasks into a prioritized day plan |
|
|
268
|
+
| `build_entity` | `entity_purpose` | Guided design + creation of a new entity, fields, enums, and a form |
|
|
269
|
+
| `migrate_from_v1` | `entity_names?` | Guided Suppa 1.0 → 2.0 schema migration (dry-run, review, execute) |
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Development
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
# Install dependencies
|
|
277
|
+
npm install
|
|
278
|
+
|
|
279
|
+
# Build
|
|
280
|
+
npm run build
|
|
281
|
+
|
|
282
|
+
# Run locally (stdio)
|
|
283
|
+
node dist/bin.js
|
|
284
|
+
|
|
285
|
+
# Test with MCP Inspector
|
|
286
|
+
npm run inspect
|
|
287
|
+
|
|
288
|
+
# Tests
|
|
289
|
+
npm test
|
|
290
|
+
|
|
291
|
+
# Watch mode
|
|
292
|
+
npm run dev
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Publish to npm
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# 1. Make sure you're logged in
|
|
301
|
+
npm login
|
|
302
|
+
|
|
303
|
+
# 2. Build & publish
|
|
304
|
+
npm publish
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
The `prepublishOnly` script automatically runs `tsc` + the full test suite before publishing.
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Project structure
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
suppa-mcp-node/
|
|
315
|
+
├── src/
|
|
316
|
+
│ ├── bin.ts # Entry point — stdio transport
|
|
317
|
+
│ ├── server.ts # McpServer + all 79 tool + 3 prompt registrations
|
|
318
|
+
│ ├── config.ts # Env / .env config surface
|
|
319
|
+
│ ├── store.ts # Credentials in the OS keychain (@napi-rs/keyring)
|
|
320
|
+
│ ├── registry.ts # Non-secret tenant registry (~/.suppa-mcp/tenants.json)
|
|
321
|
+
│ ├── tenants.ts # Tenant context, active tenant, resolve, diagnostics
|
|
322
|
+
│ ├── auth.ts # JWT refresh (single-flight) + browser Google login
|
|
323
|
+
│ ├── httpClient.ts # fetch client: retry, envelope unwrap, 401→refresh→retry
|
|
324
|
+
│ ├── utils.ts # filters, dates, JSON params, multipart, confirm gate
|
|
325
|
+
│ └── tools/
|
|
326
|
+
│ ├── tasks.ts docs.ts entity.ts forms.ts
|
|
327
|
+
│ ├── automation.ts # read + write automation tools
|
|
328
|
+
│ ├── migrate.ts nameMap.ts v1Fields.ts
|
|
329
|
+
│ └── workspace.ts
|
|
330
|
+
├── test/ # vitest suite (ports the Python test suite)
|
|
331
|
+
├── scripts/ # live read-only / write verify scripts
|
|
332
|
+
├── package.json
|
|
333
|
+
├── tsconfig.json
|
|
334
|
+
├── vitest.config.ts
|
|
335
|
+
└── README.md
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
56
339
|
|
|
57
340
|
## License
|
|
58
341
|
|
package/dist/bin.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* stdio entrypoint for the Suppa MCP server (npm `suppa-mcp-2`).
|
|
4
4
|
*
|
|
5
|
-
* Builds the server (all
|
|
5
|
+
* Builds the server (all 79 tools) and connects it to stdio, exactly like the
|
|
6
6
|
* Python package's console script. Faithful 1:1 port.
|
|
7
7
|
*/
|
|
8
8
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Suppa MCP Server — unified gateway to the Suppa platform.
|
|
3
3
|
*
|
|
4
|
-
* Faithful 1:1 port of the Python `suppa_mcp/server.py`. Wires all
|
|
4
|
+
* Faithful 1:1 port of the Python `suppa_mcp/server.py`. Wires all 79 tools,
|
|
5
5
|
* mirrors the tool-behavior annotations (_READ/_ADD/_MUT), reproduces the
|
|
6
6
|
* server `instructions` string verbatim, and OWNS all confirm-gating (the tool
|
|
7
7
|
* modules mutate unconditionally, exactly like the Python tool functions).
|
|
@@ -199,7 +199,7 @@ export function buildServer() {
|
|
|
199
199
|
// Reset so repeated buildServer() calls (e.g. in tests) do not double-count.
|
|
200
200
|
TOOL_NAMES.length = 0;
|
|
201
201
|
PROMPT_NAMES.length = 0;
|
|
202
|
-
const server = new McpServer({ name: "suppa-2.0", version: "1.
|
|
202
|
+
const server = new McpServer({ name: "suppa-2.0", version: "1.1.0" }, { instructions: INSTRUCTIONS });
|
|
203
203
|
const reg = (name, cfg, handler) => {
|
|
204
204
|
server.registerTool(name, {
|
|
205
205
|
description: cfg.description,
|
|
@@ -1043,6 +1043,118 @@ export function buildServer() {
|
|
|
1043
1043
|
annotations: _READ,
|
|
1044
1044
|
}, async (a) => text(await automation.searchEntities(a.query, a.limit)));
|
|
1045
1045
|
// =========================================================================
|
|
1046
|
+
// Automation (workflow) tools — WRITE
|
|
1047
|
+
// =========================================================================
|
|
1048
|
+
reg("suppa_create_automation", {
|
|
1049
|
+
description: "Create a DRAFT automation workflow (AutomationWorkflow). Writes only draft\n" +
|
|
1050
|
+
" columns (name/nodes/connections/settings) with isActive=false — it is NOT live\n" +
|
|
1051
|
+
" until published (suppa_publish_automation). Runs pre-flight validation (one\n" +
|
|
1052
|
+
" trigger first, unique node ids, connections reference known nodes, DAG, suppa\n" +
|
|
1053
|
+
" node params); on failure nothing is written and the errors are returned.",
|
|
1054
|
+
inputSchema: {
|
|
1055
|
+
name: z.string().describe("Automation name."),
|
|
1056
|
+
nodes_json: z
|
|
1057
|
+
.string()
|
|
1058
|
+
.describe('JSON array of nodes: [{"id","type","parameters":{...}}]. First node must be a ' +
|
|
1059
|
+
"trigger (triggerEntity/triggerManual/triggerWebhook)."),
|
|
1060
|
+
connections_json: z
|
|
1061
|
+
.string()
|
|
1062
|
+
.describe('JSON object of connections: {"srcNodeId": {"handle": [{"node": "targetId", "index": 0}]}}.'),
|
|
1063
|
+
settings_json: z
|
|
1064
|
+
.string()
|
|
1065
|
+
.nullable()
|
|
1066
|
+
.default(null)
|
|
1067
|
+
.describe("Optional JSON settings object; defaults to {}."),
|
|
1068
|
+
},
|
|
1069
|
+
annotations: _ADD,
|
|
1070
|
+
}, async (a) => text(await automation.createAutomation(a.name, a.nodes_json, a.connections_json, a.settings_json)));
|
|
1071
|
+
reg("suppa_update_automation", {
|
|
1072
|
+
description: "Partial update of a DRAFT automation (read-modify-write). Only supplied fields\n" +
|
|
1073
|
+
" change; settings is merged over the stored value (pinData and untouched keys\n" +
|
|
1074
|
+
" preserved); nodes/connections are whole-document replaces. Runs pre-flight\n" +
|
|
1075
|
+
" validation on the resulting graph.\n\n" +
|
|
1076
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and\n" +
|
|
1077
|
+
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1078
|
+
inputSchema: {
|
|
1079
|
+
automation_id: AutomationId,
|
|
1080
|
+
name: z.string().nullable().default(null).describe("New automation name."),
|
|
1081
|
+
nodes_json: z
|
|
1082
|
+
.string()
|
|
1083
|
+
.nullable()
|
|
1084
|
+
.default(null)
|
|
1085
|
+
.describe("Replacement JSON array of nodes (whole-document replace)."),
|
|
1086
|
+
connections_json: z
|
|
1087
|
+
.string()
|
|
1088
|
+
.nullable()
|
|
1089
|
+
.default(null)
|
|
1090
|
+
.describe("Replacement JSON object of connections (whole-document replace)."),
|
|
1091
|
+
settings_json: z
|
|
1092
|
+
.string()
|
|
1093
|
+
.nullable()
|
|
1094
|
+
.default(null)
|
|
1095
|
+
.describe("JSON settings object; merged over the stored settings."),
|
|
1096
|
+
confirm: Confirm,
|
|
1097
|
+
},
|
|
1098
|
+
annotations: _MUT,
|
|
1099
|
+
}, async (a) => {
|
|
1100
|
+
if (!a.confirm) {
|
|
1101
|
+
const entries = [
|
|
1102
|
+
["name", a.name],
|
|
1103
|
+
["nodes_json", a.nodes_json],
|
|
1104
|
+
["connections_json", a.connections_json],
|
|
1105
|
+
["settings_json", a.settings_json],
|
|
1106
|
+
];
|
|
1107
|
+
const changes = {};
|
|
1108
|
+
for (const [k, v] of entries) {
|
|
1109
|
+
if (v !== null && v !== undefined)
|
|
1110
|
+
changes[k] = v;
|
|
1111
|
+
}
|
|
1112
|
+
return text(confirmRequired("update automation", { automation_id: a.automation_id }, changes));
|
|
1113
|
+
}
|
|
1114
|
+
return text(await automation.updateAutomation(a.automation_id, a.name, a.nodes_json, a.connections_json, a.settings_json));
|
|
1115
|
+
});
|
|
1116
|
+
reg("suppa_delete_automation", {
|
|
1117
|
+
description: "Soft-delete an automation workflow.\n\n" +
|
|
1118
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and\n" +
|
|
1119
|
+
" deletes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1120
|
+
inputSchema: { automation_id: AutomationId, confirm: Confirm },
|
|
1121
|
+
annotations: _MUT,
|
|
1122
|
+
}, async (a) => {
|
|
1123
|
+
if (!a.confirm) {
|
|
1124
|
+
return text(confirmRequired("delete automation", { automation_id: a.automation_id }));
|
|
1125
|
+
}
|
|
1126
|
+
return text(await automation.deleteAutomation(a.automation_id));
|
|
1127
|
+
});
|
|
1128
|
+
reg("suppa_publish_automation", {
|
|
1129
|
+
description: "Publish (activate) an automation — promotes the draft to the live snapshot via\n" +
|
|
1130
|
+
" the automation-service. Requires the automation-service deployed on the tenant;\n" +
|
|
1131
|
+
" if absent the call 404s and the error is returned (never crashes). A typed 400\n" +
|
|
1132
|
+
" returns {published:false, errors, warnings, message}.\n\n" +
|
|
1133
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and\n" +
|
|
1134
|
+
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1135
|
+
inputSchema: { automation_id: AutomationId, confirm: Confirm },
|
|
1136
|
+
annotations: _MUT,
|
|
1137
|
+
}, async (a) => {
|
|
1138
|
+
if (!a.confirm) {
|
|
1139
|
+
return text(confirmRequired("publish automation", { automation_id: a.automation_id }));
|
|
1140
|
+
}
|
|
1141
|
+
return text(await automation.publishAutomation(a.automation_id));
|
|
1142
|
+
});
|
|
1143
|
+
reg("suppa_unpublish_automation", {
|
|
1144
|
+
description: "Unpublish (deactivate) an automation — clears the live snapshot via the\n" +
|
|
1145
|
+
" automation-service. Requires the automation-service deployed (else 404,\n" +
|
|
1146
|
+
" returned as an error).\n\n" +
|
|
1147
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and\n" +
|
|
1148
|
+
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1149
|
+
inputSchema: { automation_id: AutomationId, confirm: Confirm },
|
|
1150
|
+
annotations: _MUT,
|
|
1151
|
+
}, async (a) => {
|
|
1152
|
+
if (!a.confirm) {
|
|
1153
|
+
return text(confirmRequired("unpublish automation", { automation_id: a.automation_id }));
|
|
1154
|
+
}
|
|
1155
|
+
return text(await automation.unpublishAutomation(a.automation_id));
|
|
1156
|
+
});
|
|
1157
|
+
// =========================================================================
|
|
1046
1158
|
// Migration connector (Suppa 1.0 -> Suppa 2.0)
|
|
1047
1159
|
// =========================================================================
|
|
1048
1160
|
reg("suppa_migrate_entities_from_v1", {
|
package/dist/tools/automation.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* node-type catalog uses the authoritative /api/automation/nodes endpoint when
|
|
9
9
|
* present, and is otherwise DERIVED from the `nodes` JSON of live workflows.
|
|
10
10
|
*/
|
|
11
|
-
import { makeRequest, searchEntity, selectEntity } from "../httpClient.js";
|
|
12
|
-
import { makeFilter, jsonResponse } from "../utils.js";
|
|
11
|
+
import { makeRequest, searchEntity, selectEntity, insertEntity, updateEntity, removeEntity, } from "../httpClient.js";
|
|
12
|
+
import { makeFilter, jsonResponse, parseJsonParam } from "../utils.js";
|
|
13
13
|
export const WORKFLOW_ENTITY = "AutomationWorkflow";
|
|
14
14
|
export const EXECUTE_ENTITY = "AutomationWorkflowExecute";
|
|
15
15
|
export const EXECUTE_DATA_ENTITY = "AutomationWorkflowExecuteData";
|
|
@@ -774,3 +774,361 @@ export async function searchEntities(query, limit = 20) {
|
|
|
774
774
|
}
|
|
775
775
|
return jsonResponse(out);
|
|
776
776
|
}
|
|
777
|
+
// ===========================================================================
|
|
778
|
+
// WRITE tools — create / update / delete (entity API) and publish / unpublish
|
|
779
|
+
// / execute (automation-service).
|
|
780
|
+
//
|
|
781
|
+
// Draft columns we OWN: name, nodes, connections, settings, isActive. Service-
|
|
782
|
+
// managed columns (activeNodes/activeConnections/activeSettings/publishedAt/
|
|
783
|
+
// hasUnpublishedChanges/triggerEntityName) are NEVER written here — publishing
|
|
784
|
+
// promotes the draft into those via the automation-service.
|
|
785
|
+
// ===========================================================================
|
|
786
|
+
// Trigger node types. A workflow must have exactly one, and it must be first.
|
|
787
|
+
// `trigger` is the legacy/abstract type kept for backward compatibility.
|
|
788
|
+
const _TRIGGER_TYPES = new Set([
|
|
789
|
+
"triggerEntity",
|
|
790
|
+
"triggerManual",
|
|
791
|
+
"triggerWebhook",
|
|
792
|
+
"trigger",
|
|
793
|
+
]);
|
|
794
|
+
// Data-operation actions a `suppa` node may perform.
|
|
795
|
+
const _SUPPA_ACTIONS = new Set([
|
|
796
|
+
"select",
|
|
797
|
+
"insert",
|
|
798
|
+
"update",
|
|
799
|
+
"remove",
|
|
800
|
+
"getById",
|
|
801
|
+
"updateById",
|
|
802
|
+
"removeById",
|
|
803
|
+
]);
|
|
804
|
+
const _MAX_NODES = 500;
|
|
805
|
+
const _MAX_CONNECTIONS = 2000;
|
|
806
|
+
/** Cycle check (DFS 3-colour) over an adjacency map built from valid edges. */
|
|
807
|
+
function _hasCycle(adj) {
|
|
808
|
+
const WHITE = 0;
|
|
809
|
+
const GRAY = 1;
|
|
810
|
+
const BLACK = 2;
|
|
811
|
+
const color = {};
|
|
812
|
+
const seen = new Set();
|
|
813
|
+
for (const [s, ts] of Object.entries(adj)) {
|
|
814
|
+
seen.add(s);
|
|
815
|
+
for (const t of ts) {
|
|
816
|
+
seen.add(t);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
const visit = (u) => {
|
|
820
|
+
color[u] = GRAY;
|
|
821
|
+
for (const v of adj[u] || []) {
|
|
822
|
+
const c = color[v] ?? WHITE;
|
|
823
|
+
if (c === GRAY) {
|
|
824
|
+
return true;
|
|
825
|
+
}
|
|
826
|
+
if (c === WHITE && visit(v)) {
|
|
827
|
+
return true;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
color[u] = BLACK;
|
|
831
|
+
return false;
|
|
832
|
+
};
|
|
833
|
+
for (const u of seen) {
|
|
834
|
+
if ((color[u] ?? WHITE) === WHITE && visit(u)) {
|
|
835
|
+
return true;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return false;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Pre-flight structural validation (§7 of the spec). Returns a list of human-
|
|
842
|
+
* readable error strings; an empty list means the workflow is well-formed.
|
|
843
|
+
* Never throws — every branch guards against non-dict nodes/params.
|
|
844
|
+
*/
|
|
845
|
+
export function _validateWorkflow(nodes, connections) {
|
|
846
|
+
const errors = [];
|
|
847
|
+
if (!Array.isArray(nodes) || nodes.length === 0) {
|
|
848
|
+
errors.push("nodes must be a non-empty array");
|
|
849
|
+
return errors;
|
|
850
|
+
}
|
|
851
|
+
if (nodes.length > _MAX_NODES) {
|
|
852
|
+
errors.push(`too many nodes: ${nodes.length} (max ${_MAX_NODES})`);
|
|
853
|
+
}
|
|
854
|
+
// id / type shape + duplicate detection
|
|
855
|
+
const idSet = new Set();
|
|
856
|
+
const dups = new Set();
|
|
857
|
+
nodes.forEach((n, i) => {
|
|
858
|
+
if (!isPlainObject(n)) {
|
|
859
|
+
errors.push(`node at index ${i} is not an object`);
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
const id = n.id;
|
|
863
|
+
const type = n.type;
|
|
864
|
+
if (typeof id !== "string" || id.length === 0) {
|
|
865
|
+
errors.push(`node at index ${i} is missing a string 'id'`);
|
|
866
|
+
}
|
|
867
|
+
else {
|
|
868
|
+
if (idSet.has(id)) {
|
|
869
|
+
dups.add(id);
|
|
870
|
+
}
|
|
871
|
+
idSet.add(id);
|
|
872
|
+
}
|
|
873
|
+
if (typeof type !== "string" || type.length === 0) {
|
|
874
|
+
const label = typeof id === "string" ? `'${id}'` : `at index ${i}`;
|
|
875
|
+
errors.push(`node ${label} is missing a string 'type'`);
|
|
876
|
+
}
|
|
877
|
+
});
|
|
878
|
+
for (const d of sortedStrings(dups)) {
|
|
879
|
+
errors.push(`duplicate node id: ${d}`);
|
|
880
|
+
}
|
|
881
|
+
// exactly one trigger, and it must be first
|
|
882
|
+
const triggerIdx = [];
|
|
883
|
+
nodes.forEach((n, i) => {
|
|
884
|
+
if (isPlainObject(n) && typeof n.type === "string" && _TRIGGER_TYPES.has(n.type)) {
|
|
885
|
+
triggerIdx.push(i);
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
if (triggerIdx.length === 0) {
|
|
889
|
+
errors.push("no trigger node found (exactly one trigger required)");
|
|
890
|
+
}
|
|
891
|
+
else if (triggerIdx.length > 1) {
|
|
892
|
+
errors.push(`multiple trigger nodes found (${triggerIdx.length}); exactly one required`);
|
|
893
|
+
}
|
|
894
|
+
else if (triggerIdx[0] !== 0) {
|
|
895
|
+
errors.push("trigger node must be the first node");
|
|
896
|
+
}
|
|
897
|
+
// per-node parameter requirements
|
|
898
|
+
for (const n of nodes) {
|
|
899
|
+
if (!isPlainObject(n) || typeof n.type !== "string") {
|
|
900
|
+
continue;
|
|
901
|
+
}
|
|
902
|
+
// Tolerant config read (parameters||config||data), matching the read path.
|
|
903
|
+
const params = _nodeConfig(n);
|
|
904
|
+
const idLabel = typeof n.id === "string" ? n.id : "?";
|
|
905
|
+
if (n.type === "triggerEntity" && !params.entityName) {
|
|
906
|
+
errors.push(`trigger node '${idLabel}' (triggerEntity) requires parameters.entityName`);
|
|
907
|
+
}
|
|
908
|
+
if (n.type === "triggerWebhook" && !params.webhookPath) {
|
|
909
|
+
errors.push(`trigger node '${idLabel}' (triggerWebhook) requires parameters.webhookPath`);
|
|
910
|
+
}
|
|
911
|
+
// suppa data node: identified by type 'suppa' or a present `action` param.
|
|
912
|
+
const isSuppa = n.type === "suppa" || "action" in params;
|
|
913
|
+
if (isSuppa) {
|
|
914
|
+
const action = params.action;
|
|
915
|
+
if (typeof action !== "string" || !_SUPPA_ACTIONS.has(action)) {
|
|
916
|
+
errors.push(`suppa node '${idLabel}' has invalid or missing parameters.action ` +
|
|
917
|
+
`(expected one of ${sortedStrings(_SUPPA_ACTIONS).join(", ")})`);
|
|
918
|
+
}
|
|
919
|
+
if (!params.entityName) {
|
|
920
|
+
errors.push(`suppa node '${idLabel}' requires parameters.entityName`);
|
|
921
|
+
}
|
|
922
|
+
if ((action === "update" || action === "remove") && !params.conditions) {
|
|
923
|
+
errors.push(`suppa node '${idLabel}' with action '${action}' requires parameters.conditions`);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
// connections: every source id and every target .node id must exist; count cap
|
|
928
|
+
const adj = {};
|
|
929
|
+
let connCount = 0;
|
|
930
|
+
if (connections !== null && connections !== undefined && !isPlainObject(connections)) {
|
|
931
|
+
errors.push("connections must be an object");
|
|
932
|
+
}
|
|
933
|
+
else if (isPlainObject(connections)) {
|
|
934
|
+
for (const [src, byHandle] of Object.entries(connections)) {
|
|
935
|
+
if (!idSet.has(src)) {
|
|
936
|
+
errors.push(`connection source '${src}' is not a known node id`);
|
|
937
|
+
}
|
|
938
|
+
if (!isPlainObject(byHandle)) {
|
|
939
|
+
continue;
|
|
940
|
+
}
|
|
941
|
+
for (const targets of Object.values(byHandle)) {
|
|
942
|
+
if (!Array.isArray(targets)) {
|
|
943
|
+
continue;
|
|
944
|
+
}
|
|
945
|
+
for (const t of targets) {
|
|
946
|
+
connCount += 1;
|
|
947
|
+
const to = isPlainObject(t) ? t.node : undefined;
|
|
948
|
+
if (typeof to !== "string" || !idSet.has(to)) {
|
|
949
|
+
errors.push(`connection target '${to}' (from '${src}') is not a known node id`);
|
|
950
|
+
}
|
|
951
|
+
else if (idSet.has(src)) {
|
|
952
|
+
(adj[src] ||= []).push(to);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
if (connCount > _MAX_CONNECTIONS) {
|
|
959
|
+
errors.push(`too many connections: ${connCount} (max ${_MAX_CONNECTIONS})`);
|
|
960
|
+
}
|
|
961
|
+
// DAG requirement
|
|
962
|
+
if (_hasCycle(adj)) {
|
|
963
|
+
errors.push("cyclic connection detected");
|
|
964
|
+
}
|
|
965
|
+
return errors;
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Create a draft automation workflow via the entity API. Writes only draft
|
|
969
|
+
* columns (name/nodes/connections/settings) with isActive=false; the workflow
|
|
970
|
+
* is NOT live until published. Runs pre-flight validation first.
|
|
971
|
+
*/
|
|
972
|
+
export async function createAutomation(name, nodesJson, connectionsJson, settingsJson) {
|
|
973
|
+
let nodes;
|
|
974
|
+
let connections;
|
|
975
|
+
let settings;
|
|
976
|
+
try {
|
|
977
|
+
nodes = parseJsonParam(nodesJson, "nodes", "array");
|
|
978
|
+
connections = parseJsonParam(connectionsJson, "connections", "object");
|
|
979
|
+
settings =
|
|
980
|
+
settingsJson === undefined || settingsJson === null
|
|
981
|
+
? {}
|
|
982
|
+
: parseJsonParam(settingsJson, "settings", "object");
|
|
983
|
+
}
|
|
984
|
+
catch (ex) {
|
|
985
|
+
return jsonResponse({ error: ex instanceof Error ? ex.message : String(ex) });
|
|
986
|
+
}
|
|
987
|
+
const errors = _validateWorkflow(nodes, connections);
|
|
988
|
+
if (errors.length) {
|
|
989
|
+
return jsonResponse({ error: "validation failed", errors });
|
|
990
|
+
}
|
|
991
|
+
const fields = { name, nodes, connections, settings, isActive: false };
|
|
992
|
+
const rows = await insertEntity(WORKFLOW_ENTITY, [fields]);
|
|
993
|
+
const id = rows.length && isPlainObject(rows[0]) ? rows[0].id ?? null : null;
|
|
994
|
+
return jsonResponse({ created: true, id, name });
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Partial update of a draft workflow (read-modify-write). Only the fields the
|
|
998
|
+
* caller supplies are overwritten; `settings` is MERGED over the stored value
|
|
999
|
+
* (preserving pinData and any untouched keys). nodes/connections are whole-
|
|
1000
|
+
* document replaces when provided. Runs pre-flight validation on the resulting
|
|
1001
|
+
* graph before writing.
|
|
1002
|
+
*/
|
|
1003
|
+
export async function updateAutomation(automationId, name = null, nodesJson, connectionsJson, settingsJson) {
|
|
1004
|
+
const current = await selectEntity(WORKFLOW_ENTITY, [makeFilter("id", automationId)], {
|
|
1005
|
+
id: true,
|
|
1006
|
+
name: true,
|
|
1007
|
+
nodes: true,
|
|
1008
|
+
connections: true,
|
|
1009
|
+
settings: true,
|
|
1010
|
+
});
|
|
1011
|
+
if (current === null) {
|
|
1012
|
+
return jsonResponse({
|
|
1013
|
+
error: `No automation ${automationId} (wrong id, deleted, or no access).`,
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
const cur = current;
|
|
1017
|
+
const fields = {};
|
|
1018
|
+
const changed = [];
|
|
1019
|
+
if (name !== null && name !== undefined) {
|
|
1020
|
+
fields.name = name;
|
|
1021
|
+
changed.push("name");
|
|
1022
|
+
}
|
|
1023
|
+
let nodes = cur.nodes;
|
|
1024
|
+
let connections = cur.connections;
|
|
1025
|
+
const nodesSupplied = nodesJson !== undefined && nodesJson !== null;
|
|
1026
|
+
const connectionsSupplied = connectionsJson !== undefined && connectionsJson !== null;
|
|
1027
|
+
try {
|
|
1028
|
+
if (nodesSupplied) {
|
|
1029
|
+
nodes = parseJsonParam(nodesJson, "nodes", "array");
|
|
1030
|
+
fields.nodes = nodes;
|
|
1031
|
+
changed.push("nodes");
|
|
1032
|
+
}
|
|
1033
|
+
if (connectionsSupplied) {
|
|
1034
|
+
connections = parseJsonParam(connectionsJson, "connections", "object");
|
|
1035
|
+
fields.connections = connections;
|
|
1036
|
+
changed.push("connections");
|
|
1037
|
+
}
|
|
1038
|
+
if (settingsJson !== undefined && settingsJson !== null) {
|
|
1039
|
+
const incoming = parseJsonParam(settingsJson, "settings", "object");
|
|
1040
|
+
const existing = isPlainObject(cur.settings) ? cur.settings : {};
|
|
1041
|
+
fields.settings = { ...existing, ...incoming }; // merge preserves pinData + untouched keys
|
|
1042
|
+
changed.push("settings");
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
catch (ex) {
|
|
1046
|
+
return jsonResponse({ error: ex instanceof Error ? ex.message : String(ex) });
|
|
1047
|
+
}
|
|
1048
|
+
// Validate the resulting graph ONLY when the caller touches nodes/connections
|
|
1049
|
+
// (the missing half is read from the current record). A name-only or settings-
|
|
1050
|
+
// only update must not be blocked by a stored graph that predates the validator.
|
|
1051
|
+
if (nodesSupplied || connectionsSupplied) {
|
|
1052
|
+
const errors = _validateWorkflow(nodes, connections);
|
|
1053
|
+
if (errors.length) {
|
|
1054
|
+
return jsonResponse({ error: "validation failed", errors });
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
if (changed.length === 0) {
|
|
1058
|
+
return jsonResponse({ updated: false, id: automationId, fields: [] });
|
|
1059
|
+
}
|
|
1060
|
+
await updateEntity(WORKFLOW_ENTITY, automationId, fields);
|
|
1061
|
+
return jsonResponse({ updated: true, id: automationId, fields: changed });
|
|
1062
|
+
}
|
|
1063
|
+
/** Soft-delete a workflow via the entity API. */
|
|
1064
|
+
export async function deleteAutomation(automationId) {
|
|
1065
|
+
await removeEntity(WORKFLOW_ENTITY, [makeFilter("id", automationId)]);
|
|
1066
|
+
return jsonResponse({ deleted: true, id: automationId });
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Parse the JSON error body out of an "HTTP <code> <reason>: <body>" Error
|
|
1070
|
+
* message (the shape http_client throws). Returns null when there is no body
|
|
1071
|
+
* or it is not JSON.
|
|
1072
|
+
*/
|
|
1073
|
+
function _errorBody(ex) {
|
|
1074
|
+
const msg = ex instanceof Error ? ex.message : String(ex);
|
|
1075
|
+
const idx = msg.indexOf(": ");
|
|
1076
|
+
if (idx === -1) {
|
|
1077
|
+
return null;
|
|
1078
|
+
}
|
|
1079
|
+
try {
|
|
1080
|
+
const parsed = JSON.parse(msg.slice(idx + 2));
|
|
1081
|
+
return isPlainObject(parsed) ? parsed : null;
|
|
1082
|
+
}
|
|
1083
|
+
catch {
|
|
1084
|
+
return null;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
/** Shared error shaping for publish/unpublish (typed 400 body when present). */
|
|
1088
|
+
function _serviceError(id, ex, verb) {
|
|
1089
|
+
const msg = ex instanceof Error ? ex.message : String(ex);
|
|
1090
|
+
const body = _errorBody(ex);
|
|
1091
|
+
if (body) {
|
|
1092
|
+
return jsonResponse({
|
|
1093
|
+
[verb]: false,
|
|
1094
|
+
id,
|
|
1095
|
+
errors: body.errors ?? [],
|
|
1096
|
+
warnings: body.warnings ?? [],
|
|
1097
|
+
message: body.message ?? msg,
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
return jsonResponse({ [verb]: false, id, message: msg });
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Publish a workflow — promotes the draft to the live/active snapshot via the
|
|
1104
|
+
* automation-service. Requires the automation-service to be deployed on the
|
|
1105
|
+
* tenant; if it is absent the call 404s and the HTTP error is returned in the
|
|
1106
|
+
* result (never crashes).
|
|
1107
|
+
*/
|
|
1108
|
+
export async function publishAutomation(automationId) {
|
|
1109
|
+
try {
|
|
1110
|
+
const res = (await makeRequest("POST", `/api/automation/workflows/${automationId}/publish`, {}));
|
|
1111
|
+
const result = isPlainObject(res) ? res.result : undefined;
|
|
1112
|
+
return jsonResponse({
|
|
1113
|
+
published: true,
|
|
1114
|
+
id: automationId,
|
|
1115
|
+
warnings: isPlainObject(result) ? result.warnings ?? [] : [],
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
catch (ex) {
|
|
1119
|
+
return _serviceError(automationId, ex, "published");
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Unpublish a workflow — clears the live snapshot via the automation-service.
|
|
1124
|
+
* Requires the automation-service deployed (else 404, returned as an error).
|
|
1125
|
+
*/
|
|
1126
|
+
export async function unpublishAutomation(automationId) {
|
|
1127
|
+
try {
|
|
1128
|
+
await makeRequest("POST", `/api/automation/workflows/${automationId}/unpublish`, {});
|
|
1129
|
+
return jsonResponse({ unpublished: true, id: automationId });
|
|
1130
|
+
}
|
|
1131
|
+
catch (ex) {
|
|
1132
|
+
return _serviceError(automationId, ex, "unpublished");
|
|
1133
|
+
}
|
|
1134
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "MCP server for the Suppa platform (modern.suppa.me) — Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments, with multi-tenant Google auth. Node port of PyPI suppa-mcp.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": { "suppa-mcp": "dist/bin.js" },
|
|
7
|
-
"
|
|
7
|
+
"main": "dist/bin.js",
|
|
8
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
8
9
|
"engines": { "node": ">=18" },
|
|
9
10
|
"scripts": {
|
|
10
11
|
"build": "tsc",
|
|
12
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
13
|
+
"rebuild": "npm run clean && npm run build",
|
|
14
|
+
"start": "node dist/bin.js",
|
|
15
|
+
"dev": "tsc --watch",
|
|
11
16
|
"test": "vitest run",
|
|
12
|
-
"
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"prepublishOnly": "npm run build && npm test",
|
|
19
|
+
"inspect": "npx @modelcontextprotocol/inspector node dist/bin.js"
|
|
13
20
|
},
|
|
14
|
-
"keywords": [
|
|
21
|
+
"keywords": [
|
|
22
|
+
"mcp",
|
|
23
|
+
"model-context-protocol",
|
|
24
|
+
"suppa",
|
|
25
|
+
"modern-expo",
|
|
26
|
+
"ai",
|
|
27
|
+
"llm",
|
|
28
|
+
"tools",
|
|
29
|
+
"claude",
|
|
30
|
+
"copilot",
|
|
31
|
+
"cursor"
|
|
32
|
+
],
|
|
15
33
|
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://git.modern-expo.com/asu/me-development/skills.git",
|
|
37
|
+
"directory": "suppa-mcp-node"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://modern.suppa.me",
|
|
16
40
|
"dependencies": {
|
|
17
41
|
"@modelcontextprotocol/sdk": "^1.18.0",
|
|
18
42
|
"@napi-rs/keyring": "^1.1.0",
|