@cloudgrid-io/mcp 0.4.6 → 0.4.7
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/package.json +1 -2
- package/src/tools.js +31 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudgrid-io/mcp",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
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": {
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"build:mcpb": "node scripts/build-mcpb.mjs"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@cloudgrid-io/cli": "^0.9.20",
|
|
30
29
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
31
30
|
"express": "^4.22.2",
|
|
32
31
|
"zod": "^3.23.0"
|
package/src/tools.js
CHANGED
|
@@ -90,6 +90,9 @@ function resolveBundledCli() {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
// Pin the CLI version for the lazy npx fallback so behaviour is reproducible.
|
|
94
|
+
const CLI_NPX_PKG = "@cloudgrid-io/cli@^0.9.20";
|
|
95
|
+
|
|
93
96
|
async function runCloudgrid(args, opts = {}) {
|
|
94
97
|
const cwd = resolveCwd(opts.cwd);
|
|
95
98
|
const execOpts = {
|
|
@@ -99,7 +102,15 @@ async function runCloudgrid(args, opts = {}) {
|
|
|
99
102
|
...(cwd ? { cwd } : {}),
|
|
100
103
|
};
|
|
101
104
|
|
|
102
|
-
|
|
105
|
+
const extract = (err) => {
|
|
106
|
+
const detail = [err && err.stdout, err && err.stderr, err && err.message]
|
|
107
|
+
.filter(Boolean)
|
|
108
|
+
.join("\n")
|
|
109
|
+
.trim();
|
|
110
|
+
return new Error(detail || "cloudgrid command failed");
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// 1. Bundled CLI (the .mcpb ships it in its node_modules)
|
|
103
114
|
const bundled = resolveBundledCli();
|
|
104
115
|
if (bundled) {
|
|
105
116
|
try {
|
|
@@ -110,29 +121,32 @@ async function runCloudgrid(args, opts = {}) {
|
|
|
110
121
|
);
|
|
111
122
|
return (stdout || stderr || "").trim() || "Done.";
|
|
112
123
|
} catch (err) {
|
|
113
|
-
|
|
114
|
-
.filter(Boolean)
|
|
115
|
-
.join("\n")
|
|
116
|
-
.trim();
|
|
117
|
-
throw new Error(detail || "cloudgrid command failed");
|
|
124
|
+
throw extract(err);
|
|
118
125
|
}
|
|
119
126
|
}
|
|
120
127
|
|
|
121
|
-
// 2.
|
|
128
|
+
// 2. Global `cloudgrid` on PATH
|
|
122
129
|
try {
|
|
123
130
|
const { stdout, stderr } = await execFileAsync("cloudgrid", args, execOpts);
|
|
124
131
|
return (stdout || stderr || "").trim() || "Done.";
|
|
125
132
|
} catch (err) {
|
|
126
|
-
if (err && err.code === "ENOENT")
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
if (!(err && err.code === "ENOENT")) throw extract(err);
|
|
134
|
+
// Not found — fall through to lazy npx fetch
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 3. Lazy fetch: npx -y @cloudgrid-io/cli@<pinned> <args>
|
|
138
|
+
// One-time download; npx caches it for subsequent invocations.
|
|
139
|
+
console.error("cloudgrid-mcp: fetching the CloudGrid CLI (first use)…");
|
|
140
|
+
const npx = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
141
|
+
try {
|
|
142
|
+
const { stdout, stderr } = await execFileAsync(
|
|
143
|
+
npx,
|
|
144
|
+
["-y", CLI_NPX_PKG, ...args],
|
|
145
|
+
execOpts,
|
|
146
|
+
);
|
|
147
|
+
return (stdout || stderr || "").trim() || "Done.";
|
|
148
|
+
} catch (err) {
|
|
149
|
+
throw extract(err);
|
|
136
150
|
}
|
|
137
151
|
}
|
|
138
152
|
|