@hyperfixi/mcp-server 2.10.0 → 2.11.1

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: {
@@ -5463,7 +5453,7 @@ async function getService() {
5463
5453
  var compilationTools = [
5464
5454
  {
5465
5455
  name: "compile_hyperscript",
5466
- 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" } } }',
5467
5457
  inputSchema: {
5468
5458
  type: "object",
5469
5459
  properties: {
@@ -5497,7 +5487,7 @@ var compilationTools = [
5497
5487
  },
5498
5488
  {
5499
5489
  name: "validate_and_compile",
5500
- 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.",
5501
5491
  inputSchema: {
5502
5492
  type: "object",
5503
5493
  properties: {
@@ -5511,7 +5501,7 @@ var compilationTools = [
5511
5501
  },
5512
5502
  {
5513
5503
  name: "translate_code",
5514
- 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.',
5515
5505
  inputSchema: {
5516
5506
  type: "object",
5517
5507
  properties: {
@@ -5567,6 +5557,37 @@ var compilationTools = [
5567
5557
  }
5568
5558
  }
5569
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
+ },
5570
5591
  {
5571
5592
  name: "diff_behaviors",
5572
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.",
@@ -5599,6 +5620,16 @@ var compilationTools = [
5599
5620
  }
5600
5621
  }
5601
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
+ }
5602
5633
  async function handleCompilationTool(name, args) {
5603
5634
  try {
5604
5635
  const service = await getService();
@@ -5611,10 +5642,7 @@ async function handleCompilationTool(name, args) {
5611
5642
  language: args.language,
5612
5643
  confidence: args.confidence
5613
5644
  });
5614
- return {
5615
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
5616
- isError: !result.ok
5617
- };
5645
+ return compileResult(result);
5618
5646
  }
5619
5647
  case "validate_and_compile": {
5620
5648
  const result = service.validate({
@@ -5624,10 +5652,7 @@ async function handleCompilationTool(name, args) {
5624
5652
  language: args.language,
5625
5653
  confidence: args.confidence
5626
5654
  });
5627
- return {
5628
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
5629
- isError: !result.ok
5630
- };
5655
+ return compileResult(result);
5631
5656
  }
5632
5657
  case "translate_code": {
5633
5658
  const result = service.translate({
@@ -5670,6 +5695,17 @@ async function handleCompilationTool(name, args) {
5670
5695
  isError: !result.ok
5671
5696
  };
5672
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
+ }
5673
5709
  case "diff_behaviors": {
5674
5710
  const result = service.diff({
5675
5711
  a: args.a,
@@ -5904,7 +5940,7 @@ async function generateServerRoutes(args) {
5904
5940
  }
5905
5941
 
5906
5942
  // src/tools/domain-registry-setup.ts
5907
- import { createDomainRegistry } from "@lokascript/domain-config";
5943
+ import { createDomainRegistry } from "@lokascript/domains";
5908
5944
 
5909
5945
  // src/tools/bdd-extras.ts
5910
5946
  var bddScenarioParser = null;
@@ -5914,13 +5950,13 @@ async function getBDDExtras() {
5914
5950
  if (bddScenarioParser)
5915
5951
  return { parseScenario: bddScenarioParser, generator: bddGenerator, renderer: bddRenderer };
5916
5952
  try {
5917
- const mod = await import("@lokascript/domain-bdd");
5953
+ const mod = await import("@lokascript/domains/bdd");
5918
5954
  bddScenarioParser = mod.parseBDDScenario;
5919
5955
  bddGenerator = mod.bddCodeGenerator;
5920
5956
  bddRenderer = mod.renderBDD ?? null;
5921
5957
  return { parseScenario: bddScenarioParser, generator: bddGenerator, renderer: bddRenderer };
5922
5958
  } catch {
5923
- 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.");
5924
5960
  }
5925
5961
  }
5926
5962
  function serializeRoles(roles) {
@@ -6014,13 +6050,13 @@ async function getBehaviorSpecExtras() {
6014
6050
  if (behaviorSpecParser)
6015
6051
  return { parseSpec: behaviorSpecParser, compile: behaviorCompiler, render: behaviorRenderer };
6016
6052
  try {
6017
- const mod = await import("@lokascript/domain-behaviorspec");
6053
+ const mod = await import("@lokascript/domains/behaviorspec");
6018
6054
  behaviorSpecParser = mod.parseBehaviorSpec;
6019
6055
  behaviorCompiler = mod.compileBehaviorSpec;
6020
6056
  behaviorRenderer = mod.renderBehaviorSpec;
6021
6057
  return { parseSpec: behaviorSpecParser, compile: behaviorCompiler, render: behaviorRenderer };
6022
6058
  } catch {
6023
- 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.");
6024
6060
  }
6025
6061
  }
6026
6062
  function serializeRoles2(roles) {
@@ -6604,7 +6640,7 @@ Every value must have a role name. Do not invent commands or roles not in the sc
6604
6640
  var samplingTools = [
6605
6641
  {
6606
6642
  name: "ask_claude",
6607
- 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.",
6608
6644
  inputSchema: {
6609
6645
  type: "object",
6610
6646
  properties: {
@@ -6631,7 +6667,7 @@ var samplingTools = [
6631
6667
  },
6632
6668
  {
6633
6669
  name: "summarize_content",
6634
- 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.",
6635
6671
  inputSchema: {
6636
6672
  type: "object",
6637
6673
  properties: {
@@ -6658,7 +6694,7 @@ var samplingTools = [
6658
6694
  },
6659
6695
  {
6660
6696
  name: "analyze_content",
6661
- 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.",
6662
6698
  inputSchema: {
6663
6699
  type: "object",
6664
6700
  properties: {
@@ -6681,7 +6717,7 @@ var samplingTools = [
6681
6717
  },
6682
6718
  {
6683
6719
  name: "translate_content",
6684
- 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.",
6685
6721
  inputSchema: {
6686
6722
  type: "object",
6687
6723
  properties: {
@@ -6707,7 +6743,7 @@ var samplingTools = [
6707
6743
  },
6708
6744
  {
6709
6745
  name: "execute_llm",
6710
- 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.',
6711
6747
  inputSchema: {
6712
6748
  type: "object",
6713
6749
  properties: {
@@ -6846,13 +6882,13 @@ ${content}`
6846
6882
  }
6847
6883
  };
6848
6884
  }
6849
- async function handleSamplingTool(name, args, server2, registry2) {
6885
+ async function handleSamplingTool(name, args, server, registry2) {
6850
6886
  try {
6851
6887
  if (name === "execute_llm") {
6852
- return await handleExecuteLLM(args, server2, registry2);
6888
+ return await handleExecuteLLM(args, server, registry2);
6853
6889
  }
6854
6890
  const spec = argsToSpec(name, args);
6855
- return await executeSpec(spec, server2);
6891
+ return await executeSpec(spec, server);
6856
6892
  } catch (error) {
6857
6893
  const message = error instanceof Error ? error.message : String(error);
6858
6894
  return {
@@ -6861,13 +6897,28 @@ async function handleSamplingTool(name, args, server2, registry2) {
6861
6897
  };
6862
6898
  }
6863
6899
  }
6864
- async function executeSpec(spec, server2) {
6900
+ async function executeSpec(spec, server) {
6865
6901
  const params = specToSamplingParams(spec);
6866
- const response = await server2.createMessage(params);
6867
- 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"}`;
6868
6919
  return { content: [{ type: "text", text }] };
6869
6920
  }
6870
- async function handleExecuteLLM(args, server2, registry2) {
6921
+ async function handleExecuteLLM(args, server, registry2) {
6871
6922
  if (!registry2) {
6872
6923
  return {
6873
6924
  content: [{ type: "text", text: "execute_llm requires domain registry (internal error)" }],
@@ -6906,12 +6957,12 @@ async function handleExecuteLLM(args, server2, registry2) {
6906
6957
  isError: true
6907
6958
  };
6908
6959
  }
6909
- return await executeSpec(spec, server2);
6960
+ return await executeSpec(spec, server);
6910
6961
  }
6911
6962
 
6912
6963
  // src/tools/dispatcher.ts
6913
6964
  import { CrossDomainDispatcher } from "@lokascript/framework";
6914
- import { DOMAIN_PRIORITY } from "@lokascript/domain-config";
6965
+ import { DOMAIN_PRIORITY } from "@lokascript/domains";
6915
6966
  var dispatcher = null;
6916
6967
  function getDispatcher(registry2) {
6917
6968
  if (!dispatcher) {
@@ -8095,7 +8146,7 @@ function createInlineExtractor() {
8095
8146
  const fs = await import("fs");
8096
8147
  const path = await import("path");
8097
8148
  const crypto = await import("crypto");
8098
- const { glob } = await import("./esm-WMQN6QOB.js");
8149
+ const { glob } = await import("./esm-JVAYDN24.js");
8099
8150
  const globs = [
8100
8151
  "**/*.html",
8101
8152
  "**/*.htm",
@@ -8293,21 +8344,21 @@ async function loadDomainSchemas(domain) {
8293
8344
  try {
8294
8345
  switch (domain) {
8295
8346
  case "flow":
8296
- return (await import("@lokascript/domain-flow")).allSchemas;
8347
+ return (await import("@lokascript/domains/flow")).allSchemas;
8297
8348
  case "sql":
8298
- return (await import("@lokascript/domain-sql")).allSchemas;
8349
+ return (await import("@lokascript/domains/sql")).allSchemas;
8299
8350
  case "bdd":
8300
- return (await import("@lokascript/domain-bdd")).allSchemas;
8351
+ return (await import("@lokascript/domains/bdd")).allSchemas;
8301
8352
  case "llm":
8302
- return (await import("@lokascript/domain-llm")).allSchemas;
8353
+ return (await import("@lokascript/domains/llm")).allSchemas;
8303
8354
  case "jsx":
8304
- return (await import("@lokascript/domain-jsx")).allSchemas;
8355
+ return (await import("@lokascript/domains/jsx")).allSchemas;
8305
8356
  case "todo":
8306
- return (await import("@lokascript/domain-todo")).allSchemas;
8357
+ return (await import("@lokascript/domains/todo")).allSchemas;
8307
8358
  case "behaviorspec":
8308
- return (await import("@lokascript/domain-behaviorspec")).allSchemas;
8359
+ return (await import("@lokascript/domains/behaviorspec")).allSchemas;
8309
8360
  case "voice":
8310
- return (await import("@lokascript/domain-voice")).allSchemas;
8361
+ return (await import("@lokascript/domains/voice")).allSchemas;
8311
8362
  default:
8312
8363
  return null;
8313
8364
  }
@@ -8552,10 +8603,10 @@ async function handleToHyperscript(args) {
8552
8603
  try {
8553
8604
  const { CompilationService } = await import("@lokascript/compilation-service");
8554
8605
  const service = await CompilationService.create();
8555
- const compileResult = service.compile({ explicit: normalizedLse });
8556
- result.js = compileResult.ok ? compileResult.js : void 0;
8557
- if (!compileResult.ok && compileResult.diagnostics) {
8558
- 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) {
8559
8610
  if (d.severity === "error") {
8560
8611
  diagnostics.push({
8561
8612
  severity: "error",
@@ -8590,8 +8641,8 @@ async function handleExecuteLse(args) {
8590
8641
  try {
8591
8642
  const { CompilationService } = await import("@lokascript/compilation-service");
8592
8643
  const service = await CompilationService.create();
8593
- const compileResult = service.compile({ explicit: normalizedLse });
8594
- js = compileResult.ok ? compileResult.js : void 0;
8644
+ const compileResult2 = service.compile({ explicit: normalizedLse });
8645
+ js = compileResult2.ok ? compileResult2.js : void 0;
8595
8646
  } catch {
8596
8647
  }
8597
8648
  return jsonResponse({
@@ -9498,7 +9549,7 @@ function buildCorrectedExample(attempt, diagnostics) {
9498
9549
  async function buildSchemaContext(domain) {
9499
9550
  if (!domain) return null;
9500
9551
  try {
9501
- const { loadDomainSchemas: loadDomainSchemas2 } = await import("./feedback-tools-S6VDG6F5.js");
9552
+ const { loadDomainSchemas: loadDomainSchemas2 } = await import("./feedback-tools-6I5OQYZS.js");
9502
9553
  if (typeof loadDomainSchemas2 !== "function") return null;
9503
9554
  const schemas = await loadDomainSchemas2(domain);
9504
9555
  if (!schemas || schemas.length === 0) return null;
@@ -10515,150 +10566,186 @@ function readResource(uri) {
10515
10566
  // src/index.ts
10516
10567
  var registry = createDomainRegistry();
10517
10568
  var { version: pkgVersion } = createRequire2(import.meta.url)("../package.json");
10518
- var server = new Server(
10519
- {
10520
- name: "@hyperfixi/mcp-server",
10521
- version: pkgVersion
10522
- },
10523
- {
10524
- capabilities: {
10525
- tools: {},
10526
- resources: {},
10527
- 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
+ }
10528
10600
  }
10529
- }
10530
- );
10531
- server.setRequestHandler(ListToolsRequestSchema, async () => {
10532
- return {
10533
- tools: [
10534
- ...analysisTools,
10535
- ...patternTools,
10536
- ...validationTools,
10537
- ...lspBridgeTools,
10538
- ...languageDocsTools,
10539
- ...profileTools,
10540
- ...compilationTools,
10541
- ...routeTools,
10542
- ...registry.getToolDefinitions(),
10543
- ...samplingTools,
10544
- ...dispatcherTools,
10545
- ...irTools,
10546
- ...debugTools,
10547
- ...inventoryTools,
10548
- ...trainingDataTools,
10549
- ...feedbackTools,
10550
- ...lsePipelineTools,
10551
- ...grailTools,
10552
- ...lseCorrectionTools
10553
- ]
10554
- };
10555
- });
10556
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
10557
- const { name, arguments: args } = request.params;
10558
- const stale = staleSinceStartup();
10559
- if (stale.length > 0) {
10560
- return staleToolError(stale);
10561
- }
10562
- if (name.startsWith("analyze_") || name === "explain_code" || name === "recognize_intent") {
10563
- return handleAnalysisTool(name, args);
10564
- }
10565
- if (name === "search_patterns" || name === "translate_hyperscript" || name === "get_pattern_stats") {
10566
- return handlePatternTool(name, args);
10567
- }
10568
- 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") {
10569
- return handleValidationTool(name, args);
10570
- }
10571
- if (name === "get_diagnostics" || name === "get_completions" || name === "get_hover_info" || name === "get_document_symbols") {
10572
- return handleLspBridgeTool(name, args);
10573
- }
10574
- if (name === "get_command_docs" || name === "get_expression_docs" || name === "search_language_elements" || name === "suggest_best_practices") {
10575
- return handleLanguageDocsTool(name, args);
10576
- }
10577
- if (name === "get_language_profile" || name === "list_supported_languages" || name === "get_keyword_translations" || name === "get_role_markers" || name === "compare_language_profiles") {
10578
- return handleProfileTool(name, args);
10579
- }
10580
- if (name === "compile_hyperscript" || name === "validate_and_compile" || name === "translate_code" || name === "generate_tests" || name === "generate_component" || name === "diff_behaviors") {
10581
- return handleCompilationTool(name, args);
10582
- }
10583
- if (name === "detect_domain" || name === "parse_composite" || name === "compile_auto" || name === "compile_composite") {
10584
- return handleDispatcherTool(name, args, registry);
10585
- }
10586
- if (name === "convert_format" || name === "validate_explicit" || name === "validate_protocol" || name === "to_envelope" || name === "from_envelope") {
10587
- return handleIRTool(name, args);
10588
- }
10589
- if (registry.canHandle(name)) {
10590
- const typedArgs = args;
10591
- if (name.endsWith("_bdd") && isMultiStepBDD(typedArgs)) {
10592
- 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);
10593
10635
  }
10594
- if (name.endsWith("_behaviorspec") && isMultiLineBehaviorSpec(typedArgs)) {
10595
- return handleBehaviorSpecMultiLine(name, typedArgs);
10636
+ if (name.startsWith("analyze_") || name === "explain_code" || name === "recognize_intent") {
10637
+ return handleAnalysisTool(name, args);
10596
10638
  }
10597
- const result = await registry.handleToolCall(name, typedArgs);
10598
- if (result) return result;
10599
- }
10600
- if (name === "extract_routes" || name === "generate_server_routes") {
10601
- return handleRouteTool(name, args);
10602
- }
10603
- if (name === "ask_claude" || name === "summarize_content" || name === "analyze_content" || name === "translate_content" || name === "execute_llm") {
10604
- return handleSamplingTool(name, args, server, registry);
10605
- }
10606
- if (name.startsWith("debug_")) {
10607
- return handleDebugTool(name, args);
10608
- }
10609
- if (name === "scan_inventory" || name === "query_inventory") {
10610
- return handleInventoryTool(name, args);
10611
- }
10612
- if (name === "generate_training_data") {
10613
- return handleTrainingDataTool(name, args);
10614
- }
10615
- if (name === "lse_validate_and_feedback" || name === "lse_pattern_stats") {
10616
- return handleFeedbackTool(name, args);
10617
- }
10618
- if (name === "lse_from_hyperscript" || name === "lse_to_hyperscript" || name === "execute_lse" || name === "validate_lse" || name === "translate_lse") {
10619
- return handleLsePipelineTool(name, args);
10620
- }
10621
- if (name.startsWith("grail_")) {
10622
- return handleGrailTool(name, args);
10623
- }
10624
- if (name === "lse_generate_with_correction") {
10625
- return handleLseCorrectionTool(name, args);
10626
- }
10627
- if (name.startsWith("get_")) {
10628
- return handlePatternTool(name, args);
10629
- }
10630
- return {
10631
- content: [{ type: "text", text: `Unknown tool: ${name}` }],
10632
- isError: true
10633
- };
10634
- });
10635
- server.setRequestHandler(ListPromptsRequestSchema, async () => {
10636
- return {
10637
- prompts: [
10638
- ...getLLMPromptDefinitions(),
10639
- ...getDebugPromptDefinitions(),
10640
- ...getLSEPromptDefinitions()
10641
- ]
10642
- };
10643
- });
10644
- server.setRequestHandler(GetPromptRequestSchema, async (request) => {
10645
- const { name, arguments: promptArgs } = request.params;
10646
- const typedArgs = promptArgs ?? {};
10647
- if (isDebugPrompt(name)) {
10648
- return renderDebugPrompt(name, typedArgs);
10649
- }
10650
- if (isLSEPrompt(name)) {
10651
- return renderLSEPrompt(name, typedArgs);
10652
- }
10653
- return renderLLMPrompt(name, typedArgs);
10654
- });
10655
- server.setRequestHandler(ListResourcesRequestSchema, async () => {
10656
- return { resources: listResources() };
10657
- });
10658
- server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
10659
- const { uri } = request.params;
10660
- return readResource(uri);
10661
- });
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
+ }
10662
10749
  async function main() {
10663
10750
  captureFreshnessBaseline();
10664
10751
  const bornStale = staleAtStartup();
@@ -10670,8 +10757,7 @@ async function main() {
10670
10757
  ` + bornStale.map((s) => ` npm run build --prefix ${s.dir}`).join("\n")
10671
10758
  );
10672
10759
  }
10673
- const transport = new StdioServerTransport();
10674
- await server.connect(transport);
10760
+ serveStdio(() => buildServer());
10675
10761
  console.error(`HyperFixi MCP server started (${freshnessSummary()})`);
10676
10762
  }
10677
10763
  main().catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperfixi/mcp-server",
3
- "version": "2.10.0",
3
+ "version": "2.11.1",
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.10.0",
41
- "@lokascript/compilation-service": "^2.10.0",
42
- "@lokascript/domain-config": "^2.10.0",
43
- "@lokascript/framework": "^2.10.0",
44
- "@lokascript/planner": "^2.10.0",
45
- "@lokascript/semantic": "^2.10.0",
46
- "@modelcontextprotocol/sdk": "^1.25.0",
40
+ "@hyperfixi/patterns-reference": "^2.11.1",
41
+ "@lokascript/compilation-service": "^2.11.1",
42
+ "@lokascript/domains": "^2.11.1",
43
+ "@lokascript/framework": "^2.11.1",
44
+ "@lokascript/planner": "^2.11.1",
45
+ "@lokascript/semantic": "^2.11.1",
46
+ "@modelcontextprotocol/server": "^2.0.0",
47
47
  "yaml": "^2.8.3"
48
48
  },
49
49
  "peerDependencies": {
50
- "@hyperfixi/core": "^2.10.0",
51
- "@hyperfixi/patterns-reference": "^2.10.0",
52
- "@hyperfixi/server-bridge": "^2.10.0",
53
- "@lokascript/compilation-service": "^2.10.0",
54
- "@lokascript/domain-bdd": "^2.10.0",
55
- "@lokascript/domain-behaviorspec": "^2.10.0",
56
- "@lokascript/domain-flow": "^2.10.0",
57
- "@lokascript/domain-jsx": "^2.10.0",
58
- "@lokascript/domain-learn": "^2.10.0",
59
- "@lokascript/domain-llm": "^2.10.0",
60
- "@lokascript/domain-sql": "^2.10.0",
61
- "@lokascript/domain-todo": "^2.10.0",
62
- "@lokascript/domain-voice": "^2.10.0",
63
- "@lokascript/framework": "^2.10.0",
64
- "@lokascript/semantic": "^2.10.0"
50
+ "@hyperfixi/core": "^2.11.1",
51
+ "@hyperfixi/patterns-reference": "^2.11.1",
52
+ "@hyperfixi/server-bridge": "^2.11.1",
53
+ "@lokascript/compilation-service": "^2.11.1",
54
+ "@lokascript/framework": "^2.11.1",
55
+ "@lokascript/semantic": "^2.11.1"
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.10.0",
115
- "@hyperfixi/patterns-reference": "^2.10.0",
116
- "@hyperfixi/server-bridge": "^2.10.0",
117
- "@lokascript/compilation-service": "^2.10.0",
118
- "@lokascript/domain-bdd": "^2.10.0",
119
- "@lokascript/domain-behaviorspec": "^2.10.0",
120
- "@lokascript/domain-flow": "^2.10.0",
121
- "@lokascript/domain-jsx": "^2.10.0",
122
- "@lokascript/domain-learn": "^2.10.0",
123
- "@lokascript/domain-llm": "^2.10.0",
124
- "@lokascript/domain-sql": "^2.10.0",
125
- "@lokascript/domain-todo": "^2.10.0",
126
- "@lokascript/domain-voice": "^2.10.0",
127
- "@lokascript/framework": "^2.10.0",
128
- "@lokascript/semantic": "^2.10.0",
78
+ "@hyperfixi/core": "^2.11.1",
79
+ "@hyperfixi/patterns-reference": "^2.11.1",
80
+ "@hyperfixi/server-bridge": "^2.11.1",
81
+ "@lokascript/compilation-service": "^2.11.1",
82
+ "@lokascript/framework": "^2.11.1",
83
+ "@lokascript/semantic": "^2.11.1",
129
84
  "@types/node": "^26.1.2",
130
85
  "tsup": "^8.0.0",
131
86
  "tsx": "^4.23.1",