@heuresis/mcp 1.0.0-rc.6 → 1.0.0-rc.8
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 +148 -152
- package/dist/cloudOperators.js +9 -1
- package/dist/cloudTools.js +5 -15
- package/dist/llm/operatorFraming.js +53 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,152 +1,148 @@
|
|
|
1
|
-
# @heuresis/mcp
|
|
2
|
-
|
|
3
|
-
A Model Context Protocol (MCP) server that
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
The
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
npx @heuresis/mcp
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
MCP
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
## License
|
|
151
|
-
|
|
152
|
-
AGPL-3.0-or-later.
|
|
1
|
+
# @heuresis/mcp
|
|
2
|
+
|
|
3
|
+
A Model Context Protocol (MCP) server that exposes a Heuresis workspace
|
|
4
|
+
to any MCP-capable client (Claude Desktop, Claude Code, Cursor,
|
|
5
|
+
Windsurf, custom agents). The server logs into the user's Heuresis
|
|
6
|
+
account, talks to the same Supabase project the webapp talks to, and
|
|
7
|
+
respects the same RLS. Webapp and MCP are two front-ends to one cloud
|
|
8
|
+
workspace.
|
|
9
|
+
|
|
10
|
+
Current version: `1.0.0-rc.7`.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g @heuresis/mcp
|
|
16
|
+
# or on demand without installing:
|
|
17
|
+
npx -y @heuresis/mcp
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quickstart
|
|
21
|
+
|
|
22
|
+
### 1. Link this machine to your Heuresis account
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx -y @heuresis/mcp login
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The CLI prints a device code and a one-click URL of the form
|
|
29
|
+
`https://heuresis.app/device?code=XXXX-XXXX`. Open it in your browser,
|
|
30
|
+
sign in if you aren't already, and confirm the device. The CLI polls
|
|
31
|
+
in the background and writes credentials to
|
|
32
|
+
`~/.heuresis/credentials.json` (chmod 600 on POSIX) the moment you
|
|
33
|
+
confirm. Subsequent runs of the MCP are silent.
|
|
34
|
+
|
|
35
|
+
The login flow rides three Supabase Edge Functions:
|
|
36
|
+
`mcp-device-start`, `mcp-device-grant`, and `mcp-device-poll`.
|
|
37
|
+
|
|
38
|
+
To unlink a machine: `npx @heuresis/mcp logout`, or open
|
|
39
|
+
Settings ▸ Connected devices in the webapp to revoke remotely.
|
|
40
|
+
|
|
41
|
+
`npx @heuresis/mcp whoami` confirms which account a machine is
|
|
42
|
+
currently linked to.
|
|
43
|
+
|
|
44
|
+
### 2. Point your MCP client at it
|
|
45
|
+
|
|
46
|
+
**Claude Desktop.** Edit
|
|
47
|
+
`~/Library/Application Support/Claude/claude_desktop_config.json` on
|
|
48
|
+
macOS, or `%APPDATA%/Claude/claude_desktop_config.json` on Windows:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"mcpServers": {
|
|
53
|
+
"heuresis": { "command": "npx", "args": ["-y", "@heuresis/mcp"] }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Claude Code / Cursor / Windsurf.** Drop a `.mcp.json` in the
|
|
59
|
+
workspace root:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"mcpServers": {
|
|
64
|
+
"heuresis": { "command": "npx", "args": ["-y", "@heuresis/mcp"] }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Restart the client. The Heuresis tools appear in the tool menu.
|
|
70
|
+
|
|
71
|
+
### 3. CLI subcommands
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx @heuresis/mcp whoami # show the linked account + device
|
|
75
|
+
npx @heuresis/mcp logout # delete the credentials file
|
|
76
|
+
npx @heuresis/mcp --help # all options
|
|
77
|
+
npx @heuresis/mcp --no-realtime # boot once with live sync turned off (persisted)
|
|
78
|
+
npx @heuresis/mcp --realtime # re-enable live sync
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Live sync
|
|
82
|
+
|
|
83
|
+
When the MCP boots in cloud mode it subscribes to the workspace over
|
|
84
|
+
Supabase Realtime and notifies the client whenever a `nodes`, `edges`,
|
|
85
|
+
`projects`, or `ideas` row changes. Edits made in the webapp show up
|
|
86
|
+
in the agent's view without a manual refresh, and writes from one
|
|
87
|
+
MCP-connected client reach any other connected client the same way.
|
|
88
|
+
Pass `--no-realtime` to disable the subscription (useful if the
|
|
89
|
+
chatter is noisy or the client logs every notification). The
|
|
90
|
+
preference is saved to `~/.heuresis/config.json` so the flag only
|
|
91
|
+
needs to be passed once.
|
|
92
|
+
|
|
93
|
+
## Tools
|
|
94
|
+
|
|
95
|
+
34 tools total: 31 data tools against the cloud workspace, plus 3
|
|
96
|
+
operator tools that drive the same ideation operators the webapp uses.
|
|
97
|
+
|
|
98
|
+
**Reads (10).** `get_workspace_summary`, `list_projects`,
|
|
99
|
+
`get_project_graph`, `list_concepts`, `list_edges`, `get_subtree`,
|
|
100
|
+
`get_concept`, `search_concepts`, `find_concepts`,
|
|
101
|
+
`list_recent_decisions`. Most agent sessions start with
|
|
102
|
+
`get_workspace_summary` or `list_projects`.
|
|
103
|
+
|
|
104
|
+
**Writes (21).** Concepts: `add_concept`, `update_concept`,
|
|
105
|
+
`bulk_add_concepts`, `set_parent`, `validate_concept`, `set_standing`,
|
|
106
|
+
`archive_concept`, `unarchive_concept`, `star_concept`,
|
|
107
|
+
`remove_concept`. Edges: `link_concepts`, `add_kref`. Ideas:
|
|
108
|
+
`create_idea`, `rename_idea`, `recolor_idea`, `set_idea_members`,
|
|
109
|
+
`add_to_idea`, `delete_idea`. Projects: `create_project`,
|
|
110
|
+
`update_project`, `delete_project`. Every write stamps a row in
|
|
111
|
+
`public.provenance` with `origin='mcp'` so the webapp's session log
|
|
112
|
+
shows which surface made the change.
|
|
113
|
+
|
|
114
|
+
**Operator runs (3).** `run_operator` (generate candidates with
|
|
115
|
+
Branch / Matrix / ASIT / TRIZ / Combine / Free / Contradiction),
|
|
116
|
+
`run_operator_and_commit` (same, plus commit the result in one
|
|
117
|
+
round-trip), and `expand_concept` (recursive Branch, capped at depth ×
|
|
118
|
+
breadth ≤ 60).
|
|
119
|
+
|
|
120
|
+
Tool input shapes mirror their counterparts in the webapp's
|
|
121
|
+
`src/agent/tools.ts`, so an agent that uses both surfaces sees a
|
|
122
|
+
uniform contract.
|
|
123
|
+
|
|
124
|
+
Wave-shipping: `find_in_files` (in-browser embedding search) is in the
|
|
125
|
+
webapp but not yet on the MCP.
|
|
126
|
+
|
|
127
|
+
## Legacy snapshot mode (deprecated)
|
|
128
|
+
|
|
129
|
+
The original read-only snapshot reader still works as a fallback while
|
|
130
|
+
users migrate to cloud auth. With no `~/.heuresis/credentials.json`
|
|
131
|
+
and the `HEURESIS_SNAPSHOT` env var set, the server reads a JSON
|
|
132
|
+
export from disk and exposes the original read-only tool set
|
|
133
|
+
(`get_workspace_summary`, `list_projects`, `search_concepts`,
|
|
134
|
+
`get_concept`, `get_subtree`, `get_project_graph`,
|
|
135
|
+
`list_recent_decisions`).
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
export HEURESIS_SNAPSHOT="/absolute/path/to/your-export.json"
|
|
139
|
+
npx @heuresis/mcp
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
This path is deprecated and will be removed in a later release. It is
|
|
143
|
+
here so existing setups keep working through the migration to cloud
|
|
144
|
+
auth.
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
AGPL-3.0-or-later.
|
package/dist/cloudOperators.js
CHANGED
|
@@ -37,6 +37,7 @@ import { COMBINE_OPERATOR } from './operators/combine.js';
|
|
|
37
37
|
import { EXPLORE_OPERATOR } from './operators/explore.js';
|
|
38
38
|
import { TRIZ_PARAMETERS, TRIZ_PRINCIPLES, lookupPrinciples, } from './operators/triz-matrix.js';
|
|
39
39
|
import { composePrompt } from './prompt/compose.js';
|
|
40
|
+
import { composeOperatorSystemPrefix } from './llm/operatorFraming.js';
|
|
40
41
|
import { parseLlmResponse } from './prompt/parse.js';
|
|
41
42
|
import { defaultModelFor, runLlm, } from './llm/client.js';
|
|
42
43
|
import { estimateCost } from './llm/cost.js';
|
|
@@ -293,7 +294,14 @@ export async function runOperator(client, args) {
|
|
|
293
294
|
model: config.model,
|
|
294
295
|
promptChars: prompt.length,
|
|
295
296
|
});
|
|
296
|
-
|
|
297
|
+
// Prompt-caching Step 2 mirror — pass a stable operator-framing system
|
|
298
|
+
// prefix so the Anthropic prompt cache catches every repeat operator
|
|
299
|
+
// call within the 5-minute TTL. The MCP `runLlm` already wraps
|
|
300
|
+
// systemPrefix with `cache_control: ephemeral` for the Anthropic path.
|
|
301
|
+
const llmResult = await runLlm(config, {
|
|
302
|
+
prompt,
|
|
303
|
+
systemPrefix: composeOperatorSystemPrefix(),
|
|
304
|
+
});
|
|
297
305
|
const parsed = parseLlmResponse(llmResult.text);
|
|
298
306
|
if (!parsed.ok) {
|
|
299
307
|
throw new Error(`Operator run produced output the parser rejected: ${parsed.error}`);
|
package/dist/cloudTools.js
CHANGED
|
@@ -853,17 +853,14 @@ export async function listEdges(client, args) {
|
|
|
853
853
|
// ---------------------------------------------------------------------------
|
|
854
854
|
// find_concepts
|
|
855
855
|
// ---------------------------------------------------------------------------
|
|
856
|
-
// Mirrors the webapp `find_concepts` tool
|
|
857
|
-
// by='meaning'
|
|
858
|
-
//
|
|
859
|
-
// back to the same substring search as by='label' and the response carries a
|
|
860
|
-
// `note` explaining the degradation. Phase 19.5 swaps in pgvector when the
|
|
861
|
-
// schema picks it up.
|
|
856
|
+
// Mirrors the webapp `find_concepts` tool, label/substring path only. The
|
|
857
|
+
// webapp's by='meaning' variant relies on in-browser embeddings; that path is
|
|
858
|
+
// not wired on the MCP side, so this tool accepts by='label' only.
|
|
862
859
|
export const findConceptsInput = z
|
|
863
860
|
.object({
|
|
864
861
|
query: z.string().min(1),
|
|
865
862
|
k: z.number().int().positive().max(20).default(10),
|
|
866
|
-
by: z.enum(['
|
|
863
|
+
by: z.enum(['label']).default('label'),
|
|
867
864
|
projectId: z.string().optional(),
|
|
868
865
|
})
|
|
869
866
|
.strict();
|
|
@@ -885,13 +882,6 @@ export async function findConcepts(client, args) {
|
|
|
885
882
|
status: r.status,
|
|
886
883
|
score: 1,
|
|
887
884
|
}));
|
|
888
|
-
if (args.by === 'meaning') {
|
|
889
|
-
return {
|
|
890
|
-
hits,
|
|
891
|
-
mode: 'label',
|
|
892
|
-
note: 'Semantic search not yet wired in MCP (no in-browser embedding model); fell back to label/substring match.',
|
|
893
|
-
};
|
|
894
|
-
}
|
|
895
885
|
return { hits, mode: 'label' };
|
|
896
886
|
}
|
|
897
887
|
// ===========================================================================
|
|
@@ -1591,7 +1581,7 @@ export const CLOUD_TOOLS = [
|
|
|
1591
1581
|
},
|
|
1592
1582
|
{
|
|
1593
1583
|
name: 'find_concepts',
|
|
1594
|
-
description:
|
|
1584
|
+
description: 'Find concepts by label/substring match. Returns up to k hits, each with id, label, status.',
|
|
1595
1585
|
inputSchema: findConceptsInput,
|
|
1596
1586
|
handler: async (client, args) => findConcepts(client, findConceptsInput.parse(args)),
|
|
1597
1587
|
},
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// VENDORED MIRROR of src/llm/operatorFraming.ts — keep in sync with the
|
|
2
|
+
// webapp. The mcp-server is independently buildable (its own tsconfig,
|
|
3
|
+
// its own deps), so we vendor the framing block here rather than reaching
|
|
4
|
+
// across the repo boundary.
|
|
5
|
+
//
|
|
6
|
+
// Heuresis's smaller operator doctrines (ASIT ~500-800 tok, Branch ~600-1200
|
|
7
|
+
// tok) sit right around or below Sonnet's 1,024-token minimum-cacheable-size
|
|
8
|
+
// threshold. Below that floor the Anthropic API silently does NOT cache the
|
|
9
|
+
// prefix — `cache_creation_input_tokens` comes back as 0 and the next call
|
|
10
|
+
// re-tokenizes everything at full price.
|
|
11
|
+
//
|
|
12
|
+
// IMPORTANT: this block is the cache prefix for the ENTIRE MCP operator
|
|
13
|
+
// path. Editing it invalidates every operator's cache. Keep BYTE-IDENTICAL
|
|
14
|
+
// with the webapp copy at src/llm/operatorFraming.ts.
|
|
15
|
+
export const OPERATOR_FRAMING_PREAMBLE = [
|
|
16
|
+
'You are Heuresis\'s operator engine — a stateless transform that takes a parent CONCEPT plus structured context, applies one named OPERATOR (an ASIT tool, a TRIZ inventive principle, a C-K partition rule, a free-form lab prompt, etc.), and emits a JSON object proposing 1–8 child concepts.',
|
|
17
|
+
'',
|
|
18
|
+
'CONTRACT.',
|
|
19
|
+
' • You receive: the project brief, the concept-path from root to target, the target concept, a pool of validated knowledge (K), an operator definition (family / key / name / doctrine / prompt fragment), an optional graph-awareness <context> block (ancestry, sibling axes, existing labels), and optionally COMBINE inputs, an EXPLORE <branch>, or a free-form <angle>.',
|
|
20
|
+
' • You return: ONE JSON object matching the requested schema. NEVER prose before or after, NEVER markdown fences, NEVER trailing commas, NEVER comments inside the JSON. The caller parses with strict-mode zod and rejects anything that does not match.',
|
|
21
|
+
' • If the schema asks for partitions[], emit between 3 and 5 top-level partitions unless the operator explicitly says otherwise (EXPLORE allows 4–8). Each partition is a STANDALONE concept title (2–5 words, ≤60 chars, no parent-prefix, no trailing period), a 1–2 sentence description, a ≤5-word partitionAttribute naming the distinguishing AXIS, a 1–3 sentence rationale citing the operator and any K used, and a kReferences[] of K-ids you actually used.',
|
|
22
|
+
'',
|
|
23
|
+
'DOCTRINE.',
|
|
24
|
+
' • Stay faithful to the operator. ASIT operators MUST stay inside the closed world — never introduce alien components. TRIZ operators MUST honor the named inventive principle. C-K operators MUST treat C-nodes as undecidable noun-phrases (never solutions in disguise — verbs like "build", "add", "use", "implement", "create" at the start of a label belong in the parking lot, not in the C-tree).',
|
|
25
|
+
' • Be additive, not redundant. The <context> block (when present) lists existing canvas labels and sibling axes — do not propose paraphrases of either. Where possible, partition on an axis NOT yet present in <sibling_axes>.',
|
|
26
|
+
' • Be honest. Use the optional selfCritique field to surface the strongest assumption or risk in each partition. Do not flatter.',
|
|
27
|
+
' • Cite K. If a knowledge item informed a partition, list its id in kReferences. If you needed a fact you do not have, propose it via newKnowledgeProposed (1–3 items, framed as questions, never invented numbers).',
|
|
28
|
+
'',
|
|
29
|
+
'VOICE.',
|
|
30
|
+
' • Plain, sharp, conversational. Active voice, short sentences. No sales hype, no poetry, no exclamation points. Never use an em dash ("—"); use a period, comma, colon, or parentheses instead.',
|
|
31
|
+
' • Labels are concept titles, not sentences. Put long-form prose in description / rationale, never in label.',
|
|
32
|
+
'',
|
|
33
|
+
'FAILURE MODES TO AVOID.',
|
|
34
|
+
' • Restating the parent concept as a child.',
|
|
35
|
+
' • Two partitions that decompose the same axis (collapse them or pick the stronger).',
|
|
36
|
+
' • Children whose label contains the immediate parent partition\'s label.',
|
|
37
|
+
' • Nesting children deeper than one level — a child MUST NOT carry its own children[].',
|
|
38
|
+
' • Markdown / code fences around the JSON.',
|
|
39
|
+
].join('\n');
|
|
40
|
+
/**
|
|
41
|
+
* Stable system prefix shared by every operator run on the MCP side.
|
|
42
|
+
* Composed of the framing preamble plus a short prologue paragraph so the
|
|
43
|
+
* cached prefix carries both the framing and the per-call lead-in.
|
|
44
|
+
*/
|
|
45
|
+
export function composeOperatorSystemPrefix() {
|
|
46
|
+
return (OPERATOR_FRAMING_PREAMBLE +
|
|
47
|
+
'\n\n' +
|
|
48
|
+
'You are assisting an inventive design session structured by C-K theory. ' +
|
|
49
|
+
'The user grows a graph of concepts (C) drawing on a pool of validated ' +
|
|
50
|
+
'knowledge (K). When asked to apply an operator from ASIT, TRIZ, or a ' +
|
|
51
|
+
'free-form lab prompt, propose between 3 and 5 partitions of the TARGET ' +
|
|
52
|
+
'concept (3–8 for EXPLORE) unless the operator instructions say otherwise.');
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heuresis/mcp",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.8",
|
|
4
|
+
"mcpName": "io.github.toremlabs/heuresis",
|
|
4
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.",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"bin": {
|