canli-validation-mcp 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -378,6 +378,8 @@ HTTP stub. It neither publishes a package nor issues a production API key.
378
378
 
379
379
  ## Dependencies
380
380
 
381
- Only `@modelcontextprotocol/sdk` (pinned exact) and `zod` (pinned exact). No other runtime
382
- dependency is added, and nothing in this package touches the site's root `package.json`,
381
+ Only `@modelcontextprotocol/server` (pinned exact; the MCP SDK's server package, which itself
382
+ depends only on `@modelcontextprotocol/core` and `zod`) and `zod` (pinned exact): four packages in
383
+ the installed tree, where 0.7 and earlier pulled in about 95 through `@modelcontextprotocol/sdk`.
384
+ No other runtime dependency is added, and nothing in this package touches the site's root `package.json`,
383
385
  `.vercelignore`, `api/`, `scripts/`, `js/`, or `public/`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "canli-validation-mcp",
3
- "version": "0.7.1",
4
- "description": "MCP server for canlicapital.com's free validation API: deflated Sharpe, CSCV overfitting, paper-evidence conformance, and breadth ceiling, each returned as the full API envelope so the boundary language cannot be dropped.",
3
+ "version": "0.8.0",
4
+ "description": "Check whether a backtest is real: deflated Sharpe, CSCV probability of backtest overfitting, minimum track record and backtest length, haircut Sharpe and luck-equivalent trials, as an MCP server. Local mode, hosted endpoint, signed receipts.",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -16,11 +16,11 @@
16
16
  "README.md"
17
17
  ],
18
18
  "scripts": {
19
- "test": "node --test test/*.test.mjs",
19
+ "test": "node --test test/*.test.mjs test/*.test.js",
20
20
  "test:package": "node test/package-smoke.mjs"
21
21
  },
22
22
  "dependencies": {
23
- "@modelcontextprotocol/sdk": "1.30.0",
23
+ "@modelcontextprotocol/server": "2.1.0",
24
24
  "zod": "4.6.5"
25
25
  },
26
26
  "mcpName": "io.github.arhancanli/canli-validation-mcp",
@@ -34,6 +34,7 @@
34
34
  "url": "https://github.com/arhancanli/canlicapital/issues"
35
35
  },
36
36
  "devDependencies": {
37
+ "@modelcontextprotocol/client": "2.1.0",
37
38
  "fast-check": "4.10.2"
38
39
  }
39
40
  }
package/src/schemas.mjs CHANGED
@@ -303,17 +303,61 @@ export const REGISTRY_DESCRIPTION_MAX = 100;
303
303
  // calls the tool, not only inside the returned envelope.
