@cloudgrid-io/mcp 0.2.7 → 0.3.0
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/LICENSE +201 -0
- package/README.md +37 -10
- package/package.json +3 -5
- package/src/tools.js +228 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -43,30 +43,57 @@ It speaks MCP over stdio. Point any MCP client at the `cloudgrid-mcp` command.
|
|
|
43
43
|
|
|
44
44
|
## Tools
|
|
45
45
|
|
|
46
|
+
### Direct-API tools (both editions)
|
|
47
|
+
|
|
46
48
|
| Tool | Wraps | Notes |
|
|
47
49
|
|---|---|---|
|
|
48
|
-
| `cloudgrid_drop` | `POST /api/v2/drop/auto` | Artifact drop. Anonymous, or owned if signed in.
|
|
50
|
+
| `cloudgrid_drop` | `POST /api/v2/drop/auto` | Artifact drop. Anonymous, or owned if signed in. Direct API. |
|
|
49
51
|
| `cloudgrid_claim` | `POST /api/v2/anon-claim` | Claim an anonymous drop into the signed-in account. Direct API. |
|
|
50
|
-
| `cloudgrid_login` | `GET /auth/login` | Start a CLI-free sign-in; returns a URL to open.
|
|
52
|
+
| `cloudgrid_login` | `GET /auth/login` | Start a CLI-free sign-in; returns a URL to open. Direct API. |
|
|
51
53
|
| `cloudgrid_login_status` | `GET /auth/status` | Finish the sign-in; saves the token to the shared CLI credentials. |
|
|
52
54
|
| `cloudgrid_visibility` | `PATCH /api/v2/inspirations/<id>` | Change who can see a drop (private, space, authenticated, org, link). Needs sign-in. Direct API; also in the web edition. |
|
|
53
|
-
| `cloudgrid_init` | `cloudgrid init` | Register an app or agent; optionally seed a web service. |
|
|
54
|
-
| `cloudgrid_plug` | `cloudgrid plug` | Deploy a directory or URL. |
|
|
55
|
-
| `cloudgrid_logs` | `cloudgrid logs` | Snapshot of recent logs. Does not stream. |
|
|
56
|
-
| `cloudgrid_share` | `cloudgrid visibility set` | Set visibility, default link. |
|
|
57
|
-
| `cloudgrid_feedback` | `cloudgrid feedback list` | Read the org feedback feed. |
|
|
58
|
-
| `cloudgrid_brain` | `cloudgrid brain refresh` | Re-run the Grid Brain hooks. |
|
|
59
55
|
|
|
60
56
|
`cloudgrid_drop`, `cloudgrid_claim`, `cloudgrid_visibility`, and the two
|
|
61
|
-
`cloudgrid_login` tools do not wrap the CLI
|
|
57
|
+
`cloudgrid_login` tools do not wrap the CLI -- they call the API directly, so they
|
|
62
58
|
also work in the web edition where no CLI exists. `cloudgrid_login` writes the same
|
|
63
59
|
`~/.cloudgrid/credentials` the CLI uses, so the two share one identity.
|
|
64
60
|
|
|
61
|
+
### CLI-wrapping tools (local edition only)
|
|
62
|
+
|
|
63
|
+
| Tool | Wraps | Notes |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| `cloudgrid_init` | `cloudgrid init` | Register an app or agent; optionally seed a web service. |
|
|
66
|
+
| `cloudgrid_plug` | `cloudgrid plug` | Deploy a directory or URL. |
|
|
67
|
+
| `cloudgrid_logs` | `cloudgrid logs` | Snapshot of recent logs. Does not stream. Read-only. |
|
|
68
|
+
| `cloudgrid_share` | `cloudgrid visibility set` | Set visibility, default link. |
|
|
69
|
+
| `cloudgrid_feedback` | `cloudgrid feedback list` | Read the org feedback feed. Read-only. |
|
|
70
|
+
| `cloudgrid_brain` | `cloudgrid brain refresh` | Re-run the Grid Brain hooks. |
|
|
71
|
+
| `cloudgrid_whoami` | `cloudgrid whoami` | Show the signed-in user and active org. Read-only. |
|
|
72
|
+
| `cloudgrid_use` | `cloudgrid use` | Switch the active org. |
|
|
73
|
+
| `cloudgrid_logout` | `cloudgrid logout` | Sign out and clear local credentials. Destructive. |
|
|
74
|
+
| `cloudgrid_status` | `cloudgrid status` | Org dashboard or entity detail. Read-only. |
|
|
75
|
+
| `cloudgrid_info` | `cloudgrid info` | Entity metadata. Read-only. |
|
|
76
|
+
| `cloudgrid_builds` | `cloudgrid builds` | Recent builds and deploys. Read-only. |
|
|
77
|
+
| `cloudgrid_grid` | `cloudgrid grid` | List entities on the hub. Read-only. |
|
|
78
|
+
| `cloudgrid_rename` | `cloudgrid rename` | Rename an entity. |
|
|
79
|
+
| `cloudgrid_unplug` | `cloudgrid unplug` | Take an entity off the grid. Destructive; requires confirm. |
|
|
80
|
+
| `cloudgrid_delete` | `cloudgrid delete` | Archive and delete an entity. Destructive; requires confirm. |
|
|
81
|
+
| `cloudgrid_rollback` | `cloudgrid rollback` | Rollback to a previous version. |
|
|
82
|
+
| `cloudgrid_versions` | `cloudgrid versions` | List published versions. Read-only. |
|
|
83
|
+
| `cloudgrid_env` | `cloudgrid env` | Get, set, or list environment variables. |
|
|
84
|
+
| `cloudgrid_secrets` | `cloudgrid secrets` | Set or list secret names. Never returns secret values. |
|
|
85
|
+
| `cloudgrid_scaffold` | `cloudgrid scaffold` | Generate starter files. |
|
|
86
|
+
| `cloudgrid_doctor` | `cloudgrid doctor` | Run local diagnostics. Read-only. |
|
|
87
|
+
| `cloudgrid_open` | `cloudgrid open` | Return the public URL. Does not open a browser. Read-only. |
|
|
88
|
+
|
|
65
89
|
`cloudgrid_share` and `cloudgrid_visibility` overlap on purpose: `cloudgrid_share`
|
|
66
90
|
wraps the CLI and defaults to `link`; `cloudgrid_visibility` is direct API, takes an
|
|
67
|
-
explicit scope, and defaults its target to the session's last drop
|
|
91
|
+
explicit scope, and defaults its target to the session's last drop -- it is the one
|
|
68
92
|
the web edition gets.
|
|
69
93
|
|
|
94
|
+
All tools carry MCP annotations (`readOnlyHint`, `destructiveHint`,
|
|
95
|
+
`openWorldHint`) for clients that support them.
|
|
96
|
+
|
|
70
97
|
## Test
|
|
71
98
|
|
|
72
99
|
A smoke test spawns the server with a real MCP client, lists the tools, and calls
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudgrid-io/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "MCP server for CloudGrid. Two editions: a local stdio server (full toolset) and a hosted web server (light, CLI-free toolset) over MCP Streamable HTTP.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"smoke:web": "node test/smoke-web.mjs",
|
|
23
23
|
"smoke:redrop": "node test/smoke-redrop.mjs",
|
|
24
24
|
"smoke:oauth": "node test/smoke-oauth.mjs",
|
|
25
|
-
"lint:cloudbuild": "npx -y yaml-lint cloudbuild.yaml",
|
|
26
25
|
"test:auth": "node test/auth.test.mjs"
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
@@ -31,10 +30,9 @@
|
|
|
31
30
|
"zod": "^3.23.0"
|
|
32
31
|
},
|
|
33
32
|
"license": "Apache-2.0",
|
|
34
|
-
"homepage": "https://github.com/cloudgrid-io/
|
|
33
|
+
"homepage": "https://github.com/cloudgrid-io/mcp",
|
|
35
34
|
"repository": {
|
|
36
35
|
"type": "git",
|
|
37
|
-
"url": "https://github.com/cloudgrid-io/
|
|
38
|
-
"directory": "mcp-server"
|
|
36
|
+
"url": "https://github.com/cloudgrid-io/mcp.git"
|
|
39
37
|
}
|
|
40
38
|
}
|
package/src/tools.js
CHANGED
|
@@ -120,10 +120,8 @@ async function runDrop(ctx, { html, path: filePath, filename, anonymous, org, fr
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
// egress IP. A missing/bad secret silently falls back to the IP cap server-side, so
|
|
126
|
-
// this is safe to send whenever configured. Only the web edition sets ctx.trustedServer.
|
|
123
|
+
// Hosted server: attach the trusted-server credential when available.
|
|
124
|
+
// Falls back gracefully server-side if absent. Only the web edition sets ctx.trustedServer.
|
|
127
125
|
if (!headers["Authorization"] && ctx.trustedServer?.secret && ctx.trustedServer?.endUserId) {
|
|
128
126
|
headers["X-CloudGrid-Trusted-Server-Auth"] = ctx.trustedServer.secret;
|
|
129
127
|
headers["X-CloudGrid-Trusted-Server-End-User"] = ctx.trustedServer.endUserId;
|
|
@@ -138,11 +136,9 @@ async function runDrop(ctx, { html, path: filePath, filename, anonymous, org, fr
|
|
|
138
136
|
}
|
|
139
137
|
|
|
140
138
|
const form = new FormData();
|
|
141
|
-
// Redrop
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
// falls back to create, so this never hard-fails (authed in-place lands when the
|
|
145
|
-
// platform extends the gate; until then the fallback equals today's behavior).
|
|
139
|
+
// Redrop: a re-drop in the same session updates the previous drop in place (same URL,
|
|
140
|
+
// new version). `fresh: true` forces a new drop. The platform validates ownership and
|
|
141
|
+
// falls back to create if the caller does not own the previous drop.
|
|
146
142
|
// Field appended before the artifact so streaming parsers see it.
|
|
147
143
|
if (fresh !== true && ctx.state.lastDrop?.entity_id) {
|
|
148
144
|
form.append("previous_id", ctx.state.lastDrop.entity_id);
|
|
@@ -320,6 +316,8 @@ async function runVisibility(ctx, { target, visibility, org }) {
|
|
|
320
316
|
// Registers the tools onto `server`. ctx.edition decides whether the CLI-wrapping
|
|
321
317
|
// tools are included (they need a local machine).
|
|
322
318
|
export function registerTools(server, ctx) {
|
|
319
|
+
// ── Direct-API tools (both editions) ──────────────────────────────────────
|
|
320
|
+
|
|
323
321
|
// Drop — both editions.
|
|
324
322
|
server.tool(
|
|
325
323
|
"cloudgrid_drop",
|
|
@@ -335,6 +333,7 @@ export function registerTools(server, ctx) {
|
|
|
335
333
|
.optional()
|
|
336
334
|
.describe("Force a new drop even if you already dropped in this session (default: update in place)."),
|
|
337
335
|
},
|
|
336
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
338
337
|
async (input) => {
|
|
339
338
|
try {
|
|
340
339
|
return ok(await runDrop(ctx, input || {}));
|
|
@@ -352,6 +351,7 @@ export function registerTools(server, ctx) {
|
|
|
352
351
|
claim_token: z.string().optional().describe("The claim token from an anonymous drop."),
|
|
353
352
|
claim_url: z.string().optional().describe("The claim_url from an anonymous drop; the token is read from it."),
|
|
354
353
|
},
|
|
354
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
355
355
|
async (input) => {
|
|
356
356
|
try {
|
|
357
357
|
return ok(await runClaim(ctx, input || {}));
|
|
@@ -367,6 +367,7 @@ export function registerTools(server, ctx) {
|
|
|
367
367
|
"cloudgrid_login",
|
|
368
368
|
"Start a CLI-free CloudGrid sign-in. Use when the user wants to log in, sign in, or authenticate, or to claim an anonymous drop. Returns a URL to open in the browser; then call cloudgrid_login_status to finish. Uses CloudGrid's existing OAuth.",
|
|
369
369
|
{},
|
|
370
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
370
371
|
async () => {
|
|
371
372
|
const code = newLoginCode();
|
|
372
373
|
ctx.state.pendingLoginCode = code;
|
|
@@ -385,6 +386,7 @@ export function registerTools(server, ctx) {
|
|
|
385
386
|
{
|
|
386
387
|
code: z.string().optional().describe("The sign-in code. Defaults to the most recent cloudgrid_login."),
|
|
387
388
|
},
|
|
389
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
388
390
|
async (input) => {
|
|
389
391
|
const code = input?.code || ctx.state.pendingLoginCode;
|
|
390
392
|
if (!code) return fail("No sign-in is in progress. Run cloudgrid_login first.");
|
|
@@ -423,6 +425,7 @@ export function registerTools(server, ctx) {
|
|
|
423
425
|
target: z.string().optional().describe("Entity id. Defaults to this session's last drop."),
|
|
424
426
|
org: z.string().optional().describe("Org of the entity. Defaults to the active org."),
|
|
425
427
|
},
|
|
428
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
426
429
|
async (input) => {
|
|
427
430
|
try {
|
|
428
431
|
return ok(await runVisibility(ctx, input || {}));
|
|
@@ -434,7 +437,8 @@ export function registerTools(server, ctx) {
|
|
|
434
437
|
|
|
435
438
|
if (ctx.edition !== "local") return; // web edition stops here — no CLI tools
|
|
436
439
|
|
|
437
|
-
// ── CLI-wrapping tools (local edition only)
|
|
440
|
+
// ── CLI-wrapping tools (local edition only) ───────────────────────────────
|
|
441
|
+
|
|
438
442
|
server.tool(
|
|
439
443
|
"cloudgrid_init",
|
|
440
444
|
"Register a new CloudGrid app or agent, optionally seeding a web service. Wraps `cloudgrid init`.",
|
|
@@ -446,6 +450,7 @@ export function registerTools(server, ctx) {
|
|
|
446
450
|
dir: z.string().optional().describe("Target directory. Defaults to ./<name>."),
|
|
447
451
|
org: z.string().optional().describe("Override the active org for this init."),
|
|
448
452
|
},
|
|
453
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
449
454
|
cliTool(({ kind, name, type, description, dir, org }) => {
|
|
450
455
|
const args = ["init", kind, name];
|
|
451
456
|
if (type) args.push("--type", type);
|
|
@@ -464,6 +469,7 @@ export function registerTools(server, ctx) {
|
|
|
464
469
|
org: z.string().optional().describe("Pick or override the org."),
|
|
465
470
|
no_deploy: z.boolean().optional().describe("Register the entity but do not build or deploy."),
|
|
466
471
|
},
|
|
472
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
467
473
|
cliTool(({ target, org, no_deploy }) => {
|
|
468
474
|
const args = ["plug"];
|
|
469
475
|
if (target) args.push(target);
|
|
@@ -482,6 +488,7 @@ export function registerTools(server, ctx) {
|
|
|
482
488
|
tail: z.number().int().positive().optional().describe("Number of recent lines. Default 100."),
|
|
483
489
|
since: z.string().optional().describe("Only logs newer than this, e.g. 5m, 1h, 2d."),
|
|
484
490
|
},
|
|
491
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
485
492
|
cliTool(({ name, tail, since }) => {
|
|
486
493
|
const args = ["logs"];
|
|
487
494
|
if (name) args.push(name);
|
|
@@ -498,6 +505,7 @@ export function registerTools(server, ctx) {
|
|
|
498
505
|
name: z.string().describe("Entity slug."),
|
|
499
506
|
mode: z.enum(["link", "private", "authenticated", "org", "space"]).optional().describe("Visibility mode. Default link."),
|
|
500
507
|
},
|
|
508
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
501
509
|
cliTool(({ name, mode }) => ["visibility", "set", name, mode ?? "link"]),
|
|
502
510
|
);
|
|
503
511
|
|
|
@@ -509,6 +517,7 @@ export function registerTools(server, ctx) {
|
|
|
509
517
|
limit: z.number().int().positive().max(200).optional().describe("Number of events. Default 50, max 200."),
|
|
510
518
|
org: z.string().optional().describe("Read another org's feed where you have access."),
|
|
511
519
|
},
|
|
520
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
512
521
|
cliTool(({ since, limit, org }) => {
|
|
513
522
|
const args = ["feedback", "list"];
|
|
514
523
|
if (since) args.push("--since", since);
|
|
@@ -526,6 +535,7 @@ export function registerTools(server, ctx) {
|
|
|
526
535
|
wait: z.boolean().optional().describe("Wait for the refresh to finish. Default true."),
|
|
527
536
|
org: z.string().optional().describe("Target an entity in another org."),
|
|
528
537
|
},
|
|
538
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
529
539
|
cliTool(({ name, wait, org }) => {
|
|
530
540
|
const args = ["brain", "refresh", name];
|
|
531
541
|
if (wait !== false) args.push("--wait");
|
|
@@ -533,6 +543,214 @@ export function registerTools(server, ctx) {
|
|
|
533
543
|
return args;
|
|
534
544
|
}),
|
|
535
545
|
);
|
|
546
|
+
|
|
547
|
+
// ── New CLI-wrapping tools (local edition only) ───────────────────────────
|
|
548
|
+
|
|
549
|
+
server.tool(
|
|
550
|
+
"cloudgrid_whoami",
|
|
551
|
+
"Show the signed-in user and active org. Wraps `cloudgrid whoami`.",
|
|
552
|
+
{},
|
|
553
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
554
|
+
cliTool(() => ["whoami"]),
|
|
555
|
+
);
|
|
556
|
+
|
|
557
|
+
server.tool(
|
|
558
|
+
"cloudgrid_use",
|
|
559
|
+
"Switch the active org. Wraps `cloudgrid use`.",
|
|
560
|
+
{ org: z.string().describe("Org slug to switch to.") },
|
|
561
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
562
|
+
cliTool(({ org }) => ["use", org]),
|
|
563
|
+
);
|
|
564
|
+
|
|
565
|
+
server.tool(
|
|
566
|
+
"cloudgrid_logout",
|
|
567
|
+
"Sign out and clear local credentials. Wraps `cloudgrid logout`.",
|
|
568
|
+
{},
|
|
569
|
+
{ readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
570
|
+
cliTool(() => ["logout"]),
|
|
571
|
+
);
|
|
572
|
+
|
|
573
|
+
server.tool(
|
|
574
|
+
"cloudgrid_status",
|
|
575
|
+
"Org dashboard, entity detail, or deploy snapshot. Wraps `cloudgrid status`.",
|
|
576
|
+
{ name: z.string().optional().describe("Entity name or trace id. Omit for the org dashboard.") },
|
|
577
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
578
|
+
cliTool(({ name }) => (name ? ["status", name] : ["status"])),
|
|
579
|
+
);
|
|
580
|
+
|
|
581
|
+
server.tool(
|
|
582
|
+
"cloudgrid_info",
|
|
583
|
+
"Show metadata for a CloudGrid entity. Wraps `cloudgrid info`.",
|
|
584
|
+
{ name: z.string().optional().describe("Entity name. Omit for the entity linked to the current directory.") },
|
|
585
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
586
|
+
cliTool(({ name }) => {
|
|
587
|
+
const args = ["info"];
|
|
588
|
+
if (name) args.push(name);
|
|
589
|
+
return args;
|
|
590
|
+
}),
|
|
591
|
+
);
|
|
592
|
+
|
|
593
|
+
server.tool(
|
|
594
|
+
"cloudgrid_builds",
|
|
595
|
+
"List recent builds and deploys for an entity. Wraps `cloudgrid builds`.",
|
|
596
|
+
{
|
|
597
|
+
name: z.string().optional().describe("Entity name. Omit for the entity linked to the current directory."),
|
|
598
|
+
limit: z.number().int().positive().optional().describe("Number of builds to show."),
|
|
599
|
+
},
|
|
600
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
601
|
+
cliTool(({ name, limit }) => {
|
|
602
|
+
const args = ["builds"];
|
|
603
|
+
if (name) args.push(name);
|
|
604
|
+
if (limit) args.push("--limit", String(limit));
|
|
605
|
+
return args;
|
|
606
|
+
}),
|
|
607
|
+
);
|
|
608
|
+
|
|
609
|
+
server.tool(
|
|
610
|
+
"cloudgrid_grid",
|
|
611
|
+
"List entities on the hub or org. Wraps `cloudgrid grid`.",
|
|
612
|
+
{ org: z.string().optional().describe("Org slug. Omit for the active org.") },
|
|
613
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
614
|
+
cliTool(({ org }) => (org ? ["grid", "--org", org] : ["grid"])),
|
|
615
|
+
);
|
|
616
|
+
|
|
617
|
+
server.tool(
|
|
618
|
+
"cloudgrid_rename",
|
|
619
|
+
"Rename a CloudGrid entity. Wraps `cloudgrid rename`.",
|
|
620
|
+
{
|
|
621
|
+
name: z.string().describe("Current entity slug."),
|
|
622
|
+
new_name: z.string().describe("New slug."),
|
|
623
|
+
},
|
|
624
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
625
|
+
cliTool(({ name, new_name }) => ["rename", name, new_name]),
|
|
626
|
+
);
|
|
627
|
+
|
|
628
|
+
server.tool(
|
|
629
|
+
"cloudgrid_unplug",
|
|
630
|
+
"Take an entity off the grid. Destructive. Wraps `cloudgrid unplug`.",
|
|
631
|
+
{
|
|
632
|
+
name: z.string().describe("Entity slug to take down (required)."),
|
|
633
|
+
confirm: z.literal(true).describe("Must be true to proceed."),
|
|
634
|
+
},
|
|
635
|
+
{ readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
636
|
+
cliTool(({ name }) => ["unplug", name]),
|
|
637
|
+
);
|
|
638
|
+
|
|
639
|
+
server.tool(
|
|
640
|
+
"cloudgrid_delete",
|
|
641
|
+
"Archive and delete a CloudGrid entity. Destructive. Wraps `cloudgrid delete`.",
|
|
642
|
+
{
|
|
643
|
+
name: z.string().describe("Entity slug to delete (required)."),
|
|
644
|
+
confirm: z.literal(true).describe("Must be true to proceed."),
|
|
645
|
+
},
|
|
646
|
+
{ readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
647
|
+
cliTool(({ name }) => ["delete", name]),
|
|
648
|
+
);
|
|
649
|
+
|
|
650
|
+
server.tool(
|
|
651
|
+
"cloudgrid_rollback",
|
|
652
|
+
"Rollback an entity to a previous version. Wraps `cloudgrid rollback`.",
|
|
653
|
+
{
|
|
654
|
+
name: z.string().describe("Entity slug."),
|
|
655
|
+
to: z.string().optional().describe("Target version tag or id. Omit to roll back one version."),
|
|
656
|
+
},
|
|
657
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
658
|
+
cliTool(({ name, to }) => {
|
|
659
|
+
const args = ["rollback", name];
|
|
660
|
+
if (to) args.push("--to", to);
|
|
661
|
+
return args;
|
|
662
|
+
}),
|
|
663
|
+
);
|
|
664
|
+
|
|
665
|
+
server.tool(
|
|
666
|
+
"cloudgrid_versions",
|
|
667
|
+
"List published versions for an entity. Wraps `cloudgrid versions`.",
|
|
668
|
+
{ name: z.string().optional().describe("Entity name. Omit for the entity linked to the current directory.") },
|
|
669
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
670
|
+
cliTool(({ name }) => {
|
|
671
|
+
const args = ["versions"];
|
|
672
|
+
if (name) args.push(name);
|
|
673
|
+
return args;
|
|
674
|
+
}),
|
|
675
|
+
);
|
|
676
|
+
|
|
677
|
+
server.tool(
|
|
678
|
+
"cloudgrid_env",
|
|
679
|
+
"Manage environment variables for an entity. Wraps `cloudgrid env`.",
|
|
680
|
+
{
|
|
681
|
+
action: z.enum(["get", "set", "list"]).describe("get, set, or list."),
|
|
682
|
+
name: z.string().describe("Entity slug."),
|
|
683
|
+
key: z.string().optional().describe("Variable name. Required for get and set."),
|
|
684
|
+
value: z.string().optional().describe("Variable value. Required for set."),
|
|
685
|
+
},
|
|
686
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
687
|
+
cliTool(({ action, name, key, value }) => {
|
|
688
|
+
if (action === "set") {
|
|
689
|
+
if (!key || value === undefined) throw new Error("key and value are required for set");
|
|
690
|
+
return ["env", "set", name, key, value];
|
|
691
|
+
}
|
|
692
|
+
if (action === "get") {
|
|
693
|
+
if (!key) throw new Error("key is required for get");
|
|
694
|
+
return ["env", "get", name, key];
|
|
695
|
+
}
|
|
696
|
+
return ["env", "list", name];
|
|
697
|
+
}),
|
|
698
|
+
);
|
|
699
|
+
|
|
700
|
+
server.tool(
|
|
701
|
+
"cloudgrid_secrets",
|
|
702
|
+
"Set or list secret names for an entity. Never returns secret values. Wraps `cloudgrid secrets`.",
|
|
703
|
+
{
|
|
704
|
+
action: z.enum(["set", "list"]).describe("set or list (names only)."),
|
|
705
|
+
name: z.string().describe("Entity slug."),
|
|
706
|
+
key: z.string().optional().describe("Secret name. Required for set."),
|
|
707
|
+
value: z.string().optional().describe("Secret value. Required for set."),
|
|
708
|
+
},
|
|
709
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
710
|
+
cliTool(({ action, name, key, value }) => {
|
|
711
|
+
if (action === "set") {
|
|
712
|
+
if (!key || value === undefined) throw new Error("key and value are required for set");
|
|
713
|
+
return ["secrets", "set", name, key, value];
|
|
714
|
+
}
|
|
715
|
+
return ["secrets", "list", name];
|
|
716
|
+
}),
|
|
717
|
+
);
|
|
718
|
+
|
|
719
|
+
server.tool(
|
|
720
|
+
"cloudgrid_scaffold",
|
|
721
|
+
"Generate starter files for a CloudGrid entity. Wraps `cloudgrid scaffold`.",
|
|
722
|
+
{
|
|
723
|
+
template: z.string().optional().describe("Template name."),
|
|
724
|
+
dir: z.string().optional().describe("Target directory."),
|
|
725
|
+
},
|
|
726
|
+
{ readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
727
|
+
cliTool(({ template, dir }) => {
|
|
728
|
+
const args = ["scaffold"];
|
|
729
|
+
if (template) args.push(template);
|
|
730
|
+
if (dir) args.push("--dir", dir);
|
|
731
|
+
return args;
|
|
732
|
+
}),
|
|
733
|
+
);
|
|
734
|
+
|
|
735
|
+
server.tool(
|
|
736
|
+
"cloudgrid_doctor",
|
|
737
|
+
"Run CloudGrid diagnostics on the local environment. Wraps `cloudgrid doctor`.",
|
|
738
|
+
{},
|
|
739
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
740
|
+
cliTool(() => ["doctor"]),
|
|
741
|
+
);
|
|
742
|
+
|
|
743
|
+
server.tool(
|
|
744
|
+
"cloudgrid_open",
|
|
745
|
+
"Return the public URL for an entity. Does not open a browser. Wraps `cloudgrid open --url`.",
|
|
746
|
+
{ name: z.string().optional().describe("Entity name. Omit for the entity linked to the current directory.") },
|
|
747
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
748
|
+
cliTool(({ name }) => {
|
|
749
|
+
const args = ["open", "--url"];
|
|
750
|
+
if (name) args.push(name);
|
|
751
|
+
return args;
|
|
752
|
+
}),
|
|
753
|
+
);
|
|
536
754
|
}
|
|
537
755
|
|
|
538
756
|
export { decodeJwt };
|