@heuresis/mcp 1.0.0-rc.12 → 1.0.0-rc.13
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 +31 -1
- package/dist/cli.js +1 -1
- package/dist/cloudClient.js +50 -22
- package/dist/gotrue.js +57 -0
- package/dist/index.js +68 -26
- package/dist/zod-to-json-schema.js +26 -1
- package/package.json +1 -1
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
|
+
Current version: `1.0.0-rc.13`.
|
|
11
11
|
|
|
12
12
|
## Install
|
|
13
13
|
|
|
@@ -89,6 +89,36 @@ npx -y @heuresis/mcp --no-realtime # boot the server with live sync o
|
|
|
89
89
|
npx -y @heuresis/mcp --realtime # re-enable live sync
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
+
## Headless mode (CI, cloud agents, disposable containers)
|
|
93
|
+
|
|
94
|
+
Device pairing writes a **refresh token** to disk. That works great on a
|
|
95
|
+
personal machine, but it does **not** survive disposable/ephemeral
|
|
96
|
+
environments (CI runners, cloud agent containers, "Claude Code on the web"):
|
|
97
|
+
the filesystem is wiped between runs, and a Supabase refresh token is
|
|
98
|
+
**single-use under rotation** — so a token baked into config dies after the
|
|
99
|
+
first session.
|
|
100
|
+
|
|
101
|
+
For those environments, skip pairing and let the server **sign in fresh on
|
|
102
|
+
every boot** from your account email + password (a password is not consumed on
|
|
103
|
+
use, so it works forever with no re-pairing). Set three env vars:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
HEURESIS_EMAIL=you@example.com # your Heuresis account email
|
|
107
|
+
HEURESIS_PASSWORD=your-account-password # secret — store it in a secrets manager
|
|
108
|
+
HEURESIS_ANON_KEY=sb_publishable_... # project anon/publishable key (public, not a secret)
|
|
109
|
+
# optional: HEURESIS_SUPABASE_URL=... # defaults to the production project
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
When `HEURESIS_EMAIL` + `HEURESIS_PASSWORD` are present they take precedence
|
|
113
|
+
over any `credentials.json`, and the MCP server authenticates per boot — no
|
|
114
|
+
device link required. Requirements:
|
|
115
|
+
|
|
116
|
+
- Email + password sign-in must be enabled for the Supabase project, and the
|
|
117
|
+
account must have a password set (passwordless / magic-link-only accounts
|
|
118
|
+
need a password added first).
|
|
119
|
+
- Treat `HEURESIS_PASSWORD` as a secret. Prefer a dedicated account if your
|
|
120
|
+
environment can only expose env vars that are visible to its users.
|
|
121
|
+
|
|
92
122
|
## Live sync
|
|
93
123
|
|
|
94
124
|
When the MCP boots in cloud mode it subscribes to the workspace over
|
package/dist/cli.js
CHANGED
|
@@ -35,7 +35,7 @@ import { ensureProxyAgent } from './proxy.js';
|
|
|
35
35
|
// allow HEURESIS_SUPABASE_URL to override which Supabase project the CLI
|
|
36
36
|
// talks to (e.g. a staging instance). Both default to production.
|
|
37
37
|
const DEFAULT_DEVICE_BASE_URL = 'https://heuresis.app';
|
|
38
|
-
const DEFAULT_SUPABASE_URL = 'https://wpgniquyuppljeqkedqh.supabase.co';
|
|
38
|
+
export const DEFAULT_SUPABASE_URL = 'https://wpgniquyuppljeqkedqh.supabase.co';
|
|
39
39
|
const POLL_INTERVAL_MS = 5_000;
|
|
40
40
|
const POLL_TIMEOUT_MS = 15 * 60 * 1_000;
|
|
41
41
|
function log(...args) {
|
package/dist/cloudClient.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// Polyfill global WebSocket on Node < 22 before any Supabase client is built.
|
|
20
20
|
import './wsPolyfill.js';
|
|
21
21
|
import { createClient } from '@supabase/supabase-js';
|
|
22
|
-
import { exchangeRefreshToken } from './gotrue.js';
|
|
22
|
+
import { exchangeRefreshToken, signInWithPassword } from './gotrue.js';
|
|
23
23
|
let cached = null;
|
|
24
24
|
export class CloudAuthError extends Error {
|
|
25
25
|
constructor(msg) {
|
|
@@ -28,14 +28,12 @@ export class CloudAuthError extends Error {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* token
|
|
31
|
+
* Create a headless Supabase client and seed it with an already-obtained
|
|
32
|
+
* GoTrue session, so every subsequent PostgREST call carries the user's JWT
|
|
33
|
+
* and supabase-js keeps the in-memory access token alive. Caches the result.
|
|
34
34
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return cached;
|
|
38
|
-
const client = createClient(creds.supabase_url, creds.anon_key, {
|
|
35
|
+
async function seedClient(supabaseUrl, anonKey, session, userId) {
|
|
36
|
+
const client = createClient(supabaseUrl, anonKey, {
|
|
39
37
|
auth: {
|
|
40
38
|
// Headless: no localStorage, no URL detection, no auto-refresh
|
|
41
39
|
// listeners writing to disk. The library still auto-refreshes the
|
|
@@ -45,28 +43,58 @@ export async function getCloudClient(creds) {
|
|
|
45
43
|
detectSessionInUrl: false,
|
|
46
44
|
},
|
|
47
45
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const { error } = await client.auth.setSession({
|
|
47
|
+
access_token: session.access_token,
|
|
48
|
+
refresh_token: session.refresh_token,
|
|
49
|
+
});
|
|
50
|
+
if (error) {
|
|
51
|
+
throw new CloudAuthError(`Failed to seed Heuresis session: ${error.message}.`);
|
|
52
|
+
}
|
|
53
|
+
cached = { client, userId };
|
|
54
|
+
return cached;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Build (or return cached) a Supabase client bound to the credentials on
|
|
58
|
+
* disk. Bootstraps by exchanging the stored (rotating) refresh token. Throws
|
|
59
|
+
* CloudAuthError if the refresh token has been revoked/rotated away.
|
|
60
|
+
*
|
|
61
|
+
* NOTE: a stored refresh token is single-use under Supabase rotation, so this
|
|
62
|
+
* path is unsuitable for ephemeral environments that reuse the same persisted
|
|
63
|
+
* credential across boots — use getCloudClientFromPassword() for those.
|
|
64
|
+
*/
|
|
65
|
+
export async function getCloudClient(creds) {
|
|
66
|
+
if (cached)
|
|
67
|
+
return cached;
|
|
52
68
|
try {
|
|
53
69
|
const session = await exchangeRefreshToken(creds.supabase_url, creds.anon_key, creds.refresh_token);
|
|
54
|
-
|
|
55
|
-
access_token: session.access_token,
|
|
56
|
-
refresh_token: session.refresh_token,
|
|
57
|
-
});
|
|
58
|
-
if (error) {
|
|
59
|
-
throw new CloudAuthError(`Failed to seed Heuresis session: ${error.message}. ` +
|
|
60
|
-
'Run `npx -y -p @heuresis/mcp heuresis-mcp login` to re-authenticate.');
|
|
61
|
-
}
|
|
70
|
+
return await seedClient(creds.supabase_url, creds.anon_key, session, creds.user_id);
|
|
62
71
|
}
|
|
63
72
|
catch (err) {
|
|
64
73
|
if (err instanceof CloudAuthError)
|
|
65
74
|
throw err;
|
|
66
75
|
throw new CloudAuthError(`Failed to refresh Heuresis session: ${err instanceof Error ? err.message : String(err)}. Run \`npx -y -p @heuresis/mcp heuresis-mcp login\` to re-authenticate.`);
|
|
67
76
|
}
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Build (or return cached) a Supabase client by signing in fresh with an
|
|
80
|
+
* email + password. Because a password is not consumed on use, this works
|
|
81
|
+
* durably across disposable/ephemeral sessions that re-authenticate on every
|
|
82
|
+
* boot — no persisted, rotating refresh token required. Throws CloudAuthError
|
|
83
|
+
* on bad credentials or if password sign-in is disabled for the project.
|
|
84
|
+
*/
|
|
85
|
+
export async function getCloudClientFromPassword(supabaseUrl, anonKey, email, password) {
|
|
86
|
+
if (cached)
|
|
87
|
+
return cached;
|
|
88
|
+
try {
|
|
89
|
+
const session = await signInWithPassword(supabaseUrl, anonKey, email, password);
|
|
90
|
+
const userId = session.user?.id ?? '(unknown)';
|
|
91
|
+
return await seedClient(supabaseUrl, anonKey, session, userId);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
if (err instanceof CloudAuthError)
|
|
95
|
+
throw err;
|
|
96
|
+
throw new CloudAuthError(`Headless email/password sign-in failed: ${err instanceof Error ? err.message : String(err)}. Check HEURESIS_EMAIL / HEURESIS_PASSWORD / HEURESIS_ANON_KEY.`);
|
|
97
|
+
}
|
|
70
98
|
}
|
|
71
99
|
/** Clear the cached client. Used after logout. */
|
|
72
100
|
export function resetCloudClient() {
|
package/dist/gotrue.js
CHANGED
|
@@ -82,3 +82,60 @@ export async function exchangeRefreshToken(supabaseUrl, anonKey, refreshToken) {
|
|
|
82
82
|
}
|
|
83
83
|
return session;
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Sign in with an email + password directly against the GoTrue token endpoint:
|
|
87
|
+
*
|
|
88
|
+
* POST `${supabaseUrl}/auth/v1/token?grant_type=password`
|
|
89
|
+
* headers: { apikey, Authorization: Bearer <anon>, Content-Type: application/json }
|
|
90
|
+
* body: { email, password }
|
|
91
|
+
*
|
|
92
|
+
* Unlike a refresh token, a password is NOT consumed on use, so this is the
|
|
93
|
+
* right primitive for headless, ephemeral environments (e.g. cloud agent
|
|
94
|
+
* containers) that re-authenticate from scratch on every boot. Returns the
|
|
95
|
+
* full session (access_token + refresh_token + user). Throws
|
|
96
|
+
* `RefreshTokenError` with an actionable message on any failure.
|
|
97
|
+
*/
|
|
98
|
+
export async function signInWithPassword(supabaseUrl, anonKey, email, password) {
|
|
99
|
+
if (!email || !password) {
|
|
100
|
+
throw new RefreshTokenError('Headless sign-in needs both an email and a password (HEURESIS_EMAIL / HEURESIS_PASSWORD).');
|
|
101
|
+
}
|
|
102
|
+
const url = `${supabaseUrl.replace(/\/$/, '')}/auth/v1/token?grant_type=password`;
|
|
103
|
+
let res;
|
|
104
|
+
try {
|
|
105
|
+
res = await fetch(url, {
|
|
106
|
+
method: 'POST',
|
|
107
|
+
headers: {
|
|
108
|
+
apikey: anonKey,
|
|
109
|
+
Authorization: `Bearer ${anonKey}`,
|
|
110
|
+
'Content-Type': 'application/json',
|
|
111
|
+
},
|
|
112
|
+
body: JSON.stringify({ email, password }),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
throw new RefreshTokenError(`Could not reach the auth endpoint at ${url}: ${err instanceof Error ? err.message : String(err)}`);
|
|
117
|
+
}
|
|
118
|
+
let payload = null;
|
|
119
|
+
try {
|
|
120
|
+
payload = await res.json();
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
/* leave null — handled below */
|
|
124
|
+
}
|
|
125
|
+
if (!res.ok) {
|
|
126
|
+
const err = payload;
|
|
127
|
+
const detail = err?.error_description ?? err?.msg ?? err?.error ?? err?.message ?? `HTTP ${res.status}`;
|
|
128
|
+
throw new RefreshTokenError(`Email/password sign-in failed (HTTP ${res.status}): ${detail}. ` +
|
|
129
|
+
'Check HEURESIS_EMAIL / HEURESIS_PASSWORD, and that email+password sign-in is ' +
|
|
130
|
+
'enabled for the Supabase project.');
|
|
131
|
+
}
|
|
132
|
+
const session = payload;
|
|
133
|
+
if (!session || !session.access_token || !session.refresh_token) {
|
|
134
|
+
const keys = session && typeof session === 'object'
|
|
135
|
+
? Object.keys(session).join(', ') || '(empty object)'
|
|
136
|
+
: '(no JSON body)';
|
|
137
|
+
throw new RefreshTokenError(`Sign-in succeeded (HTTP ${res.status}) but the response is missing ` +
|
|
138
|
+
`access_token/refresh_token. Response keys: [${keys}].`);
|
|
139
|
+
}
|
|
140
|
+
return session;
|
|
141
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -23,9 +23,9 @@ import { HeuresisStore } from './store.js';
|
|
|
23
23
|
import { getConcept as legacyGetConcept, getConceptInput as legacyGetConceptInput, getProjectGraph as legacyGetProjectGraph, getProjectGraphInput as legacyGetProjectGraphInput, getSubtree as legacyGetSubtree, getSubtreeInput as legacyGetSubtreeInput, getWorkspaceSummary as legacyGetWorkspaceSummary, getWorkspaceSummaryInput as legacyGetWorkspaceSummaryInput, listProjects as legacyListProjects, listProjectsInput as legacyListProjectsInput, listRecentDecisions as legacyListRecentDecisions, listRecentDecisionsInput as legacyListRecentDecisionsInput, searchConcepts as legacySearchConcepts, searchConceptsInput as legacySearchConceptsInput, } from './tools.js';
|
|
24
24
|
import { CLOUD_TOOLS } from './cloudTools.js';
|
|
25
25
|
import { readCredentials } from './credentials.js';
|
|
26
|
-
import { CloudAuthError, getCloudClient } from './cloudClient.js';
|
|
26
|
+
import { CloudAuthError, getCloudClient, getCloudClientFromPassword } from './cloudClient.js';
|
|
27
27
|
import { ensureProxyAgent } from './proxy.js';
|
|
28
|
-
import { helpCommand, loginCommand, logoutCommand, whoamiCommand, } from './cli.js';
|
|
28
|
+
import { DEFAULT_SUPABASE_URL, helpCommand, loginCommand, logoutCommand, whoamiCommand, } from './cli.js';
|
|
29
29
|
import { readRealtimeFlag, resolveSubscriptionWorkspaceId, startRealtimeSubscription, stripRealtimeFlags, } from './realtime.js';
|
|
30
30
|
const VERSION = '0.2.0-alpha';
|
|
31
31
|
const MAX_RESULT_CHARS = 50_000;
|
|
@@ -46,6 +46,21 @@ function makeCloudTools(getClient, operatorTools) {
|
|
|
46
46
|
handler: async (args) => t.handler(await getClient(), args),
|
|
47
47
|
}));
|
|
48
48
|
}
|
|
49
|
+
// Phase 19.5 — try to load LLM-backed Operator tools. The module may be absent
|
|
50
|
+
// or export nothing; in that case we fall back to just the Phase 19.4 parity
|
|
51
|
+
// set. Wrapping the dynamic import in try/catch keeps the server starting
|
|
52
|
+
// cleanly either way.
|
|
53
|
+
async function loadOperatorTools() {
|
|
54
|
+
try {
|
|
55
|
+
const mod = (await import('./cloudOperators.js').catch(() => null));
|
|
56
|
+
if (mod && Array.isArray(mod.OPERATOR_TOOLS))
|
|
57
|
+
return mod.OPERATOR_TOOLS;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
/* fall through to empty */
|
|
61
|
+
}
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
49
64
|
function makeLegacySnapshotTools(store) {
|
|
50
65
|
// LEGACY FALLBACK — removed after 19.7. Read-only, no auth, snapshot file.
|
|
51
66
|
return [
|
|
@@ -99,38 +114,59 @@ async function runServer() {
|
|
|
99
114
|
await ensureProxyAgent(console.error);
|
|
100
115
|
const creds = await readCredentials();
|
|
101
116
|
const snapshotEnv = process.env.HEURESIS_SNAPSHOT;
|
|
117
|
+
// Headless credential (durable across ephemeral/disposable sessions): when
|
|
118
|
+
// HEURESIS_EMAIL + HEURESIS_PASSWORD are set, the server signs in fresh on
|
|
119
|
+
// every boot. Unlike a persisted refresh token — which is single-use under
|
|
120
|
+
// Supabase rotation and dies after one session — a password is not consumed,
|
|
121
|
+
// so this survives container resets with zero re-pairing. It takes
|
|
122
|
+
// precedence over a (possibly stale) credentials.json.
|
|
123
|
+
const headlessEmail = process.env.HEURESIS_EMAIL?.trim();
|
|
124
|
+
const headlessPassword = process.env.HEURESIS_PASSWORD;
|
|
102
125
|
let tools;
|
|
103
126
|
let modeBanner;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
127
|
+
// Single cloud client getter, shared by the tool handlers and the realtime
|
|
128
|
+
// subscription. null in legacy snapshot / unconfigured modes.
|
|
129
|
+
let cloudGetClient = null;
|
|
130
|
+
if (headlessEmail && headlessPassword) {
|
|
131
|
+
// CLOUD mode — headless email/password sign-in (recommended for cloud /
|
|
132
|
+
// disposable containers).
|
|
133
|
+
const supabaseUrl = process.env.HEURESIS_SUPABASE_URL?.trim() || DEFAULT_SUPABASE_URL;
|
|
134
|
+
const anonKey = process.env.HEURESIS_ANON_KEY?.trim();
|
|
135
|
+
if (!anonKey) {
|
|
136
|
+
console.error([
|
|
137
|
+
'[heuresis-mcp] HEURESIS_EMAIL/HEURESIS_PASSWORD are set but HEURESIS_ANON_KEY is missing.',
|
|
138
|
+
'Set HEURESIS_ANON_KEY to your project anon/publishable key (it is public, not a secret).',
|
|
139
|
+
].join('\n'));
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
cloudGetClient = async () => {
|
|
107
143
|
try {
|
|
108
|
-
const { client } = await
|
|
144
|
+
const { client } = await getCloudClientFromPassword(supabaseUrl, anonKey, headlessEmail, headlessPassword);
|
|
109
145
|
return client;
|
|
110
146
|
}
|
|
111
147
|
catch (err) {
|
|
112
|
-
if (err instanceof CloudAuthError)
|
|
148
|
+
if (err instanceof CloudAuthError)
|
|
113
149
|
throw new Error(err.message);
|
|
114
|
-
}
|
|
115
150
|
throw err;
|
|
116
151
|
}
|
|
117
152
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
operatorTools = mod.OPERATOR_TOOLS;
|
|
153
|
+
tools = makeCloudTools(cloudGetClient, await loadOperatorTools());
|
|
154
|
+
modeBanner = `cloud-authenticated (headless ${headlessEmail}; ${tools.length} tools)`;
|
|
155
|
+
}
|
|
156
|
+
else if (creds) {
|
|
157
|
+
// CLOUD mode — persisted device credential (refresh-token bootstrap).
|
|
158
|
+
cloudGetClient = async () => {
|
|
159
|
+
try {
|
|
160
|
+
const { client } = await getCloudClient(creds);
|
|
161
|
+
return client;
|
|
128
162
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
163
|
+
catch (err) {
|
|
164
|
+
if (err instanceof CloudAuthError)
|
|
165
|
+
throw new Error(err.message);
|
|
166
|
+
throw err;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
tools = makeCloudTools(cloudGetClient, await loadOperatorTools());
|
|
134
170
|
modeBanner = `cloud-authenticated (user_id ${creds.user_id}, device ${creds.device_name}; ${tools.length} tools)`;
|
|
135
171
|
}
|
|
136
172
|
else if (snapshotEnv || hasDefaultSnapshot()) {
|
|
@@ -144,9 +180,15 @@ async function runServer() {
|
|
|
144
180
|
console.error([
|
|
145
181
|
'[heuresis-mcp] Not configured.',
|
|
146
182
|
'',
|
|
147
|
-
'To use cloud mode (
|
|
183
|
+
'To use cloud mode on a personal machine (device pairing):',
|
|
148
184
|
' npx -y -p @heuresis/mcp heuresis-mcp login',
|
|
149
185
|
'',
|
|
186
|
+
'To use cloud mode headlessly (CI / cloud agents / disposable containers),',
|
|
187
|
+
'set these env vars so the server signs in fresh on every boot:',
|
|
188
|
+
' HEURESIS_EMAIL your Heuresis account email',
|
|
189
|
+
' HEURESIS_PASSWORD your Heuresis account password',
|
|
190
|
+
' HEURESIS_ANON_KEY your project anon/publishable key (public, not a secret)',
|
|
191
|
+
'',
|
|
150
192
|
'To use legacy snapshot mode (deprecated, removed after 19.7):',
|
|
151
193
|
' HEURESIS_SNAPSHOT=/path/to/export.json npx @heuresis/mcp',
|
|
152
194
|
'',
|
|
@@ -210,7 +252,7 @@ async function runServer() {
|
|
|
210
252
|
console.error(`[heuresis-mcp ${VERSION}] ready - ${modeBanner}`);
|
|
211
253
|
// Phase 19.8 - Supabase Realtime CDC subscription. Cloud mode only; legacy
|
|
212
254
|
// snapshot mode has no live source to subscribe to.
|
|
213
|
-
if (
|
|
255
|
+
if (cloudGetClient) {
|
|
214
256
|
const realtimeOn = await readRealtimeFlag();
|
|
215
257
|
if (!realtimeOn) {
|
|
216
258
|
console.error('[heuresis-mcp] realtime: disabled (--no-realtime or config).');
|
|
@@ -220,7 +262,7 @@ async function runServer() {
|
|
|
220
262
|
// client (Supabase) is not reachable, the error surfaces on stderr.
|
|
221
263
|
void (async () => {
|
|
222
264
|
try {
|
|
223
|
-
const
|
|
265
|
+
const client = await cloudGetClient();
|
|
224
266
|
const wsId = await resolveSubscriptionWorkspaceId(client);
|
|
225
267
|
if (!wsId) {
|
|
226
268
|
console.error('[heuresis-mcp] realtime: no workspace visible; skipping subscription.');
|
|
@@ -69,7 +69,32 @@ function leafSchema(schema) {
|
|
|
69
69
|
return out;
|
|
70
70
|
}
|
|
71
71
|
export function zodToJsonSchema(schema) {
|
|
72
|
-
|
|
72
|
+
// Peel wrappers to reach the underlying object whose `.shape` we can
|
|
73
|
+
// introspect: `.refine()`/`.transform()`/`.superRefine()` produce a
|
|
74
|
+
// ZodEffects (no `.shape`), and optional/default/nullable wrap the root too.
|
|
75
|
+
// Without this, a tool whose inputSchema is a ZodEffects (e.g. expand_concept)
|
|
76
|
+
// makes `Object.entries(undefined)` throw — which previously took down the
|
|
77
|
+
// ENTIRE tools/list response and caused MCP clients to drop the server.
|
|
78
|
+
let root = schema;
|
|
79
|
+
while (root && root._def) {
|
|
80
|
+
if (root instanceof z.ZodEffects) {
|
|
81
|
+
root = root._def.schema;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (root instanceof z.ZodOptional ||
|
|
85
|
+
root instanceof z.ZodDefault ||
|
|
86
|
+
root instanceof z.ZodNullable) {
|
|
87
|
+
root = root._def.innerType;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
const shape = root?.shape;
|
|
93
|
+
if (!shape || typeof shape !== 'object') {
|
|
94
|
+
// Not an object schema we can introspect — expose a permissive object so
|
|
95
|
+
// the tool still lists and still accepts its arguments.
|
|
96
|
+
return { type: 'object', additionalProperties: true };
|
|
97
|
+
}
|
|
73
98
|
const properties = {};
|
|
74
99
|
const required = [];
|
|
75
100
|
for (const [key, value] of Object.entries(shape)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heuresis/mcp",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.13",
|
|
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",
|