@superglue/cli 1.1.26 → 1.1.28

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.
@@ -25,7 +25,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
25
25
  | `sg skill redis` | Redis command syntax, connection URLs, key type handling |
26
26
  | `sg skill sftp-smb` | SFTP, FTP, and SMB operations, file upload/download semantics, path handling |
27
27
  | `sg skill file-handling` | File detection, parsing, `file::` reference syntax, lazy base64 access, transform-produced files |
28
- | `sg skill access-rules` | RBAC roles, tool/system permissions, mutation detection, custom rules (enterprise only) |
28
+ | `sg skill access-rules` | RBAC roles, resource grants, and tool/system permissions (enterprise only) |
29
29
 
30
30
  ## CRITICAL RULES — READ FIRST
31
31
 
@@ -33,7 +33,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
33
33
 
34
34
  1. **Check CLI exists**: Run `sg --version`. If it fails with `command not found`, install: `npm install -g @superglue/cli`.
35
35
  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).
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
37
 
38
38
  **Calling systems and running tools**
39
39
 
@@ -103,11 +103,11 @@ Verify with `sg system list` — should return a list (possibly empty) without e
103
103
 
104
104
  Set during `sg init` or via `SUPERGLUE_CLI_PRESET` env var. Stored in `config.json` as `"preset"`.
105
105
 
106
- | Preset | Description |
107
- | --------- | ------------------------------------------------------------------ |
108
- | `runner` | Run saved tools by ID only. Read-only lookups. No building/editing |
109
- | `builder` | Runner + build/edit/save tools, call systems. No system CRUD |
110
- | `admin` | Full access (default) |
106
+ | Preset | Description |
107
+ | --------- | -------------------------------------------------------------------------------- |
108
+ | `runner` | Run saved tools by ID only. Read-only lookups. No building/editing |
109
+ | `builder` | Runner + build/edit/save tools, call systems, manage MCP servers. No system CRUD |
110
+ | `admin` | Full access (default) |
111
111
 
112
112
  Blocked commands print a clear error showing the current preset and how to change it.
113
113
 
@@ -161,6 +161,30 @@ sg tool run --draft <draftId> --payload-file payload.json
161
161
 
162
162
  Streams live execution logs to the terminal. Use `--include-step-results` for raw per-step responses and `--include-config` for the full config dump.
163
163
 
164
+ ### Creating/Editing a Named MCP Server
165
+
166
+ Named MCP servers expose a selected set of saved tools through an MCP endpoint. The CLI always uses the configured superglue API endpoint, so it works for Cloud and self-hosted instances when `SUPERGLUE_API_ENDPOINT` or `--endpoint` points at the right API.
167
+
168
+ 1. Verify CLI setup: `sg system list` or `sg mcp list`
169
+ 2. Find saved tools to expose: `sg tool list` or `sg tool find <query>`
170
+ 3. Create the server:
171
+ ```bash
172
+ sg mcp create --name sales-tools --tool get_customer --tool create_invoice
173
+ ```
174
+ 4. Use the returned `server.connection.endpoint` and `clientConfig` in the MCP client.
175
+ 5. Edit later with:
176
+ ```bash
177
+ sg mcp edit --id <serverId> --add-tool another_tool
178
+ sg mcp edit --id <serverId> --tools get_customer,create_invoice
179
+ ```
180
+
181
+ Auth modes:
182
+
183
+ - `oauth` (default): OAuth-capable MCP clients authenticate users through the MCP auth flow.
184
+ - `creator_api_key`: private/headless clients must send `Authorization: Bearer <SUPERGLUE_API_KEY>` where the key is active and assigned to the MCP server creator.
185
+
186
+ If `sg mcp ...` returns "MCP server management is not available", the target instance or plan does not support named MCP server management. The default all-tools MCP endpoint may still be usable at `<api-endpoint>/mcp`.
187
+
164
188
  ---
165
189
 
166
190
  ## Reference
@@ -169,22 +193,25 @@ Streams live execution logs to the terminal. Use `--include-step-results` for ra
169
193
 
170
194
  Agents familiar with the web tool names can map them directly to CLI commands:
171
195
 
