@run-iq/mcp-server 0.1.9 → 0.1.10
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/dist/index.js +198 -205
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import fs from "fs/promises";
|
|
5
|
-
import path2 from "path";
|
|
6
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
6
|
|
|
@@ -43,20 +41,20 @@ var DescriptorRegistry = class {
|
|
|
43
41
|
};
|
|
44
42
|
|
|
45
43
|
// src/engine.ts
|
|
46
|
-
function createEngine(
|
|
47
|
-
const
|
|
44
|
+
function createEngine(bundles2) {
|
|
45
|
+
const descriptorRegistry2 = new DescriptorRegistry();
|
|
48
46
|
const allPlugins = [];
|
|
49
47
|
const allDsls = [];
|
|
50
|
-
if (
|
|
51
|
-
for (const bundle of
|
|
48
|
+
if (bundles2 && bundles2.length > 0) {
|
|
49
|
+
for (const bundle of bundles2) {
|
|
52
50
|
allPlugins.push(bundle.plugin);
|
|
53
|
-
|
|
51
|
+
descriptorRegistry2.register(bundle.descriptor);
|
|
54
52
|
if (bundle.dsls) {
|
|
55
53
|
allDsls.push(...bundle.dsls);
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
|
-
const
|
|
57
|
+
const engine2 = new PPEEngine({
|
|
60
58
|
plugins: allPlugins,
|
|
61
59
|
dsls: allDsls,
|
|
62
60
|
dryRun: true,
|
|
@@ -64,72 +62,108 @@ function createEngine(bundles) {
|
|
|
64
62
|
onConflict: "first",
|
|
65
63
|
onChecksumMismatch: "skip"
|
|
66
64
|
});
|
|
67
|
-
const
|
|
65
|
+
const models2 = /* @__PURE__ */ new Map();
|
|
68
66
|
for (const plugin of allPlugins) {
|
|
69
67
|
const pluginWithModels = plugin;
|
|
70
68
|
if (Array.isArray(pluginWithModels.models)) {
|
|
71
69
|
for (const model of pluginWithModels.models) {
|
|
72
|
-
|
|
70
|
+
models2.set(model.name, model);
|
|
73
71
|
}
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
|
-
return { engine, models, descriptorRegistry, plugins: allPlugins, dsls: allDsls };
|
|
74
|
+
return { engine: engine2, models: models2, descriptorRegistry: descriptorRegistry2, plugins: allPlugins, dsls: allDsls };
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
// src/loader/plugin-loader.ts
|
|
78
|
+
import { execSync } from "child_process";
|
|
79
|
+
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
80
80
|
import { readdir } from "fs/promises";
|
|
81
|
-
import { resolve } from "path";
|
|
82
|
-
import path from "path";
|
|
81
|
+
import { resolve, join } from "path";
|
|
83
82
|
import { pathToFileURL } from "url";
|
|
84
83
|
import { createRequire } from "module";
|
|
84
|
+
import { homedir } from "os";
|
|
85
85
|
var require2 = createRequire(import.meta.url);
|
|
86
|
+
var AUTO_PLUGINS_DIR = resolve(homedir(), ".run-iq", "mcp-plugins");
|
|
86
87
|
async function loadPluginsFromDir(dir) {
|
|
87
|
-
const
|
|
88
|
+
const bundles2 = [];
|
|
88
89
|
const absoluteDir = resolve(dir);
|
|
90
|
+
if (!existsSync(absoluteDir)) return [];
|
|
89
91
|
const entries = await readdir(absoluteDir, { withFileTypes: true });
|
|
90
92
|
for (const entry of entries) {
|
|
91
|
-
if (!entry.isFile()) continue;
|
|
92
|
-
if (!entry.name.endsWith(".js") && !entry.name.endsWith(".mjs")) continue;
|
|
93
|
+
if (!entry.isFile() || !/\.(mjs|js)$/.test(entry.name)) continue;
|
|
93
94
|
const filePath = resolve(absoluteDir, entry.name);
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
if (bundle["plugin"] && typeof bundle["plugin"] === "object" && bundle["descriptor"] && typeof bundle["descriptor"] === "object") {
|
|
97
|
-
bundles.push(bundle);
|
|
98
|
-
}
|
|
95
|
+
const bundle = await importBundle(pathToFileURL(filePath).href);
|
|
96
|
+
if (bundle) bundles2.push(bundle);
|
|
99
97
|
}
|
|
100
|
-
return
|
|
98
|
+
return bundles2;
|
|
101
99
|
}
|
|
102
100
|
async function loadNpmPlugins(packageNames) {
|
|
103
|
-
const
|
|
101
|
+
const bundles2 = [];
|
|
104
102
|
for (const pkgName of packageNames) {
|
|
105
103
|
try {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
resolvedPath = require2.resolve(pkgName, { paths: [process.cwd()] });
|
|
111
|
-
}
|
|
112
|
-
const mod = await import(pathToFileURL(resolvedPath).href);
|
|
113
|
-
const bundle = mod["default"] ?? mod["bundle"] ?? mod;
|
|
114
|
-
if (bundle && typeof bundle === "object" && bundle["plugin"] && bundle["descriptor"]) {
|
|
115
|
-
bundles.push(bundle);
|
|
104
|
+
const resolvedPath = await resolveOrInstallPlugin(pkgName);
|
|
105
|
+
const bundle = await importBundle(pathToFileURL(resolvedPath).href);
|
|
106
|
+
if (bundle) {
|
|
107
|
+
bundles2.push(bundle);
|
|
116
108
|
} else {
|
|
117
|
-
console.error(
|
|
118
|
-
`[MCP] Invalid PluginBundle exported by "${pkgName}". Expected { plugin, descriptor }. Found keys: ${Object.keys(bundle)}`
|
|
119
|
-
);
|
|
109
|
+
console.error(`[PluginLoader] Invalid PluginBundle in package: ${pkgName}`);
|
|
120
110
|
}
|
|
121
111
|
} catch (err) {
|
|
122
|
-
console.error(`[
|
|
112
|
+
console.error(`[PluginLoader] Failed to load NPM plugin "${pkgName}":`, err instanceof Error ? err.message : err);
|
|
123
113
|
}
|
|
124
114
|
}
|
|
125
|
-
return
|
|
115
|
+
return bundles2;
|
|
116
|
+
}
|
|
117
|
+
async function resolveOrInstallPlugin(pkgName) {
|
|
118
|
+
try {
|
|
119
|
+
return require2.resolve(pkgName, { paths: [process.cwd()] });
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
return require2.resolve(pkgName, { paths: [AUTO_PLUGINS_DIR] });
|
|
124
|
+
} catch {
|
|
125
|
+
}
|
|
126
|
+
ensurePluginsDir();
|
|
127
|
+
console.log(`[PluginLoader] Installing ${pkgName} dynamically...`);
|
|
128
|
+
execSync(`npm install ${pkgName} --no-save`, {
|
|
129
|
+
cwd: AUTO_PLUGINS_DIR,
|
|
130
|
+
stdio: "inherit"
|
|
131
|
+
});
|
|
132
|
+
return require2.resolve(pkgName, { paths: [AUTO_PLUGINS_DIR] });
|
|
133
|
+
}
|
|
134
|
+
function ensurePluginsDir() {
|
|
135
|
+
if (!existsSync(AUTO_PLUGINS_DIR)) {
|
|
136
|
+
mkdirSync(AUTO_PLUGINS_DIR, { recursive: true });
|
|
137
|
+
writeFileSync(
|
|
138
|
+
join(AUTO_PLUGINS_DIR, "package.json"),
|
|
139
|
+
JSON.stringify({ name: "mcp-plugins", private: true, version: "1.0.0" }, null, 2)
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function importBundle(url) {
|
|
144
|
+
try {
|
|
145
|
+
const mod = await import(url);
|
|
146
|
+
let bundle = mod.default ?? mod;
|
|
147
|
+
if (!bundle.plugin && bundle.bundle?.plugin) {
|
|
148
|
+
bundle = bundle.bundle;
|
|
149
|
+
}
|
|
150
|
+
if (isValidBundle(bundle)) {
|
|
151
|
+
return bundle;
|
|
152
|
+
}
|
|
153
|
+
} catch (err) {
|
|
154
|
+
console.error(`[PluginLoader] Import error for ${url}:`, err);
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
function isValidBundle(obj) {
|
|
159
|
+
return obj && typeof obj === "object" && typeof obj.plugin === "object" && typeof obj.descriptor === "object";
|
|
126
160
|
}
|
|
127
161
|
|
|
128
162
|
// src/tools/create-checksum.ts
|
|
129
163
|
import { createHash } from "crypto";
|
|
130
164
|
import { z } from "zod";
|
|
131
|
-
function registerCreateChecksumTool(
|
|
132
|
-
|
|
165
|
+
function registerCreateChecksumTool(server2) {
|
|
166
|
+
server2.tool(
|
|
133
167
|
"create_checksum",
|
|
134
168
|
"Compute the SHA-256 checksum of a params object. Used to generate the checksum field for Run-IQ rules.",
|
|
135
169
|
{ params: z.record(z.unknown()).describe("The params object to hash") },
|
|
@@ -169,7 +203,7 @@ function buildFieldSchema(field) {
|
|
|
169
203
|
}
|
|
170
204
|
return schema.describe(field.description);
|
|
171
205
|
}
|
|
172
|
-
function buildCreateRuleSchema(
|
|
206
|
+
function buildCreateRuleSchema(descriptors2) {
|
|
173
207
|
const shape = {
|
|
174
208
|
id: z2.string().describe("Unique rule identifier"),
|
|
175
209
|
model: z2.string().describe("Calculation model name (e.g. FLAT_RATE, PROGRESSIVE_BRACKET)"),
|
|
@@ -183,16 +217,16 @@ function buildCreateRuleSchema(descriptors) {
|
|
|
183
217
|
value: z2.unknown().describe("DSL-specific condition expression")
|
|
184
218
|
}).optional().describe("Optional condition expression")
|
|
185
219
|
};
|
|
186
|
-
for (const descriptor of
|
|
220
|
+
for (const descriptor of descriptors2) {
|
|
187
221
|
for (const field of descriptor.ruleExtensions) {
|
|
188
222
|
shape[field.name] = buildFieldSchema(field);
|
|
189
223
|
}
|
|
190
224
|
}
|
|
191
225
|
return shape;
|
|
192
226
|
}
|
|
193
|
-
function buildValidateExtensionErrors(rule,
|
|
227
|
+
function buildValidateExtensionErrors(rule, descriptors2) {
|
|
194
228
|
const errors = [];
|
|
195
|
-
for (const descriptor of
|
|
229
|
+
for (const descriptor of descriptors2) {
|
|
196
230
|
for (const field of descriptor.ruleExtensions) {
|
|
197
231
|
const value = rule[field.name];
|
|
198
232
|
if (field.required && (value === void 0 || value === null)) {
|
|
@@ -220,10 +254,10 @@ function buildValidateExtensionErrors(rule, descriptors) {
|
|
|
220
254
|
}
|
|
221
255
|
|
|
222
256
|
// src/tools/create-rule.ts
|
|
223
|
-
function registerCreateRuleTool(
|
|
224
|
-
const schema = buildCreateRuleSchema(
|
|
225
|
-
const extensionFields =
|
|
226
|
-
|
|
257
|
+
function registerCreateRuleTool(server2, descriptors2) {
|
|
258
|
+
const schema = buildCreateRuleSchema(descriptors2);
|
|
259
|
+
const extensionFields = descriptors2.flatMap((d) => d.ruleExtensions.map((f) => f.name));
|
|
260
|
+
server2.tool(
|
|
227
261
|
"create_rule",
|
|
228
262
|
"Generate a valid Run-IQ Rule JSON object with auto-computed SHA-256 checksum. Includes plugin-specific fields based on loaded plugins.",
|
|
229
263
|
schema,
|
|
@@ -271,17 +305,16 @@ var RuleSchema = z3.object({
|
|
|
271
305
|
checksum: z3.string(),
|
|
272
306
|
condition: z3.object({ dsl: z3.string(), value: z3.unknown() }).optional()
|
|
273
307
|
});
|
|
274
|
-
function registerValidateRulesTool(
|
|
275
|
-
|
|
308
|
+
function registerValidateRulesTool(server2, models2, descriptors2) {
|
|
309
|
+
server2.tool(
|
|
276
310
|
"validate_rules",
|
|
277
311
|
"Validate the structure, checksum, model params, and plugin-specific fields of Run-IQ rules.",
|
|
278
312
|
{
|
|
279
|
-
rules: z3.array(z3.record(z3.unknown())).
|
|
313
|
+
rules: z3.array(z3.record(z3.unknown())).describe("Array of Rule JSON objects to validate")
|
|
280
314
|
},
|
|
281
315
|
(args) => {
|
|
282
316
|
const entries = [];
|
|
283
|
-
const
|
|
284
|
-
for (const raw of rulesToValidate) {
|
|
317
|
+
for (const raw of args.rules) {
|
|
285
318
|
const parsed = RuleSchema.safeParse(raw);
|
|
286
319
|
const ruleId = typeof raw["id"] === "string" ? raw["id"] : "unknown";
|
|
287
320
|
if (!parsed.success) {
|
|
@@ -298,10 +331,10 @@ function registerValidateRulesTool(server, models, descriptors, initialRules = [
|
|
|
298
331
|
if (computed !== rule.checksum) {
|
|
299
332
|
errors.push(`Checksum mismatch: expected ${computed}, got ${rule.checksum}`);
|
|
300
333
|
}
|
|
301
|
-
const model =
|
|
334
|
+
const model = models2.get(rule.model);
|
|
302
335
|
if (!model) {
|
|
303
336
|
errors.push(
|
|
304
|
-
`Model "${rule.model}" not found. Available: ${[...
|
|
337
|
+
`Model "${rule.model}" not found. Available: ${[...models2.keys()].join(", ")}`
|
|
305
338
|
);
|
|
306
339
|
} else {
|
|
307
340
|
const validation = model.validateParams(rule.params);
|
|
@@ -309,7 +342,7 @@ function registerValidateRulesTool(server, models, descriptors, initialRules = [
|
|
|
309
342
|
errors.push(...validation.errors);
|
|
310
343
|
}
|
|
311
344
|
}
|
|
312
|
-
const extensionErrors = buildValidateExtensionErrors(raw,
|
|
345
|
+
const extensionErrors = buildValidateExtensionErrors(raw, descriptors2);
|
|
313
346
|
errors.push(...extensionErrors);
|
|
314
347
|
entries.push({
|
|
315
348
|
ruleId: rule.id,
|
|
@@ -325,14 +358,14 @@ function registerValidateRulesTool(server, models, descriptors, initialRules = [
|
|
|
325
358
|
}
|
|
326
359
|
|
|
327
360
|
// src/tools/list-models.ts
|
|
328
|
-
function registerListModelsTool(
|
|
329
|
-
|
|
361
|
+
function registerListModelsTool(server2, models2) {
|
|
362
|
+
server2.tool(
|
|
330
363
|
"list_models",
|
|
331
364
|
"List all available calculation models with their parameter schemas. Shows model name, version, and expected parameters.",
|
|
332
365
|
{},
|
|
333
366
|
() => {
|
|
334
367
|
const result = [];
|
|
335
|
-
for (const [, model] of
|
|
368
|
+
for (const [, model] of models2) {
|
|
336
369
|
const validation = model.validateParams({});
|
|
337
370
|
const paramsSchema = {};
|
|
338
371
|
if (validation.errors) {
|
|
@@ -359,8 +392,8 @@ function registerListModelsTool(server, models) {
|
|
|
359
392
|
// src/tools/evaluate.ts
|
|
360
393
|
import { z as z4 } from "zod";
|
|
361
394
|
import { hydrateRules } from "@run-iq/core";
|
|
362
|
-
function registerEvaluateTool(
|
|
363
|
-
|
|
395
|
+
function registerEvaluateTool(server2, engine2) {
|
|
396
|
+
server2.tool(
|
|
364
397
|
"evaluate",
|
|
365
398
|
"Evaluate Run-IQ rules against input data in dry-run mode. Returns the computed value, breakdown per rule, applied/skipped rules, and execution trace.",
|
|
366
399
|
{
|
|
@@ -379,7 +412,7 @@ function registerEvaluateTool(server, engine, initialRules = []) {
|
|
|
379
412
|
},
|
|
380
413
|
async (args) => {
|
|
381
414
|
try {
|
|
382
|
-
const rules = hydrateRules(
|
|
415
|
+
const rules = hydrateRules(args.rules);
|
|
383
416
|
const input = {
|
|
384
417
|
data: args.input.data,
|
|
385
418
|
requestId: args.input.requestId,
|
|
@@ -388,7 +421,7 @@ function registerEvaluateTool(server, engine, initialRules = []) {
|
|
|
388
421
|
effectiveDate: args.input.meta.effectiveDate ? new Date(args.input.meta.effectiveDate) : void 0
|
|
389
422
|
}
|
|
390
423
|
};
|
|
391
|
-
const result = await
|
|
424
|
+
const result = await engine2.evaluate(rules, input);
|
|
392
425
|
const serializable = {
|
|
393
426
|
value: result.value,
|
|
394
427
|
breakdown: result.breakdown,
|
|
@@ -428,32 +461,22 @@ function registerEvaluateTool(server, engine, initialRules = []) {
|
|
|
428
461
|
// src/tools/inspect-rule.ts
|
|
429
462
|
import { createHash as createHash4 } from "crypto";
|
|
430
463
|
import { z as z5 } from "zod";
|
|
431
|
-
function registerInspectRuleTool(
|
|
432
|
-
|
|
464
|
+
function registerInspectRuleTool(server2, models2, descriptors2) {
|
|
465
|
+
server2.tool(
|
|
433
466
|
"inspect_rule",
|
|
434
467
|
"Analyze a single Run-IQ rule in detail: checksum, model, active dates, params, and plugin-specific fields.",
|
|
435
468
|
{
|
|
436
|
-
rule: z5.record(z5.unknown()).
|
|
437
|
-
ruleId: z5.string().optional().describe("ID of a pre-loaded rule to inspect")
|
|
469
|
+
rule: z5.record(z5.unknown()).describe("A single Rule JSON object to inspect")
|
|
438
470
|
},
|
|
439
471
|
(args) => {
|
|
440
|
-
|
|
441
|
-
if (args.ruleId && !rule) {
|
|
442
|
-
rule = initialRules.find((r) => r.id === args.ruleId);
|
|
443
|
-
}
|
|
444
|
-
if (!rule) {
|
|
445
|
-
return {
|
|
446
|
-
content: [{ type: "text", text: JSON.stringify({ error: 'Rule not found. Provide either "rule" object or "ruleId" of a pre-loaded rule.' }) }],
|
|
447
|
-
isError: true
|
|
448
|
-
};
|
|
449
|
-
}
|
|
472
|
+
const rule = args.rule;
|
|
450
473
|
const id = typeof rule["id"] === "string" ? rule["id"] : "unknown";
|
|
451
474
|
const modelName = typeof rule["model"] === "string" ? rule["model"] : "";
|
|
452
475
|
const params = rule["params"];
|
|
453
476
|
const checksum = typeof rule["checksum"] === "string" ? rule["checksum"] : "";
|
|
454
477
|
const computed = createHash4("sha256").update(JSON.stringify(params)).digest("hex");
|
|
455
478
|
const checksumMatch = computed === checksum;
|
|
456
|
-
const model =
|
|
479
|
+
const model = models2.get(modelName);
|
|
457
480
|
const modelFound = model !== void 0;
|
|
458
481
|
let paramErrors;
|
|
459
482
|
if (model) {
|
|
@@ -462,7 +485,7 @@ function registerInspectRuleTool(server, models, descriptors, initialRules = [])
|
|
|
462
485
|
paramErrors = [...validation.errors];
|
|
463
486
|
}
|
|
464
487
|
}
|
|
465
|
-
const extensionErrors = buildValidateExtensionErrors(rule,
|
|
488
|
+
const extensionErrors = buildValidateExtensionErrors(rule, descriptors2);
|
|
466
489
|
const now = /* @__PURE__ */ new Date();
|
|
467
490
|
const effectiveFrom = typeof rule["effectiveFrom"] === "string" ? new Date(rule["effectiveFrom"]) : null;
|
|
468
491
|
const effectiveUntil = typeof rule["effectiveUntil"] === "string" ? new Date(rule["effectiveUntil"]) : null;
|
|
@@ -526,8 +549,8 @@ var EvaluationResultSchema = {
|
|
|
526
549
|
}).optional()
|
|
527
550
|
}).describe("An EvaluationResult (or simplified result from the evaluate tool)")
|
|
528
551
|
};
|
|
529
|
-
function registerExplainResultTool(
|
|
530
|
-
|
|
552
|
+
function registerExplainResultTool(server2) {
|
|
553
|
+
server2.tool(
|
|
531
554
|
"explain_result",
|
|
532
555
|
"Generate a human-readable explanation of an evaluation result. Summarizes the total value, applied rules with their contributions, skipped rules with reasons, and execution timing.",
|
|
533
556
|
EvaluationResultSchema,
|
|
@@ -592,8 +615,8 @@ var ScenarioSchema = z7.object({
|
|
|
592
615
|
})
|
|
593
616
|
})
|
|
594
617
|
});
|
|
595
|
-
function registerSimulateTool(
|
|
596
|
-
|
|
618
|
+
function registerSimulateTool(server2, engine2) {
|
|
619
|
+
server2.tool(
|
|
597
620
|
"simulate",
|
|
598
621
|
"Compare N scenarios using the same rules. Evaluates each scenario independently and returns side-by-side results for comparison.",
|
|
599
622
|
{
|
|
@@ -602,7 +625,7 @@ function registerSimulateTool(server, engine, initialRules = []) {
|
|
|
602
625
|
},
|
|
603
626
|
async (args) => {
|
|
604
627
|
try {
|
|
605
|
-
const rules = hydrateRules2(
|
|
628
|
+
const rules = hydrateRules2(args.rules);
|
|
606
629
|
const results = [];
|
|
607
630
|
for (const scenario of args.scenarios) {
|
|
608
631
|
const input = {
|
|
@@ -613,7 +636,7 @@ function registerSimulateTool(server, engine, initialRules = []) {
|
|
|
613
636
|
effectiveDate: scenario.input.meta.effectiveDate ? new Date(scenario.input.meta.effectiveDate) : void 0
|
|
614
637
|
}
|
|
615
638
|
};
|
|
616
|
-
const result = await
|
|
639
|
+
const result = await engine2.evaluate(rules, input);
|
|
617
640
|
results.push({
|
|
618
641
|
label: scenario.label,
|
|
619
642
|
value: result.value,
|
|
@@ -641,11 +664,11 @@ function registerSimulateTool(server, engine, initialRules = []) {
|
|
|
641
664
|
}
|
|
642
665
|
|
|
643
666
|
// src/resources/models.ts
|
|
644
|
-
function buildModelsCatalog(
|
|
667
|
+
function buildModelsCatalog(models2) {
|
|
645
668
|
const lines = [];
|
|
646
669
|
lines.push("# Run-IQ Calculation Models");
|
|
647
670
|
lines.push("");
|
|
648
|
-
for (const [, model] of
|
|
671
|
+
for (const [, model] of models2) {
|
|
649
672
|
lines.push(`## ${model.name} (v${model.version})`);
|
|
650
673
|
lines.push("");
|
|
651
674
|
const validation = model.validateParams({});
|
|
@@ -713,15 +736,15 @@ function buildModelsCatalog(models) {
|
|
|
713
736
|
}
|
|
714
737
|
return lines.join("\n");
|
|
715
738
|
}
|
|
716
|
-
function registerModelsResource(
|
|
717
|
-
|
|
739
|
+
function registerModelsResource(server2, models2) {
|
|
740
|
+
server2.resource(
|
|
718
741
|
"models-catalog",
|
|
719
742
|
"models://catalog",
|
|
720
743
|
{
|
|
721
744
|
description: "Documentation of all available calculation models with parameter schemas and usage examples"
|
|
722
745
|
},
|
|
723
746
|
() => {
|
|
724
|
-
const catalog = buildModelsCatalog(
|
|
747
|
+
const catalog = buildModelsCatalog(models2);
|
|
725
748
|
return {
|
|
726
749
|
contents: [
|
|
727
750
|
{
|
|
@@ -736,16 +759,16 @@ function registerModelsResource(server, models) {
|
|
|
736
759
|
}
|
|
737
760
|
|
|
738
761
|
// src/resources/plugins.ts
|
|
739
|
-
function registerPluginsResource(
|
|
740
|
-
|
|
762
|
+
function registerPluginsResource(server2, plugins2, dsls2, registry) {
|
|
763
|
+
server2.resource(
|
|
741
764
|
"plugins-loaded",
|
|
742
765
|
"plugins://loaded",
|
|
743
766
|
{ description: "Information about loaded plugins, DSL evaluators, and their descriptors" },
|
|
744
767
|
() => {
|
|
745
|
-
const
|
|
768
|
+
const descriptors2 = registry.getAll();
|
|
746
769
|
const info = {
|
|
747
|
-
plugins:
|
|
748
|
-
const desc =
|
|
770
|
+
plugins: plugins2.map((p) => {
|
|
771
|
+
const desc = descriptors2.find((d) => d.name === p.name);
|
|
749
772
|
const pluginWithModels = p;
|
|
750
773
|
return {
|
|
751
774
|
name: p.name,
|
|
@@ -755,7 +778,7 @@ function registerPluginsResource(server, plugins, dsls, registry) {
|
|
|
755
778
|
ruleExtensions: desc?.ruleExtensions.map((f) => f.name) ?? []
|
|
756
779
|
};
|
|
757
780
|
}),
|
|
758
|
-
dsls:
|
|
781
|
+
dsls: dsls2.map((d) => ({
|
|
759
782
|
name: d.dsl,
|
|
760
783
|
version: d.version
|
|
761
784
|
}))
|
|
@@ -774,7 +797,7 @@ function registerPluginsResource(server, plugins, dsls, registry) {
|
|
|
774
797
|
}
|
|
775
798
|
|
|
776
799
|
// src/resources/schema.ts
|
|
777
|
-
function buildSchemaDocument(
|
|
800
|
+
function buildSchemaDocument(models2, registry) {
|
|
778
801
|
const lines = [];
|
|
779
802
|
lines.push("# Run-IQ Rule Schema");
|
|
780
803
|
lines.push("");
|
|
@@ -797,11 +820,11 @@ function buildSchemaDocument(models, registry) {
|
|
|
797
820
|
lines.push("| checksum | string | auto | SHA-256 of params (auto-computed by create_rule) |");
|
|
798
821
|
lines.push("| condition | {dsl,value} | optional | DSL condition (e.g. jsonlogic) |");
|
|
799
822
|
lines.push("");
|
|
800
|
-
const
|
|
801
|
-
if (
|
|
823
|
+
const descriptors2 = registry.getAll();
|
|
824
|
+
if (descriptors2.length > 0) {
|
|
802
825
|
lines.push("## Plugin Extension Fields");
|
|
803
826
|
lines.push("");
|
|
804
|
-
for (const desc of
|
|
827
|
+
for (const desc of descriptors2) {
|
|
805
828
|
lines.push(`### ${desc.name} (v${desc.version})`);
|
|
806
829
|
lines.push("");
|
|
807
830
|
lines.push(desc.description);
|
|
@@ -819,7 +842,7 @@ function buildSchemaDocument(models, registry) {
|
|
|
819
842
|
}
|
|
820
843
|
lines.push("## Available Calculation Models");
|
|
821
844
|
lines.push("");
|
|
822
|
-
for (const [, model] of
|
|
845
|
+
for (const [, model] of models2) {
|
|
823
846
|
lines.push(`### ${model.name} (v${model.version})`);
|
|
824
847
|
lines.push("");
|
|
825
848
|
const validation = model.validateParams({});
|
|
@@ -886,8 +909,8 @@ function buildSchemaDocument(models, registry) {
|
|
|
886
909
|
}
|
|
887
910
|
return lines.join("\n");
|
|
888
911
|
}
|
|
889
|
-
function registerSchemaResource(
|
|
890
|
-
|
|
912
|
+
function registerSchemaResource(server2, models2, registry) {
|
|
913
|
+
server2.resource(
|
|
891
914
|
"rule-schema",
|
|
892
915
|
"schema://rules",
|
|
893
916
|
{
|
|
@@ -898,7 +921,7 @@ function registerSchemaResource(server, models, registry) {
|
|
|
898
921
|
{
|
|
899
922
|
uri: "schema://rules",
|
|
900
923
|
mimeType: "text/markdown",
|
|
901
|
-
text: buildSchemaDocument(
|
|
924
|
+
text: buildSchemaDocument(models2, registry)
|
|
902
925
|
}
|
|
903
926
|
]
|
|
904
927
|
})
|
|
@@ -908,13 +931,13 @@ function registerSchemaResource(server, models, registry) {
|
|
|
908
931
|
// src/prompts/analyze-text.ts
|
|
909
932
|
import { z as z8 } from "zod";
|
|
910
933
|
function buildDomainLabel(registry) {
|
|
911
|
-
const
|
|
912
|
-
if (
|
|
913
|
-
return
|
|
934
|
+
const descriptors2 = registry.getAll();
|
|
935
|
+
if (descriptors2.length === 0) return "policy";
|
|
936
|
+
return descriptors2.map((d) => d.domainLabel).join(" / ");
|
|
914
937
|
}
|
|
915
|
-
function buildModelDocs(
|
|
938
|
+
function buildModelDocs(models2) {
|
|
916
939
|
const lines = [];
|
|
917
|
-
for (const [, model] of
|
|
940
|
+
for (const [, model] of models2) {
|
|
918
941
|
const validation = model.validateParams({});
|
|
919
942
|
const paramHints = validation.errors ? validation.errors.join("; ") : "none";
|
|
920
943
|
lines.push(`- **${model.name}** (v${model.version}): ${paramHints}`);
|
|
@@ -922,10 +945,10 @@ function buildModelDocs(models) {
|
|
|
922
945
|
return lines.join("\n");
|
|
923
946
|
}
|
|
924
947
|
function buildExtensionDocs(registry) {
|
|
925
|
-
const
|
|
926
|
-
if (
|
|
948
|
+
const descriptors2 = registry.getAll();
|
|
949
|
+
if (descriptors2.length === 0) return "";
|
|
927
950
|
const lines = [];
|
|
928
|
-
for (const desc of
|
|
951
|
+
for (const desc of descriptors2) {
|
|
929
952
|
lines.push(`
|
|
930
953
|
### Plugin: ${desc.name}`);
|
|
931
954
|
lines.push(desc.description);
|
|
@@ -965,9 +988,9 @@ function buildInputDocs(registry) {
|
|
|
965
988
|
return lines.join("\n");
|
|
966
989
|
}
|
|
967
990
|
function buildGuidelinesSection(registry) {
|
|
968
|
-
const
|
|
991
|
+
const descriptors2 = registry.getAll();
|
|
969
992
|
const lines = [];
|
|
970
|
-
for (const desc of
|
|
993
|
+
for (const desc of descriptors2) {
|
|
971
994
|
if (desc.promptGuidelines.length > 0) {
|
|
972
995
|
lines.push(`
|
|
973
996
|
## ${desc.domainLabel} Guidelines`);
|
|
@@ -978,9 +1001,9 @@ function buildGuidelinesSection(registry) {
|
|
|
978
1001
|
}
|
|
979
1002
|
return lines.join("\n");
|
|
980
1003
|
}
|
|
981
|
-
function registerAnalyzeTextPrompt(
|
|
1004
|
+
function registerAnalyzeTextPrompt(server2, models2, registry) {
|
|
982
1005
|
const domainLabel = buildDomainLabel(registry);
|
|
983
|
-
|
|
1006
|
+
server2.prompt(
|
|
984
1007
|
"analyze-text",
|
|
985
1008
|
`Translate a ${domainLabel} text (law, regulation, policy) into Run-IQ rule definitions. Plugin-aware: includes all required fields.`,
|
|
986
1009
|
{
|
|
@@ -997,7 +1020,7 @@ function registerAnalyzeTextPrompt(server, models, registry) {
|
|
|
997
1020
|
text: `You are an expert at translating regulatory and policy texts into structured Run-IQ rules.
|
|
998
1021
|
|
|
999
1022
|
## Available Calculation Models
|
|
1000
|
-
${buildModelDocs(
|
|
1023
|
+
${buildModelDocs(models2)}
|
|
1001
1024
|
${buildExtensionDocs(registry)}
|
|
1002
1025
|
${buildInputDocs(registry)}
|
|
1003
1026
|
${buildGuidelinesSection(registry)}
|
|
@@ -1031,9 +1054,9 @@ ${args.source_text}`
|
|
|
1031
1054
|
// src/prompts/domain-expert.ts
|
|
1032
1055
|
import { z as z9 } from "zod";
|
|
1033
1056
|
function buildGuidelinesSection2(registry) {
|
|
1034
|
-
const
|
|
1057
|
+
const descriptors2 = registry.getAll();
|
|
1035
1058
|
const allGuidelines = [];
|
|
1036
|
-
for (const desc of
|
|
1059
|
+
for (const desc of descriptors2) {
|
|
1037
1060
|
if (desc.promptGuidelines.length > 0) {
|
|
1038
1061
|
allGuidelines.push(`### ${desc.name} (${desc.domainLabel})`);
|
|
1039
1062
|
for (const g of desc.promptGuidelines) {
|
|
@@ -1046,15 +1069,15 @@ function buildGuidelinesSection2(registry) {
|
|
|
1046
1069
|
${allGuidelines.join("\n")}`;
|
|
1047
1070
|
}
|
|
1048
1071
|
function buildDomainLabel2(registry) {
|
|
1049
|
-
const
|
|
1050
|
-
if (
|
|
1051
|
-
return
|
|
1072
|
+
const descriptors2 = registry.getAll();
|
|
1073
|
+
if (descriptors2.length === 0) return "general-purpose";
|
|
1074
|
+
return descriptors2.map((d) => d.domainLabel).join(" + ");
|
|
1052
1075
|
}
|
|
1053
|
-
function registerDomainExpertPrompt(
|
|
1054
|
-
const
|
|
1076
|
+
function registerDomainExpertPrompt(server2, registry) {
|
|
1077
|
+
const descriptors2 = registry.getAll();
|
|
1055
1078
|
const domainLabel = buildDomainLabel2(registry);
|
|
1056
|
-
const pluginList =
|
|
1057
|
-
|
|
1079
|
+
const pluginList = descriptors2.map((d) => `- ${d.name}: ${d.description}`).join("\n");
|
|
1080
|
+
server2.prompt(
|
|
1058
1081
|
"domain-expert",
|
|
1059
1082
|
`${domainLabel} calculation expertise: scenario comparison, result explanation, recommendations`,
|
|
1060
1083
|
{
|
|
@@ -1167,85 +1190,55 @@ var package_default = {
|
|
|
1167
1190
|
var VERSION = package_default.version;
|
|
1168
1191
|
|
|
1169
1192
|
// src/index.ts
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
} else if (argv[i] === "--plugin" && argv[i + 1]) {
|
|
1181
|
-
npmPlugins.push(argv[i + 1]);
|
|
1182
|
-
i++;
|
|
1183
|
-
} else if (argv[i] === "--rules" && argv[i + 1]) {
|
|
1184
|
-
rulesPath = argv[i + 1];
|
|
1185
|
-
i++;
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
const bundles = [];
|
|
1189
|
-
const initialRules = [];
|
|
1190
|
-
if (pluginsDir) {
|
|
1191
|
-
const dirBundles = await loadPluginsFromDir(pluginsDir);
|
|
1192
|
-
bundles.push(...dirBundles);
|
|
1193
|
-
}
|
|
1194
|
-
if (npmPlugins.length > 0) {
|
|
1195
|
-
const npmBundles = await loadNpmPlugins(npmPlugins);
|
|
1196
|
-
bundles.push(...npmBundles);
|
|
1197
|
-
}
|
|
1198
|
-
const { engine, models, descriptorRegistry, plugins, dsls } = createEngine(bundles);
|
|
1199
|
-
const descriptors = descriptorRegistry.getAll();
|
|
1200
|
-
if (rulesPath) {
|
|
1201
|
-
try {
|
|
1202
|
-
const fullPath = path2.resolve(process.cwd(), rulesPath);
|
|
1203
|
-
const rulesContent = await fs.readFile(fullPath, "utf-8");
|
|
1204
|
-
const loadedRules = JSON.parse(rulesContent);
|
|
1205
|
-
if (Array.isArray(loadedRules)) {
|
|
1206
|
-
initialRules.push(...loadedRules);
|
|
1207
|
-
console.error(`[MCP] Pre-loaded ${initialRules.length} rules from: ${rulesPath}`);
|
|
1208
|
-
}
|
|
1209
|
-
} catch (err) {
|
|
1210
|
-
console.error(`[MCP] Failed to pre-load rules from "${rulesPath}":`, err instanceof Error ? err.message : err);
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
const server = new McpServer(
|
|
1214
|
-
{
|
|
1215
|
-
name: "@run-iq/mcp-server",
|
|
1216
|
-
version: VERSION
|
|
1217
|
-
},
|
|
1218
|
-
{
|
|
1219
|
-
capabilities: {
|
|
1220
|
-
tools: {},
|
|
1221
|
-
resources: {},
|
|
1222
|
-
prompts: {}
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
);
|
|
1226
|
-
registerCreateChecksumTool(server);
|
|
1227
|
-
registerCreateRuleTool(server, descriptors);
|
|
1228
|
-
registerValidateRulesTool(server, models, descriptors, initialRules);
|
|
1229
|
-
registerListModelsTool(server, models);
|
|
1230
|
-
registerEvaluateTool(server, engine, initialRules);
|
|
1231
|
-
registerInspectRuleTool(server, models, descriptors, initialRules);
|
|
1232
|
-
registerExplainResultTool(server);
|
|
1233
|
-
registerSimulateTool(server, engine, initialRules);
|
|
1234
|
-
registerModelsResource(server, models);
|
|
1235
|
-
registerPluginsResource(server, plugins, dsls, descriptorRegistry);
|
|
1236
|
-
registerSchemaResource(server, models, descriptorRegistry);
|
|
1237
|
-
registerAnalyzeTextPrompt(server, models, descriptorRegistry);
|
|
1238
|
-
registerDomainExpertPrompt(server, descriptorRegistry);
|
|
1239
|
-
const transport = new StdioServerTransport();
|
|
1240
|
-
await server.connect(transport);
|
|
1241
|
-
console.error(`[MCP] Server v${VERSION} started successfully with ${bundles.length} plugins.`);
|
|
1242
|
-
} catch (error) {
|
|
1243
|
-
console.error("[MCP] Fatal error during startup:", error);
|
|
1244
|
-
process.exit(1);
|
|
1193
|
+
var pluginsDir;
|
|
1194
|
+
var npmPlugins = [];
|
|
1195
|
+
var argv = process.argv.slice(2);
|
|
1196
|
+
for (let i = 0; i < argv.length; i++) {
|
|
1197
|
+
if (argv[i] === "--plugins-dir" && argv[i + 1]) {
|
|
1198
|
+
pluginsDir = argv[i + 1];
|
|
1199
|
+
i++;
|
|
1200
|
+
} else if (argv[i] === "--plugin" && argv[i + 1]) {
|
|
1201
|
+
npmPlugins.push(argv[i + 1]);
|
|
1202
|
+
i++;
|
|
1245
1203
|
}
|
|
1246
1204
|
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1205
|
+
var bundles = [];
|
|
1206
|
+
if (pluginsDir) {
|
|
1207
|
+
const dirBundles = await loadPluginsFromDir(pluginsDir);
|
|
1208
|
+
bundles.push(...dirBundles);
|
|
1209
|
+
}
|
|
1210
|
+
if (npmPlugins.length > 0) {
|
|
1211
|
+
const npmBundles = await loadNpmPlugins(npmPlugins);
|
|
1212
|
+
bundles.push(...npmBundles);
|
|
1213
|
+
}
|
|
1214
|
+
var { engine, models, descriptorRegistry, plugins, dsls } = createEngine(bundles);
|
|
1215
|
+
var descriptors = descriptorRegistry.getAll();
|
|
1216
|
+
var server = new McpServer(
|
|
1217
|
+
{
|
|
1218
|
+
name: "@run-iq/mcp-server",
|
|
1219
|
+
version: VERSION
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
capabilities: {
|
|
1223
|
+
tools: {},
|
|
1224
|
+
resources: {},
|
|
1225
|
+
prompts: {}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
);
|
|
1229
|
+
registerCreateChecksumTool(server);
|
|
1230
|
+
registerCreateRuleTool(server, descriptors);
|
|
1231
|
+
registerValidateRulesTool(server, models, descriptors);
|
|
1232
|
+
registerListModelsTool(server, models);
|
|
1233
|
+
registerEvaluateTool(server, engine);
|
|
1234
|
+
registerInspectRuleTool(server, models, descriptors);
|
|
1235
|
+
registerExplainResultTool(server);
|
|
1236
|
+
registerSimulateTool(server, engine);
|
|
1237
|
+
registerModelsResource(server, models);
|
|
1238
|
+
registerPluginsResource(server, plugins, dsls, descriptorRegistry);
|
|
1239
|
+
registerSchemaResource(server, models, descriptorRegistry);
|
|
1240
|
+
registerAnalyzeTextPrompt(server, models, descriptorRegistry);
|
|
1241
|
+
registerDomainExpertPrompt(server, descriptorRegistry);
|
|
1242
|
+
var transport = new StdioServerTransport();
|
|
1243
|
+
await server.connect(transport);
|
|
1251
1244
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/engine.ts","../src/descriptors/registry.ts","../src/loader/plugin-loader.ts","../src/tools/create-checksum.ts","../src/tools/create-rule.ts","../src/tools/schema-builder.ts","../src/tools/validate.ts","../src/tools/list-models.ts","../src/tools/evaluate.ts","../src/tools/inspect-rule.ts","../src/tools/explain.ts","../src/tools/simulate.ts","../src/resources/models.ts","../src/resources/plugins.ts","../src/resources/schema.ts","../src/prompts/analyze-text.ts","../src/prompts/domain-expert.ts","../package.json","../src/utils/version.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { PluginBundle } from '@run-iq/plugin-sdk';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { createEngine } from './engine.js';\nimport { loadPluginsFromDir, loadNpmPlugins } from './loader/plugin-loader.js';\nimport { registerCreateChecksumTool } from './tools/create-checksum.js';\nimport { registerCreateRuleTool } from './tools/create-rule.js';\nimport { registerValidateRulesTool } from './tools/validate.js';\nimport { registerListModelsTool } from './tools/list-models.js';\nimport { registerEvaluateTool } from './tools/evaluate.js';\nimport { registerInspectRuleTool } from './tools/inspect-rule.js';\nimport { registerExplainResultTool } from './tools/explain.js';\nimport { registerSimulateTool } from './tools/simulate.js';\nimport { registerModelsResource } from './resources/models.js';\nimport { registerPluginsResource } from './resources/plugins.js';\nimport { registerSchemaResource } from './resources/schema.js';\nimport { registerAnalyzeTextPrompt } from './prompts/analyze-text.js';\nimport { registerDomainExpertPrompt } from './prompts/domain-expert.js';\nimport { VERSION } from './utils/version.js';\n\nasync function main() {\n try {\n let pluginsDir: string | undefined;\n let rulesPath: string | undefined;\n const npmPlugins: string[] = [];\n const argv = process.argv.slice(2);\n for (let i = 0; i < argv.length; i++) {\n if (argv[i] === '--plugins-dir' && argv[i + 1]) {\n pluginsDir = argv[i + 1];\n i++;\n } else if (argv[i] === '--plugin' && argv[i + 1]) {\n npmPlugins.push(argv[i + 1]!);\n i++;\n } else if (argv[i] === '--rules' && argv[i + 1]) {\n rulesPath = argv[i + 1];\n i++;\n }\n }\n\n // Load plugin bundles\n const bundles: PluginBundle[] = [];\n const initialRules: any[] = [];\n if (pluginsDir) {\n const dirBundles = await loadPluginsFromDir(pluginsDir);\n bundles.push(...dirBundles);\n }\n if (npmPlugins.length > 0) {\n const npmBundles = await loadNpmPlugins(npmPlugins);\n bundles.push(...npmBundles);\n }\n\n const { engine, models, descriptorRegistry, plugins, dsls } = createEngine(bundles);\n const descriptors = descriptorRegistry.getAll();\n\n // Pre-load rules if --rules is provided\n if (rulesPath) {\n try {\n const fullPath = path.resolve(process.cwd(), rulesPath);\n const rulesContent = await fs.readFile(fullPath, 'utf-8');\n const loadedRules = JSON.parse(rulesContent);\n if (Array.isArray(loadedRules)) {\n initialRules.push(...loadedRules);\n console.error(`[MCP] Pre-loaded ${initialRules.length} rules from: ${rulesPath}`);\n }\n } catch (err) {\n console.error(`[MCP] Failed to pre-load rules from \"${rulesPath}\":`, err instanceof Error ? err.message : err);\n }\n }\n\n const server = new McpServer(\n {\n name: '@run-iq/mcp-server',\n version: VERSION,\n },\n {\n capabilities: {\n tools: {},\n resources: {},\n prompts: {},\n },\n },\n );\n\n // Tools\n registerCreateChecksumTool(server);\n registerCreateRuleTool(server, descriptors);\n registerValidateRulesTool(server, models, descriptors, initialRules);\n registerListModelsTool(server, models);\n registerEvaluateTool(server, engine, initialRules);\n registerInspectRuleTool(server, models, descriptors, initialRules);\n registerExplainResultTool(server);\n registerSimulateTool(server, engine, initialRules);\n\n // Resources\n registerModelsResource(server, models);\n registerPluginsResource(server, plugins, dsls, descriptorRegistry);\n registerSchemaResource(server, models, descriptorRegistry);\n\n // Prompts\n registerAnalyzeTextPrompt(server, models, descriptorRegistry);\n registerDomainExpertPrompt(server, descriptorRegistry);\n\n // Start stdio transport\n const transport = new StdioServerTransport();\n await server.connect(transport);\n \n // Log successful boot to stderr\n console.error(`[MCP] Server v${VERSION} started successfully with ${bundles.length} plugins.`);\n \n } catch (error) {\n console.error('[MCP] Fatal error during startup:', error);\n process.exit(1);\n }\n}\n\nmain().catch((err) => {\n console.error('[MCP] Unhandled promise rejection during startup:', err);\n process.exit(1);\n});\n","import { PPEEngine } from '@run-iq/core';\nimport type { PPEPlugin, DSLEvaluator, CalculationModel } from '@run-iq/core';\nimport type { PluginBundle } from '@run-iq/plugin-sdk';\nimport { DescriptorRegistry } from './descriptors/registry.js';\n\nexport interface EngineContext {\n readonly engine: PPEEngine;\n readonly models: ReadonlyMap<string, CalculationModel>;\n readonly descriptorRegistry: DescriptorRegistry;\n readonly plugins: readonly PPEPlugin[];\n readonly dsls: readonly DSLEvaluator[];\n}\n\nexport function createEngine(bundles?: readonly PluginBundle[]): EngineContext {\n const descriptorRegistry = new DescriptorRegistry();\n const allPlugins: PPEPlugin[] = [];\n const allDsls: DSLEvaluator[] = [];\n\n if (bundles && bundles.length > 0) {\n for (const bundle of bundles) {\n allPlugins.push(bundle.plugin);\n descriptorRegistry.register(bundle.descriptor);\n if (bundle.dsls) {\n allDsls.push(...bundle.dsls);\n }\n }\n }\n\n const engine = new PPEEngine({\n plugins: allPlugins,\n dsls: allDsls,\n dryRun: true,\n strict: false,\n onConflict: 'first',\n onChecksumMismatch: 'skip',\n });\n\n // Build model map from plugins that expose a models property (BasePlugin pattern)\n const models = new Map<string, CalculationModel>();\n for (const plugin of allPlugins) {\n const pluginWithModels = plugin as { models?: CalculationModel[] };\n if (Array.isArray(pluginWithModels.models)) {\n for (const model of pluginWithModels.models) {\n models.set(model.name, model);\n }\n }\n }\n\n return { engine, models, descriptorRegistry, plugins: allPlugins, dsls: allDsls };\n}\n","import type {\n PluginDescriptor,\n RuleFieldDescriptor,\n InputFieldDescriptor,\n RuleExample,\n} from '@run-iq/plugin-sdk';\n\nexport class DescriptorRegistry {\n private readonly descriptors: PluginDescriptor[] = [];\n\n register(descriptor: PluginDescriptor): void {\n this.descriptors.push(descriptor);\n }\n\n getAll(): readonly PluginDescriptor[] {\n return this.descriptors;\n }\n\n getRuleExtensions(): readonly RuleFieldDescriptor[] {\n return this.descriptors.flatMap((d) => d.ruleExtensions);\n }\n\n getInputFields(): readonly InputFieldDescriptor[] {\n const seen = new Set<string>();\n const fields: InputFieldDescriptor[] = [];\n for (const d of this.descriptors) {\n for (const f of d.inputFields) {\n if (!seen.has(f.name)) {\n seen.add(f.name);\n fields.push(f);\n }\n }\n }\n return fields;\n }\n\n getExamples(): readonly RuleExample[] {\n return this.descriptors.flatMap((d) => d.examples);\n }\n\n isEmpty(): boolean {\n return this.descriptors.length === 0;\n }\n}\n","import { readdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { createRequire } from 'node:module';\nimport type { PluginBundle } from '@run-iq/plugin-sdk';\n\nconst require = createRequire(import.meta.url);\n\nexport async function loadPluginsFromDir(dir: string): Promise<PluginBundle[]> {\n const bundles: PluginBundle[] = [];\n const absoluteDir = resolve(dir);\n const entries = await readdir(absoluteDir, { withFileTypes: true });\n\n for (const entry of entries) {\n if (!entry.isFile()) continue;\n if (!entry.name.endsWith('.js') && !entry.name.endsWith('.mjs')) continue;\n\n const filePath = resolve(absoluteDir, entry.name);\n const mod: Record<string, unknown> = await import(filePath);\n\n const bundle = (mod['default'] ?? mod) as Record<string, unknown>;\n\n if (\n bundle['plugin'] &&\n typeof bundle['plugin'] === 'object' &&\n bundle['descriptor'] &&\n typeof bundle['descriptor'] === 'object'\n ) {\n bundles.push(bundle as unknown as PluginBundle);\n }\n }\n\n return bundles;\n}\n\nexport async function loadNpmPlugins(packageNames: string[]): Promise<PluginBundle[]> {\n const bundles: PluginBundle[] = [];\n\n for (const pkgName of packageNames) {\n try {\n let resolvedPath: string;\n \n // If it looks like a local path, resolve it relative to CWD\n if (pkgName.startsWith('.') || pkgName.startsWith('/') || pkgName.includes(':')) {\n resolvedPath = path.resolve(process.cwd(), pkgName);\n } else {\n // Otherwise treat as an NPM package name\n resolvedPath = require.resolve(pkgName, { paths: [process.cwd()] });\n }\n\n const mod = await import(pathToFileURL(resolvedPath).href);\n\n // Handle various export patterns (ESM default, CJS module.exports, or named 'bundle')\n const bundle = (mod['default'] ?? mod['bundle'] ?? mod) as Record<string, unknown>;\n\n if (bundle && typeof bundle === 'object' && bundle['plugin'] && bundle['descriptor']) {\n bundles.push(bundle as unknown as PluginBundle);\n } else {\n // eslint-disable-next-line no-console\n console.error(\n `[MCP] Invalid PluginBundle exported by \"${pkgName}\". Expected { plugin, descriptor }. Found keys: ${Object.keys(bundle)}`,\n );\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(`[MCP] Failed to load plugin \"${pkgName}\":`, err instanceof Error ? err.message : err);\n }\n }\n\n return bundles;\n}\n","import { createHash } from 'node:crypto';\nimport { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerCreateChecksumTool(server: McpServer): void {\n server.tool(\n 'create_checksum',\n 'Compute the SHA-256 checksum of a params object. Used to generate the checksum field for Run-IQ rules.',\n { params: z.record(z.unknown()).describe('The params object to hash') },\n (args) => {\n const checksum = createHash('sha256').update(JSON.stringify(args.params)).digest('hex');\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ checksum }, null, 2) }],\n };\n },\n );\n}\n","import { createHash } from 'node:crypto';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { PluginDescriptor } from '@run-iq/plugin-sdk';\nimport { buildCreateRuleSchema } from './schema-builder.js';\n\nexport function registerCreateRuleTool(\n server: McpServer,\n descriptors: readonly PluginDescriptor[],\n): void {\n const schema = buildCreateRuleSchema(descriptors);\n\n // Collect plugin extension field names\n const extensionFields = descriptors.flatMap((d) => d.ruleExtensions.map((f) => f.name));\n\n server.tool(\n 'create_rule',\n 'Generate a valid Run-IQ Rule JSON object with auto-computed SHA-256 checksum. Includes plugin-specific fields based on loaded plugins.',\n schema,\n (args: Record<string, unknown>) => {\n const params = args['params'] as Record<string, unknown>;\n const checksum = createHash('sha256').update(JSON.stringify(params)).digest('hex');\n\n const rule: Record<string, unknown> = {\n id: args['id'],\n version: 1,\n model: args['model'],\n params,\n priority: (args['priority'] as number | undefined) ?? 1000,\n effectiveFrom: args['effectiveFrom'],\n effectiveUntil: args['effectiveUntil'] ?? null,\n tags: (args['tags'] as string[] | undefined) ?? [],\n checksum,\n };\n\n if (args['condition']) {\n rule['condition'] = args['condition'];\n }\n\n // Add plugin extension fields\n for (const field of extensionFields) {\n if (args[field] !== undefined) {\n rule[field] = args[field];\n }\n }\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ rule }, null, 2) }],\n };\n },\n );\n}\n","import { z } from 'zod';\nimport type { RuleFieldDescriptor, PluginDescriptor } from '@run-iq/plugin-sdk';\n\nfunction buildFieldSchema(field: RuleFieldDescriptor): z.ZodTypeAny {\n let schema: z.ZodTypeAny;\n\n if (field.enum && field.enum.length > 0) {\n schema = z.enum(field.enum as [string, ...string[]]);\n } else {\n switch (field.type) {\n case 'string':\n schema = z.string();\n break;\n case 'number':\n schema = z.number();\n break;\n case 'boolean':\n schema = z.boolean();\n break;\n }\n }\n\n if (!field.required) {\n schema = schema.optional();\n }\n\n return schema.describe(field.description);\n}\n\nexport function buildCreateRuleSchema(\n descriptors: readonly PluginDescriptor[],\n): Record<string, z.ZodTypeAny> {\n const shape: Record<string, z.ZodTypeAny> = {\n id: z.string().describe('Unique rule identifier'),\n model: z.string().describe('Calculation model name (e.g. FLAT_RATE, PROGRESSIVE_BRACKET)'),\n params: z.record(z.unknown()).describe('Model-specific parameters'),\n priority: z\n .number()\n .int()\n .optional()\n .describe('Rule priority (may be auto-computed by plugins, e.g. from jurisdiction+scope)'),\n effectiveFrom: z.string().describe('ISO 8601 date string for when the rule becomes active'),\n effectiveUntil: z\n .string()\n .nullable()\n .optional()\n .describe('ISO 8601 date string for when the rule expires (null = no expiry)'),\n tags: z.array(z.string()).optional().describe('Optional tags for filtering'),\n condition: z\n .object({\n dsl: z.string().describe('DSL identifier (e.g. \"jsonlogic\")'),\n value: z.unknown().describe('DSL-specific condition expression'),\n })\n .optional()\n .describe('Optional condition expression'),\n };\n\n for (const descriptor of descriptors) {\n for (const field of descriptor.ruleExtensions) {\n shape[field.name] = buildFieldSchema(field);\n }\n }\n\n return shape;\n}\n\nexport function buildValidateExtensionErrors(\n rule: Record<string, unknown>,\n descriptors: readonly PluginDescriptor[],\n): string[] {\n const errors: string[] = [];\n\n for (const descriptor of descriptors) {\n for (const field of descriptor.ruleExtensions) {\n const value = rule[field.name];\n\n if (field.required && (value === undefined || value === null)) {\n errors.push(`\"${field.name}\" is required by ${descriptor.name}: ${field.description}`);\n continue;\n }\n\n if (value === undefined || value === null) continue;\n\n if (field.enum && !field.enum.includes(String(value))) {\n errors.push(\n `\"${field.name}\" must be one of: ${field.enum.join(', ')} (got \"${String(value)}\")`,\n );\n }\n\n if (field.type === 'string' && typeof value !== 'string') {\n errors.push(`\"${field.name}\" must be a string`);\n }\n if (field.type === 'number' && typeof value !== 'number') {\n errors.push(`\"${field.name}\" must be a number`);\n }\n if (field.type === 'boolean' && typeof value !== 'boolean') {\n errors.push(`\"${field.name}\" must be a boolean`);\n }\n }\n }\n\n return errors;\n}\n","import { createHash } from 'node:crypto';\nimport { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CalculationModel } from '@run-iq/core';\nimport type { PluginDescriptor } from '@run-iq/plugin-sdk';\nimport { buildValidateExtensionErrors } from './schema-builder.js';\n\nconst RuleSchema = z.object({\n id: z.string(),\n version: z.number(),\n model: z.string(),\n params: z.unknown(),\n priority: z.number().optional(),\n effectiveFrom: z.string(),\n effectiveUntil: z.string().nullable(),\n tags: z.array(z.string()),\n checksum: z.string(),\n condition: z.object({ dsl: z.string(), value: z.unknown() }).optional(),\n});\n\ninterface ValidationEntry {\n ruleId: string;\n valid: boolean;\n errors?: string[];\n}\n\nexport function registerValidateRulesTool(\n server: McpServer,\n models: ReadonlyMap<string, CalculationModel>,\n descriptors: readonly PluginDescriptor[],\n initialRules: any[] = [],\n): void {\n server.tool(\n 'validate_rules',\n 'Validate the structure, checksum, model params, and plugin-specific fields of Run-IQ rules.',\n {\n rules: z.array(z.record(z.unknown())).optional().describe('Array of Rule JSON objects to validate'),\n },\n (args) => {\n const entries: ValidationEntry[] = [];\n const rulesToValidate = [...initialRules, ...(args.rules || [])];\n\n for (const raw of rulesToValidate) {\n const parsed = RuleSchema.safeParse(raw);\n const ruleId = typeof raw['id'] === 'string' ? raw['id'] : 'unknown';\n\n if (!parsed.success) {\n entries.push({\n ruleId,\n valid: false,\n errors: parsed.error.errors.map((e) => `${e.path.join('.')}: ${e.message}`),\n });\n continue;\n }\n\n const rule = parsed.data;\n const errors: string[] = [];\n\n // Checksum verification\n const computed = createHash('sha256').update(JSON.stringify(rule.params)).digest('hex');\n if (computed !== rule.checksum) {\n errors.push(`Checksum mismatch: expected ${computed}, got ${rule.checksum}`);\n }\n\n // Model existence\n const model = models.get(rule.model);\n if (!model) {\n errors.push(\n `Model \"${rule.model}\" not found. Available: ${[...models.keys()].join(', ')}`,\n );\n } else {\n // Param validation via model\n const validation = model.validateParams(rule.params);\n if (!validation.valid && validation.errors) {\n errors.push(...validation.errors);\n }\n }\n\n // Plugin extension validation\n const extensionErrors = buildValidateExtensionErrors(raw, descriptors);\n errors.push(...extensionErrors);\n\n entries.push({\n ruleId: rule.id,\n valid: errors.length === 0,\n ...(errors.length > 0 ? { errors } : {}),\n });\n }\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ entries }, null, 2) }],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CalculationModel } from '@run-iq/core';\n\ninterface ModelInfo {\n name: string;\n version: string;\n paramsSchema: Record<string, string>;\n}\n\nexport function registerListModelsTool(\n server: McpServer,\n models: ReadonlyMap<string, CalculationModel>,\n): void {\n server.tool(\n 'list_models',\n 'List all available calculation models with their parameter schemas. Shows model name, version, and expected parameters.',\n {},\n () => {\n const result: ModelInfo[] = [];\n\n for (const [, model] of models) {\n // Infer param schema from validation errors with empty object\n const validation = model.validateParams({});\n const paramsSchema: Record<string, string> = {};\n\n if (validation.errors) {\n for (const error of validation.errors) {\n // Parse error messages like '\"rate\" must be a number' or '\"base\" must be a string'\n const match = error.match(/^\"(\\w+)\"\\s+must be (?:a |an )?(.+)$/);\n if (match?.[1] && match[2]) {\n paramsSchema[match[1]] = match[2];\n }\n }\n }\n\n result.push({\n name: model.name,\n version: model.version,\n paramsSchema,\n });\n }\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ models: result }, null, 2) }],\n };\n },\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { PPEEngine } from '@run-iq/core';\nimport { hydrateRules } from '@run-iq/core';\n\nexport function registerEvaluateTool(server: McpServer, engine: PPEEngine, initialRules: any[] = []): void {\n server.tool(\n 'evaluate',\n 'Evaluate Run-IQ rules against input data in dry-run mode. Returns the computed value, breakdown per rule, applied/skipped rules, and execution trace.',\n {\n rules: z.array(z.record(z.unknown())).describe('Array of Rule JSON objects'),\n input: z\n .object({\n data: z.record(z.unknown()).describe('Input data for evaluation'),\n requestId: z.string().describe('Unique request identifier'),\n meta: z.object({\n tenantId: z.string().describe('Tenant identifier'),\n userId: z.string().optional().describe('User identifier'),\n tags: z.array(z.string()).optional().describe('Tags for rule filtering'),\n context: z.record(z.unknown()).optional().describe('Additional context'),\n effectiveDate: z\n .string()\n .optional()\n .describe('ISO 8601 date for effective date evaluation'),\n }),\n })\n .describe('Evaluation input'),\n },\n async (args) => {\n try {\n const rules = hydrateRules([...initialRules, ...(args.rules || [])]);\n\n const input = {\n data: args.input.data,\n requestId: args.input.requestId,\n meta: {\n ...args.input.meta,\n effectiveDate: args.input.meta.effectiveDate\n ? new Date(args.input.meta.effectiveDate)\n : undefined,\n },\n };\n\n const result = await engine.evaluate(rules, input);\n\n const serializable = {\n value: result.value,\n breakdown: result.breakdown,\n appliedRules: result.appliedRules.map((r) => ({\n id: r.id,\n model: r.model,\n priority: r.priority,\n })),\n skippedRules: result.skippedRules.map((s) => ({\n ruleId: s.rule.id,\n reason: s.reason,\n })),\n trace: {\n steps: result.trace.steps.map((s) => ({\n ruleId: s.ruleId,\n modelUsed: s.modelUsed,\n contribution: s.contribution,\n durationMs: s.durationMs,\n })),\n totalDurationMs: result.trace.totalDurationMs,\n },\n };\n\n return {\n content: [{ type: 'text', text: JSON.stringify(serializable, null, 2) }],\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: 'text', text: JSON.stringify({ error: message }) }],\n isError: true,\n };\n }\n },\n );\n}\n","import { createHash } from 'node:crypto';\nimport { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CalculationModel } from '@run-iq/core';\nimport type { PluginDescriptor } from '@run-iq/plugin-sdk';\nimport { buildValidateExtensionErrors } from './schema-builder.js';\n\nexport function registerInspectRuleTool(\n server: McpServer,\n models: ReadonlyMap<string, CalculationModel>,\n descriptors: readonly PluginDescriptor[],\n initialRules: any[] = [],\n): void {\n server.tool(\n 'inspect_rule',\n 'Analyze a single Run-IQ rule in detail: checksum, model, active dates, params, and plugin-specific fields.',\n {\n rule: z.record(z.unknown()).optional().describe('A single Rule JSON object to inspect'),\n ruleId: z.string().optional().describe('ID of a pre-loaded rule to inspect'),\n },\n (args) => {\n let rule = args.rule;\n\n // If ruleId provided, find it in initialRules\n if (args.ruleId && !rule) {\n rule = initialRules.find((r) => r.id === args.ruleId);\n }\n\n if (!rule) {\n return {\n content: [{ type: 'text', text: JSON.stringify({ error: 'Rule not found. Provide either \"rule\" object or \"ruleId\" of a pre-loaded rule.' }) }],\n isError: true,\n };\n }\n\n const id = typeof rule['id'] === 'string' ? rule['id'] : 'unknown';\n const modelName = typeof rule['model'] === 'string' ? rule['model'] : '';\n const params = rule['params'];\n const checksum = typeof rule['checksum'] === 'string' ? rule['checksum'] : '';\n\n // Checksum match\n const computed = createHash('sha256').update(JSON.stringify(params)).digest('hex');\n const checksumMatch = computed === checksum;\n\n // Model found\n const model = models.get(modelName);\n const modelFound = model !== undefined;\n\n // Param validation\n let paramErrors: string[] | undefined;\n if (model) {\n const validation = model.validateParams(params);\n if (!validation.valid && validation.errors) {\n paramErrors = [...validation.errors];\n }\n }\n\n // Plugin extension validation\n const extensionErrors = buildValidateExtensionErrors(rule, descriptors);\n\n // Active date check\n const now = new Date();\n const effectiveFrom =\n typeof rule['effectiveFrom'] === 'string' ? new Date(rule['effectiveFrom']) : null;\n const effectiveUntil =\n typeof rule['effectiveUntil'] === 'string' ? new Date(rule['effectiveUntil']) : null;\n\n const isActive =\n effectiveFrom !== null &&\n effectiveFrom <= now &&\n (effectiveUntil === null || effectiveUntil > now);\n\n const effectivePeriod = {\n from: effectiveFrom?.toISOString() ?? null,\n until: effectiveUntil?.toISOString() ?? null,\n };\n\n const allErrors = [...(paramErrors ?? []), ...extensionErrors];\n const valid = checksumMatch && modelFound && allErrors.length === 0 && isActive;\n\n const result: Record<string, unknown> = {\n ruleId: id,\n valid,\n checksumMatch,\n modelFound,\n isActive,\n effectivePeriod,\n };\n\n if (paramErrors && paramErrors.length > 0) {\n result['paramErrors'] = paramErrors;\n }\n if (extensionErrors.length > 0) {\n result['extensionErrors'] = extensionErrors;\n }\n\n return {\n content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],\n };\n },\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nconst EvaluationResultSchema = {\n result: z\n .object({\n value: z.unknown(),\n breakdown: z.array(\n z.object({\n ruleId: z.string(),\n contribution: z.unknown(),\n modelUsed: z.string(),\n label: z.string().optional(),\n }),\n ),\n appliedRules: z.array(\n z.object({\n id: z.string(),\n model: z.string(),\n priority: z.number(),\n }),\n ),\n skippedRules: z.array(\n z.object({\n ruleId: z.string(),\n reason: z.string(),\n }),\n ),\n trace: z\n .object({\n totalDurationMs: z.number(),\n steps: z.array(z.record(z.unknown())).optional(),\n })\n .optional(),\n })\n .describe('An EvaluationResult (or simplified result from the evaluate tool)'),\n};\n\nexport function registerExplainResultTool(server: McpServer): void {\n server.tool(\n 'explain_result',\n 'Generate a human-readable explanation of an evaluation result. Summarizes the total value, applied rules with their contributions, skipped rules with reasons, and execution timing.',\n EvaluationResultSchema,\n (args) => {\n const { result } = args;\n const lines: string[] = [];\n\n lines.push(`## Evaluation Result Summary`);\n lines.push('');\n lines.push(`**Total Value**: ${String(result.value)}`);\n lines.push('');\n\n // Applied rules\n if (result.appliedRules.length > 0) {\n lines.push(`### Applied Rules (${result.appliedRules.length})`);\n lines.push('');\n\n for (const applied of result.appliedRules) {\n const breakdown = result.breakdown.find((b) => b.ruleId === applied.id);\n const contribution = breakdown ? String(breakdown.contribution) : 'N/A';\n const label = breakdown?.label ? ` (${breakdown.label})` : '';\n\n lines.push(\n `- **${applied.id}**${label}: model=${applied.model}, priority=${applied.priority}, contribution=${contribution}`,\n );\n }\n lines.push('');\n } else {\n lines.push('### No rules were applied.');\n lines.push('');\n }\n\n // Skipped rules\n if (result.skippedRules.length > 0) {\n lines.push(`### Skipped Rules (${result.skippedRules.length})`);\n lines.push('');\n\n for (const skipped of result.skippedRules) {\n lines.push(`- **${skipped.ruleId}**: ${skipped.reason}`);\n }\n lines.push('');\n }\n\n // Timing\n if (result.trace?.totalDurationMs !== undefined) {\n lines.push(`### Timing`);\n lines.push('');\n lines.push(`Total duration: ${result.trace.totalDurationMs}ms`);\n }\n\n const explanation = lines.join('\\n');\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ explanation }, null, 2) }],\n };\n },\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { PPEEngine } from '@run-iq/core';\nimport { hydrateRules } from '@run-iq/core';\n\nconst ScenarioSchema = z.object({\n label: z.string().describe('Human-readable scenario label'),\n input: z.object({\n data: z.record(z.unknown()),\n requestId: z.string(),\n meta: z.object({\n tenantId: z.string(),\n userId: z.string().optional(),\n tags: z.array(z.string()).optional(),\n context: z.record(z.unknown()).optional(),\n effectiveDate: z.string().optional(),\n }),\n }),\n});\n\nexport function registerSimulateTool(server: McpServer, engine: PPEEngine, initialRules: any[] = []): void {\n server.tool(\n 'simulate',\n 'Compare N scenarios using the same rules. Evaluates each scenario independently and returns side-by-side results for comparison.',\n {\n rules: z\n .array(z.record(z.unknown()))\n .describe('Array of Rule JSON objects (shared across all scenarios)'),\n scenarios: z.array(ScenarioSchema).min(1).describe('Array of scenarios to compare'),\n },\n async (args) => {\n try {\n const rules = hydrateRules([...initialRules, ...(args.rules || [])]);\n\n const results = [];\n for (const scenario of args.scenarios) {\n const input = {\n data: scenario.input.data,\n requestId: scenario.input.requestId,\n meta: {\n ...scenario.input.meta,\n effectiveDate: scenario.input.meta.effectiveDate\n ? new Date(scenario.input.meta.effectiveDate)\n : undefined,\n },\n };\n\n const result = await engine.evaluate(rules, input);\n\n results.push({\n label: scenario.label,\n value: result.value,\n appliedCount: result.appliedRules.length,\n skippedCount: result.skippedRules.length,\n breakdown: result.breakdown.map((b) => ({\n ruleId: b.ruleId,\n contribution: b.contribution,\n modelUsed: b.modelUsed,\n })),\n });\n }\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ results }, null, 2) }],\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: 'text', text: JSON.stringify({ error: message }) }],\n isError: true,\n };\n }\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CalculationModel } from '@run-iq/core';\n\nfunction buildModelsCatalog(models: ReadonlyMap<string, CalculationModel>): string {\n const lines: string[] = [];\n\n lines.push('# Run-IQ Calculation Models');\n lines.push('');\n\n for (const [, model] of models) {\n lines.push(`## ${model.name} (v${model.version})`);\n lines.push('');\n\n // Infer params from validation errors\n const validation = model.validateParams({});\n if (validation.errors) {\n lines.push('### Parameters');\n lines.push('');\n for (const error of validation.errors) {\n lines.push(`- ${error}`);\n }\n lines.push('');\n }\n\n // Model-specific documentation\n switch (model.name) {\n case 'FLAT_RATE':\n lines.push('Applies a flat rate to a base value: `base_value * rate`.');\n lines.push('');\n lines.push('**Example params**: `{ \"rate\": 0.18, \"base\": \"revenue\" }`');\n lines.push('**Use case**: TVA, flat tax rates.');\n break;\n case 'PROGRESSIVE_BRACKET':\n lines.push(\n 'Applies progressive tax brackets cumulatively. Each bracket taxes only the portion within its range.',\n );\n lines.push('');\n lines.push(\n '**Example params**: `{ \"base\": \"income\", \"brackets\": [{ \"from\": 0, \"to\": 500000, \"rate\": 0 }, { \"from\": 500000, \"to\": 1000000, \"rate\": 0.1 }] }`',\n );\n lines.push('**Use case**: IRPP (income tax), progressive taxes.');\n break;\n case 'MINIMUM_TAX':\n lines.push('Computes `MAX(base_value * rate, minimum)`. Ensures a minimum tax amount.');\n lines.push('');\n lines.push('**Example params**: `{ \"rate\": 0.01, \"base\": \"revenue\", \"minimum\": 50000 }`');\n lines.push('**Use case**: Minimum corporate tax.');\n break;\n case 'THRESHOLD_BASED':\n lines.push(\n 'Applies a rate only when the base value exceeds a threshold. If `above_only` is true, taxes only the amount above the threshold.',\n );\n lines.push('');\n lines.push(\n '**Example params**: `{ \"base\": \"revenue\", \"threshold\": 1000000, \"rate\": 0.05, \"above_only\": true }`',\n );\n lines.push('**Use case**: Luxury tax, excess profit tax.');\n break;\n case 'FIXED_AMOUNT':\n lines.push('Returns a fixed amount regardless of input values.');\n lines.push('');\n lines.push('**Example params**: `{ \"amount\": 25000, \"currency\": \"XOF\" }`');\n lines.push('**Use case**: Fixed registration fees, stamps.');\n break;\n case 'COMPOSITE':\n lines.push(\n 'Combines multiple sub-models using an aggregation function (SUM, MAX, or MIN).',\n );\n lines.push('');\n lines.push(\n '**Example params**: `{ \"steps\": [{ \"model\": \"FLAT_RATE\", \"params\": { \"rate\": 0.18, \"base\": \"revenue\" } }], \"aggregation\": \"SUM\" }`',\n );\n lines.push('**Use case**: Complex tax calculations combining multiple methods.');\n break;\n }\n\n lines.push('');\n lines.push('---');\n lines.push('');\n }\n\n return lines.join('\\n');\n}\n\nexport function registerModelsResource(\n server: McpServer,\n models: ReadonlyMap<string, CalculationModel>,\n): void {\n server.resource(\n 'models-catalog',\n 'models://catalog',\n {\n description:\n 'Documentation of all available calculation models with parameter schemas and usage examples',\n },\n () => {\n const catalog = buildModelsCatalog(models);\n return {\n contents: [\n {\n uri: 'models://catalog',\n mimeType: 'text/markdown',\n text: catalog,\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { PPEPlugin, DSLEvaluator } from '@run-iq/core';\nimport type { DescriptorRegistry } from '../descriptors/registry.js';\n\nexport function registerPluginsResource(\n server: McpServer,\n plugins: readonly PPEPlugin[],\n dsls: readonly DSLEvaluator[],\n registry: DescriptorRegistry,\n): void {\n server.resource(\n 'plugins-loaded',\n 'plugins://loaded',\n { description: 'Information about loaded plugins, DSL evaluators, and their descriptors' },\n () => {\n const descriptors = registry.getAll();\n\n const info = {\n plugins: plugins.map((p) => {\n const desc = descriptors.find((d) => d.name === p.name);\n const pluginWithModels = p as { models?: { name: string }[] };\n return {\n name: p.name,\n version: p.version,\n models: Array.isArray(pluginWithModels.models)\n ? pluginWithModels.models.map((m) => m.name)\n : [],\n hasDescriptor: desc !== undefined,\n ruleExtensions: desc?.ruleExtensions.map((f) => f.name) ?? [],\n };\n }),\n dsls: dsls.map((d) => ({\n name: d.dsl,\n version: d.version,\n })),\n };\n\n return {\n contents: [\n {\n uri: 'plugins://loaded',\n mimeType: 'application/json',\n text: JSON.stringify(info, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CalculationModel } from '@run-iq/core';\nimport type { DescriptorRegistry } from '../descriptors/registry.js';\n\nfunction buildSchemaDocument(\n models: ReadonlyMap<string, CalculationModel>,\n registry: DescriptorRegistry,\n): string {\n const lines: string[] = [];\n\n lines.push('# Run-IQ Rule Schema');\n lines.push('');\n lines.push('Complete schema for creating valid rules with the currently loaded plugins.');\n lines.push('');\n\n // Base Rule fields\n lines.push('## Base Rule Fields (always required)');\n lines.push('');\n lines.push('| Field | Type | Required | Description |');\n lines.push('|-------|------|----------|-------------|');\n lines.push('| id | string | yes | Unique rule identifier |');\n lines.push('| version | number | auto (=1) | Rule version |');\n lines.push('| model | string | yes | Calculation model name |');\n lines.push('| params | object | yes | Model-specific parameters |');\n lines.push(\n '| priority | number | optional | Auto-computed by plugins (e.g. jurisdiction+scope) |',\n );\n lines.push('| effectiveFrom | string | yes | ISO 8601 date |');\n lines.push('| effectiveUntil | string\\\\|null | optional | ISO 8601 date or null |');\n lines.push('| tags | string[] | optional | Filtering tags |');\n lines.push('| checksum | string | auto | SHA-256 of params (auto-computed by create_rule) |');\n lines.push('| condition | {dsl,value} | optional | DSL condition (e.g. jsonlogic) |');\n lines.push('');\n\n // Plugin extension fields\n const descriptors = registry.getAll();\n if (descriptors.length > 0) {\n lines.push('## Plugin Extension Fields');\n lines.push('');\n\n for (const desc of descriptors) {\n lines.push(`### ${desc.name} (v${desc.version})`);\n lines.push('');\n lines.push(desc.description);\n lines.push('');\n lines.push('| Field | Type | Required | Values | Description |');\n lines.push('|-------|------|----------|--------|-------------|');\n\n for (const field of desc.ruleExtensions) {\n const values = field.enum ? field.enum.join(', ') : '-';\n lines.push(\n `| ${field.name} | ${field.type} | ${field.required ? 'yes' : 'no'} | ${values} | ${field.description} |`,\n );\n }\n lines.push('');\n }\n }\n\n // Available models + params\n lines.push('## Available Calculation Models');\n lines.push('');\n\n for (const [, model] of models) {\n lines.push(`### ${model.name} (v${model.version})`);\n lines.push('');\n\n const validation = model.validateParams({});\n if (validation.errors) {\n lines.push('**Required params:**');\n for (const error of validation.errors) {\n lines.push(`- ${error}`);\n }\n }\n lines.push('');\n }\n\n // Input data fields\n const inputFields = registry.getInputFields();\n if (inputFields.length > 0) {\n lines.push('## Input Data Fields (input.data)');\n lines.push('');\n lines.push('Variables available for use in JSONLogic conditions (`{\"var\": \"fieldName\"}`)');\n lines.push('and as `base` parameter in calculation models.');\n lines.push('');\n lines.push('| Field | Type | Description | Examples |');\n lines.push('|-------|------|-------------|----------|');\n\n for (const field of inputFields) {\n const examples = field.examples ? field.examples.join(', ') : '-';\n lines.push(`| ${field.name} | ${field.type} | ${field.description} | ${examples} |`);\n }\n lines.push('');\n }\n\n // JSONLogic DSL reference\n lines.push('## JSONLogic Condition Syntax');\n lines.push('');\n lines.push('Conditions use the `jsonlogic` DSL. Format:');\n lines.push('```json');\n lines.push('{ \"dsl\": \"jsonlogic\", \"value\": <expression> }');\n lines.push('```');\n lines.push('');\n lines.push('**Common operators:**');\n lines.push('- `{\">=\": [{\"var\": \"revenue\"}, 1000000]}` - comparison');\n lines.push('- `{\"and\": [expr1, expr2]}` - logical AND');\n lines.push('- `{\"or\": [expr1, expr2]}` - logical OR');\n lines.push('- `{\"!\": expr}` - logical NOT');\n lines.push('- `{\"in\": [\"value\", {\"var\": \"tags\"}]}` - membership');\n lines.push('- `{\"==\": [{\"var\": \"type\"}, \"enterprise\"]}` - equality');\n lines.push('');\n\n // Examples\n const examples = registry.getExamples();\n if (examples.length > 0) {\n lines.push('## Complete Rule Examples');\n lines.push('');\n\n for (const example of examples) {\n lines.push(`### ${example.title}`);\n lines.push('');\n lines.push(example.description);\n lines.push('');\n lines.push('**Rule:**');\n lines.push('```json');\n lines.push(JSON.stringify(example.rule, null, 2));\n lines.push('```');\n\n if (example.input) {\n lines.push('');\n lines.push('**Input data:**');\n lines.push('```json');\n lines.push(JSON.stringify(example.input, null, 2));\n lines.push('```');\n }\n lines.push('');\n }\n }\n\n return lines.join('\\n');\n}\n\nexport function registerSchemaResource(\n server: McpServer,\n models: ReadonlyMap<string, CalculationModel>,\n registry: DescriptorRegistry,\n): void {\n server.resource(\n 'rule-schema',\n 'schema://rules',\n {\n description:\n 'Complete rule schema including base fields, plugin extensions, model params, input variables, DSL syntax, and examples. THE reference for creating valid rules.',\n },\n () => ({\n contents: [\n {\n uri: 'schema://rules',\n mimeType: 'text/markdown',\n text: buildSchemaDocument(models, registry),\n },\n ],\n }),\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CalculationModel } from '@run-iq/core';\nimport type { DescriptorRegistry } from '../descriptors/registry.js';\n\nfunction buildDomainLabel(registry: DescriptorRegistry): string {\n const descriptors = registry.getAll();\n if (descriptors.length === 0) return 'policy';\n return descriptors.map((d) => d.domainLabel).join(' / ');\n}\n\nfunction buildModelDocs(models: ReadonlyMap<string, CalculationModel>): string {\n const lines: string[] = [];\n for (const [, model] of models) {\n const validation = model.validateParams({});\n const paramHints = validation.errors ? validation.errors.join('; ') : 'none';\n lines.push(`- **${model.name}** (v${model.version}): ${paramHints}`);\n }\n return lines.join('\\n');\n}\n\nfunction buildExtensionDocs(registry: DescriptorRegistry): string {\n const descriptors = registry.getAll();\n if (descriptors.length === 0) return '';\n\n const lines: string[] = [];\n for (const desc of descriptors) {\n lines.push(`\\n### Plugin: ${desc.name}`);\n lines.push(desc.description);\n lines.push('\\n**Required fields on each rule:**');\n for (const field of desc.ruleExtensions) {\n const values = field.enum ? ` (values: ${field.enum.join(', ')})` : '';\n const req = field.required ? ' [REQUIRED]' : ' [optional]';\n lines.push(`- \\`${field.name}\\`${req}: ${field.description}${values}`);\n }\n }\n return lines.join('\\n');\n}\n\nfunction buildExampleDocs(registry: DescriptorRegistry): string {\n const examples = registry.getExamples();\n if (examples.length === 0) return '';\n\n const lines: string[] = ['\\n## Concrete Examples'];\n for (const ex of examples) {\n lines.push(`\\n### ${ex.title}`);\n lines.push(ex.description);\n lines.push('```json');\n lines.push(JSON.stringify(ex.rule, null, 2));\n lines.push('```');\n }\n return lines.join('\\n');\n}\n\nfunction buildInputDocs(registry: DescriptorRegistry): string {\n const fields = registry.getInputFields();\n if (fields.length === 0) return '';\n\n const lines: string[] = ['\\n## Available input.data Fields'];\n lines.push('Use these as `{\"var\": \"fieldName\"}` in JSONLogic conditions');\n lines.push('and as `\"base\"` parameter in calculation models:\\n');\n for (const f of fields) {\n const examples = f.examples ? ` (e.g. ${f.examples.join(', ')})` : '';\n lines.push(`- \\`${f.name}\\` (${f.type}): ${f.description}${examples}`);\n }\n return lines.join('\\n');\n}\n\nfunction buildGuidelinesSection(registry: DescriptorRegistry): string {\n const descriptors = registry.getAll();\n const lines: string[] = [];\n\n for (const desc of descriptors) {\n if (desc.promptGuidelines.length > 0) {\n lines.push(`\\n## ${desc.domainLabel} Guidelines`);\n for (const g of desc.promptGuidelines) {\n lines.push(`- ${g}`);\n }\n }\n }\n\n return lines.join('\\n');\n}\n\nexport function registerAnalyzeTextPrompt(\n server: McpServer,\n models: ReadonlyMap<string, CalculationModel>,\n registry: DescriptorRegistry,\n): void {\n const domainLabel = buildDomainLabel(registry);\n\n server.prompt(\n 'analyze-text',\n `Translate a ${domainLabel} text (law, regulation, policy) into Run-IQ rule definitions. Plugin-aware: includes all required fields.`,\n {\n source_text: z\n .string()\n .describe('The regulatory, legal, or policy text to analyze and convert into rules'),\n country: z.string().optional().describe('ISO country code (e.g. TG, FR, US, IN)'),\n },\n (args) => {\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `You are an expert at translating regulatory and policy texts into structured Run-IQ rules.\n\n## Available Calculation Models\n${buildModelDocs(models)}\n${buildExtensionDocs(registry)}\n${buildInputDocs(registry)}\n${buildGuidelinesSection(registry)}\n\n## Rule Creation Workflow\n1. Read the source text carefully\n2. Identify each rule, rate, threshold, bracket, condition, or exemption\n3. Map each identified element to the appropriate calculation model\n4. Use the \\`create_rule\\` tool — it knows ALL required fields for loaded plugins\n5. Use the \\`validate_rules\\` tool to verify your rules are valid\n6. Read \\`schema://rules\\` for the complete field reference if needed\n\n## JSONLogic Conditions\n\\`\\`\\`json\n{ \"dsl\": \"jsonlogic\", \"value\": { \">=\": [{ \"var\": \"revenue\" }, 100000] } }\n\\`\\`\\`\n${buildExampleDocs(registry)}\n${args.country ? `\\n## Target Country: ${args.country}\\n` : ''}\n## Source Text to Analyze\n${args.source_text}`,\n },\n },\n ],\n };\n },\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { DescriptorRegistry } from '../descriptors/registry.js';\n\nfunction buildGuidelinesSection(registry: DescriptorRegistry): string {\n const descriptors = registry.getAll();\n const allGuidelines: string[] = [];\n\n for (const desc of descriptors) {\n if (desc.promptGuidelines.length > 0) {\n allGuidelines.push(`### ${desc.name} (${desc.domainLabel})`);\n for (const g of desc.promptGuidelines) {\n allGuidelines.push(`- ${g}`);\n }\n }\n }\n\n if (allGuidelines.length === 0) return '';\n return `## Domain-Specific Guidelines\\n${allGuidelines.join('\\n')}`;\n}\n\nfunction buildDomainLabel(registry: DescriptorRegistry): string {\n const descriptors = registry.getAll();\n if (descriptors.length === 0) return 'general-purpose';\n return descriptors.map((d) => d.domainLabel).join(' + ');\n}\n\nexport function registerDomainExpertPrompt(server: McpServer, registry: DescriptorRegistry): void {\n const descriptors = registry.getAll();\n const domainLabel = buildDomainLabel(registry);\n const pluginList = descriptors.map((d) => `- ${d.name}: ${d.description}`).join('\\n');\n\n server.prompt(\n 'domain-expert',\n `${domainLabel} calculation expertise: scenario comparison, result explanation, recommendations`,\n {\n question: z.string().describe('The question or scenario to analyze'),\n },\n (args) => {\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `You are a ${domainLabel} expert assistant powered by the Run-IQ PPE (Parametric Policy Engine).\n\n## Loaded Plugins\n${pluginList || 'No plugins loaded.'}\n\n## Your Tools\n- **evaluate**: evaluate rules against input data (always dry-run)\n- **simulate**: compare N scenarios side-by-side\n- **validate_rules**: verify rule structure, checksum, and plugin-specific fields\n- **explain_result**: human-readable result explanation\n- **create_rule**: generate rules with ALL required plugin fields\n- **inspect_rule**: analyze a single rule in detail\n- **list_models**: show available calculation models\n- **create_checksum**: compute SHA-256 for params\n\n## Key Resources\n- \\`schema://rules\\` — THE complete rule schema reference\n- \\`models://catalog\\` — model documentation with examples\n- \\`plugins://loaded\\` — loaded plugins and their capabilities\n\n## General Guidelines\n1. Always read \\`schema://rules\\` before creating rules — it has ALL required fields\n2. When comparing scenarios, use the \\`simulate\\` tool with clear labels\n3. Always validate rules after creating them\n\n${buildGuidelinesSection(registry)}\n\n## Question\n${args.question}`,\n },\n },\n ],\n };\n },\n );\n}\n","{\n \"name\": \"@run-iq/mcp-server\",\n \"version\": \"0.1.9\",\n \"description\": \"MCP server exposing the PPE engine to LLMs via stdio\",\n \"type\": \"module\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"run-iq-mcp\": \"./dist/index.js\",\n \"mcp-server\": \"./dist/index.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint src/ tests/ && prettier --check src/ tests/\",\n \"lint:fix\": \"eslint src/ tests/ --fix && prettier --write src/ tests/\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/sdk\": \"^1.27.0\",\n \"@run-iq/core\": \"^0.2.0\",\n \"@run-iq/plugin-sdk\": \"^0.2.2\",\n \"zod\": \"^3.23.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^20.11.0\",\n \"@typescript-eslint/eslint-plugin\": \"^7.0.0\",\n \"@typescript-eslint/parser\": \"^7.0.0\",\n \"eslint\": \"^8.57.0\",\n \"prettier\": \"^3.2.0\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.7.0\",\n \"vitest\": \"^3.0.0\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/Run-IQ/mcp-server.git\"\n },\n \"homepage\": \"https://github.com/Run-IQ/mcp-server#readme\",\n \"bugs\": {\n \"url\": \"https://github.com/Run-IQ/mcp-server/issues\"\n },\n \"author\": \"Abdou-Raouf ATARMLA\",\n \"license\": \"MIT\",\n \"engines\": {\n \"node\": \">=20.0.0\"\n }\n}\n","import pkg from '../../package.json' with { type: 'json' };\nexport const VERSION = pkg.version;\n"],"mappings":";;;AAAA,OAAO,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","z","z","hydrateRules","examples","z","z","buildGuidelinesSection","buildDomainLabel","path"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/engine.ts","../src/descriptors/registry.ts","../src/loader/plugin-loader.ts","../src/tools/create-checksum.ts","../src/tools/create-rule.ts","../src/tools/schema-builder.ts","../src/tools/validate.ts","../src/tools/list-models.ts","../src/tools/evaluate.ts","../src/tools/inspect-rule.ts","../src/tools/explain.ts","../src/tools/simulate.ts","../src/resources/models.ts","../src/resources/plugins.ts","../src/resources/schema.ts","../src/prompts/analyze-text.ts","../src/prompts/domain-expert.ts","../package.json","../src/utils/version.ts"],"sourcesContent":["import type { PluginBundle } from '@run-iq/plugin-sdk';\r\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\r\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\r\nimport { createEngine } from './engine.js';\r\nimport { loadPluginsFromDir, loadNpmPlugins } from './loader/plugin-loader.js';\r\nimport { registerCreateChecksumTool } from './tools/create-checksum.js';\r\nimport { registerCreateRuleTool } from './tools/create-rule.js';\r\nimport { registerValidateRulesTool } from './tools/validate.js';\r\nimport { registerListModelsTool } from './tools/list-models.js';\r\nimport { registerEvaluateTool } from './tools/evaluate.js';\r\nimport { registerInspectRuleTool } from './tools/inspect-rule.js';\r\nimport { registerExplainResultTool } from './tools/explain.js';\r\nimport { registerSimulateTool } from './tools/simulate.js';\r\nimport { registerModelsResource } from './resources/models.js';\r\nimport { registerPluginsResource } from './resources/plugins.js';\r\nimport { registerSchemaResource } from './resources/schema.js';\r\nimport { registerAnalyzeTextPrompt } from './prompts/analyze-text.js';\r\nimport { registerDomainExpertPrompt } from './prompts/domain-expert.js';\r\nimport { VERSION } from './utils/version.js';\r\n\r\n// Parse CLI arguments\r\nlet pluginsDir: string | undefined;\r\nconst npmPlugins: string[] = [];\r\nconst argv = process.argv.slice(2);\r\nfor (let i = 0; i < argv.length; i++) {\r\n if (argv[i] === '--plugins-dir' && argv[i + 1]) {\r\n pluginsDir = argv[i + 1];\r\n i++;\r\n } else if (argv[i] === '--plugin' && argv[i + 1]) {\r\n npmPlugins.push(argv[i + 1]!);\r\n i++;\r\n }\r\n}\r\n\r\n// Load plugin bundles\r\nconst bundles: PluginBundle[] = [];\r\nif (pluginsDir) {\r\n const dirBundles = await loadPluginsFromDir(pluginsDir);\r\n bundles.push(...dirBundles);\r\n}\r\nif (npmPlugins.length > 0) {\r\n const npmBundles = await loadNpmPlugins(npmPlugins);\r\n bundles.push(...npmBundles);\r\n}\r\n\r\nconst { engine, models, descriptorRegistry, plugins, dsls } = createEngine(bundles);\r\nconst descriptors = descriptorRegistry.getAll();\r\n\r\nconst server = new McpServer(\r\n {\r\n name: '@run-iq/mcp-server',\r\n version: VERSION,\r\n },\r\n {\r\n capabilities: {\r\n tools: {},\r\n resources: {},\r\n prompts: {},\r\n },\r\n },\r\n);\r\n\r\n// Tools\r\nregisterCreateChecksumTool(server);\r\nregisterCreateRuleTool(server, descriptors);\r\nregisterValidateRulesTool(server, models, descriptors);\r\nregisterListModelsTool(server, models);\r\nregisterEvaluateTool(server, engine);\r\nregisterInspectRuleTool(server, models, descriptors);\r\nregisterExplainResultTool(server);\r\nregisterSimulateTool(server, engine);\r\n\r\n// Resources\r\nregisterModelsResource(server, models);\r\nregisterPluginsResource(server, plugins, dsls, descriptorRegistry);\r\nregisterSchemaResource(server, models, descriptorRegistry);\r\n\r\n// Prompts\r\nregisterAnalyzeTextPrompt(server, models, descriptorRegistry);\r\nregisterDomainExpertPrompt(server, descriptorRegistry);\r\n\r\n// Start stdio transport\r\nconst transport = new StdioServerTransport();\r\nawait server.connect(transport);\r\n","import { PPEEngine } from '@run-iq/core';\nimport type { PPEPlugin, DSLEvaluator, CalculationModel } from '@run-iq/core';\nimport type { PluginBundle } from '@run-iq/plugin-sdk';\nimport { DescriptorRegistry } from './descriptors/registry.js';\n\nexport interface EngineContext {\n readonly engine: PPEEngine;\n readonly models: ReadonlyMap<string, CalculationModel>;\n readonly descriptorRegistry: DescriptorRegistry;\n readonly plugins: readonly PPEPlugin[];\n readonly dsls: readonly DSLEvaluator[];\n}\n\nexport function createEngine(bundles?: readonly PluginBundle[]): EngineContext {\n const descriptorRegistry = new DescriptorRegistry();\n const allPlugins: PPEPlugin[] = [];\n const allDsls: DSLEvaluator[] = [];\n\n if (bundles && bundles.length > 0) {\n for (const bundle of bundles) {\n allPlugins.push(bundle.plugin);\n descriptorRegistry.register(bundle.descriptor);\n if (bundle.dsls) {\n allDsls.push(...bundle.dsls);\n }\n }\n }\n\n const engine = new PPEEngine({\n plugins: allPlugins,\n dsls: allDsls,\n dryRun: true,\n strict: false,\n onConflict: 'first',\n onChecksumMismatch: 'skip',\n });\n\n // Build model map from plugins that expose a models property (BasePlugin pattern)\n const models = new Map<string, CalculationModel>();\n for (const plugin of allPlugins) {\n const pluginWithModels = plugin as { models?: CalculationModel[] };\n if (Array.isArray(pluginWithModels.models)) {\n for (const model of pluginWithModels.models) {\n models.set(model.name, model);\n }\n }\n }\n\n return { engine, models, descriptorRegistry, plugins: allPlugins, dsls: allDsls };\n}\n","import type {\n PluginDescriptor,\n RuleFieldDescriptor,\n InputFieldDescriptor,\n RuleExample,\n} from '@run-iq/plugin-sdk';\n\nexport class DescriptorRegistry {\n private readonly descriptors: PluginDescriptor[] = [];\n\n register(descriptor: PluginDescriptor): void {\n this.descriptors.push(descriptor);\n }\n\n getAll(): readonly PluginDescriptor[] {\n return this.descriptors;\n }\n\n getRuleExtensions(): readonly RuleFieldDescriptor[] {\n return this.descriptors.flatMap((d) => d.ruleExtensions);\n }\n\n getInputFields(): readonly InputFieldDescriptor[] {\n const seen = new Set<string>();\n const fields: InputFieldDescriptor[] = [];\n for (const d of this.descriptors) {\n for (const f of d.inputFields) {\n if (!seen.has(f.name)) {\n seen.add(f.name);\n fields.push(f);\n }\n }\n }\n return fields;\n }\n\n getExamples(): readonly RuleExample[] {\n return this.descriptors.flatMap((d) => d.examples);\n }\n\n isEmpty(): boolean {\n return this.descriptors.length === 0;\n }\n}\n","import { execSync } from 'node:child_process';\r\nimport { existsSync, mkdirSync, writeFileSync } from 'node:fs';\r\nimport { readdir } from 'node:fs/promises';\r\nimport { resolve, join } from 'node:path';\r\nimport { pathToFileURL } from 'node:url';\r\nimport { createRequire } from 'node:module';\r\nimport { homedir } from 'node:os';\r\nimport type { PluginBundle } from '@run-iq/plugin-sdk';\r\n\r\nconst require = createRequire(import.meta.url);\r\nconst AUTO_PLUGINS_DIR = resolve(homedir(), '.run-iq', 'mcp-plugins');\r\n\r\n/**\r\n * Loads all plugin bundles from a directory.\r\n */\r\nexport async function loadPluginsFromDir(dir: string): Promise<PluginBundle[]> {\r\n const bundles: PluginBundle[] = [];\r\n const absoluteDir = resolve(dir);\r\n\r\n if (!existsSync(absoluteDir)) return [];\r\n\r\n const entries = await readdir(absoluteDir, { withFileTypes: true });\r\n\r\n for (const entry of entries) {\r\n if (!entry.isFile() || !/\\.(mjs|js)$/.test(entry.name)) continue;\r\n\r\n const filePath = resolve(absoluteDir, entry.name);\r\n const bundle = await importBundle(pathToFileURL(filePath).href);\r\n if (bundle) bundles.push(bundle);\r\n }\r\n\r\n return bundles;\r\n}\r\n\r\n/**\r\n * Loads plugin bundles from NPM packages, installing them if necessary.\r\n */\r\nexport async function loadNpmPlugins(packageNames: string[]): Promise<PluginBundle[]> {\r\n const bundles: PluginBundle[] = [];\r\n\r\n for (const pkgName of packageNames) {\r\n try {\r\n const resolvedPath = await resolveOrInstallPlugin(pkgName);\r\n const bundle = await importBundle(pathToFileURL(resolvedPath).href);\r\n\r\n if (bundle) {\r\n bundles.push(bundle);\r\n } else {\r\n console.error(`[PluginLoader] Invalid PluginBundle in package: ${pkgName}`);\r\n }\r\n } catch (err) {\r\n console.error(`[PluginLoader] Failed to load NPM plugin \"${pkgName}\":`, err instanceof Error ? err.message : err);\r\n }\r\n }\r\n\r\n return bundles;\r\n}\r\n\r\n/**\r\n * Attempts to resolve a plugin package, installing it in .mcp-plugins if not found.\r\n */\r\nasync function resolveOrInstallPlugin(pkgName: string): Promise<string> {\r\n // 1. Try local node_modules first\r\n try {\r\n return require.resolve(pkgName, { paths: [process.cwd()] });\r\n } catch {\r\n /* Not found locally */\r\n }\r\n\r\n // 2. Try .mcp-plugins directory\r\n try {\r\n return require.resolve(pkgName, { paths: [AUTO_PLUGINS_DIR] });\r\n } catch {\r\n /* Not found in auto-plugins dir */\r\n }\r\n\r\n // 3. Install dynamically\r\n ensurePluginsDir();\r\n console.log(`[PluginLoader] Installing ${pkgName} dynamically...`);\r\n \r\n execSync(`npm install ${pkgName} --no-save`, {\r\n cwd: AUTO_PLUGINS_DIR,\r\n stdio: 'inherit',\r\n });\r\n\r\n return require.resolve(pkgName, { paths: [AUTO_PLUGINS_DIR] });\r\n}\r\n\r\n/**\r\n * Ensures the .mcp-plugins directory exists and is initialized.\r\n */\r\nfunction ensurePluginsDir(): void {\r\n if (!existsSync(AUTO_PLUGINS_DIR)) {\r\n mkdirSync(AUTO_PLUGINS_DIR, { recursive: true });\r\n writeFileSync(\r\n join(AUTO_PLUGINS_DIR, 'package.json'),\r\n JSON.stringify({ name: 'mcp-plugins', private: true, version: '1.0.0' }, null, 2),\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Safely imports a module and extracts the PluginBundle.\r\n */\r\nasync function importBundle(url: string): Promise<PluginBundle | null> {\r\n try {\r\n const mod = await import(url);\r\n let bundle = (mod.default ?? mod) as any;\r\n\r\n // Handle bundles nested under a 'bundle' property (common in some build setups)\r\n if (!bundle.plugin && bundle.bundle?.plugin) {\r\n bundle = bundle.bundle;\r\n }\r\n\r\n if (isValidBundle(bundle)) {\r\n return bundle as PluginBundle;\r\n }\r\n } catch (err) {\r\n console.error(`[PluginLoader] Import error for ${url}:`, err);\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * Validates that an object conforms to the PluginBundle interface.\r\n */\r\nfunction isValidBundle(obj: any): boolean {\r\n return (\r\n obj &&\r\n typeof obj === 'object' &&\r\n typeof obj.plugin === 'object' &&\r\n typeof obj.descriptor === 'object'\r\n );\r\n}\r\n","import { createHash } from 'node:crypto';\nimport { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerCreateChecksumTool(server: McpServer): void {\n server.tool(\n 'create_checksum',\n 'Compute the SHA-256 checksum of a params object. Used to generate the checksum field for Run-IQ rules.',\n { params: z.record(z.unknown()).describe('The params object to hash') },\n (args) => {\n const checksum = createHash('sha256').update(JSON.stringify(args.params)).digest('hex');\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ checksum }, null, 2) }],\n };\n },\n );\n}\n","import { createHash } from 'node:crypto';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { PluginDescriptor } from '@run-iq/plugin-sdk';\nimport { buildCreateRuleSchema } from './schema-builder.js';\n\nexport function registerCreateRuleTool(\n server: McpServer,\n descriptors: readonly PluginDescriptor[],\n): void {\n const schema = buildCreateRuleSchema(descriptors);\n\n // Collect plugin extension field names\n const extensionFields = descriptors.flatMap((d) => d.ruleExtensions.map((f) => f.name));\n\n server.tool(\n 'create_rule',\n 'Generate a valid Run-IQ Rule JSON object with auto-computed SHA-256 checksum. Includes plugin-specific fields based on loaded plugins.',\n schema,\n (args: Record<string, unknown>) => {\n const params = args['params'] as Record<string, unknown>;\n const checksum = createHash('sha256').update(JSON.stringify(params)).digest('hex');\n\n const rule: Record<string, unknown> = {\n id: args['id'],\n version: 1,\n model: args['model'],\n params,\n priority: (args['priority'] as number | undefined) ?? 1000,\n effectiveFrom: args['effectiveFrom'],\n effectiveUntil: args['effectiveUntil'] ?? null,\n tags: (args['tags'] as string[] | undefined) ?? [],\n checksum,\n };\n\n if (args['condition']) {\n rule['condition'] = args['condition'];\n }\n\n // Add plugin extension fields\n for (const field of extensionFields) {\n if (args[field] !== undefined) {\n rule[field] = args[field];\n }\n }\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ rule }, null, 2) }],\n };\n },\n );\n}\n","import { z } from 'zod';\nimport type { RuleFieldDescriptor, PluginDescriptor } from '@run-iq/plugin-sdk';\n\nfunction buildFieldSchema(field: RuleFieldDescriptor): z.ZodTypeAny {\n let schema: z.ZodTypeAny;\n\n if (field.enum && field.enum.length > 0) {\n schema = z.enum(field.enum as [string, ...string[]]);\n } else {\n switch (field.type) {\n case 'string':\n schema = z.string();\n break;\n case 'number':\n schema = z.number();\n break;\n case 'boolean':\n schema = z.boolean();\n break;\n }\n }\n\n if (!field.required) {\n schema = schema.optional();\n }\n\n return schema.describe(field.description);\n}\n\nexport function buildCreateRuleSchema(\n descriptors: readonly PluginDescriptor[],\n): Record<string, z.ZodTypeAny> {\n const shape: Record<string, z.ZodTypeAny> = {\n id: z.string().describe('Unique rule identifier'),\n model: z.string().describe('Calculation model name (e.g. FLAT_RATE, PROGRESSIVE_BRACKET)'),\n params: z.record(z.unknown()).describe('Model-specific parameters'),\n priority: z\n .number()\n .int()\n .optional()\n .describe('Rule priority (may be auto-computed by plugins, e.g. from jurisdiction+scope)'),\n effectiveFrom: z.string().describe('ISO 8601 date string for when the rule becomes active'),\n effectiveUntil: z\n .string()\n .nullable()\n .optional()\n .describe('ISO 8601 date string for when the rule expires (null = no expiry)'),\n tags: z.array(z.string()).optional().describe('Optional tags for filtering'),\n condition: z\n .object({\n dsl: z.string().describe('DSL identifier (e.g. \"jsonlogic\")'),\n value: z.unknown().describe('DSL-specific condition expression'),\n })\n .optional()\n .describe('Optional condition expression'),\n };\n\n for (const descriptor of descriptors) {\n for (const field of descriptor.ruleExtensions) {\n shape[field.name] = buildFieldSchema(field);\n }\n }\n\n return shape;\n}\n\nexport function buildValidateExtensionErrors(\n rule: Record<string, unknown>,\n descriptors: readonly PluginDescriptor[],\n): string[] {\n const errors: string[] = [];\n\n for (const descriptor of descriptors) {\n for (const field of descriptor.ruleExtensions) {\n const value = rule[field.name];\n\n if (field.required && (value === undefined || value === null)) {\n errors.push(`\"${field.name}\" is required by ${descriptor.name}: ${field.description}`);\n continue;\n }\n\n if (value === undefined || value === null) continue;\n\n if (field.enum && !field.enum.includes(String(value))) {\n errors.push(\n `\"${field.name}\" must be one of: ${field.enum.join(', ')} (got \"${String(value)}\")`,\n );\n }\n\n if (field.type === 'string' && typeof value !== 'string') {\n errors.push(`\"${field.name}\" must be a string`);\n }\n if (field.type === 'number' && typeof value !== 'number') {\n errors.push(`\"${field.name}\" must be a number`);\n }\n if (field.type === 'boolean' && typeof value !== 'boolean') {\n errors.push(`\"${field.name}\" must be a boolean`);\n }\n }\n }\n\n return errors;\n}\n","import { createHash } from 'node:crypto';\r\nimport { z } from 'zod';\r\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\r\nimport type { CalculationModel } from '@run-iq/core';\r\nimport type { PluginDescriptor } from '@run-iq/plugin-sdk';\r\nimport { buildValidateExtensionErrors } from './schema-builder.js';\r\n\r\nconst RuleSchema = z.object({\r\n id: z.string(),\r\n version: z.number(),\r\n model: z.string(),\r\n params: z.unknown(),\r\n priority: z.number().optional(),\r\n effectiveFrom: z.string(),\r\n effectiveUntil: z.string().nullable(),\r\n tags: z.array(z.string()),\r\n checksum: z.string(),\r\n condition: z.object({ dsl: z.string(), value: z.unknown() }).optional(),\r\n});\r\n\r\ninterface ValidationEntry {\r\n ruleId: string;\r\n valid: boolean;\r\n errors?: string[];\r\n}\r\n\r\nexport function registerValidateRulesTool(\r\n server: McpServer,\r\n models: ReadonlyMap<string, CalculationModel>,\r\n descriptors: readonly PluginDescriptor[],\r\n): void {\r\n server.tool(\r\n 'validate_rules',\r\n 'Validate the structure, checksum, model params, and plugin-specific fields of Run-IQ rules.',\r\n {\r\n rules: z.array(z.record(z.unknown())).describe('Array of Rule JSON objects to validate'),\r\n },\r\n (args) => {\r\n const entries: ValidationEntry[] = [];\r\n\r\n for (const raw of args.rules) {\r\n const parsed = RuleSchema.safeParse(raw);\r\n const ruleId = typeof raw['id'] === 'string' ? raw['id'] : 'unknown';\r\n\r\n if (!parsed.success) {\r\n entries.push({\r\n ruleId,\r\n valid: false,\r\n errors: parsed.error.errors.map((e) => `${e.path.join('.')}: ${e.message}`),\r\n });\r\n continue;\r\n }\r\n\r\n const rule = parsed.data;\r\n const errors: string[] = [];\r\n\r\n // Checksum verification\r\n const computed = createHash('sha256').update(JSON.stringify(rule.params)).digest('hex');\r\n if (computed !== rule.checksum) {\r\n errors.push(`Checksum mismatch: expected ${computed}, got ${rule.checksum}`);\r\n }\r\n\r\n // Model existence\r\n const model = models.get(rule.model);\r\n if (!model) {\r\n errors.push(\r\n `Model \"${rule.model}\" not found. Available: ${[...models.keys()].join(', ')}`,\r\n );\r\n } else {\r\n // Param validation via model\r\n const validation = model.validateParams(rule.params);\r\n if (!validation.valid && validation.errors) {\r\n errors.push(...validation.errors);\r\n }\r\n }\r\n\r\n // Plugin extension validation\r\n const extensionErrors = buildValidateExtensionErrors(raw, descriptors);\r\n errors.push(...extensionErrors);\r\n\r\n entries.push({\r\n ruleId: rule.id,\r\n valid: errors.length === 0,\r\n ...(errors.length > 0 ? { errors } : {}),\r\n });\r\n }\r\n\r\n return {\r\n content: [{ type: 'text', text: JSON.stringify({ entries }, null, 2) }],\r\n };\r\n },\r\n );\r\n}\r\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CalculationModel } from '@run-iq/core';\n\ninterface ModelInfo {\n name: string;\n version: string;\n paramsSchema: Record<string, string>;\n}\n\nexport function registerListModelsTool(\n server: McpServer,\n models: ReadonlyMap<string, CalculationModel>,\n): void {\n server.tool(\n 'list_models',\n 'List all available calculation models with their parameter schemas. Shows model name, version, and expected parameters.',\n {},\n () => {\n const result: ModelInfo[] = [];\n\n for (const [, model] of models) {\n // Infer param schema from validation errors with empty object\n const validation = model.validateParams({});\n const paramsSchema: Record<string, string> = {};\n\n if (validation.errors) {\n for (const error of validation.errors) {\n // Parse error messages like '\"rate\" must be a number' or '\"base\" must be a string'\n const match = error.match(/^\"(\\w+)\"\\s+must be (?:a |an )?(.+)$/);\n if (match?.[1] && match[2]) {\n paramsSchema[match[1]] = match[2];\n }\n }\n }\n\n result.push({\n name: model.name,\n version: model.version,\n paramsSchema,\n });\n }\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ models: result }, null, 2) }],\n };\n },\n );\n}\n","import { z } from 'zod';\r\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\r\nimport type { PPEEngine } from '@run-iq/core';\r\nimport { hydrateRules } from '@run-iq/core';\r\n\r\nexport function registerEvaluateTool(server: McpServer, engine: PPEEngine): void {\r\n server.tool(\r\n 'evaluate',\r\n 'Evaluate Run-IQ rules against input data in dry-run mode. Returns the computed value, breakdown per rule, applied/skipped rules, and execution trace.',\r\n {\r\n rules: z.array(z.record(z.unknown())).describe('Array of Rule JSON objects'),\r\n input: z\r\n .object({\r\n data: z.record(z.unknown()).describe('Input data for evaluation'),\r\n requestId: z.string().describe('Unique request identifier'),\r\n meta: z.object({\r\n tenantId: z.string().describe('Tenant identifier'),\r\n userId: z.string().optional().describe('User identifier'),\r\n tags: z.array(z.string()).optional().describe('Tags for rule filtering'),\r\n context: z.record(z.unknown()).optional().describe('Additional context'),\r\n effectiveDate: z\r\n .string()\r\n .optional()\r\n .describe('ISO 8601 date for effective date evaluation'),\r\n }),\r\n })\r\n .describe('Evaluation input'),\r\n },\r\n async (args) => {\r\n try {\r\n const rules = hydrateRules(args.rules);\r\n\r\n const input = {\r\n data: args.input.data,\r\n requestId: args.input.requestId,\r\n meta: {\r\n ...args.input.meta,\r\n effectiveDate: args.input.meta.effectiveDate\r\n ? new Date(args.input.meta.effectiveDate)\r\n : undefined,\r\n },\r\n };\r\n\r\n const result = await engine.evaluate(rules, input);\r\n\r\n const serializable = {\r\n value: result.value,\r\n breakdown: result.breakdown,\r\n appliedRules: result.appliedRules.map((r) => ({\r\n id: r.id,\r\n model: r.model,\r\n priority: r.priority,\r\n })),\r\n skippedRules: result.skippedRules.map((s) => ({\r\n ruleId: s.rule.id,\r\n reason: s.reason,\r\n })),\r\n trace: {\r\n steps: result.trace.steps.map((s) => ({\r\n ruleId: s.ruleId,\r\n modelUsed: s.modelUsed,\r\n contribution: s.contribution,\r\n durationMs: s.durationMs,\r\n })),\r\n totalDurationMs: result.trace.totalDurationMs,\r\n },\r\n };\r\n\r\n return {\r\n content: [{ type: 'text', text: JSON.stringify(serializable, null, 2) }],\r\n };\r\n } catch (error) {\r\n const message = error instanceof Error ? error.message : String(error);\r\n return {\r\n content: [{ type: 'text', text: JSON.stringify({ error: message }) }],\r\n isError: true,\r\n };\r\n }\r\n },\r\n );\r\n}\r\n","import { createHash } from 'node:crypto';\r\nimport { z } from 'zod';\r\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\r\nimport type { CalculationModel } from '@run-iq/core';\r\nimport type { PluginDescriptor } from '@run-iq/plugin-sdk';\r\nimport { buildValidateExtensionErrors } from './schema-builder.js';\r\n\r\nexport function registerInspectRuleTool(\r\n server: McpServer,\r\n models: ReadonlyMap<string, CalculationModel>,\r\n descriptors: readonly PluginDescriptor[],\r\n): void {\r\n server.tool(\r\n 'inspect_rule',\r\n 'Analyze a single Run-IQ rule in detail: checksum, model, active dates, params, and plugin-specific fields.',\r\n {\r\n rule: z.record(z.unknown()).describe('A single Rule JSON object to inspect'),\r\n },\r\n (args) => {\r\n const rule = args.rule;\r\n const id = typeof rule['id'] === 'string' ? rule['id'] : 'unknown';\r\n const modelName = typeof rule['model'] === 'string' ? rule['model'] : '';\r\n const params = rule['params'];\r\n const checksum = typeof rule['checksum'] === 'string' ? rule['checksum'] : '';\r\n\r\n // Checksum match\r\n const computed = createHash('sha256').update(JSON.stringify(params)).digest('hex');\r\n const checksumMatch = computed === checksum;\r\n\r\n // Model found\r\n const model = models.get(modelName);\r\n const modelFound = model !== undefined;\r\n\r\n // Param validation\r\n let paramErrors: string[] | undefined;\r\n if (model) {\r\n const validation = model.validateParams(params);\r\n if (!validation.valid && validation.errors) {\r\n paramErrors = [...validation.errors];\r\n }\r\n }\r\n\r\n // Plugin extension validation\r\n const extensionErrors = buildValidateExtensionErrors(rule, descriptors);\r\n\r\n // Active date check\r\n const now = new Date();\r\n const effectiveFrom =\r\n typeof rule['effectiveFrom'] === 'string' ? new Date(rule['effectiveFrom']) : null;\r\n const effectiveUntil =\r\n typeof rule['effectiveUntil'] === 'string' ? new Date(rule['effectiveUntil']) : null;\r\n\r\n const isActive =\r\n effectiveFrom !== null &&\r\n effectiveFrom <= now &&\r\n (effectiveUntil === null || effectiveUntil > now);\r\n\r\n const effectivePeriod = {\r\n from: effectiveFrom?.toISOString() ?? null,\r\n until: effectiveUntil?.toISOString() ?? null,\r\n };\r\n\r\n const allErrors = [...(paramErrors ?? []), ...extensionErrors];\r\n const valid = checksumMatch && modelFound && allErrors.length === 0 && isActive;\r\n\r\n const result: Record<string, unknown> = {\r\n ruleId: id,\r\n valid,\r\n checksumMatch,\r\n modelFound,\r\n isActive,\r\n effectivePeriod,\r\n };\r\n\r\n if (paramErrors && paramErrors.length > 0) {\r\n result['paramErrors'] = paramErrors;\r\n }\r\n if (extensionErrors.length > 0) {\r\n result['extensionErrors'] = extensionErrors;\r\n }\r\n\r\n return {\r\n content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],\r\n };\r\n },\r\n );\r\n}\r\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nconst EvaluationResultSchema = {\n result: z\n .object({\n value: z.unknown(),\n breakdown: z.array(\n z.object({\n ruleId: z.string(),\n contribution: z.unknown(),\n modelUsed: z.string(),\n label: z.string().optional(),\n }),\n ),\n appliedRules: z.array(\n z.object({\n id: z.string(),\n model: z.string(),\n priority: z.number(),\n }),\n ),\n skippedRules: z.array(\n z.object({\n ruleId: z.string(),\n reason: z.string(),\n }),\n ),\n trace: z\n .object({\n totalDurationMs: z.number(),\n steps: z.array(z.record(z.unknown())).optional(),\n })\n .optional(),\n })\n .describe('An EvaluationResult (or simplified result from the evaluate tool)'),\n};\n\nexport function registerExplainResultTool(server: McpServer): void {\n server.tool(\n 'explain_result',\n 'Generate a human-readable explanation of an evaluation result. Summarizes the total value, applied rules with their contributions, skipped rules with reasons, and execution timing.',\n EvaluationResultSchema,\n (args) => {\n const { result } = args;\n const lines: string[] = [];\n\n lines.push(`## Evaluation Result Summary`);\n lines.push('');\n lines.push(`**Total Value**: ${String(result.value)}`);\n lines.push('');\n\n // Applied rules\n if (result.appliedRules.length > 0) {\n lines.push(`### Applied Rules (${result.appliedRules.length})`);\n lines.push('');\n\n for (const applied of result.appliedRules) {\n const breakdown = result.breakdown.find((b) => b.ruleId === applied.id);\n const contribution = breakdown ? String(breakdown.contribution) : 'N/A';\n const label = breakdown?.label ? ` (${breakdown.label})` : '';\n\n lines.push(\n `- **${applied.id}**${label}: model=${applied.model}, priority=${applied.priority}, contribution=${contribution}`,\n );\n }\n lines.push('');\n } else {\n lines.push('### No rules were applied.');\n lines.push('');\n }\n\n // Skipped rules\n if (result.skippedRules.length > 0) {\n lines.push(`### Skipped Rules (${result.skippedRules.length})`);\n lines.push('');\n\n for (const skipped of result.skippedRules) {\n lines.push(`- **${skipped.ruleId}**: ${skipped.reason}`);\n }\n lines.push('');\n }\n\n // Timing\n if (result.trace?.totalDurationMs !== undefined) {\n lines.push(`### Timing`);\n lines.push('');\n lines.push(`Total duration: ${result.trace.totalDurationMs}ms`);\n }\n\n const explanation = lines.join('\\n');\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ explanation }, null, 2) }],\n };\n },\n );\n}\n","import { z } from 'zod';\r\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\r\nimport type { PPEEngine } from '@run-iq/core';\r\nimport { hydrateRules } from '@run-iq/core';\r\n\r\nconst ScenarioSchema = z.object({\r\n label: z.string().describe('Human-readable scenario label'),\r\n input: z.object({\r\n data: z.record(z.unknown()),\r\n requestId: z.string(),\r\n meta: z.object({\r\n tenantId: z.string(),\r\n userId: z.string().optional(),\r\n tags: z.array(z.string()).optional(),\r\n context: z.record(z.unknown()).optional(),\r\n effectiveDate: z.string().optional(),\r\n }),\r\n }),\r\n});\r\n\r\nexport function registerSimulateTool(server: McpServer, engine: PPEEngine): void {\r\n server.tool(\r\n 'simulate',\r\n 'Compare N scenarios using the same rules. Evaluates each scenario independently and returns side-by-side results for comparison.',\r\n {\r\n rules: z\r\n .array(z.record(z.unknown()))\r\n .describe('Array of Rule JSON objects (shared across all scenarios)'),\r\n scenarios: z.array(ScenarioSchema).min(1).describe('Array of scenarios to compare'),\r\n },\r\n async (args) => {\r\n try {\r\n const rules = hydrateRules(args.rules);\r\n\r\n const results = [];\r\n for (const scenario of args.scenarios) {\r\n const input = {\r\n data: scenario.input.data,\r\n requestId: scenario.input.requestId,\r\n meta: {\r\n ...scenario.input.meta,\r\n effectiveDate: scenario.input.meta.effectiveDate\r\n ? new Date(scenario.input.meta.effectiveDate)\r\n : undefined,\r\n },\r\n };\r\n\r\n const result = await engine.evaluate(rules, input);\r\n\r\n results.push({\r\n label: scenario.label,\r\n value: result.value,\r\n appliedCount: result.appliedRules.length,\r\n skippedCount: result.skippedRules.length,\r\n breakdown: result.breakdown.map((b) => ({\r\n ruleId: b.ruleId,\r\n contribution: b.contribution,\r\n modelUsed: b.modelUsed,\r\n })),\r\n });\r\n }\r\n\r\n return {\r\n content: [{ type: 'text', text: JSON.stringify({ results }, null, 2) }],\r\n };\r\n } catch (error) {\r\n const message = error instanceof Error ? error.message : String(error);\r\n return {\r\n content: [{ type: 'text', text: JSON.stringify({ error: message }) }],\r\n isError: true,\r\n };\r\n }\r\n },\r\n );\r\n}\r\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CalculationModel } from '@run-iq/core';\n\nfunction buildModelsCatalog(models: ReadonlyMap<string, CalculationModel>): string {\n const lines: string[] = [];\n\n lines.push('# Run-IQ Calculation Models');\n lines.push('');\n\n for (const [, model] of models) {\n lines.push(`## ${model.name} (v${model.version})`);\n lines.push('');\n\n // Infer params from validation errors\n const validation = model.validateParams({});\n if (validation.errors) {\n lines.push('### Parameters');\n lines.push('');\n for (const error of validation.errors) {\n lines.push(`- ${error}`);\n }\n lines.push('');\n }\n\n // Model-specific documentation\n switch (model.name) {\n case 'FLAT_RATE':\n lines.push('Applies a flat rate to a base value: `base_value * rate`.');\n lines.push('');\n lines.push('**Example params**: `{ \"rate\": 0.18, \"base\": \"revenue\" }`');\n lines.push('**Use case**: TVA, flat tax rates.');\n break;\n case 'PROGRESSIVE_BRACKET':\n lines.push(\n 'Applies progressive tax brackets cumulatively. Each bracket taxes only the portion within its range.',\n );\n lines.push('');\n lines.push(\n '**Example params**: `{ \"base\": \"income\", \"brackets\": [{ \"from\": 0, \"to\": 500000, \"rate\": 0 }, { \"from\": 500000, \"to\": 1000000, \"rate\": 0.1 }] }`',\n );\n lines.push('**Use case**: IRPP (income tax), progressive taxes.');\n break;\n case 'MINIMUM_TAX':\n lines.push('Computes `MAX(base_value * rate, minimum)`. Ensures a minimum tax amount.');\n lines.push('');\n lines.push('**Example params**: `{ \"rate\": 0.01, \"base\": \"revenue\", \"minimum\": 50000 }`');\n lines.push('**Use case**: Minimum corporate tax.');\n break;\n case 'THRESHOLD_BASED':\n lines.push(\n 'Applies a rate only when the base value exceeds a threshold. If `above_only` is true, taxes only the amount above the threshold.',\n );\n lines.push('');\n lines.push(\n '**Example params**: `{ \"base\": \"revenue\", \"threshold\": 1000000, \"rate\": 0.05, \"above_only\": true }`',\n );\n lines.push('**Use case**: Luxury tax, excess profit tax.');\n break;\n case 'FIXED_AMOUNT':\n lines.push('Returns a fixed amount regardless of input values.');\n lines.push('');\n lines.push('**Example params**: `{ \"amount\": 25000, \"currency\": \"XOF\" }`');\n lines.push('**Use case**: Fixed registration fees, stamps.');\n break;\n case 'COMPOSITE':\n lines.push(\n 'Combines multiple sub-models using an aggregation function (SUM, MAX, or MIN).',\n );\n lines.push('');\n lines.push(\n '**Example params**: `{ \"steps\": [{ \"model\": \"FLAT_RATE\", \"params\": { \"rate\": 0.18, \"base\": \"revenue\" } }], \"aggregation\": \"SUM\" }`',\n );\n lines.push('**Use case**: Complex tax calculations combining multiple methods.');\n break;\n }\n\n lines.push('');\n lines.push('---');\n lines.push('');\n }\n\n return lines.join('\\n');\n}\n\nexport function registerModelsResource(\n server: McpServer,\n models: ReadonlyMap<string, CalculationModel>,\n): void {\n server.resource(\n 'models-catalog',\n 'models://catalog',\n {\n description:\n 'Documentation of all available calculation models with parameter schemas and usage examples',\n },\n () => {\n const catalog = buildModelsCatalog(models);\n return {\n contents: [\n {\n uri: 'models://catalog',\n mimeType: 'text/markdown',\n text: catalog,\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { PPEPlugin, DSLEvaluator } from '@run-iq/core';\nimport type { DescriptorRegistry } from '../descriptors/registry.js';\n\nexport function registerPluginsResource(\n server: McpServer,\n plugins: readonly PPEPlugin[],\n dsls: readonly DSLEvaluator[],\n registry: DescriptorRegistry,\n): void {\n server.resource(\n 'plugins-loaded',\n 'plugins://loaded',\n { description: 'Information about loaded plugins, DSL evaluators, and their descriptors' },\n () => {\n const descriptors = registry.getAll();\n\n const info = {\n plugins: plugins.map((p) => {\n const desc = descriptors.find((d) => d.name === p.name);\n const pluginWithModels = p as { models?: { name: string }[] };\n return {\n name: p.name,\n version: p.version,\n models: Array.isArray(pluginWithModels.models)\n ? pluginWithModels.models.map((m) => m.name)\n : [],\n hasDescriptor: desc !== undefined,\n ruleExtensions: desc?.ruleExtensions.map((f) => f.name) ?? [],\n };\n }),\n dsls: dsls.map((d) => ({\n name: d.dsl,\n version: d.version,\n })),\n };\n\n return {\n contents: [\n {\n uri: 'plugins://loaded',\n mimeType: 'application/json',\n text: JSON.stringify(info, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CalculationModel } from '@run-iq/core';\nimport type { DescriptorRegistry } from '../descriptors/registry.js';\n\nfunction buildSchemaDocument(\n models: ReadonlyMap<string, CalculationModel>,\n registry: DescriptorRegistry,\n): string {\n const lines: string[] = [];\n\n lines.push('# Run-IQ Rule Schema');\n lines.push('');\n lines.push('Complete schema for creating valid rules with the currently loaded plugins.');\n lines.push('');\n\n // Base Rule fields\n lines.push('## Base Rule Fields (always required)');\n lines.push('');\n lines.push('| Field | Type | Required | Description |');\n lines.push('|-------|------|----------|-------------|');\n lines.push('| id | string | yes | Unique rule identifier |');\n lines.push('| version | number | auto (=1) | Rule version |');\n lines.push('| model | string | yes | Calculation model name |');\n lines.push('| params | object | yes | Model-specific parameters |');\n lines.push(\n '| priority | number | optional | Auto-computed by plugins (e.g. jurisdiction+scope) |',\n );\n lines.push('| effectiveFrom | string | yes | ISO 8601 date |');\n lines.push('| effectiveUntil | string\\\\|null | optional | ISO 8601 date or null |');\n lines.push('| tags | string[] | optional | Filtering tags |');\n lines.push('| checksum | string | auto | SHA-256 of params (auto-computed by create_rule) |');\n lines.push('| condition | {dsl,value} | optional | DSL condition (e.g. jsonlogic) |');\n lines.push('');\n\n // Plugin extension fields\n const descriptors = registry.getAll();\n if (descriptors.length > 0) {\n lines.push('## Plugin Extension Fields');\n lines.push('');\n\n for (const desc of descriptors) {\n lines.push(`### ${desc.name} (v${desc.version})`);\n lines.push('');\n lines.push(desc.description);\n lines.push('');\n lines.push('| Field | Type | Required | Values | Description |');\n lines.push('|-------|------|----------|--------|-------------|');\n\n for (const field of desc.ruleExtensions) {\n const values = field.enum ? field.enum.join(', ') : '-';\n lines.push(\n `| ${field.name} | ${field.type} | ${field.required ? 'yes' : 'no'} | ${values} | ${field.description} |`,\n );\n }\n lines.push('');\n }\n }\n\n // Available models + params\n lines.push('## Available Calculation Models');\n lines.push('');\n\n for (const [, model] of models) {\n lines.push(`### ${model.name} (v${model.version})`);\n lines.push('');\n\n const validation = model.validateParams({});\n if (validation.errors) {\n lines.push('**Required params:**');\n for (const error of validation.errors) {\n lines.push(`- ${error}`);\n }\n }\n lines.push('');\n }\n\n // Input data fields\n const inputFields = registry.getInputFields();\n if (inputFields.length > 0) {\n lines.push('## Input Data Fields (input.data)');\n lines.push('');\n lines.push('Variables available for use in JSONLogic conditions (`{\"var\": \"fieldName\"}`)');\n lines.push('and as `base` parameter in calculation models.');\n lines.push('');\n lines.push('| Field | Type | Description | Examples |');\n lines.push('|-------|------|-------------|----------|');\n\n for (const field of inputFields) {\n const examples = field.examples ? field.examples.join(', ') : '-';\n lines.push(`| ${field.name} | ${field.type} | ${field.description} | ${examples} |`);\n }\n lines.push('');\n }\n\n // JSONLogic DSL reference\n lines.push('## JSONLogic Condition Syntax');\n lines.push('');\n lines.push('Conditions use the `jsonlogic` DSL. Format:');\n lines.push('```json');\n lines.push('{ \"dsl\": \"jsonlogic\", \"value\": <expression> }');\n lines.push('```');\n lines.push('');\n lines.push('**Common operators:**');\n lines.push('- `{\">=\": [{\"var\": \"revenue\"}, 1000000]}` - comparison');\n lines.push('- `{\"and\": [expr1, expr2]}` - logical AND');\n lines.push('- `{\"or\": [expr1, expr2]}` - logical OR');\n lines.push('- `{\"!\": expr}` - logical NOT');\n lines.push('- `{\"in\": [\"value\", {\"var\": \"tags\"}]}` - membership');\n lines.push('- `{\"==\": [{\"var\": \"type\"}, \"enterprise\"]}` - equality');\n lines.push('');\n\n // Examples\n const examples = registry.getExamples();\n if (examples.length > 0) {\n lines.push('## Complete Rule Examples');\n lines.push('');\n\n for (const example of examples) {\n lines.push(`### ${example.title}`);\n lines.push('');\n lines.push(example.description);\n lines.push('');\n lines.push('**Rule:**');\n lines.push('```json');\n lines.push(JSON.stringify(example.rule, null, 2));\n lines.push('```');\n\n if (example.input) {\n lines.push('');\n lines.push('**Input data:**');\n lines.push('```json');\n lines.push(JSON.stringify(example.input, null, 2));\n lines.push('```');\n }\n lines.push('');\n }\n }\n\n return lines.join('\\n');\n}\n\nexport function registerSchemaResource(\n server: McpServer,\n models: ReadonlyMap<string, CalculationModel>,\n registry: DescriptorRegistry,\n): void {\n server.resource(\n 'rule-schema',\n 'schema://rules',\n {\n description:\n 'Complete rule schema including base fields, plugin extensions, model params, input variables, DSL syntax, and examples. THE reference for creating valid rules.',\n },\n () => ({\n contents: [\n {\n uri: 'schema://rules',\n mimeType: 'text/markdown',\n text: buildSchemaDocument(models, registry),\n },\n ],\n }),\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { CalculationModel } from '@run-iq/core';\nimport type { DescriptorRegistry } from '../descriptors/registry.js';\n\nfunction buildDomainLabel(registry: DescriptorRegistry): string {\n const descriptors = registry.getAll();\n if (descriptors.length === 0) return 'policy';\n return descriptors.map((d) => d.domainLabel).join(' / ');\n}\n\nfunction buildModelDocs(models: ReadonlyMap<string, CalculationModel>): string {\n const lines: string[] = [];\n for (const [, model] of models) {\n const validation = model.validateParams({});\n const paramHints = validation.errors ? validation.errors.join('; ') : 'none';\n lines.push(`- **${model.name}** (v${model.version}): ${paramHints}`);\n }\n return lines.join('\\n');\n}\n\nfunction buildExtensionDocs(registry: DescriptorRegistry): string {\n const descriptors = registry.getAll();\n if (descriptors.length === 0) return '';\n\n const lines: string[] = [];\n for (const desc of descriptors) {\n lines.push(`\\n### Plugin: ${desc.name}`);\n lines.push(desc.description);\n lines.push('\\n**Required fields on each rule:**');\n for (const field of desc.ruleExtensions) {\n const values = field.enum ? ` (values: ${field.enum.join(', ')})` : '';\n const req = field.required ? ' [REQUIRED]' : ' [optional]';\n lines.push(`- \\`${field.name}\\`${req}: ${field.description}${values}`);\n }\n }\n return lines.join('\\n');\n}\n\nfunction buildExampleDocs(registry: DescriptorRegistry): string {\n const examples = registry.getExamples();\n if (examples.length === 0) return '';\n\n const lines: string[] = ['\\n## Concrete Examples'];\n for (const ex of examples) {\n lines.push(`\\n### ${ex.title}`);\n lines.push(ex.description);\n lines.push('```json');\n lines.push(JSON.stringify(ex.rule, null, 2));\n lines.push('```');\n }\n return lines.join('\\n');\n}\n\nfunction buildInputDocs(registry: DescriptorRegistry): string {\n const fields = registry.getInputFields();\n if (fields.length === 0) return '';\n\n const lines: string[] = ['\\n## Available input.data Fields'];\n lines.push('Use these as `{\"var\": \"fieldName\"}` in JSONLogic conditions');\n lines.push('and as `\"base\"` parameter in calculation models:\\n');\n for (const f of fields) {\n const examples = f.examples ? ` (e.g. ${f.examples.join(', ')})` : '';\n lines.push(`- \\`${f.name}\\` (${f.type}): ${f.description}${examples}`);\n }\n return lines.join('\\n');\n}\n\nfunction buildGuidelinesSection(registry: DescriptorRegistry): string {\n const descriptors = registry.getAll();\n const lines: string[] = [];\n\n for (const desc of descriptors) {\n if (desc.promptGuidelines.length > 0) {\n lines.push(`\\n## ${desc.domainLabel} Guidelines`);\n for (const g of desc.promptGuidelines) {\n lines.push(`- ${g}`);\n }\n }\n }\n\n return lines.join('\\n');\n}\n\nexport function registerAnalyzeTextPrompt(\n server: McpServer,\n models: ReadonlyMap<string, CalculationModel>,\n registry: DescriptorRegistry,\n): void {\n const domainLabel = buildDomainLabel(registry);\n\n server.prompt(\n 'analyze-text',\n `Translate a ${domainLabel} text (law, regulation, policy) into Run-IQ rule definitions. Plugin-aware: includes all required fields.`,\n {\n source_text: z\n .string()\n .describe('The regulatory, legal, or policy text to analyze and convert into rules'),\n country: z.string().optional().describe('ISO country code (e.g. TG, FR, US, IN)'),\n },\n (args) => {\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `You are an expert at translating regulatory and policy texts into structured Run-IQ rules.\n\n## Available Calculation Models\n${buildModelDocs(models)}\n${buildExtensionDocs(registry)}\n${buildInputDocs(registry)}\n${buildGuidelinesSection(registry)}\n\n## Rule Creation Workflow\n1. Read the source text carefully\n2. Identify each rule, rate, threshold, bracket, condition, or exemption\n3. Map each identified element to the appropriate calculation model\n4. Use the \\`create_rule\\` tool — it knows ALL required fields for loaded plugins\n5. Use the \\`validate_rules\\` tool to verify your rules are valid\n6. Read \\`schema://rules\\` for the complete field reference if needed\n\n## JSONLogic Conditions\n\\`\\`\\`json\n{ \"dsl\": \"jsonlogic\", \"value\": { \">=\": [{ \"var\": \"revenue\" }, 100000] } }\n\\`\\`\\`\n${buildExampleDocs(registry)}\n${args.country ? `\\n## Target Country: ${args.country}\\n` : ''}\n## Source Text to Analyze\n${args.source_text}`,\n },\n },\n ],\n };\n },\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { DescriptorRegistry } from '../descriptors/registry.js';\n\nfunction buildGuidelinesSection(registry: DescriptorRegistry): string {\n const descriptors = registry.getAll();\n const allGuidelines: string[] = [];\n\n for (const desc of descriptors) {\n if (desc.promptGuidelines.length > 0) {\n allGuidelines.push(`### ${desc.name} (${desc.domainLabel})`);\n for (const g of desc.promptGuidelines) {\n allGuidelines.push(`- ${g}`);\n }\n }\n }\n\n if (allGuidelines.length === 0) return '';\n return `## Domain-Specific Guidelines\\n${allGuidelines.join('\\n')}`;\n}\n\nfunction buildDomainLabel(registry: DescriptorRegistry): string {\n const descriptors = registry.getAll();\n if (descriptors.length === 0) return 'general-purpose';\n return descriptors.map((d) => d.domainLabel).join(' + ');\n}\n\nexport function registerDomainExpertPrompt(server: McpServer, registry: DescriptorRegistry): void {\n const descriptors = registry.getAll();\n const domainLabel = buildDomainLabel(registry);\n const pluginList = descriptors.map((d) => `- ${d.name}: ${d.description}`).join('\\n');\n\n server.prompt(\n 'domain-expert',\n `${domainLabel} calculation expertise: scenario comparison, result explanation, recommendations`,\n {\n question: z.string().describe('The question or scenario to analyze'),\n },\n (args) => {\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `You are a ${domainLabel} expert assistant powered by the Run-IQ PPE (Parametric Policy Engine).\n\n## Loaded Plugins\n${pluginList || 'No plugins loaded.'}\n\n## Your Tools\n- **evaluate**: evaluate rules against input data (always dry-run)\n- **simulate**: compare N scenarios side-by-side\n- **validate_rules**: verify rule structure, checksum, and plugin-specific fields\n- **explain_result**: human-readable result explanation\n- **create_rule**: generate rules with ALL required plugin fields\n- **inspect_rule**: analyze a single rule in detail\n- **list_models**: show available calculation models\n- **create_checksum**: compute SHA-256 for params\n\n## Key Resources\n- \\`schema://rules\\` — THE complete rule schema reference\n- \\`models://catalog\\` — model documentation with examples\n- \\`plugins://loaded\\` — loaded plugins and their capabilities\n\n## General Guidelines\n1. Always read \\`schema://rules\\` before creating rules — it has ALL required fields\n2. When comparing scenarios, use the \\`simulate\\` tool with clear labels\n3. Always validate rules after creating them\n\n${buildGuidelinesSection(registry)}\n\n## Question\n${args.question}`,\n },\n },\n ],\n };\n },\n );\n}\n","{\r\n \"name\": \"@run-iq/mcp-server\",\r\n \"version\": \"0.1.9\",\r\n \"description\": \"MCP server exposing the PPE engine to LLMs via stdio\",\r\n \"type\": \"module\",\r\n \"main\": \"./dist/index.js\",\r\n \"types\": \"./dist/index.d.ts\",\r\n \"bin\": {\r\n \"run-iq-mcp\": \"./dist/index.js\",\r\n \"mcp-server\": \"./dist/index.js\"\r\n },\r\n \"exports\": {\r\n \".\": {\r\n \"types\": \"./dist/index.d.ts\",\r\n \"default\": \"./dist/index.js\"\r\n }\r\n },\r\n \"files\": [\r\n \"dist\"\r\n ],\r\n \"scripts\": {\r\n \"build\": \"tsup\",\r\n \"test\": \"vitest run\",\r\n \"typecheck\": \"tsc --noEmit\",\r\n \"lint\": \"eslint src/ tests/ && prettier --check src/ tests/\",\r\n \"lint:fix\": \"eslint src/ tests/ --fix && prettier --write src/ tests/\"\r\n },\r\n \"dependencies\": {\r\n \"@modelcontextprotocol/sdk\": \"^1.27.0\",\r\n \"@run-iq/core\": \"^0.2.0\",\r\n \"@run-iq/plugin-sdk\": \"^0.2.2\",\r\n \"zod\": \"^3.23.0\"\r\n },\r\n \"devDependencies\": {\r\n \"@types/node\": \"^20.11.0\",\r\n \"@typescript-eslint/eslint-plugin\": \"^7.0.0\",\r\n \"@typescript-eslint/parser\": \"^7.0.0\",\r\n \"eslint\": \"^8.57.0\",\r\n \"prettier\": \"^3.2.0\",\r\n \"tsup\": \"^8.0.0\",\r\n \"typescript\": \"^5.7.0\",\r\n \"vitest\": \"^3.0.0\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/Run-IQ/mcp-server.git\"\r\n },\r\n \"homepage\": \"https://github.com/Run-IQ/mcp-server#readme\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/Run-IQ/mcp-server/issues\"\r\n },\r\n \"author\": \"Abdou-Raouf ATARMLA\",\r\n \"license\": \"MIT\",\r\n \"engines\": {\r\n \"node\": \">=20.0.0\"\r\n }\r\n}\r\n","import pkg from '../../package.json' with { type: 'json' };\nexport const VERSION = pkg.version;\n"],"mappings":";;;AACA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;;;ACFrC,SAAS,iBAAiB;;;ACOnB,IAAM,qBAAN,MAAyB;AAAA,EACb,cAAkC,CAAC;AAAA,EAEpD,SAAS,YAAoC;AAC3C,SAAK,YAAY,KAAK,UAAU;AAAA,EAClC;AAAA,EAEA,SAAsC;AACpC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,oBAAoD;AAClD,WAAO,KAAK,YAAY,QAAQ,CAAC,MAAM,EAAE,cAAc;AAAA,EACzD;AAAA,EAEA,iBAAkD;AAChD,UAAM,OAAO,oBAAI,IAAY;AAC7B,UAAM,SAAiC,CAAC;AACxC,eAAW,KAAK,KAAK,aAAa;AAChC,iBAAW,KAAK,EAAE,aAAa;AAC7B,YAAI,CAAC,KAAK,IAAI,EAAE,IAAI,GAAG;AACrB,eAAK,IAAI,EAAE,IAAI;AACf,iBAAO,KAAK,CAAC;AAAA,QACf;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,cAAsC;AACpC,WAAO,KAAK,YAAY,QAAQ,CAAC,MAAM,EAAE,QAAQ;AAAA,EACnD;AAAA,EAEA,UAAmB;AACjB,WAAO,KAAK,YAAY,WAAW;AAAA,EACrC;AACF;;;AD9BO,SAAS,aAAaA,UAAkD;AAC7E,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,GAAG;AAChD,eAAW,KAAK,KAAK,IAAI,CAAC,CAAE;AAC5B;AAAA,EACF;AACF;AAGA,IAAM,UAA0B,CAAC;AACjC,IAAI,YAAY;AACd,QAAM,aAAa,MAAM,mBAAmB,UAAU;AACtD,UAAQ,KAAK,GAAG,UAAU;AAC5B;AACA,IAAI,WAAW,SAAS,GAAG;AACzB,QAAM,aAAa,MAAM,eAAe,UAAU;AAClD,UAAQ,KAAK,GAAG,UAAU;AAC5B;AAEA,IAAM,EAAE,QAAQ,QAAQ,oBAAoB,SAAS,KAAK,IAAI,aAAa,OAAO;AAClF,IAAM,cAAc,mBAAmB,OAAO;AAE9C,IAAM,SAAS,IAAI;AAAA,EACjB;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,cAAc;AAAA,MACZ,OAAO,CAAC;AAAA,MACR,WAAW,CAAC;AAAA,MACZ,SAAS,CAAC;AAAA,IACZ;AAAA,EACF;AACF;AAGA,2BAA2B,MAAM;AACjC,uBAAuB,QAAQ,WAAW;AAC1C,0BAA0B,QAAQ,QAAQ,WAAW;AACrD,uBAAuB,QAAQ,MAAM;AACrC,qBAAqB,QAAQ,MAAM;AACnC,wBAAwB,QAAQ,QAAQ,WAAW;AACnD,0BAA0B,MAAM;AAChC,qBAAqB,QAAQ,MAAM;AAGnC,uBAAuB,QAAQ,MAAM;AACrC,wBAAwB,QAAQ,SAAS,MAAM,kBAAkB;AACjE,uBAAuB,QAAQ,QAAQ,kBAAkB;AAGzD,0BAA0B,QAAQ,QAAQ,kBAAkB;AAC5D,2BAA2B,QAAQ,kBAAkB;AAGrD,IAAM,YAAY,IAAI,qBAAqB;AAC3C,MAAM,OAAO,QAAQ,SAAS;","names":["bundles","descriptorRegistry","engine","models","require","bundles","server","createHash","z","descriptors","server","descriptors","createHash","createHash","z","z","server","models","descriptors","createHash","server","models","z","server","engine","createHash","z","server","models","descriptors","z","createHash","z","server","z","hydrateRules","server","engine","models","server","server","plugins","dsls","descriptors","models","descriptors","examples","server","z","descriptors","models","server","z","buildGuidelinesSection","descriptors","buildDomainLabel","server"]}
|