@heuresis/mcp 1.0.0-rc.10 → 1.0.0-rc.11

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/README.md CHANGED
@@ -7,7 +7,7 @@ account, talks to the same Supabase project the webapp talks to, and
7
7
  respects the same RLS. Webapp and MCP are two front-ends to one cloud
8
8
  workspace.
9
9
 
10
- Current version: `1.0.0-rc.10`.
10
+ Current version: `1.0.0-rc.11`.
11
11
 
12
12
  ## Install
13
13
 
package/dist/cli.js CHANGED
@@ -27,6 +27,7 @@ import { createInterface } from 'node:readline/promises';
27
27
  import { stdin as input, stdout as output } from 'node:process';
28
28
  import { credentialsPath, defaultDeviceName, deleteCredentials, readCredentials, writeCredentials, } from './credentials.js';
29
29
  import { exchangeRefreshToken, RefreshTokenError } from './gotrue.js';
30
+ import { ensureProxyAgent } from './proxy.js';
30
31
  // Where the device pairing UI lives. Production default; can be overridden
31
32
  // for staging / self-hosted deploys via HEURESIS_DEVICE_BASE_URL. We also
32
33
  // allow HEURESIS_SUPABASE_URL to override which Supabase project the CLI
@@ -98,34 +99,8 @@ function parseLoginFlags(argv) {
98
99
  function sleep(ms) {
99
100
  return new Promise((resolve) => setTimeout(resolve, ms));
100
101
  }
101
- // Wire HTTPS_PROXY / HTTP_PROXY env vars into Node's global fetch dispatcher.
102
- // Node 18-22's undici does NOT auto-honor these vars (Node 24+ does). Without
103
- // this, the CLI fails with "fetch failed" on corporate networks. Idempotent
104
- // and a no-op when no proxy var is set.
105
- let proxyAgentInstalled = false;
106
- async function ensureProxyAgent() {
107
- if (proxyAgentInstalled)
108
- return;
109
- proxyAgentInstalled = true;
110
- const proxyUrl = process.env.HTTPS_PROXY ||
111
- process.env.https_proxy ||
112
- process.env.HTTP_PROXY ||
113
- process.env.http_proxy;
114
- if (!proxyUrl)
115
- return;
116
- try {
117
- // Dynamic import keeps undici out of the cold-start path when no proxy
118
- // is in play. Node ships undici as part of the runtime so this resolves.
119
- const { ProxyAgent, setGlobalDispatcher } = await import('undici');
120
- setGlobalDispatcher(new ProxyAgent(proxyUrl));
121
- log(`(routing through proxy ${proxyUrl})`);
122
- }
123
- catch (err) {
124
- log(`(could not configure proxy ${proxyUrl}: ${err instanceof Error ? err.message : String(err)})`);
125
- }
126
- }
127
102
  async function postJson(url, body) {
128
- await ensureProxyAgent();
103
+ await ensureProxyAgent(log);
129
104
  const res = await fetch(url, {
130
105
  method: 'POST',
131
106
  headers: { 'Content-Type': 'application/json' },
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ import { getConcept as legacyGetConcept, getConceptInput as legacyGetConceptInpu
24
24
  import { CLOUD_TOOLS } from './cloudTools.js';
25
25
  import { readCredentials } from './credentials.js';
26
26
  import { CloudAuthError, getCloudClient } from './cloudClient.js';
27
+ import { ensureProxyAgent } from './proxy.js';
27
28
  import { helpCommand, loginCommand, logoutCommand, whoamiCommand, } from './cli.js';
28
29
  import { readRealtimeFlag, resolveSubscriptionWorkspaceId, startRealtimeSubscription, stripRealtimeFlags, } from './realtime.js';
29
30
  const VERSION = '0.2.0-alpha';
@@ -93,6 +94,9 @@ function makeLegacySnapshotTools(store) {
93
94
  ];
94
95
  }
95
96
  async function runServer() {
97
+ // Route outbound fetch (GoTrue refresh + PostgREST queries) through
98
+ // HTTPS_PROXY / HTTP_PROXY before any cloud call. No-op when unset.
99
+ await ensureProxyAgent(console.error);
96
100
  const creds = await readCredentials();
97
101
  const snapshotEnv = process.env.HEURESIS_SNAPSHOT;
98
102
  let tools;
package/dist/proxy.js ADDED
@@ -0,0 +1,43 @@
1
+ // Heuresis MCP — proxy wiring for Node's global fetch dispatcher.
2
+ //
3
+ // Node 18-22's undici does NOT auto-honor HTTPS_PROXY / HTTP_PROXY (Node 24+
4
+ // does). Without this, every outbound fetch fails with "fetch failed" on
5
+ // networks that require an egress proxy — both the device-pairing + GoTrue
6
+ // refresh calls in the CLI and the SupabaseClient's PostgREST queries in the
7
+ // running MCP server. We install an undici ProxyAgent as the global
8
+ // dispatcher once, at process start.
9
+ //
10
+ // Idempotent across the whole process (module-level flag) and a no-op when no
11
+ // proxy var is set, so it is safe to call from every entry point.
12
+ //
13
+ // NOTE: this only covers `fetch` (PostgREST + auth). The Realtime websocket
14
+ // uses a separate transport that the global dispatcher does not touch; live
15
+ // sync behind a strict proxy is a known follow-up, but it is best-effort and
16
+ // fire-and-forget, so it never blocks tool calls.
17
+ let proxyAgentInstalled = false;
18
+ /**
19
+ * Route Node's global `fetch` through HTTPS_PROXY / HTTP_PROXY when set.
20
+ * Pass a logger to surface the routing decision (the CLI logs to stderr; the
21
+ * server passes console.error). Resolves once the dispatcher is in place.
22
+ */
23
+ export async function ensureProxyAgent(log = () => { }) {
24
+ if (proxyAgentInstalled)
25
+ return;
26
+ proxyAgentInstalled = true;
27
+ const proxyUrl = process.env.HTTPS_PROXY ||
28
+ process.env.https_proxy ||
29
+ process.env.HTTP_PROXY ||
30
+ process.env.http_proxy;
31
+ if (!proxyUrl)
32
+ return;
33
+ try {
34
+ // Dynamic import keeps undici off the cold-start path when no proxy is in
35
+ // play. It's a direct dependency, so this resolves.
36
+ const { ProxyAgent, setGlobalDispatcher } = await import('undici');
37
+ setGlobalDispatcher(new ProxyAgent(proxyUrl));
38
+ log(`(routing through proxy ${proxyUrl})`);
39
+ }
40
+ catch (err) {
41
+ log(`(could not configure proxy ${proxyUrl}: ${err instanceof Error ? err.message : String(err)})`);
42
+ }
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heuresis/mcp",
3
- "version": "1.0.0-rc.10",
3
+ "version": "1.0.0-rc.11",
4
4
  "mcpName": "io.github.ToremLabs/heuresis",
5
5
  "description": "Cloud-authenticated Model Context Protocol server for a Heuresis workspace. Logs into the user's Heuresis account and lets any MCP client (Claude Desktop, Claude Code, Cursor, custom agents) read and write the same workspace the webapp uses. 31 data tools, 3 operator tools (Branch/Matrix/C-K/ASIT/TRIZ/Free/Combine/Explore), and live Realtime change subscriptions.",
6
6
  "type": "module",