304
304
  export const TOOL_DESCRIPTIONS = Object.freeze({
305
305
  get_key: `Issue a free canlicapital.com validation key (POST /api/v1/keys) and hold it in memory for this session. Only needed before a validation when neither CANLI_KEY nor local mode is set; the read tools (get_receipt, service_status, company_financial_history) never need a key. ${LIMITS_SENTENCES.quotas}`,
306
- validate_deflated_sharpe: `Whether a Sharpe survives the number of variants tried: probabilistic and deflated Sharpe (0 to 1) and the Sharpe luck alone would reach. Send the seven statistics or a return series, not both. ${LIMITS_SENTENCES.notAdmission}`,
307
- audit_backtest: `Audit one strategy's return series in one call: deflated Sharpe, the minimum track record length for its Sharpe to beat the benchmark, and, with every variant's returns, the probability of backtest overfitting. Point returns_file at the backtest's CSV or JSON rather than copying long series into the call. Each check is the matching validate_ tool's result with its own receipt, side by side; the audit does not grade the strategy. Uses one validation per check. ${LIMITS_SENTENCES.notAdmission}`,
308
- validate_overfitting: `Probability (0 to 1) that picking the best of several backtested variants was overfitting, by CSCV over every variant's returns. ${LIMITS_SENTENCES.notAdmission}`,
309
- validate_paper_evidence: `Whether a paper or simulated performance record meets canli.paper-evidence.v0, with each failure's JSON pointer. ${LIMITS_SENTENCES.scope}`,
310
- validate_backtest_length: `Minimum backtest length, in years, before the best of N independent trials is not expected to reach a target Sharpe by luck, and with backtest_years, the most independent trials those years allow. Send effective_independent_trials, backtest_years, or both. ${LIMITS_SENTENCES.notAdmission}`,
311
- validate_luck_trials: `How many skill-less strategies a search would have had to try for its best to reach this Sharpe by luck, and, with a trial count, the chance that it did. Calibrated by Monte Carlo. ${LIMITS_SENTENCES.notAdmission}`,
312
- validate_haircut_sharpe: `Haircut Sharpe ratio for multiple testing (Harvey and Liu, 2015): the Sharpe a single test would have needed once the number of tests is counted, by Bonferroni and for independent tests, and with the other tests' Sharpe ratios by Holm and BHY. ${LIMITS_SENTENCES.notAdmission}`,
313
- validate_track_record: `Minimum track record length, in observations and years, for an observed Sharpe to beat a benchmark at a confidence level, and with observations, the record's probabilistic Sharpe so far. ${LIMITS_SENTENCES.notAdmission}`,
314
- validate_breadth: `Highest book Sharpe reachable by adding sleeves of this quality and correlation, the Sharpe at a sleeve count, and the sleeves a target needs. ${LIMITS_SENTENCES.scope}`,
306
+ validate_deflated_sharpe: `Deflated Sharpe ratio: the probability (0 to 1) that one selected strategy's Sharpe beats the best Sharpe that luck alone would give across the variants tried, with the probabilistic Sharpe and that luck benchmark. Use it for the strategy you kept after a search, when you know how many variants were tried and how their Sharpe ratios spread; send the seven statistics or a return series, not both. With every variant's returns use validate_overfitting; to state luck as a trial count use validate_luck_trials; for a multiple-testing haircut use validate_haircut_sharpe. ${LIMITS_SENTENCES.notAdmission}`,
307
+ audit_backtest: `Audit one strategy's return series in one call: deflated Sharpe, the minimum track record length for its Sharpe to beat the benchmark, and, with every variant's returns, the probability of backtest overfitting. Point returns_file at the backtest's CSV or JSON rather than copying long series into the call. Each check is the matching validate_ tool's result with its own receipt, side by side; the audit does not grade the strategy. Prefer it to calling those validators one by one when you have one strategy's return series. Uses one validation per check. ${LIMITS_SENTENCES.notAdmission}`,
308
+ validate_overfitting: `Probability of backtest overfitting (0 to 1) by CSCV: how often the variant that is best in sample falls below the median out of sample. Use it when you have every variant's returns as a matrix (periods by variants); with summary statistics only, use validate_deflated_sharpe. ${LIMITS_SENTENCES.notAdmission}`,
309
+ validate_paper_evidence: `Whether a paper or simulated performance record meets canli.paper-evidence.v0, with each failure's JSON pointer. Use it on a record document before publishing or relying on it: it checks structure and required disclosures, not whether the returns are good. ${LIMITS_SENTENCES.scope}`,
310
+ validate_backtest_length: `Minimum backtest length, in years, before the best of N independent trials is not expected to reach a target Sharpe by luck, and with backtest_years, the most independent trials those years allow. Send effective_independent_trials, backtest_years, or both. Use it before or while planning a search, to size the backtest for the number of trials; once a search has a result, use validate_deflated_sharpe. ${LIMITS_SENTENCES.notAdmission}`,
311
+ validate_luck_trials: `How many skill-less strategies a search would have had to try for its best to reach this Sharpe by luck, and, with a trial count, the chance that it did. Calibrated by Monte Carlo. Use it to state luck as a count ("as good as the best of N random tries") or to test a result against the trials actually run; for a probability that the Sharpe is real, use validate_deflated_sharpe. ${LIMITS_SENTENCES.notAdmission}`,
312
+ validate_haircut_sharpe: `Haircut Sharpe ratio for multiple testing (Harvey and Liu, 2015): the Sharpe a single test would have needed once the number of tests is counted, by Bonferroni and for independent tests, and with the other tests' Sharpe ratios by Holm and BHY. Use it to report a Sharpe adjusted for the number of tests, as finance papers do; for a probability that the Sharpe is real, use validate_deflated_sharpe. ${LIMITS_SENTENCES.notAdmission}`,
313
+ validate_track_record: `Minimum track record length, in observations and years, for an observed Sharpe to beat a benchmark at a confidence level, and with observations, the record's probabilistic Sharpe so far. Use it for a live or paper record: how long it must run before its Sharpe is evidence. To size a backtest against the number of trials, use validate_backtest_length. ${LIMITS_SENTENCES.notAdmission}`,
314
+ validate_breadth: `Highest book Sharpe reachable by adding sleeves of this quality and correlation, the Sharpe at a sleeve count, and the sleeves a target needs. Use it for portfolio construction, to see what adding strategies can and cannot do; it validates no single strategy. ${LIMITS_SENTENCES.scope}`,
315
315
  verify_receipt: `Check a validation receipt's Ed25519 signature offline against the canlicapital.com public key bundled in this package, that its output hashes to its output_sha256, and that its content hashes to its id. Send an id to fetch the receipt first, or a receipt already fetched. ${LIMITS_SENTENCES.unsigned}`,
316
- get_receipt: `Fetch a stored verdict by receipt id (GET /api/v1/receipts/{id}) to re-check an earlier result. No key. ${LIMITS_SENTENCES.unsigned}`,
316
+ get_receipt: `Fetch a stored verdict by receipt id (GET /api/v1/receipts/{id}) to re-read an earlier result. No key. To check that the receipt is genuine, use verify_receipt. ${LIMITS_SENTENCES.unsigned}`,
317
317
  service_status: `Whether the validation API is up, with quota constants (GET /api/v1/validate/status); check after a timeout before resubmitting. No key. ${LIMITS_SENTENCES.scope}`,
318
318
  company_financial_history: `SEC-reported financial history for one company from the canlicapital.com company reference (GET /company-data/{cik}.json), by cik or by ticker (resolved through GET /api/v1/company-tickers.json, companies in the release only). Without a concept it lists the available histories; with one it returns observations, newest first, each with its filing accession, form, filed date and unit, plus the SHA-256 of the original SEC response. No key required. ${COMPANY_REFERENCE_BOUNDARY}`,
319
319
  });
