@superglue/cli 1.1.31 → 1.1.33

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,6 +1,6 @@
1
1
  ---
2
2
  name: superglue
3
- description: "Build, test, deploy and integrate superglue tools via the sg CLI and superglue SDKs. IMPORTANT — you MUST invoke this skill and read the full reference BEFORE running ANY sg command or writing ANY superglue SDK/REST/webhook integration code. Before using the sg CLI, first check that it is installed (run sg --version; if not found, install with npm install -g @superglue/cli), then verify it is configured (check that sg init has been run or that SUPERGLUE_API_KEY and SUPERGLUE_API_ENDPOINT environment variables are set). If not, guide the user through setup first. After reading SKILL.md, also run `sg skill <topic>` for the specific protocols and topics involved."
3
+ description: "Build, test, deploy and integrate superglue tools via the sg CLI and superglue SDKs. IMPORTANT — you MUST invoke this skill and read the full reference BEFORE running ANY sg command or writing ANY superglue SDK/REST/webhook integration code. Before using the sg CLI, first check that it is installed (run sg --version; if not found, install with npm install -g @superglue/cli), then verify either that it is configured with sg login or, for headless/API-key auth, that SUPERGLUE_API_KEY and SUPERGLUE_API_ENDPOINT environment variables are set. If not, guide the user through setup first. After reading SKILL.md, also run `sg skill <topic>` for the specific protocols and topics involved."
4
4
  ---
5
5
 
6
6
  # superglue CLI (`sg`) — Agent Reference
@@ -23,6 +23,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
23
23
  | `sg skill mssql` | MSSQL / Azure SQL connection URLs, schema introspection, parameterized queries |
24
24
  | `sg skill odbc` | ODBC connections (SAP ASE / Sybase via FreeTDS), driver config, positional `?` params |
25
25
  | `sg skill redis` | Redis command syntax, connection URLs, key type handling |
