@hyperfixi/mcp-server 2.9.4 → 2.11.0

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/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Changed
11
+
12
+ - **MCP TypeScript SDK v2 / protocol revision 2026-07-28.** Migrated from
13
+ `@modelcontextprotocol/sdk` (v1) to `@modelcontextprotocol/server` `^2.0.0`.
14
+ The server now serves **both protocol eras** per connection via `serveStdio`:
15
+ the stateless `2026-07-28` revision (mandatory `server/discover`, no
16
+ `initialize` handshake, `resultType` stamped on every result) and the legacy
17
+ `initialize` dialect for current clients. Tool definitions remain plain JSON
18
+ Schema; the single `tools/call` dispatch path and the freshness guard are
19
+ unchanged.
20
+ - **Cache hints (protocol 2026-07-28):** `tools/list`, `prompts/list`,
21
+ `resources/list`, and `resources/read` responses now advertise
22
+ `ttlMs: 3600000` / `cacheScope: "public"` — all four surfaces are static per
23
+ process.
24
+
25
+ ### Deprecated
26
+
27
+ - The five sampling tools (`ask_claude`, `summarize_content`, `analyze_content`,
28
+ `translate_content`, `execute_llm`) rely on MCP sampling
29
+ (`sampling/createMessage`), which protocol revision 2026-07-28 deprecates —
30
+ server-initiated requests only exist on legacy-era connections whose client
31
+ advertises the sampling capability. They keep working there through the SDK's
32
+ ≥12-month deprecation window; on modern-era connections they return a clear
33
+ `isError` explanation. Deferred follow-up: convert them to the
34
+ `input_required` (MRTR) pattern before sampling's removal (~2027-07).
35
+ Also deferred, deliberately: per-tool `outputSchema`, tool titles/annotations,
36
+ and the `io.modelcontextprotocol/tasks` extension (no tool is long-running
37
+ enough to warrant task handles).
38
+
10
39
  ### Fixed
11
40
 
12
41
  - **Dispatch:** `execute_lse`, `validate_lse`, and `translate_lse` were advertised
package/README.md CHANGED
@@ -1,6 +1,25 @@
1
1
  # @hyperfixi/mcp-server
2
2
 
3
- MCP (Model Context Protocol) server for hyperscript and multilingual DSL development. Provides **107 tools**, **9 resources**, and **9 prompts** spanning: GRAIL workflow orchestration, validation, compilation, analysis, patterns, LSP bridge, language profiles, code generation, route extraction, 9 domain DSLs, IR conversion, cross-domain dispatch, MCP sampling, AI-assisted debugging, template inventory, and the LSE round-trip pipeline.
3
+ MCP (Model Context Protocol) server for hyperscript and multilingual DSL development. Provides **108 tools**, **9 resources**, and **9 prompts** spanning: GRAIL workflow orchestration, validation, compilation, analysis, patterns, LSP bridge, language profiles, code generation, route extraction, 9 domain DSLs, IR conversion, cross-domain dispatch, MCP sampling (opt-in), AI-assisted debugging, template inventory, and the LSE round-trip pipeline.
4
+
5
+ ## The agent loop
6
+
7
+ The headline use case: an LLM agent emitting hyperscript instead of free-form JavaScript, with every check done by a real parser/compiler — deterministic, instant, no LLM in the checker. The server advertises this loop via MCP `instructions`, so a connected agent gets it without reading docs:
8
+
9
+ 1. **`validate_and_compile`** — parse the candidate into semantic IR with diagnostics; check the returned action/roles/trigger against intent.
10
+ 2. **Repair** — apply the diagnostics and re-validate. `get_code_fixes` maps coded errors to concrete fixes; `get_command_docs` / `search_patterns` show correct usage. Failed results carry a next-step hint block.
11
+ 3. **`compile_hyperscript`** — once valid, emit JavaScript (or stop at valid hyperscript for an `_="..."` attribute).
12
+
13
+ To present code to a human, `translate_code` renders it in any of 24 languages via deterministic grammar transformation, `diff_behaviors` proves two snippets behaviorally equivalent, and `score_fidelity` scores a candidate against a reference — including across languages — naming exactly what is missing or hallucinated. See the repo-root [AGENTS.md](../../AGENTS.md) for a worked end-to-end example.
14
+
15
+ ## Protocol Support
16
+
17
+ Built on the MCP TypeScript SDK v2 (`@modelcontextprotocol/server`) and serves **both protocol eras** on every stdio connection:
18
+
19
+ - **`2026-07-28` (stateless):** `server/discover` answered cold, `resultType` on every result, and cache hints (`ttlMs: 3600000`, `cacheScope: "public"`) on `tools/list`, `prompts/list`, `resources/list`, and `resources/read`.
20
+ - **Legacy (`initialize` handshake):** current clients (Claude Code, Claude Desktop) connect this way; nothing changes for them.
21
+
22
+ The five sampling tools (`ask_claude`, `summarize_content`, `analyze_content`, `translate_content`, `execute_llm`) depend on MCP sampling, which revision `2026-07-28` deprecates — they work on legacy-era connections whose client advertises the sampling capability and return a clear error elsewhere. **They are also opt-in:** they invoke a generic LLM, which a connected agent can do itself, so they are hidden from `tools/list` and refuse calls unless the server is started with `LOKASCRIPT_MCP_LLM_TOOLS=1`.
4
23
 
5
24
  ## Installation
6
25
 
@@ -61,7 +80,7 @@ See **[GRAIL.md](GRAIL.md)** for full documentation, schema reference, and examp
61
80
 
62
81
  ## Available Tools
63
82
 
64
- The **102** tools below, plus the **5** GRAIL tools above, total **107**.
83
+ The **103** tools below, plus the **5** GRAIL tools above, total **108**.
65
84
 
66
85
  ### Validation & Semantic Tools (8)
67
86
 
@@ -76,7 +95,7 @@ The **102** tools below, plus the **5** GRAIL tools above, total **107**.
76
95
  | `explain_in_language` | Explain code with grammar rules, roles, and translations |
77
96
  | `get_code_fixes` | Get auto-fixes for specific error codes |
78
97
 
79
- ### Compilation & Code Generation (6)
98
+ ### Compilation & Code Generation (7)
80
99
 
81
100
  | Tool | Description |
82
101
  | ---------------------- | --------------------------------------------------------------------------- |
@@ -85,6 +104,7 @@ The **102** tools below, plus the **5** GRAIL tools above, total **107**.
85
104
  | `translate_code` | High-fidelity translation with SVO/SOV/VSO grammar transformation |
86
105
  | `generate_tests` | Generate Playwright behavior tests from hyperscript |
87
106
  | `generate_component` | Generate React, Vue, or Svelte component from hyperscript |
107
+ | `score_fidelity` | Score a candidate against a reference: recall/precision/role/value signals |
88
108
  | `diff_behaviors` | Compare two inputs for semantic equivalence |
89
109
 
90
110
  ### Analysis (4)
@@ -159,7 +179,7 @@ The **102** tools below, plus the **5** GRAIL tools above, total **107**.
159
179
  | `parse_composite` | Parse multi-line input across domains |
160
180
  | `compile_composite` | Compile multi-line input across domains |
161
181
 
162
- ### MCP Sampling (5)
182
+ ### MCP Sampling (5) — opt-in via `LOKASCRIPT_MCP_LLM_TOOLS=1`
163
183
 
164
184
  | Tool | Description |
165
185
  | ------------------- | ------------------------------------------------------ |