320
+
321
+ // Output schemas (0.8.0). Published OPEN: extra fields always pass. A client validates a tool's
322
+ // structured result against the output schema it listed, so a closed schema turns every field a
323
+ // later version adds into a failed call (2026-09-26, the mcp-factory servers). Every field is
324
+ // optional because refusals and local results carry different subsets. They are kept terse: the
325
+ // tool list is re-sent to the model every turn, and one sentence per schema says what to read.
326
+ const refusal = z.looseObject({}).nullable().optional();
327
+ const sentences = z.array(z.string()).optional();
328
+ const loose = z.looseObject({}).optional();
329
+
330
+ export const validationOutput = z
331
+ .looseObject({
332
+ data: loose,
333
+ error: refusal,
334
+ limits: sentences,
335
+ receipt: z.looseObject({}).nullable().optional(),
336
+ computed: z.string().optional(),
337
+ note: z.string().optional(),
338
+ })
339
+ .describe("data.result holds the statistics (data.plain_reading states them); limits say what the result does not establish; receipt ({id, url}) is the signed record, null when none was stored; error ({code, message}) is set only on refusal.");
340
+
341
+ export const auditOutput = z
342
+ .looseObject({ readings: loose, checks: loose, not_run: loose, limits: sentences, note: z.string().optional(), error: refusal })
343
+ .describe("checks holds each check's full validate_ result by name; readings one sentence per check; not_run the checks skipped and why.");
344
+
345
+ export const keyOutput = z
346
+ .looseObject({ note: z.string().optional(), key_source: z.string().optional(), key_present: z.boolean().optional(), data: loose, error: refusal })
347
+ .describe("key_source says which key the session uses; data.key is set when a new key was issued.");
348
+
349
+ export const receiptOutput = z
350
+ .looseObject({ data: loose, error: refusal, limits: sentences })
351
+ .describe("data is the stored receipt: validator, input, output, their hashes, source hashes and signature.");
352
+
353
+ export const verifyReceiptOutput = z
354
+ .looseObject({ receipt_id: z.string().nullable().optional(), valid: z.boolean().optional(), checks: z.unknown().optional(), key_id: z.string().nullable().optional(), meaning: z.string().optional(), error: refusal })
355
+ .describe("valid is true only when the signature, output hash and content id all check out; checks lists each.");
356
+
357
+ export const statusOutput = z
358
+ .looseObject({ data: loose, limits: sentences, error: refusal })
359
+ .describe("data.store_reachable, data.quotas and, when available, data.usage for this key.");
360
+
361
+ export const companyHistoryOutput = z
362
+ .looseObject({ company: loose, claim_boundary: z.string().optional(), source: loose, histories: z.array(z.unknown()).optional(), history: loose, error: refusal })
363
+ .describe("Without a concept, histories lists what is available; with one, history holds the observations newest first as columns and rows, each with its filing. Values are as reported to the SEC.");
package/src/server.mjs CHANGED
@@ -8,33 +8,13 @@
8
8
  // CANLI_KEY; when CANLI_KEY is set, get_key does not call the network.
9
9
  import { readFileSync, realpathSync } from "node:fs";
10
10
  import { pathToFileURL } from "node:url";
11
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
11
+ import { McpServer } from "@modelcontextprotocol/server";
12
12
  import { z } from "zod";