172
- | Web agent tool | CLI command | Notes |
173
- | -------------------------------------------- | --------------------------------------------- | ------------------------------------------------------------------ |
174
- | `build_tool` | `sg tool build --config '{...}'` | CLI is not AI-powered — you provide the full JSON config |
175
- | `edit_tool` | `sg tool edit --tool <id> --patches '[...]'` | JSON Patch (RFC 6902). Use `--draft <id>` for drafts |
176
- | `run_tool` | `sg tool run --tool <id>` / `--draft <id>` | Add `--include-step-results` to inspect per-step data |
177
- | `save_tool` | `sg tool save --draft <draftId>` | Persists a draft to the database |
178
- | `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 |
179
- | `create_system` | `sg system create --name "..." --url "..."` | Use `--template <id>` when available |
180
- | `edit_system` | `sg system edit --id <id> ...` | Supports `--env dev\|prod` |
181
- | `run_command` with `vfs` for `/org/systems/` | `sg system find <query>` / `--id <id>` | Returns `storedCredentials` and system URL |
182
- | Credentials VFS / user-owned credentials | `sg system credentials get/set/clear` | Manage current user's credentials for user-owned systems |
183
- | `call_system` | `sg system call --url "..." --system-id <id>` | Authenticated ad-hoc calls for testing / schema introspection |
184
- | `run_command search` | `sg system search-docs --system-id <id> -k` | Targeted keyword search over ingested system docs |
185
- | `authenticate_oauth` | `sg system oauth --system-id <id> [--scopes]` | Opens browser flow. Supports `--grant-type client_credentials` too |
186
- | `run_command` with `vfs` for `/org/runs/` | `sg run list` / `sg run get <runId>` | Filter `list` by `--tool`, `--status`, `--source`, `--limit` |
187
- | (no direct equivalent) | `sg init`, `sg update`, `sg skill` | CLI-specific setup, updater, and this reference system |
196
+ | Web agent tool | CLI command | Notes |
197
+ | ------------------------------------------------ | --------------------------------------------- | ------------------------------------------------------------------ |
198
+ | `build_tool` | `sg tool build --config '{...}'` | CLI is not AI-powered — you provide the full JSON config |
199
+ | `edit_tool` | `sg tool edit --tool <id> --patches '[...]'` | JSON Patch (RFC 6902). Use `--draft <id>` for drafts |
200
+ | `run_tool` | `sg tool run --tool <id>` / `--draft <id>` | Add `--include-step-results` to inspect per-step data |
201
+ | `save_tool` | `sg tool save --draft <draftId>` | Persists a draft to the database |
202
+ | `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 |
203
+ | `create_system` | `sg system create --name "..." --url "..."` | Use `--template <id>` when available |
204
+ | `edit_system` | `sg system edit --id <id> ...` | Supports `--env dev\|prod` |
205
+ | `run_command` with `vfs` for `/org/systems/` | `sg system find <query>` / `--id <id>` | Returns `storedCredentials` and system URL |
206
+ | Credentials VFS / user-owned credentials | `sg system credentials get/set/clear` | Manage current user's credentials for user-owned systems |
207
+ | `call_system` | `sg system call --url "..." --system-id <id>` | Authenticated ad-hoc calls for testing / schema introspection |
208
+ | `run_command search` | `sg system search-docs --system-id <id> -k` | Targeted keyword search over ingested system docs |
209
+ | `authenticate_oauth` | `sg system oauth --system-id <id> [--scopes]` | Opens browser flow. Supports `--grant-type client_credentials` too |
210
+ | `run_command` with `vfs` for `/org/runs/` | `sg run list` / `sg run get <runId>` | Filter `list` by `--tool`, `--status`, `--source`, `--limit` |
211
+ | `run_command` with `vfs` for `/org/mcp-servers/` | `sg mcp list` / `sg mcp find --id <id>` | Returns endpoint, auth mode, selected tool IDs, and client config |
212
+ | `create_mcp_server` | `sg mcp create --name <n> --tool <id>` | Creates a named MCP endpoint for selected saved tools |
213
+ | `edit_mcp_server` | `sg mcp edit --id <id> ...` | Edits name, auth mode, description, or selected tool IDs |
214
+ | (no direct equivalent) | `sg init`, `sg update`, `sg skill` | CLI-specific setup, updater, and this reference system |
188
215
 
189
216
  Web-agent-only concepts with no CLI equivalent: `run_command`'s virtual filesystem (CLI uses concrete `sg` subcommands), `create_schedule`/`edit_schedule` (manage schedules via web app or REST API), `authenticate_oauth`'s dedicated MCP `authenticate` tool (CLI uses `sg system oauth`).
190
217
 
@@ -227,6 +254,19 @@ sg system oauth --system-id gmail --scopes "https://www.googleapis.com/auth/gmai
227
254
  sg system oauth --system-id my_api --grant-type client_credentials --scopes "read write"
228
255
  ```
229
256
 
257
+ **MCP server commands:**
258
+
259
+ ```bash
260
+ sg mcp list
261
+ sg mcp find sales
262
+ sg mcp find --id <serverId>
263
+ sg mcp create --name sales-tools --tool get_customer --tool create_invoice
264
+ sg mcp create --name sales-tools --tools get_customer,create_invoice --auth-mode oauth
265
+ sg mcp edit --id <serverId> --add-tool another_tool
266
+ sg mcp edit --id <serverId> --remove-tool old_tool
267
+ sg mcp edit --id <serverId> --auth-mode creator_api_key
268
+ ```
269
+
230
270
  **Run commands:**
231
271
 
232
272
  ```bash
@@ -354,6 +394,19 @@ sourceData = {
354
394
  }