@@ -206,21 +206,21 @@ async function loadDomainSchemas(domain) {
206
206
  try {
207
207
  switch (domain) {
208
208
  case "flow":
209
- return (await import("@lokascript/domain-flow")).allSchemas;
209
+ return (await import("@lokascript/domains/flow")).allSchemas;
210
210
  case "sql":
211
- return (await import("@lokascript/domain-sql")).allSchemas;
211
+ return (await import("@lokascript/domains/sql")).allSchemas;
212
212
  case "bdd":
213
- return (await import("@lokascript/domain-bdd")).allSchemas;
213
+ return (await import("@lokascript/domains/bdd")).allSchemas;
214
214
  case "llm":
215
- return (await import("@lokascript/domain-llm")).allSchemas;
215
+ return (await import("@lokascript/domains/llm")).allSchemas;
216
216
  case "jsx":
217
- return (await import("@lokascript/domain-jsx")).allSchemas;
217
+ return (await import("@lokascript/domains/jsx")).allSchemas;
218
218
  case "todo":
219
- return (await import("@lokascript/domain-todo")).allSchemas;
219
+ return (await import("@lokascript/domains/todo")).allSchemas;
220
220
  case "behaviorspec":
221
- return (await import("@lokascript/domain-behaviorspec")).allSchemas;
221
+ return (await import("@lokascript/domains/behaviorspec")).allSchemas;
222
222
  case "voice":
223
- return (await import("@lokascript/domain-voice")).allSchemas;
223
+ return (await import("@lokascript/domains/voice")).allSchemas;
224
224
  default:
225
225
  return null;
226
226
  }
@@ -139,7 +139,7 @@ function combine(acc, pre, values, max, maxLength, dropEmpties) {
139
139
  }
140
140
  return out;
141
141
  }
142
- function expandSequence(body, isAlphaSequence, max) {
142
+ function expandSequence(body, isAlphaSequence, max, maxLength) {
143
143
  const n = body.split(/\.\./);
144
144
  const N = [];
145
145
  if (n[0] === void 0 || n[1] === void 0) {
@@ -156,6 +156,7 @@ function expandSequence(body, isAlphaSequence, max) {
156
156
  test = gte;
157
157
  }
158
158
  const pad = n.some(isPadded);
159
+ let length = 0;
159
160
  for (let i = x2; test(i, y) && N.length < max; i += incr) {
160
161
  let c;
161
162
  if (isAlphaSequence) {
@@ -177,7 +178,10 @@ function expandSequence(body, isAlphaSequence, max) {
177
178
  }
178
179
  }
179
180
  }
181
+ if (length + c.length > maxLength)
182
+ break;
180
183
  N.push(c);
184
+ length += c.length;
181
185
  }
182
186
  return N;
183
187
  }
@@ -217,7 +221,7 @@ function expand_(str, max, maxLength, isTop) {
217
221
  }
218
222
  let values;
219
223
  if (isSequence) {
220
- values = expandSequence(m.body, isAlphaSequence, max);
224
+ values = expandSequence(m.body, isAlphaSequence, max, maxLength);
221
225
  } else {
222
226
  let n = parseCommaParts(m.body);
223
227
  if (n.length === 1 && n[0] !== void 0) {
@@ -230,9 +234,26 @@ function expand_(str, max, maxLength, isTop) {
230
234
  continue;
231
235
  }
232
236
  }
237
+ let dropsEmpties = dropEmpties && !m.post.length && !pre;
238
+ for (let d3 = 0; dropsEmpties && d3 < acc.length; d3++) {
239
+ if (acc[d3]) {
240
+ dropsEmpties = false;
241
+ }
242
+ }
233
243
  values = [];
234
- for (let j2 = 0; j2 < n.length; j2++) {
235
- values.push.apply(values, expand_(n[j2], max, maxLength, false));
244
+ let valuesLength = 0;
245
+ outer: for (let j2 = 0; j2 < n.length; j2++) {
246
+ const expanded = expand_(n[j2], max, maxLength, false);
247
+ for (let k2 = 0; k2 < expanded.length; k2++) {
248
+ const v = expanded[k2];
249
+ if (dropsEmpties && !v)
250
+ continue;
251
+ if (values.length >= max || valuesLength + v.length > maxLength) {
252
+ break outer;
253
+ }
254
+ values.push(v);
255
+ valuesLength += v.length;
256
+ }
236
257
  }
237
258
  }
238
259
  acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
@@ -2,7 +2,7 @@ import {
2
2
  feedbackTools,
3
3
  getSharedTracker,
4
4
  handleFeedbackTool
5
- } from "./chunk-P76KH42G.js";
5
+ } from "./chunk-E2TYUII7.js";
6
6
  export {
7
7
  feedbackTools,
8
8
  getSharedTracker,
package/dist/index.js CHANGED
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  feedbackTools,
4
4
  handleFeedbackTool
5
- } from "./chunk-P76KH42G.js";
5
+ } from "./chunk-E2TYUII7.js";
6
6
 
7
7
  // src/index.ts
8
8
  import { createRequire as createRequire2 } from "module";
9
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
10
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9
+ import { Server } from "@modelcontextprotocol/server";
10
+ import { serveStdio } from "@modelcontextprotocol/server/stdio";
11
11
 
12
12
  // src/freshness.ts
13
13
  import { createRequire } from "module";
@@ -107,16 +107,6 @@ function freshnessSummary() {
107
107
  return `watching ${watched.length} workspace dist entries`;
108
108
  }
109
109
 
110
- // src/index.ts
111
- import {
112
- CallToolRequestSchema,
113
- GetPromptRequestSchema,
114
- ListPromptsRequestSchema,
115
- ListResourcesRequestSchema,
116
- ListToolsRequestSchema,
117
- ReadResourceRequestSchema
118
- } from "@modelcontextprotocol/sdk/types.js";
119
-
120
110
  // src/tools/analysis.ts
121
111
  var analysisTools = [
122
112
  {
@@ -1464,7 +1454,7 @@ var validationTools = [
1464
1454
  },
1465
1455
  {
1466
1456
  name: "get_code_fixes",
1467
- description: "Get available auto-fixes for a specific error code or diagnostic. Returns LSP-compatible CodeFix suggestions that can be applied to fix common errors. Useful for LLMs to suggest corrections without running full diagnostics.",
1457
+ description: "Get available auto-fixes for a specific error code or diagnostic \u2014 the repair half of the agent loop. When validate_and_compile or validate_hyperscript reports a coded error, this returns LSP-compatible CodeFix suggestions to apply before re-validating.",
1468
1458
  inputSchema: {
1469
1459
  type: "object",
1470
1460
  properties: {
@@ -4391,6 +4381,14 @@ var ROLE_CATALOG = {
4391
4381
  commands: ["remove", "on", "get", "take", "pick", "repeat", "for", "measure", "fetch"],
4392
4382
  explicitExample: "[fetch source:/api/data responseType:json]"
4393
4383
  },
4384
+ recipient: {
4385
+ name: "recipient",
4386
+ description: "Who receives what the action transfers \u2014 the far end of a transfer.",
4387
+ origin: "Linguistic thematic role: the beneficiary/goal of a transfer.",
4388
+ usage: "The element a class moves ONTO in `take` (its patient moves OFF the source), so both ends are named. Marked with `for` in English; most languages render it as a bare trailing pronoun.",
4389
+ commands: ["take"],
4390
+ explicitExample: "[take patient:.active source:.tab-button recipient:me]"
4391
+ },
4394
4392
  event: {
4395
4393
  name: "event",
4396
4394
  description: "The trigger event for an event handler.",
@@ -4419,8 +4417,8 @@ var ROLE_CATALOG = {
4419
4417
  name: "duration",
4420
4418
  description: "A time span for the action.",
4421
4419
  origin: "Temporal adverbial role.",
4422
- usage: "How long a transition takes.",
4423
- commands: ["transition"],
4420
+ usage: "How long a transition takes, or how long a toggled class stays on before reverting.",
4421
+ commands: ["transition", "toggle"],
4424
4422
  explicitExample: "[transition patient:opacity duration:500ms]"
4425
4423
  },
4426
4424
  goal: {
@@ -5455,7 +5453,7 @@ async function getService() {
5455
5453
  var compilationTools = [
5456
5454
  {
5457
5455
  name: "compile_hyperscript",
5458
- description: 'Compile hyperscript to optimized JavaScript. Accepts natural language (code + language), explicit syntax (explicit), or LLM JSON (semantic). Common roles: patient (what to act on), destination (where to), source (where from). Use get_command_docs for per-command roles. Examples: explicit="[toggle patient:.active destination:#btn]", semantic={ action: "toggle", roles: { patient: { type: "selector", value: ".active" } } }',
5456
+ description: 'Compile hyperscript to optimized JavaScript \u2014 the FINAL step of the agent loop (generate \u2192 validate_and_compile \u2192 repair \u2192 compile_hyperscript). Validate first: this tool reports the same failures but returns JavaScript only on success. Accepts natural language (code + language), explicit syntax (explicit), or LLM JSON (semantic). Common roles: patient (what to act on), destination (where to), source (where from). Use get_command_docs for per-command roles. Examples: explicit="[toggle patient:.active destination:#btn]", semantic={ action: "toggle", roles: { patient: { type: "selector", value: ".active" } } }',
5459
5457
  inputSchema: {
5460
5458
  type: "object",
5461
5459
  properties: {
@@ -5489,7 +5487,7 @@ var compilationTools = [
5489
5487
  },
5490
5488
  {
5491
5489
  name: "validate_and_compile",
5492
- description: "Parse hyperscript into semantic IR with diagnostics, without generating JavaScript. Returns action, roles, and trigger structure. Accepts natural language, explicit bracket syntax, or LLM JSON \u2014 same input formats as compile_hyperscript.",
5490
+ description: "START HERE when generating hyperscript: parse into semantic IR with diagnostics, without generating JavaScript. Returns action, roles, and trigger structure so you can check the parse matches your intent. Accepts natural language, explicit bracket syntax, or LLM JSON \u2014 same input formats as compile_hyperscript. On failure, apply the diagnostics and re-validate (get_code_fixes maps error codes to concrete fixes; get_command_docs lists per-command roles); once valid, call compile_hyperscript for JavaScript. This validate \u2192 repair \u2192 compile loop is deterministic \u2014 no LLM in the checker.",
5493
5491
  inputSchema: {
5494
5492
  type: "object",
5495
5493
  properties: {
@@ -5503,7 +5501,7 @@ var compilationTools = [
5503
5501
  },
5504
5502
  {
5505
5503
  name: "translate_code",
5506
- description: "Translate hyperscript between any of 24 languages via full semantic parsing. Higher fidelity than translate_hyperscript \u2014 handles SVO/SOV/VSO grammar transformation. Preferred for production translations.",
5504
+ description: 'Translate hyperscript between any of 24 languages via full semantic parsing \u2014 deterministic grammar transformation (SVO/SOV/VSO word order), not LLM translation. Every result carries a `verification` report (the output scored against the source via score_fidelity): verification.faithful === true is the claim "this rendering is structurally exact", so present it alongside the translation when showing code to a user for review. Higher fidelity than translate_hyperscript; preferred for production translations.',
5507
5505
  inputSchema: {
5508
5506
  type: "object",
5509
5507
  properties: {
@@ -5559,6 +5557,37 @@ var compilationTools = [
5559
5557
  }
5560
5558
  }
5561
5559
  },
5560
+ {
5561
+ name: "score_fidelity",
5562
+ description: "Score a candidate hyperscript snippet against a reference for structural fidelity \u2014 the multilingual CI ratchet's deterministic scorers applied to one pair. Returns actionRecall/multisetRecall/precision/roleFidelity/valueRecall (each 0\u20131), plus the exact missing/spurious actions and lost invariant values (e.g. a silently rewritten target: toggle.destination=#panel). Sides accept any input format and may be in DIFFERENT languages, so it also verifies a translation preserved meaning. Use after editing or translating code to prove the result faithful; diff_behaviors answers identical-or-not, this answers how-faithful-and-what-drifted.",
5563
+ inputSchema: {
5564
+ type: "object",
5565
+ properties: {
5566
+ reference: {
5567
+ type: "object",
5568
+ description: "The trusted side (code/explicit/semantic + language)",
5569
+ properties: {
5570
+ code: { type: "string" },
5571
+ explicit: { type: "string" },
5572
+ semantic: { type: "object" },
5573
+ language: { type: "string" }
5574
+ }
5575
+ },
5576
+ candidate: {
5577
+ type: "object",
5578
+ description: "The side being checked (same shape as reference)",
5579
+ properties: {
5580
+ code: { type: "string" },
5581
+ explicit: { type: "string" },
5582
+ semantic: { type: "object" },
5583
+ language: { type: "string" }
5584
+ }
5585
+ },
5586
+ confidence: { type: "number", description: "Minimum confidence threshold" }
5587
+ },
5588
+ required: ["reference", "candidate"]
5589
+ }
5590
+ },
5562
5591
  {
5563
5592
  name: "diff_behaviors",
5564
5593
  description: "Compare two hyperscript inputs at the behavior level. Returns whether they are semantically identical, trigger diffs, and per-operation diffs. Works across languages and input formats.",
@@ -5591,6 +5620,16 @@ var compilationTools = [
5591
5620
  }
5592
5621
  }
5593
5622
  ];
5623
+ var REPAIR_HINT = "Next step: apply the diagnostics above and re-run validate_and_compile. If an error names a code (e.g. MISSING.ARGUMENT), get_code_fixes returns concrete fixes for it; get_command_docs lists the roles each command accepts.";
5624
+ function compileResult(result) {
5625
+ const content = [
5626
+ { type: "text", text: JSON.stringify(result, null, 2) }
5627
+ ];
5628
+ if (!result.ok) {
5629
+ content.push({ type: "text", text: REPAIR_HINT });
5630
+ }
5631
+ return { content, isError: !result.ok };
5632
+ }
5594
5633
  async function handleCompilationTool(name, args) {
5595
5634
  try {
5596
5635
  const service = await getService();
@@ -5603,10 +5642,7 @@ async function handleCompilationTool(name, args) {
5603
5642
  language: args.language,
5604
5643
  confidence: args.confidence
5605
5644
  });
5606
- return {
5607
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
5608
- isError: !result.ok
5609
- };
5645
+ return compileResult(result);
5610
5646
  }
5611
5647
  case "validate_and_compile": {
5612
5648
  const result = service.validate({
@@ -5616,10 +5652,7 @@ async function handleCompilationTool(name, args) {
5616
5652
  language: args.language,
5617
5653
  confidence: args.confidence
5618
5654
  });
5619
- return {
5620
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
5621
- isError: !result.ok
5622
- };
5655
+ return compileResult(result);
5623
5656
  }
5624
5657
  case "translate_code": {
5625
5658
  const result = service.translate({
@@ -5662,6 +5695,17 @@ async function handleCompilationTool(name, args) {
5662
5695
  isError: !result.ok
5663
5696
  };
5664
5697
  }
5698
+ case "score_fidelity": {
5699
+ const result = service.scoreFidelity({
5700
+ reference: args.reference,
5701
+ candidate: args.candidate,
5702
+ confidence: args.confidence
5703
+ });
5704
+ return {
5705
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
5706
+ isError: !result.ok
5707
+ };
5708
+ }
5665
5709
  case "diff_behaviors": {
5666
5710
  const result = service.diff({
5667
5711
  a: args.a,
@@ -5896,7 +5940,7 @@ async function generateServerRoutes(args) {
5896
5940
  }
5897
5941
 
5898
5942
  // src/tools/domain-registry-setup.ts
5899
- import { createDomainRegistry } from "@lokascript/domain-config";
5943
+ import { createDomainRegistry } from "@lokascript/domains";
5900
5944
 
5901
5945
  // src/tools/bdd-extras.ts
5902
5946
  var bddScenarioParser = null;
@@ -5906,13 +5950,13 @@ async function getBDDExtras() {
5906
5950
  if (bddScenarioParser)
5907
5951
  return { parseScenario: bddScenarioParser, generator: bddGenerator, renderer: bddRenderer };
5908
5952
  try {
5909
- const mod = await import("@lokascript/domain-bdd");
5953
+ const mod = await import("@lokascript/domains/bdd");
5910
5954
  bddScenarioParser = mod.parseBDDScenario;
5911
5955
  bddGenerator = mod.bddCodeGenerator;
5912
5956
  bddRenderer = mod.renderBDD ?? null;
5913
5957
  return { parseScenario: bddScenarioParser, generator: bddGenerator, renderer: bddRenderer };
5914
5958
  } catch {
5915
- throw new Error("@lokascript/domain-bdd not available for multi-step parsing.");
5959
+ throw new Error("@lokascript/domains/bdd not available for multi-step parsing.");
5916
5960
  }
5917
5961
  }
5918
5962
  function serializeRoles(roles) {
@@ -6006,13 +6050,13 @@ async function getBehaviorSpecExtras() {
6006
6050
  if (behaviorSpecParser)
6007
6051
  return { parseSpec: behaviorSpecParser, compile: behaviorCompiler, render: behaviorRenderer };
6008
6052
  try {
6009
- const mod = await import("@lokascript/domain-behaviorspec");
6053
+ const mod = await import("@lokascript/domains/behaviorspec");
6010
6054
  behaviorSpecParser = mod.parseBehaviorSpec;
6011
6055
  behaviorCompiler = mod.compileBehaviorSpec;
6012
6056
  behaviorRenderer = mod.renderBehaviorSpec;
6013
6057
  return { parseSpec: behaviorSpecParser, compile: behaviorCompiler, render: behaviorRenderer };
6014
6058
  } catch {
6015
- throw new Error("@lokascript/domain-behaviorspec not available for multi-line parsing.");
6059
+ throw new Error("@lokascript/domains/behaviorspec not available for multi-line parsing.");
6016
6060
  }
6017
6061
  }
6018
6062
  function serializeRoles2(roles) {
@@ -6596,7 +6640,7 @@ Every value must have a role name. Do not invent commands or roles not in the sc
6596
6640
  var samplingTools = [
6597
6641
  {
6598
6642
  name: "ask_claude",
6599
- description: "Ask Claude a question with optional context. Uses MCP sampling \u2014 the client handles model selection and user approval.",
6643
+ description: "Ask Claude a question with optional context. Uses MCP sampling \u2014 the client handles model selection and user approval. DEPRECATED: MCP sampling is deprecated as of protocol revision 2026-07-28 and works only on legacy-era connections whose client advertises the sampling capability; planned replacement is the input_required (MRTR) pattern.",
6600
6644
  inputSchema: {
6601
6645
  type: "object",
6602
6646
  properties: {
@@ -6623,7 +6667,7 @@ var samplingTools = [
6623
6667
  },
6624
6668
  {
6625
6669
  name: "summarize_content",
6626
- description: "Summarize text content using Claude. Uses MCP sampling \u2014 the client handles model selection and user approval.",
6670
+ description: "Summarize text content using Claude. Uses MCP sampling \u2014 the client handles model selection and user approval. DEPRECATED: MCP sampling is deprecated as of protocol revision 2026-07-28 and works only on legacy-era connections whose client advertises the sampling capability; planned replacement is the input_required (MRTR) pattern.",
6627
6671
  inputSchema: {
6628
6672
  type: "object",
6629
6673
  properties: {
@@ -6650,7 +6694,7 @@ var samplingTools = [
6650
6694
  },
6651
6695
  {
6652
6696
  name: "analyze_content",
6653
- description: "Analyze text content for sentiment, entities, themes, or other qualities using Claude. Uses MCP sampling.",
6697
+ description: "Analyze text content for sentiment, entities, themes, or other qualities using Claude. Uses MCP sampling. DEPRECATED: MCP sampling is deprecated as of protocol revision 2026-07-28 and works only on legacy-era connections whose client advertises the sampling capability; planned replacement is the input_required (MRTR) pattern.",
6654
6698
  inputSchema: {
6655
6699
  type: "object",
6656
6700
  properties: {
@@ -6673,7 +6717,7 @@ var samplingTools = [
6673
6717
  },
6674
6718
  {
6675
6719
  name: "translate_content",
6676
- description: "Translate text between natural languages using Claude. Uses MCP sampling \u2014 the client handles model selection and user approval.",
6720
+ description: "Translate text between natural languages using Claude. Uses MCP sampling \u2014 the client handles model selection and user approval. DEPRECATED: MCP sampling is deprecated as of protocol revision 2026-07-28 and works only on legacy-era connections whose client advertises the sampling capability; planned replacement is the input_required (MRTR) pattern.",
6677
6721
  inputSchema: {
6678
6722
  type: "object",
6679
6723
  properties: {
@@ -6699,7 +6743,7 @@ var samplingTools = [
6699
6743
  },
6700
6744
  {
6701
6745
  name: "execute_llm",
6702
- description: 'Execute an LLM command written in natural language (8 languages supported). Compiles via domain-llm then invokes Claude via MCP sampling. Examples: "ask what is 2+2", "summarize #article as bullets", "\uC694\uC57D \uC774 \uBB38\uC11C\uB97C \uAE00\uBA38\uB9AC\uB85C" (Korean).',
6746
+ description: 'Execute an LLM command written in natural language (8 languages supported). Compiles via domain-llm then invokes Claude via MCP sampling. Examples: "ask what is 2+2", "summarize #article as bullets", "\uC694\uC57D \uC774 \uBB38\uC11C\uB97C \uAE00\uBA38\uB9AC\uB85C" (Korean). DEPRECATED: MCP sampling is deprecated as of protocol revision 2026-07-28 and works only on legacy-era connections whose client advertises the sampling capability; planned replacement is the input_required (MRTR) pattern.',
6703
6747
  inputSchema: {
6704
6748
  type: "object",
6705
6749
  properties: {
@@ -6838,13 +6882,13 @@ ${content}`
6838
6882
  }
6839
6883
  };
6840
6884
  }
6841
- async function handleSamplingTool(name, args, server2, registry2) {
6885
+ async function handleSamplingTool(name, args, server, registry2) {
6842
6886
  try {
6843
6887
  if (name === "execute_llm") {
6844
- return await handleExecuteLLM(args, server2, registry2);
6888
+ return await handleExecuteLLM(args, server, registry2);
6845
6889
  }
6846
6890
  const spec = argsToSpec(name, args);
6847
- return await executeSpec(spec, server2);
6891
+ return await executeSpec(spec, server);
6848
6892
  } catch (error) {
6849
6893
  const message = error instanceof Error ? error.message : String(error);
6850
6894
  return {
@@ -6853,13 +6897,28 @@ async function handleSamplingTool(name, args, server2, registry2) {
6853
6897
  };
6854
6898
  }
6855
6899
  }
6856
- async function executeSpec(spec, server2) {
6900
+ async function executeSpec(spec, server) {
6857
6901
  const params = specToSamplingParams(spec);
6858
- const response = await server2.createMessage(params);
6859
- const text = response.content.type === "text" ? response.content.text : `Received non-text response of type: ${response.content.type}`;
6902
+ let response;
6903
+ try {
6904
+ response = await server.createMessage(params);
6905
+ } catch (error) {
6906
+ const message = error instanceof Error ? error.message : String(error);
6907
+ return {
6908
+ content: [
6909
+ {
6910
+ type: "text",
6911
+ text: `Sampling unavailable: ${message}. This tool relies on MCP sampling (deprecated in protocol revision 2026-07-28), which requires a legacy-era connection and a client that advertises the sampling capability.`
6912
+ }
6913
+ ],
6914
+ isError: true
6915
+ };
6916
+ }
6917
+ const block = Array.isArray(response.content) ? response.content[0] : response.content;
6918
+ const text = block?.type === "text" ? block.text : `Received non-text response of type: ${block?.type ?? "empty"}`;
6860
6919
  return { content: [{ type: "text", text }] };
6861
6920
  }
6862
- async function handleExecuteLLM(args, server2, registry2) {
6921
+ async function handleExecuteLLM(args, server, registry2) {
6863
6922
  if (!registry2) {
6864
6923
  return {
6865
6924
  content: [{ type: "text", text: "execute_llm requires domain registry (internal error)" }],
@@ -6898,12 +6957,12 @@ async function handleExecuteLLM(args, server2, registry2) {
6898
6957
  isError: true
6899
6958
  };
6900
6959
  }
6901
- return await executeSpec(spec, server2);
6960
+ return await executeSpec(spec, server);
6902
6961
  }
6903
6962
 
6904
6963
  // src/tools/dispatcher.ts
6905
6964
  import { CrossDomainDispatcher } from "@lokascript/framework";
6906
- import { DOMAIN_PRIORITY } from "@lokascript/domain-config";
6965
+ import { DOMAIN_PRIORITY } from "@lokascript/domains";
6907
6966
  var dispatcher = null;
6908
6967
  function getDispatcher(registry2) {
6909
6968
  if (!dispatcher) {
@@ -8087,7 +8146,7 @@ function createInlineExtractor() {
8087
8146
  const fs = await import("fs");
8088
8147
  const path = await import("path");
8089
8148
  const crypto = await import("crypto");
8090
- const { glob } = await import("./esm-WMQN6QOB.js");
8149
+ const { glob } = await import("./esm-JVAYDN24.js");
8091
8150
  const globs = [
8092
8151
  "**/*.html",
8093
8152
  "**/*.htm",
@@ -8285,21 +8344,21 @@ async function loadDomainSchemas(domain) {
8285
8344
  try {
8286
8345
  switch (domain) {
8287
8346
  case "flow":
8288
- return (await import("@lokascript/domain-flow")).allSchemas;
8347
+ return (await import("@lokascript/domains/flow")).allSchemas;
8289
8348
  case "sql":
8290
- return (await import("@lokascript/domain-sql")).allSchemas;
8349
+ return (await import("@lokascript/domains/sql")).allSchemas;
8291
8350
  case "bdd":
8292
- return (await import("@lokascript/domain-bdd")).allSchemas;
8351
+ return (await import("@lokascript/domains/bdd")).allSchemas;
8293
8352
  case "llm":
8294
- return (await import("@lokascript/domain-llm")).allSchemas;
8353
+ return (await import("@lokascript/domains/llm")).allSchemas;
8295
8354
  case "jsx":
8296
- return (await import("@lokascript/domain-jsx")).allSchemas;
8355
+ return (await import("@lokascript/domains/jsx")).allSchemas;
8297
8356
  case "todo":
8298
- return (await import("@lokascript/domain-todo")).allSchemas;
8357
+ return (await import("@lokascript/domains/todo")).allSchemas;
8299
8358
  case "behaviorspec":
8300
- return (await import("@lokascript/domain-behaviorspec")).allSchemas;
8359
+ return (await import("@lokascript/domains/behaviorspec")).allSchemas;
8301
8360
  case "voice":
8302
- return (await import("@lokascript/domain-voice")).allSchemas;
8361
+ return (await import("@lokascript/domains/voice")).allSchemas;
8303
8362
  default:
8304
8363
  return null;
8305
8364
  }
@@ -8544,10 +8603,10 @@ async function handleToHyperscript(args) {
8544
8603
  try {
8545
8604
  const { CompilationService } = await import("@lokascript/compilation-service");
8546
8605
  const service = await CompilationService.create();
8547
- const compileResult = service.compile({ explicit: normalizedLse });
8548
- result.js = compileResult.ok ? compileResult.js : void 0;
8549
- if (!compileResult.ok && compileResult.diagnostics) {
8550
- for (const d of compileResult.diagnostics) {
8606
+ const compileResult2 = service.compile({ explicit: normalizedLse });
8607
+ result.js = compileResult2.ok ? compileResult2.js : void 0;
8608
+ if (!compileResult2.ok && compileResult2.diagnostics) {
8609
+ for (const d of compileResult2.diagnostics) {
8551
8610
  if (d.severity === "error") {
8552
8611
  diagnostics.push({
8553
8612
  severity: "error",
@@ -8582,8 +8641,8 @@ async function handleExecuteLse(args) {
8582
8641
  try {
8583
8642
  const { CompilationService } = await import("@lokascript/compilation-service");
8584
8643
  const service = await CompilationService.create();
8585
- const compileResult = service.compile({ explicit: normalizedLse });
8586
- js = compileResult.ok ? compileResult.js : void 0;
8644
+ const compileResult2 = service.compile({ explicit: normalizedLse });
8645
+ js = compileResult2.ok ? compileResult2.js : void 0;
8587
8646
  } catch {
8588
8647
  }
8589
8648
  return jsonResponse({
@@ -9490,7 +9549,7 @@ function buildCorrectedExample(attempt, diagnostics) {
9490
9549
  async function buildSchemaContext(domain) {
9491
9550
  if (!domain) return null;
9492
9551
  try {
9493
- const { loadDomainSchemas: loadDomainSchemas2 } = await import("./feedback-tools-S6VDG6F5.js");
9552
+ const { loadDomainSchemas: loadDomainSchemas2 } = await import("./feedback-tools-6I5OQYZS.js");
9494
9553
  if (typeof loadDomainSchemas2 !== "function") return null;
9495
9554
  const schemas = await loadDomainSchemas2(domain);
9496
9555
  if (!schemas || schemas.length === 0) return null;
@@ -10507,150 +10566,186 @@ function readResource(uri) {
10507
10566
  // src/index.ts
10508
10567
  var registry = createDomainRegistry();
10509
10568
  var { version: pkgVersion } = createRequire2(import.meta.url)("../package.json");
10510
- var server = new Server(
10511
- {
10512
- name: "@hyperfixi/mcp-server",
10513
- version: pkgVersion
10514
- },
10515
- {
10516
- capabilities: {
10517
- tools: {},
10518
- resources: {},
10519
- prompts: {}
10569
+ var LLM_SAMPLING_ENABLED = process.env.LOKASCRIPT_MCP_LLM_TOOLS === "1";
10570
+ var SERVER_INSTRUCTIONS = `Deterministic tooling for hyperscript (a compact DOM-behavior DSL) in 24 human languages. No tool here calls an LLM \u2014 every check is a real parser/compiler you can trust.
10571
+
10572
+ The core loop for GENERATING hyperscript:
10573
+ 1. validate_and_compile \u2014 parse your candidate into semantic IR with diagnostics; check the returned action/roles/trigger against your intent.
10574
+ 2. On failure: apply the diagnostics and re-validate. get_code_fixes maps error codes to concrete fixes; get_command_docs and search_patterns show correct usage.
10575
+ 3. compile_hyperscript \u2014 once valid, emit JavaScript. Or stop at valid hyperscript for an _="..." attribute.
10576
+
10577
+ To PRESENT code to a user, translate_code renders it in any of 24 languages via deterministic grammar transformation (word-order faithful, not LLM translation); translate_to_english normalizes foreign input. diff_behaviors checks two snippets for behavioral equivalence, and score_fidelity scores a candidate against a reference (how faithful, what exactly is missing or hallucinated) \u2014 use it to prove an edit or translation preserved meaning.
10578
+
10579
+ Prefer natural language input (code + language) for simple cases; use explicit bracket syntax ([toggle patient:.active]) or semantic JSON when you need unambiguous role control.`;
10580
+ var STATIC_SURFACE_CACHE = { ttlMs: 36e5, cacheScope: "public" };
10581
+ function buildServer() {
10582
+ const server = new Server(
10583
+ {
10584
+ name: "@hyperfixi/mcp-server",
10585
+ version: pkgVersion
10586
+ },
10587
+ {
10588
+ capabilities: {
10589
+ tools: {},
10590
+ resources: {},
10591
+ prompts: {}
10592
+ },
10593
+ instructions: SERVER_INSTRUCTIONS,
10594
+ cacheHints: {
10595
+ "tools/list": STATIC_SURFACE_CACHE,
10596
+ "prompts/list": STATIC_SURFACE_CACHE,
10597
+ "resources/list": STATIC_SURFACE_CACHE,
10598
+ "resources/read": STATIC_SURFACE_CACHE
10599
+ }
10520
10600
  }
10521
- }
10522
- );
10523
- server.setRequestHandler(ListToolsRequestSchema, async () => {
10524
- return {
10525
- tools: [
10526
- ...analysisTools,
10527
- ...patternTools,
10528
- ...validationTools,
10529
- ...lspBridgeTools,
10530
- ...languageDocsTools,
10531
- ...profileTools,
10532
- ...compilationTools,
10533
- ...routeTools,
10534
- ...registry.getToolDefinitions(),
10535
- ...samplingTools,
10536
- ...dispatcherTools,
10537
- ...irTools,
10538
- ...debugTools,
10539
- ...inventoryTools,
10540
- ...trainingDataTools,
10541
- ...feedbackTools,
10542
- ...lsePipelineTools,
10543
- ...grailTools,
10544
- ...lseCorrectionTools
10545
- ]
10546
- };
10547
- });
10548
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
10549
- const { name, arguments: args } = request.params;
10550
- const stale = staleSinceStartup();
10551
- if (stale.length > 0) {
10552
- return staleToolError(stale);
10553
- }
10554
- if (name.startsWith("analyze_") || name === "explain_code" || name === "recognize_intent") {
10555
- return handleAnalysisTool(name, args);
10556
- }
10557
- if (name === "search_patterns" || name === "translate_hyperscript" || name === "get_pattern_stats") {
10558
- return handlePatternTool(name, args);
10559
- }
10560
- if (name === "validate_hyperscript" || name === "validate_schema" || name === "suggest_command" || name === "get_bundle_config" || name === "parse_multilingual" || name === "translate_to_english" || name === "explain_in_language" || name === "get_code_fixes") {
10561
- return handleValidationTool(name, args);
10562
- }
10563
- if (name === "get_diagnostics" || name === "get_completions" || name === "get_hover_info" || name === "get_document_symbols") {
10564
- return handleLspBridgeTool(name, args);
10565
- }
10566
- if (name === "get_command_docs" || name === "get_expression_docs" || name === "search_language_elements" || name === "suggest_best_practices") {
10567
- return handleLanguageDocsTool(name, args);
10568
- }
10569
- if (name === "get_language_profile" || name === "list_supported_languages" || name === "get_keyword_translations" || name === "get_role_markers" || name === "compare_language_profiles") {
10570
- return handleProfileTool(name, args);
10571
- }
10572
- if (name === "compile_hyperscript" || name === "validate_and_compile" || name === "translate_code" || name === "generate_tests" || name === "generate_component" || name === "diff_behaviors") {
10573
- return handleCompilationTool(name, args);
10574
- }
10575
- if (name === "detect_domain" || name === "parse_composite" || name === "compile_auto" || name === "compile_composite") {
10576
- return handleDispatcherTool(name, args, registry);
10577
- }
10578
- if (name === "convert_format" || name === "validate_explicit" || name === "validate_protocol" || name === "to_envelope" || name === "from_envelope") {
10579
- return handleIRTool(name, args);
10580
- }
10581
- if (registry.canHandle(name)) {
10582
- const typedArgs = args;
10583
- if (name.endsWith("_bdd") && isMultiStepBDD(typedArgs)) {
10584
- return handleBDDMultiStep(name, typedArgs);
10601
+ );
10602
+ server.setRequestHandler("tools/list", async () => {
10603
+ return {
10604
+ tools: [
10605
+ ...analysisTools,
10606
+ ...patternTools,
10607
+ ...validationTools,
10608
+ ...lspBridgeTools,
10609
+ ...languageDocsTools,
10610
+ ...profileTools,
10611
+ ...compilationTools,
10612
+ ...routeTools,
10613
+ // Cast: the framework's MCPToolDefinition types inputSchema.properties
10614
+ // as Record<string, unknown>, wider than the SDK's JSONValue index —
10615
+ // the values are plain JSON Schema literals at runtime.
10616
+ ...registry.getToolDefinitions(),
10617
+ ...LLM_SAMPLING_ENABLED ? samplingTools : [],
10618
+ ...dispatcherTools,
10619
+ ...irTools,
10620
+ ...debugTools,
10621
+ ...inventoryTools,
10622
+ ...trainingDataTools,
10623
+ ...feedbackTools,
10624
+ ...lsePipelineTools,
10625
+ ...grailTools,
10626
+ ...lseCorrectionTools
10627
+ ]
10628
+ };
10629
+ });
10630
+ server.setRequestHandler("tools/call", async (request) => {
10631
+ const { name, arguments: args } = request.params;
10632
+ const stale = staleSinceStartup();
10633
+ if (stale.length > 0) {
10634
+ return staleToolError(stale);
10585
10635
  }
10586
- if (name.endsWith("_behaviorspec") && isMultiLineBehaviorSpec(typedArgs)) {
10587
- return handleBehaviorSpecMultiLine(name, typedArgs);
10636
+ if (name.startsWith("analyze_") || name === "explain_code" || name === "recognize_intent") {
10637
+ return handleAnalysisTool(name, args);
10588
10638
  }
10589
- const result = await registry.handleToolCall(name, typedArgs);
10590
- if (result) return result;
10591
- }
10592
- if (name === "extract_routes" || name === "generate_server_routes") {
10593
- return handleRouteTool(name, args);
10594
- }
10595
- if (name === "ask_claude" || name === "summarize_content" || name === "analyze_content" || name === "translate_content" || name === "execute_llm") {
10596
- return handleSamplingTool(name, args, server, registry);
10597
- }
10598
- if (name.startsWith("debug_")) {
10599
- return handleDebugTool(name, args);
10600
- }
10601
- if (name === "scan_inventory" || name === "query_inventory") {
10602
- return handleInventoryTool(name, args);
10603
- }
10604
- if (name === "generate_training_data") {
10605
- return handleTrainingDataTool(name, args);
10606
- }
10607
- if (name === "lse_validate_and_feedback" || name === "lse_pattern_stats") {
10608
- return handleFeedbackTool(name, args);
10609
- }
10610
- if (name === "lse_from_hyperscript" || name === "lse_to_hyperscript" || name === "execute_lse" || name === "validate_lse" || name === "translate_lse") {
10611
- return handleLsePipelineTool(name, args);
10612
- }
10613
- if (name.startsWith("grail_")) {
10614
- return handleGrailTool(name, args);
10615
- }
10616
- if (name === "lse_generate_with_correction") {
10617
- return handleLseCorrectionTool(name, args);
10618
- }
10619
- if (name.startsWith("get_")) {
10620
- return handlePatternTool(name, args);
10621
- }
10622
- return {
10623
- content: [{ type: "text", text: `Unknown tool: ${name}` }],
10624
- isError: true
10625
- };
10626
- });
10627
- server.setRequestHandler(ListPromptsRequestSchema, async () => {
10628
- return {
10629
- prompts: [
10630
- ...getLLMPromptDefinitions(),
10631
- ...getDebugPromptDefinitions(),
10632
- ...getLSEPromptDefinitions()
10633
- ]
10634
- };
10635
- });
10636
- server.setRequestHandler(GetPromptRequestSchema, async (request) => {
10637
- const { name, arguments: promptArgs } = request.params;
10638
- const typedArgs = promptArgs ?? {};
10639
- if (isDebugPrompt(name)) {
10640
- return renderDebugPrompt(name, typedArgs);
10641
- }
10642
- if (isLSEPrompt(name)) {
10643
- return renderLSEPrompt(name, typedArgs);
10644
- }
10645
- return renderLLMPrompt(name, typedArgs);
10646
- });
10647
- server.setRequestHandler(ListResourcesRequestSchema, async () => {
10648
- return { resources: listResources() };
10649
- });
10650
- server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
10651
- const { uri } = request.params;
10652
- return readResource(uri);
10653
- });
10639
+ if (name === "search_patterns" || name === "translate_hyperscript" || name === "get_pattern_stats") {
10640
+ return handlePatternTool(name, args);
10641
+ }
10642
+ if (name === "validate_hyperscript" || name === "validate_schema" || name === "suggest_command" || name === "get_bundle_config" || name === "parse_multilingual" || name === "translate_to_english" || name === "explain_in_language" || name === "get_code_fixes") {
10643
+ return handleValidationTool(name, args);
10644
+ }
10645
+ if (name === "get_diagnostics" || name === "get_completions" || name === "get_hover_info" || name === "get_document_symbols") {
10646
+ return handleLspBridgeTool(name, args);
10647
+ }
10648
+ if (name === "get_command_docs" || name === "get_expression_docs" || name === "search_language_elements" || name === "suggest_best_practices") {
10649
+ return handleLanguageDocsTool(name, args);
10650
+ }
10651
+ if (name === "get_language_profile" || name === "list_supported_languages" || name === "get_keyword_translations" || name === "get_role_markers" || name === "compare_language_profiles") {
10652
+ return handleProfileTool(name, args);
10653
+ }
10654
+ if (name === "compile_hyperscript" || name === "validate_and_compile" || name === "translate_code" || name === "generate_tests" || name === "generate_component" || name === "score_fidelity" || name === "diff_behaviors") {
10655
+ return handleCompilationTool(name, args);
10656
+ }
10657
+ if (name === "detect_domain" || name === "parse_composite" || name === "compile_auto" || name === "compile_composite") {
10658
+ return handleDispatcherTool(name, args, registry);
10659
+ }
10660
+ if (name === "convert_format" || name === "validate_explicit" || name === "validate_protocol" || name === "to_envelope" || name === "from_envelope") {
10661
+ return handleIRTool(name, args);
10662
+ }
10663
+ if (registry.canHandle(name)) {
10664
+ const typedArgs = args;
10665
+ if (name.endsWith("_bdd") && isMultiStepBDD(typedArgs)) {
10666
+ return handleBDDMultiStep(name, typedArgs);
10667
+ }
10668
+ if (name.endsWith("_behaviorspec") && isMultiLineBehaviorSpec(typedArgs)) {
10669
+ return handleBehaviorSpecMultiLine(name, typedArgs);
10670
+ }
10671
+ const result = await registry.handleToolCall(name, typedArgs);
10672
+ if (result) return result;
10673
+ }
10674
+ if (name === "extract_routes" || name === "generate_server_routes") {
10675
+ return handleRouteTool(name, args);
10676
+ }
10677
+ if (name === "ask_claude" || name === "summarize_content" || name === "analyze_content" || name === "translate_content" || name === "execute_llm") {
10678
+ if (!LLM_SAMPLING_ENABLED) {
10679
+ return {
10680
+ content: [
10681
+ {
10682
+ type: "text",
10683
+ text: `${name} is disabled: the MCP-sampling tools are opt-in (set LOKASCRIPT_MCP_LLM_TOOLS=1 in the server's environment and restart). They invoke a generic LLM, which a connected agent can do itself. For hyperscript work use validate_and_compile / compile_hyperscript; for natural-language translation of CODE, use translate_code (deterministic, not an LLM).`
10684
+ }
10685
+ ],
10686
+ isError: true
10687
+ };
10688
+ }
10689
+ return handleSamplingTool(name, args, server, registry);
10690
+ }
10691
+ if (name.startsWith("debug_")) {
10692
+ return handleDebugTool(name, args);
10693
+ }
10694
+ if (name === "scan_inventory" || name === "query_inventory") {
10695
+ return handleInventoryTool(name, args);
10696
+ }
10697
+ if (name === "generate_training_data") {
10698
+ return handleTrainingDataTool(name, args);
10699
+ }
10700
+ if (name === "lse_validate_and_feedback" || name === "lse_pattern_stats") {
10701
+ return handleFeedbackTool(name, args);
10702
+ }
10703
+ if (name === "lse_from_hyperscript" || name === "lse_to_hyperscript" || name === "execute_lse" || name === "validate_lse" || name === "translate_lse") {
10704
+ return handleLsePipelineTool(name, args);
10705
+ }
10706
+ if (name.startsWith("grail_")) {
10707
+ return handleGrailTool(name, args);
10708
+ }
10709
+ if (name === "lse_generate_with_correction") {
10710
+ return handleLseCorrectionTool(name, args);
10711
+ }
10712
+ if (name.startsWith("get_")) {
10713
+ return handlePatternTool(name, args);
10714
+ }
10715
+ return {
10716
+ content: [{ type: "text", text: `Unknown tool: ${name}` }],
10717
+ isError: true
10718
+ };
10719
+ });
10720
+ server.setRequestHandler("prompts/list", async () => {
10721
+ return {
10722
+ prompts: [
10723
+ ...getLLMPromptDefinitions(),
10724
+ ...getDebugPromptDefinitions(),
10725
+ ...getLSEPromptDefinitions()
10726
+ ]
10727
+ };
10728
+ });
10729
+ server.setRequestHandler("prompts/get", async (request) => {
10730
+ const { name, arguments: promptArgs } = request.params;
10731
+ const typedArgs = promptArgs ?? {};
10732
+ if (isDebugPrompt(name)) {
10733
+ return renderDebugPrompt(name, typedArgs);
10734
+ }
10735
+ if (isLSEPrompt(name)) {
10736
+ return renderLSEPrompt(name, typedArgs);
10737
+ }
10738
+ return renderLLMPrompt(name, typedArgs);
10739
+ });
10740
+ server.setRequestHandler("resources/list", async () => {
10741
+ return { resources: listResources() };
10742
+ });
10743
+ server.setRequestHandler("resources/read", async (request) => {
10744
+ const { uri } = request.params;
10745
+ return readResource(uri);
10746
+ });
10747
+ return server;
10748
+ }
10654
10749
  async function main() {
10655
10750
  captureFreshnessBaseline();
10656
10751
  const bornStale = staleAtStartup();
@@ -10662,8 +10757,7 @@ async function main() {
10662
10757
  ` + bornStale.map((s) => ` npm run build --prefix ${s.dir}`).join("\n")
10663
10758
  );
10664
10759
  }
10665
- const transport = new StdioServerTransport();
10666
- await server.connect(transport);
10760
+ serveStdio(() => buildServer());
10667
10761
  console.error(`HyperFixi MCP server started (${freshnessSummary()})`);
10668
10762
  }
10669
10763
  main().catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperfixi/mcp-server",
3
- "version": "2.9.4",
3
+ "version": "2.11.0",
4
4
  "description": "Model Context Protocol server for HyperFixi hyperscript development",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -9,11 +9,11 @@
9
9
  },
10
10
  "scripts": {
11
11
  "build": "tsup src/index.ts --format esm --dts",
12
- "prebuild": "../../scripts/ensure-fresh.sh ../compilation-service ../semantic ../framework ../intent ../domain-config ../domain-learn ../planner",
12
+ "prebuild": "../../scripts/ensure-fresh.sh ../compilation-service ../semantic ../framework ../intent ../planner",
13
13
  "start": "node dist/index.js",
14
14
  "dev": "tsx src/index.ts",
15
15
  "dev:watch": "tsx watch src/index.ts",
16
- "pretest": "../../scripts/ensure-fresh.sh ../compilation-service ../semantic ../framework ../intent ../domain-config ../domain-learn ../planner",
16
+ "pretest": "../../scripts/ensure-fresh.sh ../compilation-service ../semantic ../framework ../intent ../planner",
17
17
  "test": "vitest",
18
18
  "typecheck": "tsc --noEmit",
19
19
  "service:setup": "echo 'Copy com.lokascript.mcp-server.plist.example to com.lokascript.mcp-server.plist and update paths, then run service:install'",
@@ -37,31 +37,22 @@
37
37
  "author": "LokaScript Contributors",
38
38
  "license": "MIT",
39
39
  "dependencies": {
40
- "@hyperfixi/patterns-reference": "^2.9.4",
41
- "@lokascript/compilation-service": "^2.9.4",
42
- "@lokascript/domain-config": "^2.9.4",
43
- "@lokascript/framework": "^2.9.4",
44
- "@lokascript/planner": "^2.9.4",
45
- "@lokascript/semantic": "^2.9.4",
46
- "@modelcontextprotocol/sdk": "^1.25.0",
40
+ "@hyperfixi/patterns-reference": "^2.11.0",
41
+ "@lokascript/compilation-service": "^2.11.0",
42
+ "@lokascript/domains": "^2.11.1",
43
+ "@lokascript/framework": "^2.11.0",
44
+ "@lokascript/planner": "^2.11.0",
45
+ "@lokascript/semantic": "^2.11.0",
46
+ "@modelcontextprotocol/server": "^2.0.0",
47
47
  "yaml": "^2.8.3"
48
48
  },
49
49
  "peerDependencies": {
50
- "@hyperfixi/core": "^2.9.4",
51
- "@hyperfixi/patterns-reference": "^2.9.4",
52
- "@hyperfixi/server-bridge": "^2.9.4",
53
- "@lokascript/compilation-service": "^2.9.4",
54
- "@lokascript/domain-bdd": "^2.9.4",
55
- "@lokascript/domain-behaviorspec": "^2.9.4",
56
- "@lokascript/domain-flow": "^2.9.4",
57
- "@lokascript/domain-jsx": "^2.9.4",
58
- "@lokascript/domain-learn": "^2.9.4",
59
- "@lokascript/domain-llm": "^2.9.4",
60
- "@lokascript/domain-sql": "^2.9.4",
61
- "@lokascript/domain-todo": "^2.9.4",
62
- "@lokascript/domain-voice": "^2.9.4",
63
- "@lokascript/framework": "^2.9.4",
64
- "@lokascript/semantic": "^2.9.4"
50
+ "@hyperfixi/core": "^2.11.0",
51
+ "@hyperfixi/patterns-reference": "^2.11.0",
52
+ "@hyperfixi/server-bridge": "^2.11.0",
53
+ "@lokascript/compilation-service": "^2.11.0",
54
+ "@lokascript/framework": "^2.11.0",
55
+ "@lokascript/semantic": "^2.11.0"
65
56
  },
66
57
  "peerDependenciesMeta": {
67
58
  "@lokascript/compilation-service": {
@@ -79,53 +70,17 @@
79
70
  "@lokascript/semantic": {
80
71
  "optional": true
81
72
  },
82
- "@lokascript/domain-sql": {
83
- "optional": true
84
- },
85
- "@lokascript/domain-bdd": {
86
- "optional": true
87
- },
88
- "@lokascript/domain-behaviorspec": {
89
- "optional": true
90
- },
91
- "@lokascript/domain-jsx": {
92
- "optional": true
93
- },
94
- "@lokascript/domain-learn": {
95
- "optional": true
96
- },
97
- "@lokascript/domain-flow": {
98
- "optional": true
99
- },
100
- "@lokascript/domain-llm": {
101
- "optional": true
102
- },
103
- "@lokascript/domain-todo": {
104
- "optional": true
105
- },
106
- "@lokascript/domain-voice": {
107
- "optional": true
108
- },
109
73
  "@hyperfixi/server-bridge": {
110
74
  "optional": true
111
75
  }
112
76
  },
113
77
  "devDependencies": {
114
- "@hyperfixi/core": "^2.9.4",
115
- "@hyperfixi/patterns-reference": "^2.9.4",
116
- "@hyperfixi/server-bridge": "^2.9.4",
117
- "@lokascript/compilation-service": "^2.9.4",
118
- "@lokascript/domain-bdd": "^2.9.4",
119
- "@lokascript/domain-behaviorspec": "^2.9.4",
120
- "@lokascript/domain-flow": "^2.9.4",
121
- "@lokascript/domain-jsx": "^2.9.4",
122
- "@lokascript/domain-learn": "^2.9.4",
123
- "@lokascript/domain-llm": "^2.9.4",
124
- "@lokascript/domain-sql": "^2.9.4",
125
- "@lokascript/domain-todo": "^2.9.4",
126
- "@lokascript/domain-voice": "^2.9.4",
127
- "@lokascript/framework": "^2.9.4",
128
- "@lokascript/semantic": "^2.9.4",
78
+ "@hyperfixi/core": "^2.11.0",
79
+ "@hyperfixi/patterns-reference": "^2.11.0",
80
+ "@hyperfixi/server-bridge": "^2.11.0",
81
+ "@lokascript/compilation-service": "^2.11.0",
82
+ "@lokascript/framework": "^2.11.0",
83
+ "@lokascript/semantic": "^2.11.0",
129
84
  "@types/node": "^26.1.2",
130
85
  "tsup": "^8.0.0",
131
86
  "tsx": "^4.23.1",