@cloudgrid-io/mcp 0.20.28 → 0.20.29

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudgrid-io/mcp",
3
- "version": "0.20.28",
3
+ "version": "0.20.29",
4
4
  "description": "MCP access to CloudGrid — the live runtime environment where the user's apps run WITH the infrastructure they need out of the box: managed MongoDB, Redis (cache/queues/pub-sub), a pgvector store, persistent disk, and built-in AI with no API keys, in any language or stack, no Docker or Kubernetes to manage. Brainstorm, build, plug, and improve apps, games, dashboards, and tools; instant single-page publishes and full runtime-app deploys with a live URL — for developers and non-technical users. Three editions: local stdio (full toolset), hosted web (light, CLI-free), and a public docs-search server.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -53,12 +53,14 @@
53
53
  "test:fork": "node test/fork.test.mjs",
54
54
  "test:set-sharing": "node test/set-sharing.test.mjs",
55
55
  "test:check-deploy": "node test/check-deploy.test.mjs",
56
- "test:staleness": "node test/staleness.test.mjs"
56
+ "test:staleness": "node test/staleness.test.mjs",
57
+ "test:proxy": "node test/proxy.test.mjs"
57
58
  },
58
59
  "dependencies": {
59
60
  "@modelcontextprotocol/sdk": "^1.0.0",
60
61
  "express": "^4.22.2",
61
62
  "fflate": "^0.8.3",
63
+ "undici": "^8.7.0",
62
64
  "zod": "^3.23.0"
63
65
  },
64
66
  "license": "Apache-2.0",
package/src/auth.js CHANGED
@@ -45,7 +45,17 @@ export function buildLoginUrl(code) {
45
45
  // A 404 means the session for this code does not exist yet — the user has not
46
46
  // opened the sign-in URL — so it is reported as 'not_started', not an error.
47
47
  export async function pollStatusOnce(code) {
48
- const res = await fetch(`${API_BASE}/auth/status?code=${encodeURIComponent(code)}`);
48
+ let res;
49
+ try {
50
+ res = await fetch(`${API_BASE}/auth/status?code=${encodeURIComponent(code)}`);
51
+ } catch (err) {
52
+ const cause = err?.cause?.code || err?.cause?.message || err?.cause || err.message;
53
+ throw new Error(
54
+ `Can't reach api.cloudgrid.io (${cause}). ` +
55
+ `If you are behind a proxy, set HTTPS_PROXY; or use the hosted connector ` +
56
+ `https://mcp-connected.cloudgrid.io/mcp.`,
57
+ );
58
+ }
49
59
  if (res.status === 404) {
50
60
  return { status: "not_started" };
51
61
  }
package/src/index.js CHANGED
@@ -5,6 +5,9 @@
5
5
  // Desktop). Full toolset, including the CLI-wrapping tools. Identity comes from
6
6
  // the shared ~/.cloudgrid/credentials file, so it interoperates with the CLI.
7
7
 
8
+ import { installProxy } from "./proxy.js";
9
+ installProxy();
10
+
8
11
  import { readFileSync } from "node:fs";
9
12
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
13
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
package/src/proxy.js ADDED
@@ -0,0 +1,63 @@
1
+ // Corporate proxy support for Node's global fetch (undici).
2
+ //
3
+ // Node's built-in fetch ignores HTTPS_PROXY / HTTP_PROXY. This module reads
4
+ // the standard proxy env vars and, when set, installs an undici ProxyAgent as
5
+ // the global dispatcher so every subsequent fetch() honors the proxy.
6
+ //
7
+ // Fully guarded: if undici is unavailable or the env is unset, this is a
8
+ // silent no-op. Never throws at startup.
9
+
10
+ import { createRequire } from "node:module";
11
+
12
+ export function resolveProxy() {
13
+ const proxyUrl =
14
+ process.env.HTTPS_PROXY ||
15
+ process.env.https_proxy ||
16
+ process.env.HTTP_PROXY ||
17
+ process.env.http_proxy ||
18
+ null;
19
+
20
+ if (!proxyUrl) return null;
21
+
22
+ const raw =
23
+ process.env.NO_PROXY ||
24
+ process.env.no_proxy ||
25
+ "";
26
+
27
+ const noProxy = raw
28
+ .split(",")
29
+ .map((s) => s.trim())
30
+ .filter(Boolean);
31
+
32
+ return { proxyUrl, noProxy };
33
+ }
34
+
35
+ export function shouldBypassProxy(hostname, noProxyList) {
36
+ if (!noProxyList || noProxyList.length === 0) return false;
37
+ for (const entry of noProxyList) {
38
+ if (entry === "*") return true;
39
+ if (hostname === entry) return true;
40
+ if (entry.startsWith(".") && hostname.endsWith(entry)) return true;
41
+ }
42
+ return false;
43
+ }
44
+
45
+ export function installProxy() {
46
+ try {
47
+ const cfg = resolveProxy();
48
+ if (!cfg) return;
49
+
50
+ const require = createRequire(import.meta.url);
51
+ const { ProxyAgent, setGlobalDispatcher } = require("undici");
52
+
53
+ setGlobalDispatcher(
54
+ new ProxyAgent({
55
+ uri: cfg.proxyUrl,
56
+ noProxy: cfg.noProxy.join(","),
57
+ }),
58
+ );
59
+ } catch {
60
+ // Silent: undici unavailable or ProxyAgent unsupported — fall through to
61
+ // default (unproxied) fetch. Never break startup.
62
+ }
63
+ }
package/src/web.js CHANGED
@@ -14,6 +14,9 @@
14
14
  //
15
15
  // Run: PORT=8080 node src/web.js Health: GET /healthz
16
16
 
17
+ import { installProxy } from "./proxy.js";
18
+ installProxy();
19
+
17
20
  import { readFileSync } from "node:fs";
18
21
  import { randomUUID } from "node:crypto";
19
22
  import express from "express";