355
395
  ```
356
396
 
397
+ ### Naming Rules — Avoiding Key Collisions
398
+
399
+ Everything in `sourceData` shares ONE flat namespace, and the runtime does not detect collisions — when two sources use the same key, one silently wins and the tool misbehaves with no error. Prevent collisions at design time:
400
+
401
+ Never use these as payload input keys or step ids:
402
+
403
+ - `__files__`, `currentItem`, `sg_auth_email` — overwritten by the runtime
404
+ - `page`, `offset`, `cursor`, `limit`, `pageSize` — a payload key with one of these names shadows the live pagination counters; paginated steps silently stop advancing past the first page
405
+ - the tool's own step ids — the step result overwrites a same-named payload key for all subsequent steps
406
+ - credential keys available to a step (`<systemId>_<credKey>`, `<systemId>_url`, and any runtime-supplied credential names) — the credential value silently replaces the payload value
407
+
408
+ Safe naming: payload inputs get specific, domain-flavored names (`customerId`, `reportMonth`, `maxResults` — never `page`, `limit`, `cursor`, `data`); step ids are verb-prefixed camelCase (`fetchUsers`) and distinct from every payload key. If the user asks for an input named like a reserved key, use a safe alternative and explain why.
409
+
357
410
  ### Step Result Envelopes
358
411
 
359
412
  **Every** step result is wrapped in `{ currentItem, data, success }`. You MUST account for this when writing data selectors or transforms.
@@ -548,6 +601,7 @@ curl -X POST "https://api.superglue.cloud/v1/hooks/{toolId}?token=$SUPERGLUE_API
548
601
  - **POST for read-only ops** — GraphQL queries via POST should have `modify: false`. Don't rely on HTTP method alone
549
602
  - **Saving without approval** — always present `sg tool run` results and ask before `sg tool save`
550
603
  - **`sg_auth_email` in scheduled runs** — not available in scheduler-triggered executions. Tools using `<<sg_auth_email>>` will fail
604
+ - **Reserved key collisions** — payload inputs or step ids named after reserved/injected keys (see Naming Rules) fail silently with wrong values, never with an error
551
605
 
552
606
  ---
553
607
 
@@ -587,6 +641,7 @@ For protocol-specific error recovery (HTTP, Postgres, MSSQL, Redis, GraphQL, SFT
587
641
  2. Re-run with `--include-step-results` to see the exact envelope shape
588
642
  3. Paginated steps merge into a single `.data` field — do not `.map()` over them
589
643
  4. Verify `sourceData.currentItem` is only referenced inside looping steps (set by the step's own `dataSelector`, not upstream)
644
+ 5. If a step silently received the wrong value (no error thrown) or pagination stopped after one page, check for a key collision between payload inputs, step ids, credential keys, and reserved runtime keys — see Naming Rules. Fix by renaming the input, not by working around it
590
645
 
591
646
  ### Persistent failures
592
647
 
@@ -1,147 +1,111 @@
1
1
  # Access Rules (RBAC)
2
2
 
3
- On superglue, roles define tool-level and system-level allowlists. Users can have multiple roles. Roles and access rules are only available on enterprise organizations. Non-enterprise orgs do not have RBAC — all users have admin access on personal organizations.
3
+ On superglue, roles define active resource grants for tools and systems. Users can have multiple roles. Roles and access rules are only available on enterprise organizations.
4
4
 
5
5
  ## Data Model
6
6
 
7
- ### Role
8
-
9
7
  ```typescript