13
13
  import { computeLocally } from "./local.mjs";
14
14
  import { readMatrixFile, readSeriesFile } from "./series-file.mjs";
15
15
  import { verifyReceipt } from "./local/js/receipt-statement.js";
16
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
17
- import {
18
- breadthInput,
19
- trackRecordInput,
20
- auditBacktestInput,
21
- verifyReceiptToolShape,
22
- backtestLengthInput,
23
- haircutSharpeInput,
24
- luckTrialsInput,
25
- auditBacktestToolShape,
26
- companyHistoryInput,
27
- companyHistoryToolShape,
28
- deflatedSharpeInput,
29
- deflatedSharpeToolShape,
30
- emptyInput,
31
- getKeyInput,
32
- getReceiptInput,
33
- overfittingInput,
34
- LIMITS_SENTENCES,
35
- paperEvidenceInput,
36
- TOOL_DESCRIPTIONS,
37
- } from "./schemas.mjs";
16
+ import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
17
+ import { breadthInput, trackRecordInput, auditBacktestInput, verifyReceiptToolShape, backtestLengthInput, haircutSharpeInput, luckTrialsInput, auditBacktestToolShape, companyHistoryInput, companyHistoryToolShape, deflatedSharpeInput, deflatedSharpeToolShape, emptyInput, getKeyInput, getReceiptInput, overfittingInput, LIMITS_SENTENCES, paperEvidenceInput, TOOL_DESCRIPTIONS, validationOutput, auditOutput, keyOutput, receiptOutput, verifyReceiptOutput, statusOutput, companyHistoryOutput } from "./schemas.mjs";
38
18
 
39
19
  export const DEFAULT_BASE = "https://canlicapital.com";
40
20
  export const SERVER_NAME = "canlicapital-validation-mcp";