26
+ | `sg skill mongodb` | MongoDB connection URLs (mongodb:// / mongodb+srv://), CRUD operations, Extended JSON, aggregation |
26
27
  | `sg skill sftp-smb` | SFTP, FTP, and SMB operations, file upload/download semantics, path handling |
27
28
  | `sg skill file-handling` | File detection, parsing, `file::` reference syntax, lazy base64 access, transform-produced files |
28
29
  | `sg skill access-rules` | RBAC roles, resource grants, and tool/system permissions (enterprise only) |
@@ -33,7 +34,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
33
34
 
34
35
  1. **Check CLI exists**: Run `sg --version`. If it fails with `command not found`, install: `npm install -g @superglue/cli`.
35
36
  2. **Keep CLI and SDK up to date**: Always use the latest versions. Run `sg update` to update the CLI. For the SDK, run `npm install @superglue/client@latest` (JS) or `pip install --upgrade superglue-client` (Python).
36
- 3. **Verify configuration**: Run `sg system list`. If it fails with `fetch failed` or auth errors, the CLI needs configuration via `sg init` (see Setup below). For custom/self-hosted instances, the CLI must know both the instance API endpoint and an org-scoped API key.
37
+ 3. **Verify configuration**: Run `sg whoami` or `sg system list`. If it fails with `fetch failed` or auth errors, the CLI needs configuration via `sg login` (see Setup below). For custom/self-hosted instances, the CLI must know the instance API endpoint; browser login also needs the web app endpoint when it differs from the API URL. Use API-key auth only for headless/legacy environments.
37
38
 
38
39
  **Calling systems and running tools**
39
40
 
@@ -53,7 +54,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
53
54
 
54
55
  **Non-interactive environments (AI agents, CI)**
55
56
 
56
- - Pass ALL credentials (including secrets) directly via `--credentials '{"api_key":"sk-xxx"}'`. Ask the user for secret values, then include them in the JSON.
57
+ - Pass all secret values directly via `--credentials '{"api_key":"sk-xxx"}'`. Ask the user for secret values, then include them in the JSON.
57
58
 
58
59
  ---
59
60
 
@@ -67,26 +68,22 @@ npm install -g @superglue/cli
67
68
 
68
69
  After installation the `sg` command is available globally.
69
70
 
70
- ### Initialization
71
+ ### Authentication
71
72
 
72
- The CLI will not work until configured with an API key. The endpoint defaults to `https://api.superglue.cloud`.
73
+ The preferred CLI setup is browser OAuth via `sg login`. Headless/API-key auth is available for CI and legacy automation. The API endpoint defaults to `https://api.superglue.cloud`.
73
74
 
74
- **Interactive (humans):**
75
+ **Browser login (humans):**
75
76
 
76
77
  ```bash
77
- sg init
78
+ sg login
79
+ sg --endpoint "https://custom-api.example.com" login --web-endpoint "https://custom-app.example.com" --save-config
78
80
  ```
79
81
 
80
- Prompts for: API key (required — get one at https://app.superglue.cloud/api-keys), API endpoint, web endpoint (for OAuth callbacks), output mode (`stdout` or `stdout+file`), and config location (project-local `.superglue/config.json` vs global `~/.superglue/config.json`). Verifies the connection before saving.
82
+ Opens the browser, completes OAuth login, and stores the OAuth session in `~/.superglue/auth.json`. This file is separate from `config.json`. Use `--save-config` to persist non-secret endpoint settings in `config.json`, and `sg logout` to remove the OAuth session.
81
83
 
82
- **Non-interactive (CI, agents):**
84
+ **Headless/API-key auth (CI, agents, backwards-compatible):**
83
85
 
84
- ```bash
85
- sg init --api-key "your-api-key" --global
86
- sg init --api-key "your-api-key" --endpoint "https://custom.endpoint.com" --global
87
- ```
88
-
89
- `--api-key` and `--endpoint` are global flags and work on all subcommands.
86
+ Use environment variables, global flags, or an existing `.superglue/config.json`. `sg init` remains available as a legacy hidden command for scripts that already use it, but new setup should prefer `sg login` for humans and env vars/config files for headless API-key auth.
90
87
 
91
88
  **Environment variables (no config file):**
92
89
 
@@ -95,13 +92,13 @@ export SUPERGLUE_API_KEY="your-api-key"
95
92
  export SUPERGLUE_API_ENDPOINT="https://api.superglue.cloud" # optional, this is the default
96
93
  ```
97
94
 
98
- **Config resolution order:** CLI flags > environment variables > local `.superglue/config.json` > global `~/.superglue/config.json`.
95
+ **Config resolution order:** CLI flags > environment variables > local `.superglue/config.json` > global `~/.superglue/config.json`. For authentication, API keys from flags/env/config take precedence; if no API key is configured, the CLI uses the matching OAuth session from `~/.superglue/auth.json`.
99
96
 
100
- Verify with `sg system list` — should return a list (possibly empty) without errors.
97
+ Verify with `sg whoami` or `sg system list` — should return authenticated context without errors.
101
98
 
102
99
  ### Capability Presets
103
100
 
104
- Set during `sg init` or via `SUPERGLUE_CLI_PRESET` env var. Stored in `config.json` as `"preset"`.
101
+ Set via `SUPERGLUE_CLI_PRESET` env var or `config.json` as `"preset"`. Legacy `sg init --preset` still writes this value for existing scripts.
105
102
 
106
103
  | Preset | Description |
107
104
  | --------- | ---------------------------------------------------------------------------------------------- |
@@ -127,7 +124,7 @@ Blocked commands print a clear error showing the current preset and how to chang
127
124
  ### Building a Tool
128
125
 
129
126
  1. **Load relevant protocol references** via `sg skill <topic>` based on the systems involved (http, postgres, graphql, etc.)
130
- 2. Use `sg system find` for every involved system — note `storedCredentials` and the system URL
127
+ 2. Use `sg system find` for every involved system — note the available secret names and the system URL
131
128
  3. Use `sg system search-docs` for each system — look up endpoints, auth patterns, pagination, response structure
132
129
  4. Use `sg system call` to test 1-2 primary endpoints — verify response structure and field names before building
133
130
  5. Call `sg tool build --config '{...}'` with the full tool config (see Reference → Tool Config Schema)
@@ -148,7 +145,7 @@ Blocked commands print a clear error showing the current preset and how to chang
148
145
  1. Search for an existing system first: `sg system find <query>`
149
146
  2. If creating: `sg system create --name "..." --url "..." --credentials '{...}'`. Prefer `--template <id>` when one exists — it auto-fills URL and OAuth config
150
147
  3. For OAuth: `sg system oauth --system-id <id> [--scopes "..."]` opens a browser flow. User approves → tokens saved automatically
151
- 4. For user-owned non-OAuth credentials: `sg system credentials set --system-id <id> --credentials '{...}'`
148
+ 4. For non-OAuth secrets: `sg system credentials set --system-id <id> --credentials '{...}'`
152
149
  5. Verify connectivity with `sg system call`
153
150
  6. For updates: `sg system edit --id <id>` with the fields to change
154
151
 
@@ -222,8 +219,8 @@ Agents familiar with the web tool names can map them directly to CLI commands:
222
219
  | `run_command` with `vfs` for `/org/tools/` | `sg tool find --id <id>` / `sg tool find <q>` | Full config with `--id`, compact search with a query string |
223
220
  | `create_system` | `sg system create --name "..." --url "..."` | Use `--template <id>` when available |
224
221
  | `edit_system` | `sg system edit --id <id> ...` | Supports `--env dev\|prod` |
225
- | `run_command` with `vfs` for `/org/systems/` | `sg system find <query>` / `--id <id>` | Returns `storedCredentials` and system URL |
226
- | Credentials VFS / user-owned credentials | `sg system credentials get/set/clear` | Manage current user's credentials for user-owned systems |
222
+ | `run_command` with `vfs` for `/org/systems/` | `sg system find <query>` / `--id <id>` | Returns secret-key presence and the system URL |
223
+ | Credentials VFS / saved credentials | `sg system credentials get/set/clear` | Manage the current user's credentials for a system |
227
224
  | `call_system` | `sg system call --url "..." --system-id <id>` | Authenticated ad-hoc calls for testing / schema introspection |
228
225
  | `run_command search` | `sg system search-docs --system-id <id> -k` | Targeted keyword search over ingested system docs |
229
226
  | `authenticate_oauth` | `sg system oauth --system-id <id> [--scopes]` | Opens browser flow. Supports `--grant-type client_credentials` too |
@@ -233,13 +230,17 @@ Agents familiar with the web tool names can map them directly to CLI commands:
233
230
  | `edit_mcp_server` | `sg mcp edit --id <id> ...` | Edits name, auth mode, description, or selected tool IDs |
234
231
  | `create_schedule` | `sg schedule create --tool <id> --cron <expr>` | Creates a cron schedule for a saved tool |
235
232
  | `edit_schedule` | `sg schedule edit --tool <id> --id <schedule>` | Updates, enables, or disables an existing schedule |
236
- | (no direct equivalent) | `sg init`, `sg update`, `sg skill` | CLI-specific setup, updater, and this reference system |
233
+ | (no direct equivalent) | `sg login`, `sg update`, `sg skill` | CLI-specific setup, updater, and this reference system |
237
234
 
238
235
  Web-agent-only concepts with no CLI equivalent: `run_command`'s virtual filesystem (CLI uses concrete `sg` subcommands), `authenticate_oauth`'s dedicated MCP `authenticate` tool (CLI uses `sg system oauth`).
239
236
 
240
237
  ### Command Reference
241
238
 
242
- **`sg init`** — Interactive or non-interactive setup. Creates `.superglue/` config. Flags: `--api-key`, `--endpoint`, `--preset`, `--global`.
239
+ **`sg login`** — Browser OAuth setup. Stores the OAuth session in `~/.superglue/auth.json`. Flags: `--web-endpoint`, `--no-browser`, `--save-config`, `--global`. Use global `--endpoint` for custom/self-hosted API URLs.
240
+
241
+ **`sg logout`** — Removes the stored OAuth session from `~/.superglue/auth.json`.
242
+
243
+ **`sg whoami`** — Shows the authenticated superglue user and organization.
243
244
 
244
245
  **Tool commands:**
245
246
 
@@ -335,7 +336,7 @@ Attach files with repeatable `--file key=path`. Reference in payloads with `file
335
336
  }
336
337
  ```
337
338
 
338
- **Request step fields** (HTTP, Postgres, MSSQL, Redis, FTP/SFTP, SMB) — see protocol-specific references for full details:
339
+ **Request step fields** (HTTP, Postgres, MSSQL, Redis, MongoDB, FTP/SFTP, SMB) — see protocol-specific references for full details:
339
340
 
340
341
  | Field | Type | Description |
341
342
  | ------------- | ------ | ------------------------------------------------------------------------ |
@@ -377,7 +378,8 @@ All step config fields (url, headers, body, queryParams) support `<<expression>>
377
378
  <<page>> <<offset>> <<cursor>> <<limit>> <<pageSize>> pagination variables
378
379
  <<systemId_api_key>> system credentials (namespaced: systemId_credKey)
379
380
  <<systemId_url>> system base URLs (namespaced: systemId_url)
380
- <<sg_auth_email>> email of the authenticated user (NOT available in scheduled runs)
381
+ <<sg_auth_email>> email of the user triggering this run (in scheduled runs: the schedule creator)
382
+ <<sg_auth_jwt>> short-lived signed JWT proving the identity of the user triggering this run; receivers verify it against superglue's outbound JWKS endpoint (/api/auth/outbound-jwks on the web app origin)
381
383
  ```
382
384
 
383
385
  Simple `<<varName>>` only works for top-level keys. No dots, no nesting. `<<currentItem.id>>`, `<<sourceData.userId>>`, `<<user.name>>` all FAIL at runtime.
@@ -422,7 +424,7 @@ sourceData = {
422
424
 
423
425
  Everything in `sourceData` shares ONE flat namespace. Saving a tool rejects payload input keys and step ids that collide with it:
424
426
 
425
- - `__files__`, `currentItem`, `sg_auth_email` — injected by the runtime
427
+ - `__files__`, `currentItem`, `sg_auth_email`, `sg_auth_jwt` — injected by the runtime
426
428
  - `page`, `offset`, `cursor`, `limit`, `pageSize` — rejected only when the tool has a paginated step, because they would shadow the live pagination counters; on non-paginated tools they are allowed but discouraged (a later edit that adds pagination will force a rename)
427
429
  - the tool's own step ids — the step result overwrites a same-named payload key
428
430
  - anything starting with `<systemId>_` for a system the tool uses — the entire prefix is reserved for namespaced credentials (`<systemId>_<credKey>`, `<systemId>_url`), even names that don't match an existing credential, because credentials added to the system later would silently shadow the input
@@ -490,10 +492,10 @@ All user-provided JS runs in an isolated Deno sandbox.
490
492
 
491
493
  ### Credentials and Systems
492
494
 
493
- Credentials are namespaced as `<<systemId_credentialKey>>` and resolved server-side at execution time. You MUST explicitly reference them:
495
+ Secrets are referenced by name as `<<systemId_credentialKey>>` and resolved from the selected credential at execution time. You MUST explicitly reference them:
494
496
 
495
497
  ```
496
- System id="stripe", storedCredentials: api_key → "sk_proj****"
498
+ System id="stripe", selected credential has secret named: api_key
497
499
  → Available as: <<stripe_api_key>>
498
500
  ```
499
501
 
@@ -516,11 +518,11 @@ Basic auth auto-encodes: if the value after `Basic ` isn't already base64, the e
516
518
 
517
519
  **Credential lifecycle:**
518
520
 
519
- - Pass ALL credentials (including secrets) via `--credentials '{"api_key":"...","client_secret":"..."}'` on create/edit
520
- - For user-owned systems, use `sg system credentials set --system-id <id> --credentials '{...}'` to save credentials for the current API-key user
521
- - Use `sg system credentials get --system-id <id>` to inspect current-user credential keys; values are masked unless `--reveal` is passed
521
+ - Pass all secret values via `--credentials '{"api_key":"...","client_secret":"..."}'` on create/edit
522
+ - Use `sg system credentials set --system-id <id> --credentials '{...}'` to save secrets in the current API-key user's credential
523
+ - Use `sg system credentials get --system-id <id>` to inspect the current user's secret names and whether each has a non-empty value; secret values are never returned
522
524
  - OAuth tokens (`access_token`, `refresh_token`) auto-refresh before each step execution
523
- - Non-sensitive fields (`client_id`, `auth_url`, `token_url`) are stored alongside secrets in the same `--credentials` JSON
525
+ - Non-sensitive fields (`client_id`, `auth_url`, `token_url`) can be submitted alongside secrets in the same `--credentials` JSON
524
526
 
525
527
  **System IDs:** lowercase letters, numbers, underscores only — no hyphens. Used for credential namespacing.
526
528
 
@@ -586,7 +588,7 @@ Drafts live under the active CLI config directory: local `.superglue/drafts/` wh
586
588
 
587
589
  After building and saving, tools can be invoked from code via REST API, SDK, or webhook. See `sg skill integration` for complete SDK (TypeScript/Python), REST API, and webhook examples including retry patterns.
588
590
 
589
- **IP whitelisting:** if a customer's system requires IP whitelisting (firewall rules, security groups, etc.), superglue's outbound IPs are `34.234.12.178` and `18.198.191.215`.
591
+ **IP whitelisting:** if a customer's system requires IP whitelisting for firewall rules, security groups, or vendor access controls, superglue Cloud outbound requests come from `34.234.12.178` and `18.198.191.215`. These IPs apply to superglue Cloud only; self-hosted and enterprise deployments use deployment-specific networking.
590
592
 
591
593
  Quick reference:
592
594
 
@@ -622,14 +624,13 @@ curl -X POST "https://api.superglue.cloud/v1/hooks/{toolId}?token=$SUPERGLUE_API
622
624
  - **Double-encoded JSON** — when the body contains nested/stringified JSON (e.g. LLM APIs), have `<<>>` expressions return a string via `JSON.stringify(...)`, and use a single expression for the whole body rather than mixing `<<>>` with static JSON
623
625
  - **POST for read-only ops** — GraphQL queries via POST should have `modify: false`. Don't rely on HTTP method alone
624
626
  - **Saving without approval** — always present `sg tool run` results and ask before `sg tool save`
625
- - **`sg_auth_email` in scheduled runs** — not available in scheduler-triggered executions. Tools using `<<sg_auth_email>>` will fail
626
627
  - **Reserved key collisions** — payload inputs or step ids named after reserved/injected keys (see Naming Rules) are rejected at save time; pick a different name instead of retrying
627
628
 
628
629
  ---
629
630
 
630
631
  ## Error Recovery
631
632
 
632
- For protocol-specific error recovery (HTTP, Postgres, MSSQL, Redis, GraphQL, SFTP/SMB), run `sg skill <protocol>`. General strategies below.
633
+ For protocol-specific error recovery (HTTP, Postgres, MSSQL, Redis, MongoDB, GraphQL, SFTP/SMB), run `sg skill <protocol>`. General strategies below.
633
634
 
634
635
  ### Tool build fails validation
635
636
 
@@ -639,14 +640,14 @@ For protocol-specific error recovery (HTTP, Postgres, MSSQL, Redis, GraphQL, SFT
639
640
 
640
641
  1. Re-run with `--include-step-results` to see raw per-step responses and `data` fields
641
642
  2. Use `sg system call` to test the failing endpoint directly — isolates step config vs system/auth issues
642
- 3. Use `sg system find --id <systemId>` to verify `storedCredentials` keys match what the step references
643
+ 3. Use `sg system find --id <systemId>` to verify the stored secret names match what the step references
643
644
  4. For HTTP: run `sg skill http` and follow the error recovery section (endpoint vs system isolation, credential scopes, rate limiting)
644
645
  5. For databases: run `sg skill postgres` or `sg skill mssql` — SSL/TLS and schema issues are common causes
645
646
  6. Use `sg system search-docs` and web search to verify the current API shape. APIs change across versions
646
647
 
647
648
  ### Authentication failures
648
649
 
649
- 1. Run `sg system find --id <systemId>` → check `storedCredentials` for masked but present values
650
+ 1. Run `sg system find --id <systemId>` → check which secret names are present and whether they have non-empty values
650
651
  2. For OAuth: re-run `sg system oauth` if tokens are missing or expired
651
652
  3. For custom OAuth: verify `client_id`, `client_secret`, `auth_url`, `token_url` are all present. Confirm the redirect URI is registered on the provider's OAuth app
652
653
  4. Check scopes — 403 / empty responses often mean the token lacks required scopes
@@ -44,7 +44,7 @@ N/A — file handling is a runtime behavior, not a protocol. Authentication is h
44
44
 
45
45
  Every response is read as raw bytes. The runtime classifies it using this priority chain:
46
46
 
47
- 1. **Magic-byte detection** — known binary signatures (ZIP `PK\x03\x04`, PDF `%PDF`, GZIP `\x1f\x8b`, plus internal ZIP structure checks for Excel/DOCX)
47
+ 1. **Magic-byte detection** — known binary signatures (ZIP `PK\x03\x04`, PDF `%PDF`, GZIP `\x1f\x8b`, plus internal ZIP structure checks for Excel/DOCX/PPTX)
48
48
  2. **`Content-Disposition: attachment`** — `attachment` or `filename=` in this header forces file treatment
49
49
  3. **`application/octet-stream`** — explicit octet-stream MIME catches unlabeled binary payloads
50
50
  4. **25MB size fallback** — only when byte detection returned `RAW`, the response exceeds 25MB, and `Content-Type` is not text-like (`text/*`, `application/json`, `*+json`, `application/xml`)
@@ -53,11 +53,11 @@ File server `get` operations always produce files regardless of detected type.
53
53
 
54
54
  ### Classification
55
55
 
56
- | Classification | Types | Destination |
57
- | ------------------- | --------------------------- | -------------------------------------------------------------- |
58
- | **Binary** | PDF, Excel, DOCX, ZIP, GZIP | `producedFiles` + `data` (extracted/parsed content) |
59
- | **Structured text** | JSON, XML, CSV, YAML, HTML | `data` only (parsed to JS objects) |
60
- | **RAW** | Unrecognized | File if attachment/octet-stream/25MB fallback, else raw string |
56
+ | Classification | Types | Destination |
57
+ | ------------------- | --------------------------------- | -------------------------------------------------------------- |
58
+ | **Binary** | PDF, Excel, DOCX, PPTX, ZIP, GZIP | `producedFiles` + `data` (extracted/parsed content) |
59
+ | **Structured text** | JSON, XML, CSV, YAML, HTML | `data` only (parsed to JS objects) |
60
+ | **RAW** | Unrecognized | File if attachment/octet-stream/25MB fallback, else raw string |
61
61
 
62
62
  Binary responses expose `stepFileKeys` and populate `sourceData.__files__`. Structured text responses only populate `sourceData.stepId.data`.
63
63
 
@@ -73,10 +73,13 @@ Binary responses expose `stepFileKeys` and populate `sourceData.__files__`. Stru
73
73
  | Excel | Object keyed by sheet name, each value is array of row objects |
74
74
  | PDF | `{ textContent, structuredContent: [{ page, text }] }` |
75
75
  | DOCX | Markdown string |
76
+ | PPTX | Plain text, separated by slide |
76
77
  | ZIP | Object keyed by entry filename, each value recursively parsed |
77
78
  | GZIP | Recursively parsed inner content |
78
79
  | RAW | UTF-8 string fallback |
79
80
 
81
+ **PPTX rules:** extraction includes slide text, including text inside basic tables. It does not include images, charts, layout, animations, or speaker notes.
82
+
80
83
  **Excel rules:**
81
84
 
82
85
  - Excel is never a flat array. It is always `{ "SheetName": [ {row}, ... ] }` — even for single-sheet files
@@ -68,8 +68,15 @@ Some APIs (e.g. Salesforce) use SOAP XML login where credentials are embedded in
68
68
 
69
69
  `<<systemId_password>><<systemId_security_token>>` resolves to the password and token concatenated — no separator needed. This works in URL, headers, and body fields.
70
70
 
71
- Headers starting with `x-` are treated as custom headers.
72
- Modern APIs expect auth in headers, not query parameters, unless docs explicitly say otherwise.
71
+ ### Parsing XML responses
72
+
73
+ XML responses (SOAP and other XML APIs) are auto-parsed to an object on `sourceData.stepId.data`. The parser has quirks you MUST account for in transforms and stopConditions — probe the real response with a small page before writing selectors:
74
+
75
+ - **Every tag name is UPPERCASED.** `<response><record>` becomes `RESPONSE.RECORD`, regardless of the source casing. Always select uppercase keys.
76
+ - **Single vs multiple children collapse.** One child element parses to an object; multiple with the same tag parse to an array. Normalize before mapping: `const rows = Array.isArray(x) ? x : (x ? [x] : [])`.
77
+ - **Element attributes become keys on the element object** (also uppercased). `<data count="2" total="127">` gives `DATA.COUNT` and `DATA.TOTAL` alongside the child records.
78
+ - **Text with attributes goes to `_TEXT`.** An element with both attributes and text content stores the text under a `_TEXT` key. Empty elements (`<field></field>`) become `{}`.
79
+ - **Numbers and booleans are strings.** Everything is a string; wrap with `Number(...)` where you need arithmetic.
73
80
 
74
81
  ## HTTP Runtime Details
75
82
 
@@ -143,11 +150,15 @@ Multipart restrictions:
143
150
 
144
151
  All HTTP responses are read as raw bytes, then classified by byte-level detection (see `file-handling.md` for the full detection logic).
145
152
 
146
- - **Binary types** (PDF, Excel, DOCX, ZIP, GZIP): treated as files, parsed content also populates `data`. Later steps can reference via `file::<stepId>.raw/base64/extracted`.
153
+ - **File responses**: formats classified as files by `file-handling.md` are stored as files, and parsed content populates `data` when extraction is available. Later steps can reference them via `file::<stepId>.raw/base64/extracted`.
147
154
  - **`application/octet-stream`**: always treated as a file.
148
155
  - **Responses over 25 MB**: treated as files as a safety fallback.
149
156
  - **RAW + `Content-Disposition: attachment`**: treated as a file.
150
- - **Structured/text responses** (JSON, XML, CSV, YAML, HTML, text under size limit): parsed inline to `data` only.
157
+ - **Inline responses**: formats classified as structured or plain text by `file-handling.md` populate `data` without producing a stored file unless another file rule applies.
158
+
159
+ ### XML Response Casing
160
+
161
+ XML responses are parsed into a JSON tree with ALL tag names normalized to UPPERCASE — the parsed keys will not match the raw document's casing. This applies identically to `sg system call` and to request steps in tools. A raw `fetch()` inside a transform step is the exception: it returns the original document with its real casing (often lowercase envelope tags with uppercase field tags). Never write string-level XML parsing logic in a transform from memory of what `sg system call` showed — capture a raw probe first (e.g. return `{ rawXml: xml.slice(0, 1500) }`), and guard against self-closing empty containers (`<data/>` has no closing tag) and repeated sibling result blocks.
151
162
 
152
163
  ### Error Detection
153
164
 
@@ -0,0 +1,136 @@
1
+ # MongoDB
2
+
3
+ ## Step Configuration
4
+
5
+ ```typescript
6
+ {
7
+ type: "request",
8
+ systemId: "my_mongo",
9
+ url: "mongodb://<<my_mongo_username>>:<<my_mongo_password>>@<<my_mongo_host>>:<<my_mongo_port>>/<<my_mongo_database>>?authSource=admin",
10
+ body: '{"collection": "users", "operation": "find", "filter": {"status": "active"}, "options": {"limit": 50, "sort": {"createdAt": -1}}}'
11
+ }
12
+ ```
13
+
14
+ Configure the connection URL based on the selected credential's secrets — use `sg system find` to inspect the available secret names and reference them accordingly.
15
+
16
+ `method`, `headers`, `queryParams`, and `pagination` are HTTP-only fields — omit them for MongoDB steps.
17
+
18
+ ### Fields
19
+
20
+ | Field | Required | Notes |
21
+ | ---------- | -------- | -------------------------------------------------------------- |
22
+ | `url` | yes | Connection string with `<<credential>>` placeholders |
23
+ | `body` | yes | JSON: single operation object or array of operations |
24
+ | `systemId` | no | Links system credentials for `<<systemId_credKey>>` resolution |
25
+
26
+ ### URL Format
27
+
28
+ ```
29
+ mongodb://user:password@host:port/database?authSource=admin
30
+ mongodb+srv://user:password@cluster.example.mongodb.net/database (SRV seedlist, e.g. Atlas)
31
+ ```
32
+
33
+ - `mongodb://` for a standard host:port connection.
34
+ - `mongodb+srv://` for DNS SRV seedlists (MongoDB Atlas). The driver resolves the seedlist and enables TLS automatically; do not add a port.
35
+ - The default database comes from the URL path; override per operation with a `database` field in the body.
36
+ - Common query params: `authSource` (auth database, usually `admin` for root users), `replicaSet`, `tls`, `retryWrites`.
37
+ - Special characters in the username or password are URL-encoded automatically before the driver parses the string.
38
+
39
+ ### Body Format
40
+
41
+ JSON string with `operation` (required) and `collection` (required for all operations except `listCollections`). Bodies are parsed as MongoDB Extended JSON, so `{ "$oid": "..." }` becomes an `ObjectId` and `{ "$date": "..." }` becomes a `Date`:
42
+
43
+ ```json
44
+ {
45
+ "collection": "orders",
46
+ "operation": "find",
47
+ "filter": { "_id": { "$oid": "652c1f77bcf86cd799439011" } }
48
+ }
49
+ ```
50
+
51
+ For several operations in one step, pass an array (executed in order, results returned as an array):
52
+
53
+ ```json
54
+ [
55
+ { "collection": "orders", "operation": "countDocuments", "filter": { "status": "paid" } },
56
+ {
57
+ "collection": "orders",
58
+ "operation": "find",
59
+ "filter": { "status": "paid" },
60
+ "options": { "limit": 10 }
61
+ }
62
+ ]
63
+ ```
64
+
65
+ ### Supported Operations
66
+
67
+ | Operation | Required fields | Returns |
68
+ | ------------------------------------------------------------- | ------------------------------------------------- | ---------------------------------------------- |
69
+ | `find` | `collection` | array of documents |
70
+ | `findOne` | `collection` | a document or `null` |
71
+ | `aggregate` | `collection`, `pipeline` | array of documents |
72
+ | `countDocuments` | `collection` | number |
73
+ | `estimatedDocumentCount` | `collection` | number |
74
+ | `distinct` | `collection`, `field` | array of values |
75
+ | `listCollections` | — | array of collection info |
76
+ | `insertOne` | `collection`, `document` | `{ acknowledged, insertedId }` |
77
+ | `insertMany` | `collection`, `documents` | `{ acknowledged, insertedCount, insertedIds }` |
78
+ | `updateOne` / `updateMany` | `collection`, `filter`, `update` | `{ matchedCount, modifiedCount, upsertedId }` |
79
+ | `replaceOne` | `collection`, `filter`, `replacement` | update result |
80
+ | `deleteOne` / `deleteMany` | `collection`, `filter` | `{ acknowledged, deletedCount }` |
81
+ | `findOneAndUpdate` / `findOneAndReplace` / `findOneAndDelete` | `collection`, `filter` (+ `update`/`replacement`) | the affected document |
82
+ | `bulkWrite` | `collection`, `operations` | bulk write result |
83
+
84
+ `filter`, `pipeline`, `document`, `update`, `replacement`, and driver `options` (e.g. `limit`, `skip`, `sort`, `projection`, `upsert`) are passed straight through to the driver.
85
+
86
+ Dynamic values with variables:
87
+
88
+ ```json
89
+ {
90
+ "collection": "users",
91
+ "operation": "find",
92
+ "filter": { "orgId": "<<(sourceData) => sourceData.orgId>>" }
93
+ }
94
+ ```
95
+
96
+ ## Authentication
97
+
98
+ Credentials are embedded directly in the connection URL using `<<systemId_credentialKey>>` placeholders. Nothing is injected automatically. Root/admin users almost always need `?authSource=admin`.
99
+
100
+ ```
101
+ mongodb://<<my_mongo_username>>:<<my_mongo_password>>@<<my_mongo_host>>:<<my_mongo_port>>/<<my_mongo_database>>?authSource=admin
102
+ ```
103
+
104
+ ## MongoDB Runtime Details
105
+
106
+ ### Return Values
107
+
108
+ Documents are returned as Extended JSON (relaxed): an `ObjectId` becomes `{ "$oid": "..." }` and a `Date` becomes `{ "$date": "..." }`. Query those values back with the same form. A single operation returns its result directly; an array of operations returns an array of results in order.
109
+
110
+ ### Connection Management
111
+
112
+ - Clients are reused per connection string within a run and closed after completion.
113
+ - TLS is automatic for `mongodb+srv://` and when the connection string sets `tls=true`.
114
+ - Connection timeout defaults to 30 seconds; operation/socket timeout follows the system/protocol timeout.
115
+
116
+ ### Retry Behavior
117
+
118
+ Default retries come from server config. On final failure, the error includes the failing operation name.
119
+
120
+ ## Common Pitfalls
121
+
122
+ - Omitting `?authSource=admin` when authenticating as a root user — auth fails with "Authentication failed".
123
+ - Adding a port to a `mongodb+srv://` URL — SRV connection strings must not include a port.
124
+ - Passing an `_id` as a plain string when the document stores an `ObjectId` — wrap it as `{ "$oid": "..." }` so it matches.
125
+ - Putting `limit`/`sort`/`projection` at the top level — they belong inside `options`.
126
+ - Accessing the step result directly instead of via `.data` — MongoDB results follow the same envelope as all steps: `sourceData.stepId.data`.
127
+
128
+ ## Error Recovery
129
+
130
+ When a MongoDB step fails:
131
+
132
+ 1. **Read the error message** — superglue includes the operation name in the error. Check for unknown operations, missing required fields (`filter`, `update`, `pipeline`), or malformed Extended JSON.
133
+ 2. **Verify connection secrets** — use `sg system find` to confirm the stored secret names match the placeholders in your URL. Test with a `listCollections` operation via `sg system call`.
134
+ 3. **Check auth source** — "Authentication failed" usually means a missing or wrong `authSource`. Root users authenticate against `admin`.
135
+ 4. **Check connectivity** — connection refused or server-selection timeouts mean the host is unreachable, the SRV record can't resolve, or an IP allowlist (Atlas) is blocking you. `mongodb+srv://` requires outbound DNS.
136
+ 5. **Check the operation shape** — read operations (`find`, `countDocuments`, `distinct`) never mutate; write operations require their specific fields. `aggregate` is read-only unless its pipeline contains a `$out` or `$merge` stage, which writes results back to a collection. Confirm `filter`/`update`/`pipeline` are objects/arrays, not strings.
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ```
15
15
 
16
- Configure the connection URL based on which credentials are stored in the system — use `sg system find` to check `storedCredentials` and reference them accordingly.
16
+ Configure the connection URL based on the selected credential's secrets — use `sg system find` to inspect the available secret names and reference them accordingly.
17
17
 
18
18
  `method`, `headers`, `queryParams`, and `pagination` are HTTP-only fields — omit them for database steps.
19
19
 
@@ -93,46 +93,46 @@ mssql://<<my_db_user>>:<<my_db_password>>@<<my_db_host>>:<<my_db_port>>/<<my_db_
93
93
 
94
94
  ### Windows Authentication (NTLM)
95
95
 
96
- For on-prem SQL Servers that only accept Windows domain logins (no SQL auth), store these credential keys on the system:
96
+ For on-prem SQL Servers that only accept Windows domain logins (no SQL auth), add secrets with these names to the credential:
97
97
 
98
- | Credential Key | Required | Notes |
99
- | -------------- | -------- | ----------------------------------------------------- |
100
- | `authType` | yes | `ntlm` |
101
- | `domain` | yes | Windows domain (e.g. `CORP`) |
102
- | `user` | yes | Windows username (also accepts `username`, or in URL) |
103
- | `password` | yes | Windows password (or in URL) |
98
+ | Secret Name | Required | Notes |
99
+ | ----------- | -------- | ----------------------------------------------------- |
100
+ | `authType` | yes | `ntlm` |
101
+ | `domain` | yes | Windows domain (e.g. `CORP`) |
102
+ | `user` | yes | Windows username (also accepts `username`, or in URL) |
103
+ | `password` | yes | Windows password (or in URL) |
104
104
 
105
105
  ```
106
106
  URL: mssql://<<sys_user>>:<<sys_password>>@<<sys_host>>:<<sys_port>>/<<sys_database>>
107
- Credentials: { authType: "ntlm", domain, user, password, host, port, database }
107
+ Secrets: { authType: "ntlm", domain, user, password, host, port, database }
108
108
  ```
109
109
 
110
110
  Alternatively, pass the domain as a `?domain=CORP` query parameter on the URL — any URL with a `domain` set authenticates via NTLM. Kerberos-only environments are not supported; ask the DBA to permit NTLM or create a SQL login.
111
111
 
112
112
  ### Azure Active Directory Authentication
113
113
 
114
- For Azure AD auth, store the following credential keys on the system alongside the standard connection fields:
114
+ For Azure AD auth, add secrets with the following names to the credential alongside the standard connection fields:
115
115
 
116
116
  **Entra ID User + Password** — authenticates as an Azure AD user. Requires an Azure app registration.
117
117
 
118
- | Credential Key | Required | Notes |
119
- | -------------- | -------- | ------------------------------------------------------ |
120
- | `authType` | yes | `azure-active-directory-password` |
121
- | `clientId` | yes | Application (client) ID from Azure app registration |
122
- | `tenantId` | no | Directory (tenant) ID |
123
- | `user` | yes | Azure AD username (also accepts `username`, or in URL) |
124
- | `password` | yes | Azure AD password (or in URL) |
118
+ | Secret Name | Required | Notes |
119
+ | ----------- | -------- | ------------------------------------------------------ |
120
+ | `authType` | yes | `azure-active-directory-password` |
121
+ | `clientId` | yes | Application (client) ID from Azure app registration |
122
+ | `tenantId` | no | Directory (tenant) ID |
123
+ | `user` | yes | Azure AD username (also accepts `username`, or in URL) |
124
+ | `password` | yes | Azure AD password (or in URL) |
125
125
 
126
- `user` and `password` can be stored as credentials or embedded in the URL — values resolved into the URL take precedence; stored credentials only fill gaps the URL omits.
126
+ `user` and `password` can be stored as secrets or embedded in the URL — values resolved into the URL take precedence; stored secrets only fill gaps the URL omits.
127
127
 
128
128
  ```
129
129
  URL: mssql://<<sys_user>>:<<sys_password>>@myserver.database.windows.net:1433/mydb
130
- Credentials: { authType, clientId, tenantId, user, password, host, port, database }
130
+ Secrets: { authType, clientId, tenantId, user, password, host, port, database }
131
131
  ```
132
132
 
133
133
  **Service Principal** — authenticates as an Azure AD application. No user/password needed in the URL.
134
134
 
135
- | Credential Key | Required | Notes |
135
+ | Secret Name | Required | Notes |
136
136
  | -------------- | -------- | ------------------------------------------------- |
137
137
  | `authType` | yes | `azure-active-directory-service-principal-secret` |
138
138
  | `clientId` | yes | Application (client) ID |
@@ -141,7 +141,7 @@ Credentials: { authType, clientId, tenantId, user, password, host, port, databas
141
141
 
142
142
  ```
143
143
  URL: mssql://myserver.database.windows.net:1433/mydb
144
- Credentials: { authType, clientId, clientSecret, tenantId, host, port, database }
144
+ Secrets: { authType, clientId, clientSecret, tenantId, host, port, database }
145
145
  ```
146
146
 
147
147
  The runtime authenticates entirely via the service principal credentials — no user or password is needed in the URL.
@@ -245,7 +245,7 @@ Default retries from server config. On final failure, error includes query text
245
245
  When an MSSQL step fails and the cause is not obvious:
246
246
 
247
247
  1. **Read the error message** — superglue includes the query text and params in the error. Check for syntax errors, missing columns, or type mismatches.
248
- 2. **Verify connection credentials** — use `sg system find` to confirm `storedCredentials` keys match the placeholders in your URL. Test connectivity with a simple `SELECT 1` via `sg system call`.
248
+ 2. **Verify connection secrets** — use `sg system find` to confirm the stored secret names match the placeholders in your URL. Test connectivity with a simple `SELECT 1` via `sg system call`.
249
249
  3. **Check database-side access** — connection refused or permission denied errors typically mean the database user lacks access. Verify with the user that the credentials have the required grants.
250
250
  4. **Check Azure-specific issues** — if connecting to Azure SQL:
251
251
  - Confirm the client IP is allowed in the Azure SQL firewall rules
@@ -11,7 +11,7 @@
11
11
  }
12
12
  ```
13
13
 
14
- Configure the connection URL based on which credentials are stored in the system — use `sg system find` to check `storedCredentials` and reference them accordingly.
14
+ Configure the connection URL based on the selected credential's secrets — use `sg system find` to inspect the available secret names and reference them accordingly.
15
15
 
16
16
  `method`, `headers`, `queryParams`, and `pagination` are HTTP-only fields — omit them for database steps.
17
17
 
@@ -185,7 +185,7 @@ For other ODBC-backed databases, look up the database/driver-specific error code
185
185
  When an ODBC step fails and the cause is not obvious:
186
186
 
187
187
  1. **Read the error message** — superglue includes a truncated query preview in the error. Check for syntax errors, missing columns, or type mismatches.
188
- 2. **Verify connection credentials** — use `sg system find` to confirm `storedCredentials` keys match the placeholders in your URL. Test connectivity with a simple `SELECT 1` via `sg system call`.
188
+ 2. **Verify connection secrets** — use `sg system find` to confirm the stored secret names match the placeholders in your URL. Test connectivity with a simple `SELECT 1` via `sg system call`.
189
189
  3. **Check database-side access** — connection refused or permission denied errors typically mean the database user lacks access. Verify with the user that the credentials have the required grants.
190
190
  4. **Check driver availability** — if the error mentions "driver not found", the `DRIVER` query parameter does not match any registered driver in `/etc/odbcinst.ini`. Verify the driver name is correct and the driver is installed in the Docker image.
191
191
  5. **Test the query directly** — use `sg system call` with a simplified version of the query to isolate whether the issue is the query itself, the parameters, or the connection.
@@ -11,7 +11,7 @@
11
11
  }
12
12
  ```
13
13
 
14
- Configure the connection URL based on which credentials are stored in the system — use `sg system find` to check `storedCredentials` and reference them accordingly.
14
+ Configure the connection URL based on the selected credential's secrets — use `sg system find` to inspect the available secret names and reference them accordingly.
15
15
 
16
16
  `method`, `headers`, `queryParams`, and `pagination` are HTTP-only fields — omit them for database steps.
17
17
 
@@ -148,7 +148,7 @@ Default retries from server config. On final failure, error includes query text
148
148
  When a PostgreSQL step fails and the cause is not obvious:
149
149
 
150
150
  1. **Read the error message** — superglue includes the query text and params in the error. Check for syntax errors, missing columns, or type mismatches.
151
- 2. **Verify connection credentials** — use `sg system find` to confirm `storedCredentials` keys match the placeholders in your URL. Test connectivity with a simple `SELECT 1` via `sg system call`.
151
+ 2. **Verify connection secrets** — use `sg system find` to confirm the stored secret names match the placeholders in your URL. Test connectivity with a simple `SELECT 1` via `sg system call`.
152
152
  3. **Check database-side access** — connection refused or permission denied errors typically mean the database user lacks access to the database, schema, or table. Verify with the user that the credentials have the required grants.
153
153
  4. **Test the query directly** — use `sg system call` with a simplified version of the query to isolate whether the issue is the query itself, the parameters, or the connection.
154
154
  5. **Check for SSL/TLS issues** — if the error mentions SSL or handshake failure, check the SSL / TLS section above. For non-localhost servers that don't support SSL, add `?sslmode=disable` to the URL. For servers that require SSL, add `?sslmode=require`.
@@ -11,7 +11,7 @@
11
11
  }
12
12
  ```
13
13
 
14
- Configure the connection URL based on which credentials are stored in the system — use `sg system find` to check `storedCredentials` and reference them accordingly.
14
+ Configure the connection URL based on the selected credential's secrets — use `sg system find` to inspect the available secret names and reference them accordingly.
15
15
 
16
16
  `method`, `headers`, `queryParams`, and `pagination` are HTTP-only fields — omit them for Redis steps.
17
17
 
@@ -133,7 +133,7 @@ Default retries from server config. On final failure, error includes command and
133
133
  When a Redis step fails:
134
134
 
135
135
  1. **Read the error message** — superglue includes the command and args in the error. Check for unknown commands, wrong argument counts, or type errors (e.g. running a list command on a string key).
136
- 2. **Verify connection credentials** — use `sg system find` to confirm `storedCredentials` keys match the placeholders in your URL. Test with a simple `PING` command via `sg system call`.
136
+ 2. **Verify connection secrets** — use `sg system find` to confirm the stored secret names match the placeholders in your URL. Test with a simple `PING` command via `sg system call`.
137
137
  3. **Check connectivity and access** — connection refused errors typically mean the Redis server is unreachable or requires TLS (`rediss://`). AUTH errors mean the password is wrong or the user lacks access.
138
138
  4. **Check key types** — Redis commands are type-specific. Running `GET` on a hash key or `HGETALL` on a string key returns a `WRONGTYPE` error. Use `TYPE` command via `sg system call` to check a key's type before building.
139
139
  5. **Verify TLS requirements** — if the error mentions connection reset or handshake failure, try switching between `redis://` and `rediss://`.