10
- interface Role {
11
- id: string;
12
- name: string;
13
- description?: string;
14
- tools: "ALL" | string[]; // tool allowlist
15
- systems: "ALL" | Record<string, SystemPermission>; // system allowlist
16
- isBaseRole?: boolean; // true for admin, member, enduser
8
+ interface ResourceGrant {
9
+ roleId: string;
10
+ resourceRef: "tool:<encodedId>" | "system:<encodedId>" | "tool:*" | "system:*";
11
+ permissions: Array<"viewer" | "editor">;
12
+ source: "access_rule" | "ownership" | "share";
13
+ grantedByUserId?: string;
14
+ revokedAt?: Date;
15
+ revokedByUserId?: string;
17
16
  }
18
- ```
19
-
20
- ### SystemPermission
21
-
22
- Each system entry is either a predefined access level or a custom rule:
23
17
 
24
- ```typescript
25
- type SystemPermission = SystemAccessLevel | { rules: CustomRule[] };
26
- ```
27
-
28
- | Type | Meaning |
29
- | ------------------ | ------------------------------------------------ |
30
- | `"read-write"` | All HTTP methods allowed |
31
- | `"read-only"` | Only GET and HEAD; POST/PUT/PATCH/DELETE blocked |
32
- | `{ rules: [...] }` | Custom JS expressions that gate access |
33
-
34
- Systems not listed in the role's `systems` map are DENIED, unless the system access is set to `"ALL"`.
35
-
36
- ### CustomRule
37
-
38
- ```typescript
39
- interface CustomRule {
18
+ interface Role {
40
19
  id: string;
41
20
  name: string;
42
- expression?: string; // JS expression, receives stepConfig
43
- isActive: boolean;
21
+ description?: string;
22
+ resourceGrants: ResourceGrant[];
23
+ isBaseRole?: boolean;
44
24
  }
45
25
  ```
46
26
 
47
- Custom rules are inline in the systems map. A system either has a standard access level OR a custom rule, never both. Custom rules must return truthy to **allow** the request. If it returns falsy, throws, or has no expression, the request is blocked (fail-closed).
48
-
49
- ## Tool Permissions
50
-
51
- - `tools: "ALL"` — every tool is allowed, including tools created in the future
52
- - `tools: ["tool-id-1", "tool-id-2"]` — only these specific tools are allowed; new tools are NOT auto-included (but see Auto-Append below)
53
-
54
- ## System Permissions
27
+ Only active grants where `revokedAt` is empty contribute to access. `editor` implies `viewer`.
55
28
 
56
- - `systems: "ALL"` — every system allowed at READ_WRITE level, including future systems. Custom rules are not possible in this mode.
57
- - `systems: { "gmail": "read-write", "stripe": "read-only" }` — SPECIFIC mode: per-system access levels; unlisted systems are denied.
58
- - `systems: { "gmail": { rules: [{ name: "block-deletes", expression: "stepConfig.method !== 'DELETE'", isActive: true }] } }` — custom rule on a specific system
29
+ ## Resource Refs
59
30
 
60
- ## Mutation Detection by Protocol
31
+ - `tool:<encodedToolId>` — one specific tool.
32
+ - `system:<encodedSystemId>` — one specific system.
33
+ - `tool:*` — every current and future tool.
34
+ - `system:*` — every current and future system.
61
35
 
62
- Read-only mode blocks mutating requests. How "mutating" is determined per protocol:
36
+ Resource ids are URL-encoded inside `resourceRef`; use shared helpers rather than hand-building refs.
63
37
 
64
- - **HTTP** — POST, PUT, PATCH, DELETE are mutating; GET and HEAD are read-only
65
- - **Postgres** — SQL statements starting with or containing INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, etc. are mutating; everything else (SELECT) is read-only
66
- - **FTP / SMB** — operations other than `list`, `get`, `exists`, `stat` are mutating
67
- - **Redis** — commands not in the read-only set (GET, MGET, EXISTS, KEYS, SCAN, TTL, TYPE, HGET, HGETALL, LRANGE, SMEMBERS, SCARD, etc.) are mutating
68
- - **Transform** — never mutating (pure data transformation, no external system)
38
+ ## Permissions
69
39
 
70
- On parse failure, all protocols default to **mutating** (fail-closed).
40
+ - `viewer` — can see and execute/use the resource.
41
+ - `editor` — can mutate/delete/share the resource and includes `viewer`.
71
42
 
72
- ## Custom Rule Expressions
43
+ Current configured role access and ownership grants are generally stored as `editor`.
73
44
 
74
- Custom rules only apply in SPECIFIC mode. If systems is `"ALL"`, no custom rules exist.
45
+ ## Grant Sources
75
46
 
76
- Expressions receive a **resolved** `stepConfig` object — all template variables (`<<variable>>` and `<<(sourceData) => ...>>` expressions) are substituted with their actual runtime values before the rule evaluates. This means rules see the real URL, headers, body, and query params, not raw templates.
77
-
78
- ```typescript
79
- interface StepConfig {
80
- url: string;
81
- method: string;
82
- headers: Record<string, string>;
83
- queryParams: Record<string, string>;
84
- body: unknown;
85
- systemId: string;
86
- }
87
- ```
47
+ - `access_rule` — explicit admin/Access Rules edit.
48
+ - `ownership` — authorization projection from the resource creator.
49
+ - `share` — explicit user-to-user sharing through the app/agent sharing flow.
88
50
 
89
- Example expressions:
51
+ Ownership source of truth remains the tool/system row. Ownership grants are a permission projection and should be preserved by ordinary role edits.
90
52
 
91
- ```javascript
92
- // Block all POST requests to a specific endpoint
93
- stepConfig.method !== "POST" || !stepConfig.url.includes("/admin");
53
+ ## Visibility and Execution Surfaces
94
54
 
95
- // Only allow GET requests to /api/v1/read endpoints
96
- stepConfig.method === "GET" && stepConfig.url.includes("/api/v1/read");
97
-
98
- // Block requests with certain headers
99
- !stepConfig.headers["x-dangerous-header"];
100
-
101
- // Block a specific datasource ID in the resolved body
102
- !(typeof stepConfig.body === "object" && stepConfig.body?.datasource?.id === "blocked-id");
103
- ```
55
+ - **Tools** — list/detail, agent views, VFS, REST detail, and tool history use tool `viewer`.
56
+ - **Systems** — list/detail, agent views, VFS, docs, credentials, and `sg system call` use system `viewer`.
57
+ - **Execution** — running a tool requires tool `viewer` plus system `viewer` for every referenced system.
58
+ - **Editing** — updating tools/systems requires `editor`.
59
+ - **Runs** — visible only when the user has tool `viewer` and system `viewer` for every captured system.
60
+ - **Schedules** — visibility follows current tool behavior; editing requires tool `editor`.
61
+ - **MCP** — config shows configured tools; runtime registration uses tool `viewer`, and execution still checks referenced systems.
104
62
 
105
63
  ## Multi-Role Semantics
106
64
 
107
- Users can have multiple roles. Resolution is **union (most permissive wins) everywhere**:
108
-
109
- | Layer | Semantics | Example |
110
- | ------------ | ------------------------------ | --------------------------------------------------------------------------- |
111
- | Tools | Union (most permissive wins) | If role A allows tool X and role B doesn't, tool X is allowed |
112
- | Systems | Union (most permissive wins) | If role A gives READ_ONLY and role B gives READ_WRITE, result is READ_WRITE |
113
- | Custom rules | Per-role union (any role wins) | If any role's complete rule set allows the request, it goes through |
65
+ Users can have multiple roles. Resolution is union:
114
66
 
115
- Custom rule detail:
67
+ | Layer | Semantics |
68
+ | ------- | -------------------------------------------------------------------------- |
69
+ | Tools | If any active grant targets a tool, that grant's permission is effective |
70
+ | Systems | If any active grant targets a system, that grant's permission is effective |
116
71
 
117
- - **Within a single role**, all custom rules for that system must pass (AND logic)
118
- - **Across roles**, evaluation is per-role: if any role fully allows the request (all its rules pass, or it has no custom rule for that system), the request is allowed (OR logic)
72
+ Assigned roles can add access but cannot remove access granted by another role.
119
73
 
120
74
  ## Base Roles
121
75
 
122
- Every user has exactly **one** base role. There are three:
76
+ Every user has exactly one base role:
123
77
 
124
- - **`admin`** — Full access to everything. Bypasses all RBAC checks. The admin role is **immutable** — it cannot be edited at all, nor can it be re-assigned.
125
- - **`member`** — Default for org team members. Starts with `tools: "ALL"`, `systems: "ALL"`. Tool and system allowlists can be narrowed to restrict access. Name and description cannot be changed. Cannot be deleted.
126
- - **`enduser`** — Default for end users with Credentials-only access. Starts with `tools: []`, `systems: {}` (no access). Tool and system allowlists must be explicitly populated to grant access. Name and description cannot be changed. Cannot be deleted.
78
+ - **`admin`** — full access to everything. The admin role is immutable and has wildcard `editor` grants.
79
+ - **`member`** — default for org team members. New organizations seed it with wildcard `editor` grants for tools and systems. Access-rule grants can be narrowed. Name and description cannot be changed. Cannot be deleted.
127
80
 
128
- Base roles define the starting permissions that custom roles can extend or build on top of. Users can also have additional **custom roles** on top of their base role. Custom roles are fully editable (name, description, tools, systems) and can be created and deleted.
81
+ Users can also have additional custom roles on top of their base role. Custom roles are fully editable and can be created/deleted.
129
82
 
130
83
  ## Personal Roles
131
84
 
132
- Admins can create a **personal role** for a specific user. A personal role is a per-user override that scopes which tools and systems that individual can access — independent of their base role and shared custom roles.
85
+ Personal roles are per-user containers for ownership, share, and explicit access-rule grants.
86
+
87
+ - Each user can have at most one personal role.
88
+ - Ownership grants are added automatically when a user creates a tool or system.
89
+ - Personal role grants are unioned with the user's other roles.
90
+ - Managed via the Personal Roles tab in Access Rules and backend role APIs.
91
+
92
+ ## Sharing Semantics
93
+
94
+ V1 sharing targets organization users only. It does not share directly to base roles or custom roles.
133
95
 
134
- - Each user can have at most one personal role
135
- - Personal roles follow the same structure as custom roles (tools allowlist, systems map, custom rules)
136
- - Resolution: personal role permissions are unioned with the user's other roles (most permissive wins)
137
- - Use case: giving a single team member access to a sensitive system without creating a shared role
138
- - Managed via the **Personal Roles** tab in Access Rules (web app) or the REST API (`POST /v1/users/:userId/personal-role`)
96
+ - Sharing writes `source: "share"` grants into the target user's personal role.
97
+ - A user can grant only permissions up to their own effective access: viewer can grant viewer, editor can grant viewer or editor.
98
+ - If the target already has the requested permission or stronger from any active grant, sharing is redundant and should be blocked.
99
+ - If the target has viewer access and the acting user can grant editor, sharing can promote the user to editor through the personal `source: "share"` grant.
100
+ - Sharing a tool also grants viewer access to required systems when the recipient lacks system access.
101
+ - Tool sharing is atomic. If any selected user or required system grant cannot be applied, nothing is shared.
102
+ - Normal users cannot unshare in V1. Admin cleanup should use Access Rules/admin grant management.
139
103
 
140
- ### Auto-append on resource creation
104
+ ## Auto-Grant On Resource Creation
141
105
 
142
- When a user creates a new tool or system, the backend automatically adds it to the **creator's personal role**:
106
+ When a user creates a new tool or system, the backend automatically grants ownership access to the creator's personal role:
143
107
 
144
- - New tool created → appended to the creator's personal role's `tools` list
145
- - New system created → appended to the creator's personal role's `systems` map with `read-write` access
108
+ - New tool created -> `ownership` grant on `tool:<toolId>` with `editor`.
109
+ - New system created -> `ownership` grant on `system:<systemId>` with `editor`.
146
110
 
147
- This only affects the creator's personal role, not base roles or additional custom roles. It ensures that a user on a restricted allowlist automatically gets access to resources they create without granting those resources to everyone with the same base role.
111
+ This only affects the creator's personal role, not base roles or additional custom roles.
@@ -54,7 +54,7 @@ The persistent left sidebar contains these top-level items:
54
54
  - **Landscape** (`/landscape`) — graph overview of tools, systems, and their connections.
55
55
  - **Tools** (`/tools`, detail at `/tools/{toolId}`) — saved tools; opens the tool playground for editing, testing, and running.
56
56
  - **Systems** (`/systems`, detail at `/systems/{systemId}`) — connected external systems with credentials and documentation.
57
- - **My Credentials** (`/credentials`) — credential management. The **My Credentials** section is for personal user-owned system credentials; the **superglue API keys** section is for API keys. Admins and members open it inside the normal app shell from the sidebar; end users only see this standalone credentials surface.
57
+ - **My Credentials** (`/credentials`) — credential management. The **My Credentials** section is for personal user-owned system credentials; the **superglue API keys** section is for API keys. Admins and members open it inside the normal app shell from the sidebar.
58
58
  - **Runs** (`/runs`, detail at `/runs/{runId}`) — execution history for full, draft, and single-step tool runs. Runs is a top-level sidebar item, not a Control Panel sub-item.
59
59
  - **Control Panel** (`/admin`) — expandable group for organization and account administration:
60
60
  - **Overview** (`/admin`) — dashboard summary, including failed-run and schedule summaries.
@@ -81,7 +81,6 @@ Below the navigation, the sidebar shows the organization switcher and Sign Out.
81
81
  e. Wrap result: `{ currentItem, data, success }`
82
82
  f. On failure: abort if `failureBehavior !== "continue"`
83
83
  3. **Output transform** (if present): run JS function, validate against outputSchema
84
- 4. **Response filters** (if present): remove/mask/fail on pattern matches
85
84
 
86
85
  ### Strategy Routing
87
86
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superglue/cli",
3
- "version": "1.1.26",
3
+ "version": "1.1.28",
4
4
  "bin": {
5
5
  "sg": "./dist/cli.js"
6
6
  },
@@ -25,7 +25,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
25
25
  | `sg skill redis` | Redis command syntax, connection URLs, key type handling |
26
26
  | `sg skill sftp-smb` | SFTP, FTP, and SMB operations, file upload/download semantics, path handling |
27
27
  | `sg skill file-handling` | File detection, parsing, `file::` reference syntax, lazy base64 access, transform-produced files |
28
- | `sg skill access-rules` | RBAC roles, tool/system permissions, mutation detection, custom rules (enterprise only) |
28
+ | `sg skill access-rules` | RBAC roles, resource grants, and tool/system permissions (enterprise only) |
29
29
 
30
30
  ## CRITICAL RULES — READ FIRST
31
31
 
@@ -33,7 +33,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
33
33
 
34
34
  1. **Check CLI exists**: Run `sg --version`. If it fails with `command not found`, install: `npm install -g @superglue/cli`.
35
35
  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).
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
37
 
38
38
  **Calling systems and running tools**
39
39
 
@@ -103,11 +103,11 @@ Verify with `sg system list` — should return a list (possibly empty) without e
103
103
 
104
104
  Set during `sg init` or via `SUPERGLUE_CLI_PRESET` env var. Stored in `config.json` as `"preset"`.
105
105
 
106
- | Preset | Description |
107
- | --------- | ------------------------------------------------------------------ |
108
- | `runner` | Run saved tools by ID only. Read-only lookups. No building/editing |
109
- | `builder` | Runner + build/edit/save tools, call systems. No system CRUD |
110
- | `admin` | Full access (default) |
106
+ | Preset | Description |
107
+ | --------- | -------------------------------------------------------------------------------- |
108
+ | `runner` | Run saved tools by ID only. Read-only lookups. No building/editing |
109
+ | `builder` | Runner + build/edit/save tools, call systems, manage MCP servers. No system CRUD |
110
+ | `admin` | Full access (default) |
111
111
 
112
112
  Blocked commands print a clear error showing the current preset and how to change it.
113
113
 
@@ -161,6 +161,30 @@ sg tool run --draft <draftId> --payload-file payload.json
161
161
 
162
162
  Streams live execution logs to the terminal. Use `--include-step-results` for raw per-step responses and `--include-config` for the full config dump.
163
163
 
164
+ ### Creating/Editing a Named MCP Server
165
+
166
+ Named MCP servers expose a selected set of saved tools through an MCP endpoint. The CLI always uses the configured superglue API endpoint, so it works for Cloud and self-hosted instances when `SUPERGLUE_API_ENDPOINT` or `--endpoint` points at the right API.
167
+
168
+ 1. Verify CLI setup: `sg system list` or `sg mcp list`
169
+ 2. Find saved tools to expose: `sg tool list` or `sg tool find <query>`
170
+ 3. Create the server:
171
+ ```bash
172
+ sg mcp create --name sales-tools --tool get_customer --tool create_invoice
173
+ ```
174
+ 4. Use the returned `server.connection.endpoint` and `clientConfig` in the MCP client.
175
+ 5. Edit later with:
176
+ ```bash
177
+ sg mcp edit --id <serverId> --add-tool another_tool
178
+ sg mcp edit --id <serverId> --tools get_customer,create_invoice
179
+ ```
180
+
181
+ Auth modes:
182
+
183
+ - `oauth` (default): OAuth-capable MCP clients authenticate users through the MCP auth flow.
184
+ - `creator_api_key`: private/headless clients must send `Authorization: Bearer <SUPERGLUE_API_KEY>` where the key is active and assigned to the MCP server creator.
185
+
186
+ If `sg mcp ...` returns "MCP server management is not available", the target instance or plan does not support named MCP server management. The default all-tools MCP endpoint may still be usable at `<api-endpoint>/mcp`.
187
+
164
188
  ---
165
189
 
166
190
  ## Reference
@@ -169,22 +193,25 @@ Streams live execution logs to the terminal. Use `--include-step-results` for ra
169
193
 
170
194
  Agents familiar with the web tool names can map them directly to CLI commands:
171
195
 
172
- | Web agent tool | CLI command | Notes |
173
- | -------------------------------------------- | --------------------------------------------- | ------------------------------------------------------------------ |
174
- | `build_tool` | `sg tool build --config '{...}'` | CLI is not AI-powered — you provide the full JSON config |
175
- | `edit_tool` | `sg tool edit --tool <id> --patches '[...]'` | JSON Patch (RFC 6902). Use `--draft <id>` for drafts |
176
- | `run_tool` | `sg tool run --tool <id>` / `--draft <id>` | Add `--include-step-results` to inspect per-step data |
177
- | `save_tool` | `sg tool save --draft <draftId>` | Persists a draft to the database |
178
- | `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 |
179
- | `create_system` | `sg system create --name "..." --url "..."` | Use `--template <id>` when available |
180
- | `edit_system` | `sg system edit --id <id> ...` | Supports `--env dev\|prod` |
181
- | `run_command` with `vfs` for `/org/systems/` | `sg system find <query>` / `--id <id>` | Returns `storedCredentials` and system URL |
182
- | Credentials VFS / user-owned credentials | `sg system credentials get/set/clear` | Manage current user's credentials for user-owned systems |
183
- | `call_system` | `sg system call --url "..." --system-id <id>` | Authenticated ad-hoc calls for testing / schema introspection |
184
- | `run_command search` | `sg system search-docs --system-id <id> -k` | Targeted keyword search over ingested system docs |
185
- | `authenticate_oauth` | `sg system oauth --system-id <id> [--scopes]` | Opens browser flow. Supports `--grant-type client_credentials` too |
186
- | `run_command` with `vfs` for `/org/runs/` | `sg run list` / `sg run get <runId>` | Filter `list` by `--tool`, `--status`, `--source`, `--limit` |
187
- | (no direct equivalent) | `sg init`, `sg update`, `sg skill` | CLI-specific setup, updater, and this reference system |
196
+ | Web agent tool | CLI command | Notes |
197
+ | ------------------------------------------------ | --------------------------------------------- | ------------------------------------------------------------------ |
198
+ | `build_tool` | `sg tool build --config '{...}'` | CLI is not AI-powered — you provide the full JSON config |
199
+ | `edit_tool` | `sg tool edit --tool <id> --patches '[...]'` | JSON Patch (RFC 6902). Use `--draft <id>` for drafts |
200
+ | `run_tool` | `sg tool run --tool <id>` / `--draft <id>` | Add `--include-step-results` to inspect per-step data |
201
+ | `save_tool` | `sg tool save --draft <draftId>` | Persists a draft to the database |
202
+ | `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 |
203
+ | `create_system` | `sg system create --name "..." --url "..."` | Use `--template <id>` when available |
204
+ | `edit_system` | `sg system edit --id <id> ...` | Supports `--env dev\|prod` |
205
+ | `run_command` with `vfs` for `/org/systems/` | `sg system find <query>` / `--id <id>` | Returns `storedCredentials` and system URL |
206
+ | Credentials VFS / user-owned credentials | `sg system credentials get/set/clear` | Manage current user's credentials for user-owned systems |
207
+ | `call_system` | `sg system call --url "..." --system-id <id>` | Authenticated ad-hoc calls for testing / schema introspection |
208
+ | `run_command search` | `sg system search-docs --system-id <id> -k` | Targeted keyword search over ingested system docs |
209
+ | `authenticate_oauth` | `sg system oauth --system-id <id> [--scopes]` | Opens browser flow. Supports `--grant-type client_credentials` too |
210
+ | `run_command` with `vfs` for `/org/runs/` | `sg run list` / `sg run get <runId>` | Filter `list` by `--tool`, `--status`, `--source`, `--limit` |
211
+ | `run_command` with `vfs` for `/org/mcp-servers/` | `sg mcp list` / `sg mcp find --id <id>` | Returns endpoint, auth mode, selected tool IDs, and client config |
212
+ | `create_mcp_server` | `sg mcp create --name <n> --tool <id>` | Creates a named MCP endpoint for selected saved tools |
213
+ | `edit_mcp_server` | `sg mcp edit --id <id> ...` | Edits name, auth mode, description, or selected tool IDs |
214
+ | (no direct equivalent) | `sg init`, `sg update`, `sg skill` | CLI-specific setup, updater, and this reference system |
188
215
 
189
216
  Web-agent-only concepts with no CLI equivalent: `run_command`'s virtual filesystem (CLI uses concrete `sg` subcommands), `create_schedule`/`edit_schedule` (manage schedules via web app or REST API), `authenticate_oauth`'s dedicated MCP `authenticate` tool (CLI uses `sg system oauth`).
190
217
 
@@ -227,6 +254,19 @@ sg system oauth --system-id gmail --scopes "https://www.googleapis.com/auth/gmai
227
254
  sg system oauth --system-id my_api --grant-type client_credentials --scopes "read write"
228
255
  ```
229
256
 
257
+ **MCP server commands:**
258
+
259
+ ```bash
260
+ sg mcp list
261
+ sg mcp find sales
262
+ sg mcp find --id <serverId>
263
+ sg mcp create --name sales-tools --tool get_customer --tool create_invoice
264
+ sg mcp create --name sales-tools --tools get_customer,create_invoice --auth-mode oauth
265
+ sg mcp edit --id <serverId> --add-tool another_tool
266
+ sg mcp edit --id <serverId> --remove-tool old_tool
267
+ sg mcp edit --id <serverId> --auth-mode creator_api_key
268
+ ```
269
+
230
270
  **Run commands:**
231
271
 
232
272
  ```bash
@@ -354,6 +394,19 @@ sourceData = {
354
394
  }
355
395
  ```
356
396
 
397
+ ### Naming Rules — Avoiding Key Collisions
398
+
399
+ Everything in `sourceData` shares ONE flat namespace, and the runtime does not detect collisions — when two sources use the same key, one silently wins and the tool misbehaves with no error. Prevent collisions at design time:
400
+
401
+ Never use these as payload input keys or step ids:
402
+
403
+ - `__files__`, `currentItem`, `sg_auth_email` — overwritten by the runtime
404
+ - `page`, `offset`, `cursor`, `limit`, `pageSize` — a payload key with one of these names shadows the live pagination counters; paginated steps silently stop advancing past the first page
405
+ - the tool's own step ids — the step result overwrites a same-named payload key for all subsequent steps
406
+ - credential keys available to a step (`<systemId>_<credKey>`, `<systemId>_url`, and any runtime-supplied credential names) — the credential value silently replaces the payload value
407
+
408
+ Safe naming: payload inputs get specific, domain-flavored names (`customerId`, `reportMonth`, `maxResults` — never `page`, `limit`, `cursor`, `data`); step ids are verb-prefixed camelCase (`fetchUsers`) and distinct from every payload key. If the user asks for an input named like a reserved key, use a safe alternative and explain why.
409
+
357
410
  ### Step Result Envelopes
358
411
 
359
412
  **Every** step result is wrapped in `{ currentItem, data, success }`. You MUST account for this when writing data selectors or transforms.
@@ -548,6 +601,7 @@ curl -X POST "https://api.superglue.cloud/v1/hooks/{toolId}?token=$SUPERGLUE_API
548
601
  - **POST for read-only ops** — GraphQL queries via POST should have `modify: false`. Don't rely on HTTP method alone
549
602
  - **Saving without approval** — always present `sg tool run` results and ask before `sg tool save`
550
603
  - **`sg_auth_email` in scheduled runs** — not available in scheduler-triggered executions. Tools using `<<sg_auth_email>>` will fail
604
+ - **Reserved key collisions** — payload inputs or step ids named after reserved/injected keys (see Naming Rules) fail silently with wrong values, never with an error
551
605
 
552
606
  ---
553
607
 
@@ -587,6 +641,7 @@ For protocol-specific error recovery (HTTP, Postgres, MSSQL, Redis, GraphQL, SFT
587
641
  2. Re-run with `--include-step-results` to see the exact envelope shape
588
642
  3. Paginated steps merge into a single `.data` field — do not `.map()` over them
589
643
  4. Verify `sourceData.currentItem` is only referenced inside looping steps (set by the step's own `dataSelector`, not upstream)
644
+ 5. If a step silently received the wrong value (no error thrown) or pagination stopped after one page, check for a key collision between payload inputs, step ids, credential keys, and reserved runtime keys — see Naming Rules. Fix by renaming the input, not by working around it
590
645
 
591
646
  ### Persistent failures
592
647