@@ -526,72 +506,72 @@ export function registerTools(server, session) {
526
506
  const register = (name, ...rest) => { if (enabled.has(name)) server.registerTool(name, ...rest); };
527
507
  register(
528
508
  "get_key",
529
- { title: "Get a free validation key", annotations: { title: "Get a free validation key", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true }, description: TOOL_DESCRIPTIONS.get_key, inputSchema: getKeyInput },
509
+ { title: "Get a free validation key", annotations: { title: "Get a free validation key", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true }, description: TOOL_DESCRIPTIONS.get_key, inputSchema: getKeyInput, outputSchema: keyOutput },
530
510
  (args) => toolGetKey(session, args),
531
511
  );
532
512
  register(
533
513
  "validate_deflated_sharpe",
534
- { title: "Validate deflated Sharpe", annotations: { title: "Validate deflated Sharpe", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_deflated_sharpe, inputSchema: deflatedSharpeToolShape },
514
+ { title: "Validate deflated Sharpe", annotations: { title: "Validate deflated Sharpe", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_deflated_sharpe, inputSchema: deflatedSharpeToolShape, outputSchema: validationOutput },
535
515
  (args) => toolValidateDeflatedSharpe(session, args),
536
516
  );
537
517
  register(
538
518
  "validate_overfitting",
539
- { title: "Validate overfitting (CSCV)", annotations: { title: "Validate overfitting (CSCV)", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_overfitting, inputSchema: overfittingInput },
519
+ { title: "Validate overfitting (CSCV)", annotations: { title: "Validate overfitting (CSCV)", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_overfitting, inputSchema: overfittingInput, outputSchema: validationOutput },
540
520
  (args) => toolValidateOverfitting(session, args),
541
521
  );
542
522
  register(
543
523
  "validate_paper_evidence",
544
- { title: "Validate paper evidence", annotations: { title: "Validate paper evidence", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_paper_evidence, inputSchema: paperEvidenceInput },
524
+ { title: "Validate paper evidence", annotations: { title: "Validate paper evidence", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_paper_evidence, inputSchema: paperEvidenceInput, outputSchema: validationOutput },
545
525
  (args) => toolValidatePaperEvidence(session, args),
546
526
  );
547
527
  register(
548
528
  "validate_breadth",
549
- { title: "Validate breadth ceiling", annotations: { title: "Validate breadth ceiling", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_breadth, inputSchema: breadthInput },
529
+ { title: "Validate breadth ceiling", annotations: { title: "Validate breadth ceiling", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_breadth, inputSchema: breadthInput, outputSchema: validationOutput },
550
530
  (args) => toolValidateBreadth(session, args),
551
531
  );
552
532
  register(
553
533
  "validate_track_record",
554
- { title: "Minimum track record length", annotations: { title: "Minimum track record length", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_track_record, inputSchema: trackRecordInput },
534
+ { title: "Minimum track record length", annotations: { title: "Minimum track record length", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_track_record, inputSchema: trackRecordInput, outputSchema: validationOutput },
555
535
  (args) => toolValidateTrackRecord(session, args),
556
536
  );
557
537
  register(
558
538
  "validate_backtest_length",
559
- { title: "Minimum backtest length", annotations: { title: "Minimum backtest length", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_backtest_length, inputSchema: backtestLengthInput },
539
+ { title: "Minimum backtest length", annotations: { title: "Minimum backtest length", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_backtest_length, inputSchema: backtestLengthInput, outputSchema: validationOutput },
560
540
  (args) => toolValidateBacktestLength(session, args),
561
541
  );
562
542
  register(
563
543
  "validate_haircut_sharpe",
564
- { title: "Haircut Sharpe ratio", annotations: { title: "Haircut Sharpe ratio", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_haircut_sharpe, inputSchema: haircutSharpeInput },
544
+ { title: "Haircut Sharpe ratio", annotations: { title: "Haircut Sharpe ratio", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_haircut_sharpe, inputSchema: haircutSharpeInput, outputSchema: validationOutput },
565
545
  (args) => toolValidateHaircutSharpe(session, args),
566
546
  );
567
547
  register(
568
548
  "validate_luck_trials",
569
- { title: "Luck-equivalent trials", annotations: { title: "Luck-equivalent trials", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_luck_trials, inputSchema: luckTrialsInput },
549
+ { title: "Luck-equivalent trials", annotations: { title: "Luck-equivalent trials", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.validate_luck_trials, inputSchema: luckTrialsInput, outputSchema: validationOutput },
570
550
  (args) => toolValidateLuckTrials(session, args),
571
551
  );
572
552
  register(
573
553
  "audit_backtest",
574
- { title: "Audit a backtest", annotations: { title: "Audit a backtest", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.audit_backtest, inputSchema: auditBacktestToolShape },
554
+ { title: "Audit a backtest", annotations: { title: "Audit a backtest", ...WRITES_RECEIPT }, description: TOOL_DESCRIPTIONS.audit_backtest, inputSchema: auditBacktestToolShape, outputSchema: auditOutput },
575
555
  (args) => toolAuditBacktest(session, args),
576
556
  );
577
557
  register(
578
558
  "get_receipt",
579
- { title: "Get a receipt", annotations: { title: "Get a receipt", ...READ_ONLY }, description: TOOL_DESCRIPTIONS.get_receipt, inputSchema: getReceiptInput },
559
+ { title: "Get a receipt", annotations: { title: "Get a receipt", ...READ_ONLY }, description: TOOL_DESCRIPTIONS.get_receipt, inputSchema: getReceiptInput, outputSchema: receiptOutput },
580
560
  (args) => toolGetReceipt(session, args),
581
561
  );
582
562
  register(
583
563
  "verify_receipt",
584
- { title: "Verify a receipt", annotations: { title: "Verify a receipt", ...READ_ONLY }, description: TOOL_DESCRIPTIONS.verify_receipt, inputSchema: verifyReceiptToolShape },
564
+ { title: "Verify a receipt", annotations: { title: "Verify a receipt", ...READ_ONLY }, description: TOOL_DESCRIPTIONS.verify_receipt, inputSchema: verifyReceiptToolShape, outputSchema: verifyReceiptOutput },
585
565
  (args) => toolVerifyReceipt(session, args),
586
566
  );
587
567
  register(
588
568
  "service_status",
589
- { title: "Service status", annotations: { title: "Service status", ...READ_ONLY }, description: TOOL_DESCRIPTIONS.service_status, inputSchema: emptyInput },
569
+ { title: "Service status", annotations: { title: "Service status", ...READ_ONLY }, description: TOOL_DESCRIPTIONS.service_status, inputSchema: emptyInput, outputSchema: statusOutput },
590
570
  () => toolServiceStatus(session),
591
571
  );
592
572
  register(
593
573
  "company_financial_history",
594
- { title: "Company financial history (SEC)", annotations: { title: "Company financial history (SEC)", ...READ_ONLY }, description: TOOL_DESCRIPTIONS.company_financial_history, inputSchema: companyHistoryToolShape },
574
+ { title: "Company financial history (SEC)", annotations: { title: "Company financial history (SEC)", ...READ_ONLY }, description: TOOL_DESCRIPTIONS.company_financial_history, inputSchema: companyHistoryToolShape, outputSchema: companyHistoryOutput },
595
575
  (args) => toolCompanyFinancialHistory(session, args),
596
576
  );
597
577
  }