evidence-mcp-dev 1.0.19 → 1.0.21

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.
Files changed (2) hide show
  1. package/dist/index.js +101 -56
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3217,6 +3217,7 @@ var VARIABLES = [
3217
3217
  "FH_EVIDENCE_DIR",
3218
3218
  "FH_LOG_KEEP_DAYS",
3219
3219
  "FH_ENV",
3220
+ "FH_SOURCES",
3220
3221
  "FH_TIERS",
3221
3222
  "FH_CONTACT_EMAIL",
3222
3223
  "FH_ELSEVIER_API_KEY",
@@ -3303,7 +3304,8 @@ function resolveTiers(env = process.env) {
3303
3304
  for (const t of BUILTIN) available.set(t.name, t.make({ tokens: tokens2, api_key: str("FH_CORE_API_KEY", env) || void 0 }));
3304
3305
  const proxyUrl = str("FH_PROXY_URL", env);
3305
3306
  if (proxyUrl) available.set("proxy", urlTier("proxy", proxyUrl, proxyHeaders(str("FH_PROXY_HEADERS", env))));
3306
- const listed = str("FH_TIERS", env);
3307
+ const key2 = str("FH_SOURCES", env) || !str("FH_TIERS", env) ? "FH_SOURCES" : "FH_TIERS";
3308
+ const listed = str(key2, env);
3307
3309
  const order2 = listed ? listed.split(",").map((s) => s.trim()).filter(Boolean) : [...available.keys()];
3308
3310
  const tiers = [], seen2 = /* @__PURE__ */ new Set();
3309
3311
  for (const name of order2) {
@@ -3311,11 +3313,11 @@ function resolveTiers(env = process.env) {
3311
3313
  seen2.add(name);
3312
3314
  const t = available.get(name);
3313
3315
  if (t) tiers.push(t);
3314
- else if (name === "proxy") problems.push('FH_TIERS: "proxy" listed, but FH_PROXY_URL is unset');
3315
- else problems.push(`FH_TIERS: unknown tier "${name}" (built-in: ${BUILTIN.map((t2) => t2.name).join(", ")}; proxy when FH_PROXY_URL is set)`);
3316
+ else if (name === "proxy") problems.push(`${key2}: "proxy" listed, but FH_PROXY_URL is unset`);
3317
+ else problems.push(`${key2}: unknown source "${name}" (built-in: ${BUILTIN.map((t2) => t2.name).join(", ")}; proxy when FH_PROXY_URL is set)`);
3316
3318
  }
3317
3319
  const all = [...tiers.map((t) => ({ name: t.name, enabled: true })), ...[...available.keys()].filter((n) => !seen2.has(n)).map((name) => ({ name, enabled: false }))];
3318
- return { tiers, all, source: sourceOf("FH_TIERS", env), problems };
3320
+ return { tiers, all, source: sourceOf(key2, env), problems };
3319
3321
  }
3320
3322
 
3321
3323
  // src/verify/google.ts
@@ -5264,7 +5266,7 @@ async function verifyClaim(claim, id, cfg, decide, read2 = readPaper) {
5264
5266
  if (!cfg || !decide) return { ...out, error: "no decision model configured: set FH_VERIFY_PROVIDER and its API key in .env" };
5265
5267
  out.basis = paper.basis;
5266
5268
  out.glyphs_unresolved = countUnresolved(paper.text);
5267
- if (paper.basis === "title") return { ...out, verdict: "fail", reason: NOTHING_TO_VERIFY };
5269
+ if (paper.basis === "title") return { ...out, verdict: "not_supported", reason: NOTHING_TO_VERIFY };
5268
5270
  const ws = windows(paper.text, cfg.window_chars);
5269
5271
  out.windows = ws.length;
5270
5272
  try {
@@ -5282,8 +5284,8 @@ async function verifyClaim(claim, id, cfg, decide, read2 = readPaper) {
5282
5284
  } catch (e) {
5283
5285
  return { ...out, error: e instanceof Error ? e.message : String(e) };
5284
5286
  }
5285
- if (out.score >= cfg.threshold) return { ...out, verdict: "pass" };
5286
- return paper.basis === "full_text" ? { ...out, verdict: "fail" } : { ...out, verdict: "unverifiable", reason: "only the abstract is stored and it does not state the claim; the full text may" };
5287
+ if (out.score >= cfg.threshold) return { ...out, verdict: "supported" };
5288
+ return paper.basis === "full_text" ? { ...out, verdict: "not_supported" } : { ...out, verdict: "unverifiable", reason: "only the abstract is stored and it does not state the claim; the full text may" };
5287
5289
  }
5288
5290
 
5289
5291
  // src/verify/cache.ts
@@ -5302,7 +5304,11 @@ var verdictFile = (libraryDir, key2) => join11(libraryDir, "verify", key2.slice(
5302
5304
  function readVerdict(file3) {
5303
5305
  if (!existsSync12(file3)) return null;
5304
5306
  try {
5305
- return JSON.parse(readFileSync10(file3, "utf8"));
5307
+ const c = JSON.parse(readFileSync10(file3, "utf8"));
5308
+ const old = c.verdict;
5309
+ if (old === "pass") c.verdict = "supported";
5310
+ else if (old === "fail") c.verdict = "not_supported";
5311
+ return c;
5306
5312
  } catch {
5307
5313
  return null;
5308
5314
  }
@@ -6126,6 +6132,11 @@ function getObject(lib, evid, name, opts = {}, env = process.env) {
6126
6132
  const text4 = readFileSync15(file3, "utf8");
6127
6133
  const type = typeOf(name);
6128
6134
  const maxChars = opts.max_chars ?? DEFAULT_MAX_CHARS;
6135
+ if (opts.lines !== void 0) {
6136
+ if (opts.section !== void 0 || opts.query !== void 0) return fail("lines: alone, not with section or query");
6137
+ if (type === "json") return fail("lines: .md, .txt and .csv objects; a .json object is read whole");
6138
+ return byLines(type, text4, opts.lines, maxChars);
6139
+ }
6129
6140
  if (opts.section !== void 0) {
6130
6141
  if (type !== "md") return fail(`section: .md objects only; ${name} is .${type}`);
6131
6142
  if (opts.query === void 0) {
@@ -6147,7 +6158,7 @@ function getObject(lib, evid, name, opts = {}, env = process.env) {
6147
6158
  return { ok: true, ...r };
6148
6159
  }
6149
6160
  if (text4.length <= maxChars) return { ok: true, content: text4 };
6150
- return { ok: true, too_large: `${text4.length} chars, above max_chars ${maxChars}: the outline instead; read with section or query, or a larger max_chars`, outline: outlineOf(type, text4) };
6161
+ return { ok: true, too_large: `${text4.length} chars, above max_chars ${maxChars}: the outline instead; read with lines (e.g. "1-50"${type === "csv" ? ", data rows" : ""}), section or query, or a larger max_chars`, outline: outlineOf(type, text4) };
6151
6162
  }
6152
6163
  function outlineOf(type, text4) {
6153
6164
  if (type === "md") {
@@ -6164,6 +6175,38 @@ function outlineOf(type, text4) {
6164
6175
  }
6165
6176
  return { lines: text4.split("\n").length, words: (text4.match(/\S+/g) ?? []).length };
6166
6177
  }
6178
+ function parseLines(spec) {
6179
+ const m = /^\s*(\d+)\s*(?:(-)\s*(\d*))?\s*$/.exec(spec);
6180
+ if (!m) return null;
6181
+ const from = Number(m[1]);
6182
+ const to = m[2] ? m[3] ? Number(m[3]) : null : from;
6183
+ return from >= 1 && (to === null || to >= from) ? { from, to } : null;
6184
+ }
6185
+ function byLines(type, text4, spec, maxChars) {
6186
+ const range = parseLines(spec);
6187
+ if (!range) return fail(`lines: "${spec}" \u2014 give "a-b", "a" or "a-" (1-based)`);
6188
+ let columns2;
6189
+ let items;
6190
+ if (type === "csv") {
6191
+ const r = parseCsv(text4);
6192
+ if (!r.ok) return fail(r.error);
6193
+ [columns2] = r.rows;
6194
+ const physical = text4.replace(/\r?\n$/, "").split(/\r?\n/);
6195
+ items = physical.length === r.rows.length ? physical.slice(1) : r.rows.slice(1).map((row3) => row3.map((c) => /[",\n\r]/.test(c) ? `"${c.replace(/"/g, '""')}"` : c).join(","));
6196
+ } else items = text4.replace(/\n$/, "").split("\n");
6197
+ const total = items.length;
6198
+ if (range.from > total) return fail(`lines: from ${range.from}, but there are ${total}${type === "csv" ? " data rows" : " lines"}`);
6199
+ const want = items.slice(range.from - 1, range.to === null ? total : Math.min(range.to, total));
6200
+ const out = [];
6201
+ let used = 0;
6202
+ for (const l of want) {
6203
+ if (out.length && used + l.length + 1 > maxChars) break;
6204
+ out.push(l);
6205
+ used += l.length + 1;
6206
+ }
6207
+ const last = range.from + out.length - 1;
6208
+ return { ok: true, ...columns2 ? { columns: columns2.join(",") } : {}, [type === "csv" ? "rows" : "text"]: out.join("\n"), first: range.from, last, total, ...last < (range.to === null ? total : Math.min(range.to, total)) ? { cut: `at max_chars ${maxChars}; continue with lines "${last + 1}-"` } : {} };
6209
+ }
6167
6210
  function csvQuery(text4, query, maxHits) {
6168
6211
  const r = parseCsv(text4);
6169
6212
  if (!r.ok) return { error: r.error };
@@ -6220,7 +6263,7 @@ var SCHEMA = {
6220
6263
  required: [...FIELDS2],
6221
6264
  additionalProperties: false
6222
6265
  };
6223
- var fill = (prompt, topic, paper) => prompt.split("{{topic}}").join(topic).split("{{paper}}").join(paper);
6266
+ var fill = (prompt, topic, paper) => prompt.split("{{topic}}").join(topic).split("{{article}}").join(paper);
6224
6267
  var cacheKey2 = (model, prompt, topic) => createHash10("sha256").update(JSON.stringify([model, fill(prompt, topic, "")])).digest("hex").slice(0, 16);
6225
6268
  var ScreenError = class extends Error {
6226
6269
  constructor(message, status) {
@@ -6372,7 +6415,7 @@ var literatureEnabled = (env = process.env) => /^(true|1|yes|on)$/i.test(env.FH_
6372
6415
  var maxQueries = (env = process.env) => num("FH_LITERATURE_MAX_QUERIES", 10, env, (n) => n >= 1 && Number.isInteger(n));
6373
6416
  var maxResultsPerQuery = (env = process.env) => num("FH_LITERATURE_MAX_RESULTS_PER_QUERY", 200, env, (n) => n >= 1 && n <= 1e3 && Number.isInteger(n));
6374
6417
  var COLUMNS6 = ["pmid", "title", "first_author", "year", "journal", "types", "score", "signals", "relevance", "population", "design", "n", "outcome", "finding", "aspect", "reason"];
6375
- var SLOTS = ["{{topic}}", "{{paper}}"];
6418
+ var SLOTS = ["{{topic}}", "{{article}}"];
6376
6419
  var SETTINGS = "FH_LITERATURE_SCREEN_PROVIDER, FH_LITERATURE_SCREEN_API_KEY, FH_LITERATURE_SCREEN_MODEL, FH_LITERATURE_SCREEN_URL";
6377
6420
  var live5 = (lib) => ({
6378
6421
  search: async (query, max) => {
@@ -6388,7 +6431,7 @@ var live5 = (lib) => ({
6388
6431
  const f = entryPaths(lib, "pmid", pmid).md;
6389
6432
  return existsSync19(f) ? readFileSync17(f, "utf8") : null;
6390
6433
  },
6391
- log: (id, message) => log("literature", id, message)
6434
+ log: (id, message) => log("lit", id, message)
6392
6435
  });
6393
6436
  function csvCell(v) {
6394
6437
  const s = v == null ? "" : String(v);
@@ -6447,7 +6490,8 @@ async function doResearch(lib, evid, queries, screening, env = process.env, now2
6447
6490
  const row3 = (p, sc, sig, f) => [p.pmid, p.title, p.first_author, p.year, p.journal, p.types, sc, sig, ...FIELDS2.map((k) => f?.[k] ?? "")].map(csvCell).join(",");
6448
6491
  const signals = (p) => `in ${p.queries.length} of ${n} queries`;
6449
6492
  const queriesJson = JSON.stringify({ date: started, max_results_per_query: perQuery, queries: runs.map((r, i) => ({ ...r, unique: r.error ? 0 : unique(i) })) }, null, 2) + "\n";
6450
- const base = { started, queries: n, failed_queries: runs.filter((r) => r.error).length, found: ids.length, retracted: retracted.size, not_found: notFound, model: screener.model, endpoint: screener.where };
6493
+ const identified = runs.reduce((a, r) => a + r.kept, 0);
6494
+ const base = { started, queries: n, failed_queries: runs.filter((r) => r.error).length, identified, duplicates: identified - ids.length, removed_retracted: retracted.size, not_found: notFound, model: screener.model, endpoint: screener.where };
6451
6495
  const t = Date.now();
6452
6496
  const model = screener.model;
6453
6497
  const text4 = (pmid) => {
@@ -6463,7 +6507,7 @@ Publication types: ${papers.get(pmid).types ?? "none listed"}`;
6463
6507
  if (probe2 && results2[0].error) {
6464
6508
  const error = results2[0].error;
6465
6509
  for (const [name, content] of [["lit-queries.json", queriesJson], ["lit-run.json", JSON.stringify({ ...base, finished: (/* @__PURE__ */ new Date()).toISOString(), state: "failed", error }, null, 2) + "\n"]]) putObject(lib, o.evid, name, content, env);
6466
- return { ok: false, failed: true, error: `screening failed on the first paper (pmid:${probe2}): ${error}. The searches ran: ${kept.length} papers found and stored in the library with their abstracts; nothing was screened, no lit-papers.csv. lit-queries.json and lit-run.json are in the EVID; call again once the cause is fixed (the searches answer from the cache).` };
6510
+ return { ok: false, failed: true, error: `screening failed on the first paper (pmid:${probe2}): ${error}. The searches ran: ${kept.length} papers found and stored in the library with their abstracts; nothing was screened, no lit-map.csv. lit-queries.json and lit-run.json are in the EVID; call again once the cause is fixed (the searches answer from the cache).` };
6467
6511
  }
6468
6512
  results2.push(...await screenAll(lib, order2.filter((pmid) => pmid !== probe2), screening, topic, text4, screener.ask, model, screenParallel(env), note));
6469
6513
  const by = new Map(results2.map((r) => [r.pmid, r]));
@@ -6476,22 +6520,22 @@ Publication types: ${papers.get(pmid).types ?? "none listed"}`;
6476
6520
  const lines = ranked.map(({ p, f, sc }) => row3(p, sc ?? "", signals(p), f));
6477
6521
  const count = (k) => results2.filter((r) => r.screened?.relevance === k).length;
6478
6522
  const failures = results2.filter((r) => r.error);
6479
- const screenRun = { seconds: Math.round((Date.now() - t) / 1e3), screened: results2.filter((r) => r.screened).length, cached: results2.filter((r) => r.cached).length, errors: failures.length, ...failures.length ? { first_error: failures[0].error } : {}, direct: count("direct"), indirect: count("indirect"), background: count("background"), off_topic: count("off-topic") };
6523
+ const screenRun = { screened: results2.filter((r) => r.screened).length, not_screened: failures.length, ...failures.length ? { first_error: failures[0].error } : {}, excluded: count("off-topic"), relevance: { direct: count("direct"), indirect: count("indirect"), background: count("background") }, cached: results2.filter((r) => r.cached).length, seconds: Math.round((Date.now() - t) / 1e3) };
6480
6524
  const csv = [COLUMNS6.join(","), ...lines].join("\n") + "\n";
6481
6525
  const state = "screened";
6482
6526
  const puts = [
6483
6527
  ["lit-screening.md", screening],
6484
6528
  ["lit-queries.json", queriesJson],
6485
- ["lit-papers.csv", csv],
6529
+ ["lit-map.csv", csv],
6486
6530
  ["lit-screened.csv", screenedCsv],
6487
- ["lit-run.json", JSON.stringify({ ...base, finished: (/* @__PURE__ */ new Date()).toISOString(), state, ...screenRun, papers: lines.length }, null, 2) + "\n"]
6531
+ ["lit-run.json", JSON.stringify({ ...base, finished: (/* @__PURE__ */ new Date()).toISOString(), state, ...screenRun, included: lines.length }, null, 2) + "\n"]
6488
6532
  ];
6489
6533
  for (const [name, content] of puts) {
6490
6534
  const r = putObject(lib, o.evid, name, content, env);
6491
6535
  if (!r.ok) return r;
6492
6536
  }
6493
- const partial = failures.length ? { screening_errors: failures.length, first_error: failures[0].error, note: `${failures.length} of ${results2.length} papers could not be screened; they stay in lit-papers.csv, unscored, at the end (errors in lit-screened.csv). Call again to retry only those: screened papers answer from the cache.` } : {};
6494
- return { ok: true, evid: o.evid, state, papers: lines.length, objects: puts.map(([name]) => name), ...partial };
6537
+ const partial = failures.length ? { screening_errors: failures.length, first_error: failures[0].error, note: `${failures.length} of ${results2.length} papers could not be screened; they stay in lit-map.csv, unscored, at the end (errors in lit-screened.csv). Call again to retry only those: screened papers answer from the cache.` } : {};
6538
+ return { ok: true, evid: o.evid, state, included: lines.length, objects: puts.map(([name]) => name), ...partial };
6495
6539
  }
6496
6540
 
6497
6541
  // src/tools.ts
@@ -6502,11 +6546,11 @@ var pkg = (() => {
6502
6546
  return { name: "evidence-mcp", version: "0.0.0" };
6503
6547
  }
6504
6548
  })();
6505
- var INSTRUCTIONS = `evidence-mcp keeps a local library of scientific papers, FDA drug labels, clinical trial records and web pages, so you can check what a source actually says, and searches ClinicalTrials.gov. The server downloads each record, converts it to Markdown and stores it on disk. Every tool returns a small JSON answer; the document itself never enters your context \u2014 except fh_fetch_url, which is the standard fetch tool with a cache. One ID per call.
6549
+ var INSTRUCTIONS = `evidence-mcp keeps a local library of scientific articles, FDA drug labels, clinical trial records and web pages, so you can check what a source actually says, and searches ClinicalTrials.gov. The server downloads each record, converts it to Markdown and stores it on disk. Every tool returns a small JSON answer; the document itself never enters your context \u2014 except fh_fetch_url, which is the standard fetch tool with a cache. One ID per call.
6506
6550
 
6507
6551
  IDs \u2014 always "type:value"
6508
- - pmid:30955454 \u2014 a paper by PubMed ID. Bare digits are taken as a PMID.
6509
- - doi:10.\u2026 \u2014 a paper by DOI. A DOI PubMed indexes is stored under its PMID; any other gets its record from Crossref.
6552
+ - pmid:30955454 \u2014 an article by PubMed ID. Bare digits are taken as a PMID.
6553
+ - doi:10.\u2026 \u2014 an article by DOI. A DOI PubMed indexes is stored under its PMID; any other gets its record from Crossref.
6510
6554
  - dailymed:<set ID> \u2014 an FDA prescribing-information label, current version. The set ID comes from fh_dailymed_search_labels, or is the "setid=" value in the label's DailyMed URL.
6511
6555
  - nct:05173896 \u2014 a ClinicalTrials.gov trial record, current version. NCT05173896 is accepted too.
6512
6556
 
@@ -6516,9 +6560,9 @@ Tools
6516
6560
  - fh_library_status(id) \u2014 the status of one record without downloading; level "missing" when it is not stored.
6517
6561
  - fh_library_read(id, section?, query?, max_chars?, max_hits?, abstract_only?) \u2014 one small piece of a stored document: its outline, one section, or the passages matching a query. abstract_only: true when the abstract is enough \u2014 answered at once, no full-text download.
6518
6562
  - fh_verify_claim(claim, id) \u2014 does this one source state this one finding? A decision model judges the stored text and returns a verdict.
6519
- - fh_pubmed_fetch_articles(pmids) \u2014 title, first author, year, publication types, retracted and level for up to 200 PMIDs at once; faster and far smaller than asking PubMed, known papers from disk, the rest in one request and stored. For abstract or full text: fh_library_read.
6563
+ - fh_pubmed_fetch_articles(pmids) \u2014 title, first author, year, publication types, retracted and level for up to 200 PMIDs at once; faster and far smaller than asking PubMed, known articles from disk, the rest in one request and stored. For abstract or full text: fh_library_read.
6520
6564
  - fh_pubmed_search_articles(query, max_results?, sort?, years?) \u2014 search PubMed in its own syntax: the total and rows in columns order (PMID, title, first author, year, journal, publication types, PMCID, library level); faster and far smaller than asking PubMed. Cached a week.
6521
- ${citationsEnabled() ? "- fh_pubmed_citing_articles(id, types?, years?, sort?, max_results?) \u2014 the papers that cite a paper (pmid: or doi:), as rows in fh_pubmed_search_articles' columns: follow-ups of a trial, later meta-analyses that include it, guidelines (sort: cited), comments on it (types comment, letter, editorial: PubMed's comments on the paper first, listed in comments_on). At most 100 rows, no paging: narrow with types or years. Cached a week.\n" : ""}${evidEnabled() ? "- fh_evid_create(metadata), fh_evid_find(query), fh_evid_list_objects(evid), fh_evid_put(evid, name, content), fh_evid_get(evid, name, section?, query?, max_chars?, max_hits?, previous?) \u2014 an EVID (evid:<16 hex digits>) is a store that outlives the session: metadata fixed at creation, objects (.json, .csv, .txt, .md) any later session or agent given the EVID reads back. Nothing can be deleted; a put keeps the replaced object as its previous version.\n" : ""}${literatureEnabled() ? "- fh_literature_do_research(evid, queries, screening) \u2014 the literature research for an EVID: you bring the PubMed queries and the screening prompt; the result appears in the EVID as lit-papers.csv (fh_evid_get).\n" : ""}- fh_clinicaltrials_search_studies(query | intervention | condition, status?, sort?, max_results?) \u2014 search ClinicalTrials.gov: the total and rows in columns order (NCT ID, title, status, phase, enrollment, dates, primary outcome, conditions, interventions, has_results). Cached a week.
6565
+ ${citationsEnabled() ? "- fh_pubmed_citing_articles(id, types?, years?, sort?, max_results?) \u2014 the articles that cite an article (pmid: or doi:), as rows in fh_pubmed_search_articles' columns: follow-ups of a trial, later meta-analyses that include it, guidelines (sort: cited), comments on it (types comment, letter, editorial: PubMed's comments on the article first, listed in comments_on). At most 100 rows, no paging: narrow with types or years. Cached a week.\n" : ""}${evidEnabled() ? "- fh_evid_create(metadata), fh_evid_find(query), fh_evid_list_objects(evid), fh_evid_put(evid, name, content), fh_evid_get(evid, name, section?, query?, lines?, max_chars?, max_hits?, previous?) \u2014 an EVID (evid:<16 hex digits>) is a store that outlives the session: metadata fixed at creation, objects (.json, .csv, .txt, .md) any later session or agent given the EVID reads back. Nothing can be deleted; a put keeps the replaced object as its previous version.\n" : ""}${literatureEnabled() ? "- fh_literature_map_evidence(evid, queries, screening) \u2014 the evidence map for an EVID: you bring the PubMed queries and the screening prompt; the result, one ranked row per article with its design, population, outcome and finding, appears in the EVID as lit-map.csv (fh_evid_get).\n" : ""}- fh_clinicaltrials_search_studies(query | intervention | condition, status?, sort?, max_results?) \u2014 search ClinicalTrials.gov: the total and rows in columns order (NCT ID, title, status, phase, enrollment, dates, primary outcome, conditions, interventions, has_results). Cached a week.
6522
6566
  - fh_dailymed_search_labels(drug_name, labeler?, max_results?) \u2014 find FDA drug labels by generic or brand name: the total and rows in columns order (set ID, title, labeler, published, version, level), newest first; labeler narrows to one company. Use it rather than DailyMed's search page, which shows no set IDs as Markdown. Cached a week.
6523
6567
  ${webSearchConfigured() ? "- fh_web_search(query, max_results?) \u2014 search the web; use it instead of the built-in web search. Links (title, URL, date, author) with a short passage from each page, not the page text, so a fraction of the context; read a result with fh_fetch_url. site: in the query restricts it to a site, as with any search engine. For more results, search again with other words. Cached locally for a week.\n" : ""}- fh_clinicaltrials_get_study_record(nct) \u2014 one trial as a review needs it (status, design, enrollment, dates, outcomes, eligibility, result publications, summary), from the stored record; added first when missing.
6524
6568
  - fh_clinicaltrials_get_study_results(nct, max_chars?) \u2014 a trial's posted results as Markdown, capped; the outcome titles listed for fh_library_read.
@@ -6526,25 +6570,25 @@ ${webSearchConfigured() ? "- fh_web_search(query, max_results?) \u2014 search th
6526
6570
 
6527
6571
  Hints
6528
6572
  - fh_library_read and fh_verify_claim store a missing record themselves; the fh_library_read answer then carries added: true. No fh_library_add necessary first.
6529
- - Many papers to look over (a search, lit-papers.csv): abstract_only: true for each, then without it only the papers that need the full text.
6530
- - citable false \u2014 the paper is retracted (a retraction notice, or PubMed's publication type), or holds nothing to read: no abstract and no full text. comment says which; corrections lists the notices as {type, pmid, source}.
6573
+ - Many articles to look over (a search, lit-map.csv): abstract_only: true for each, then without it only the articles that need the full text.
6574
+ - citable false \u2014 the article is retracted (a retraction notice, or PubMed's publication type), or holds nothing to read: no abstract and no full text. comment says which; corrections lists the notices as {type, pmid, source}.
6531
6575
  - level \u2014 what is stored: "full_text", "abstract" or "title" (not even an abstract; citable false). "abstract": searched, no full text found (the log says why); or fulltext "not tried": stored from PubMed alone, searched at the next read without abstract_only, verify or add.
6532
6576
  - error "pmid not found", "doi not found", "ctgov: not a study record", "dailymed: not an SPL document" \u2014 no service knows the ID. Remembered for a day (FH_RETRY_AFTER_DAYS): the same call answers from disk with the date it was checked; after that the service is asked again. "invalid id" \u2014 the ID itself is malformed; the same call gives the same answer. A URL is no library ID: it is refused with what to send instead \u2014 the record's ID for a PubMed, doi.org, ClinicalTrials.gov or DailyMed URL, else fh_fetch_url for the web page.
6533
6577
  - Calls may run in parallel: fh_library_add, fh_library_read and fh_verify_claim. Two calls on the same missing record share one add.
6534
- - fh_fetch_url takes any URL that is not a paper, label or trial record; those have IDs, and fh_library_add, fh_library_read and fh_verify_claim work on the stored document. A second pass over the same review reads every page from disk; a failed fetch is remembered for a day.
6578
+ - fh_fetch_url takes any URL that is not an article, label or trial record; those have IDs, and fh_library_add, fh_library_read and fh_verify_claim work on the stored document. A second pass over the same review reads every page from disk; a failed fetch is remembered for a day.
6535
6579
  - To verify that a web page exists and what it is: fh_fetch_url(url, title_only: true). The answer is "Contents of <url>:" and the page's title line \u2014 a few tokens \u2014 or the fetch error; the page itself is stored in full, so a later fh_fetch_url of the same URL reads from disk.
6536
6580
 
6537
6581
  Verifying a claim
6538
- - fh_verify_claim judges one claim against one stored document. A finding backed by three papers takes three calls with the same claim.
6582
+ - fh_verify_claim judges one claim against one stored document. A finding backed by three articles takes three calls with the same claim.
6539
6583
  - It expects the finding as a complete sentence: who or what, the intervention, the outcome, the number. Citation markers and commentary around the finding are not part of what a document states.
6540
- - It can only confirm what this one document states. A finding about two interventions from two papers is two claims, each against its own paper. A summary of several trials ("trials used 60\u2013200 mg") is stated by none of them; the dose this one trial used is.
6584
+ - It can only confirm what this one document states. A finding about two interventions from two articles is two claims, each against its own article. A summary of several trials ("trials used 60\u2013200 mg") is stated by none of them; the dose this one trial used is.
6541
6585
  - It returns error for a claim under four words, a sentence fragment, or a claim still containing citations. A short finding with its setting (in vitro, cell line, dose) is accepted; filler words do not help.
6542
- - verdict "pass" \u2014 the document states the claim. score is the model's probability.
6543
- - verdict "fail" \u2014 the stored full text does not state the claim as worded; fh_library_read with a query shows what the document does say. Or, with basis "title", nothing is stored to read: reason says so, score is null.
6586
+ - verdict "supported" \u2014 the document states the claim. score is the model's probability.
6587
+ - verdict "not_supported" \u2014 the stored full text does not state the claim as worded; fh_library_read with a query shows what the document does say. Or, with basis "title", nothing is stored to read: reason says so, score is null.
6544
6588
  - verdict "unverifiable" \u2014 only the abstract is stored and it does not state the claim; the full text may (reason says so). A retry gives the same answer until a full text is stored.
6545
6589
  - glyphs_unresolved above 0 \u2014 the PDF font lost symbols (minus, \xB1, \u2264); a fail on a number may be the font. fh_library_read shows the passage.
6546
6590
  - superseded true \u2014 a published correction replaced the figure the claim uses; the status's corrections holds the notice.
6547
- - Verdicts are kept for 30 days: the same claim against the same stored text answers from disk, no model call. A paper that gains its full text is judged afresh.
6591
+ - Verdicts are kept for 30 days: the same claim against the same stored text answers from disk, no model call. An article that gains its full text is judged afresh.
6548
6592
 
6549
6593
  Reading a document
6550
6594
  - fh_library_read with only the ID returns the outline: every heading with its word count, and whether the full text or only the abstract is stored.
@@ -6558,7 +6602,7 @@ Reading a document
6558
6602
  Status fields: pmid, pmcid, setid, nctid, publications, year, publication_types, retracted, corrections, citable, comment, has_abstract, level, fulltext, version, retrieved_by, glyphs_unresolved, error. fulltext: "not tried" (no source tried yet) or "stored" (abstract_only read, full text exists). Funding and conflicts of interest: fh_library_read section "Declarations". Answers carry only what the call did not send: no echo of the ID, claim or query; a field that is null or an empty list is left out. fh_verify_claim always has verdict, score (null: no judgement) and basis.
6559
6603
 
6560
6604
  Where records come from: PubMed for the record and abstract; the full text from PubMed Central, Europe PMC, publishers' text-mining links, Unpaywall, OpenAlex, CORE, and a proxy URL template from the configuration. Every action is appended as one line to <library>/logs/evidence.log.`;
6561
- var idSchema = z.string().describe('ID as "type:value": a paper "pmid:30955454" (bare digits count as pmid) or "doi:10.5812/asjsm.110753" (a paper PubMed does not index; a DOI PubMed indexes is taken as its PMID), a drug label "dailymed:<set ID>" (the set ID from fh_dailymed_search_labels, or the "setid=" value of its DailyMed URL), or a trial record "nct:05173896" (the eight digits; nct:NCT05173896 and a bare NCT05173896 are accepted).');
6605
+ var idSchema = z.string().describe('ID as "type:value": an article "pmid:30955454" (bare digits count as pmid) or "doi:10.5812/asjsm.110753" (an article PubMed does not index; a DOI PubMed indexes is taken as its PMID), a drug label "dailymed:<set ID>" (the set ID from fh_dailymed_search_labels, or the "setid=" value of its DailyMed URL), or a trial record "nct:05173896" (the eight digits; nct:NCT05173896 and a bare NCT05173896 are accepted).');
6562
6606
  var levelWord = (m) => m.level === "abstract" && !m.has_abstract ? "title" : m.level;
6563
6607
  var json = (s) => ({ content: [{ type: "text", text: statusAnswer(s) }] });
6564
6608
  function noticeTag(m) {
@@ -6574,10 +6618,10 @@ function noticeTag(m) {
6574
6618
  var modelFailure = (error, cfg) => error.startsWith("no decision model configured") || !!cfg && error.startsWith(`${cfg.model}:`);
6575
6619
  function registerTools(server2) {
6576
6620
  async function completeFulltext(paths, meta, requested) {
6577
- const paper = { title: meta.title, pmid: meta.pmid, pmcid: meta.pmcid, doi: meta.doi, headLine: readHeadLine(paths) };
6621
+ const article = { title: meta.title, pmid: meta.pmid, pmcid: meta.pmcid, doi: meta.doi, headLine: readHeadLine(paths) };
6578
6622
  const tried = /* @__PURE__ */ new Set();
6579
6623
  let ran = false;
6580
- const { hit } = await fulltextCascade(paper, meta.attempts, (e) => {
6624
+ const { hit } = await fulltextCascade(article, meta.attempts, (e) => {
6581
6625
  if (e.ok === "alert") {
6582
6626
  log("add", requested, `!! ${e.message}`);
6583
6627
  return;
@@ -6686,7 +6730,7 @@ function registerTools(server2) {
6686
6730
  }
6687
6731
  server2.tool(
6688
6732
  "fh_library_add",
6689
- "Download and store one record \u2014 a paper (pmid:, doi:), a drug label (dailymed:<set ID>) or a trial record (nct:<8 digits>) \u2014 and return its status JSON. A paper gets its record, abstract and correction notices from PubMed (Crossref for a DOI PubMed does not index), then the full text from the configured sources; a label or trial record is stored as a full text. A stored full text is returned without any download; an abstract-level record retries only sources that failed transiently; a record older than 30 days gets its notices re-read.",
6733
+ "Download and store one record \u2014 an article (pmid:, doi:), a drug label (dailymed:<set ID>) or a trial record (nct:<8 digits>) \u2014 and return its status JSON. An article gets its record, abstract and correction notices from PubMed (Crossref for a DOI PubMed does not index), then the full text from the configured sources; a label or trial record is stored as a full text. A stored full text is returned without any download; an abstract-level record retries only sources that failed transiently; a record older than 30 days gets its notices re-read.",
6690
6734
  { id: idSchema },
6691
6735
  ({ id }) => addEntry(id)
6692
6736
  );
@@ -6853,7 +6897,7 @@ function registerTools(server2) {
6853
6897
  }
6854
6898
  server2.tool(
6855
6899
  "fh_library_status",
6856
- 'Read-only status of the library entry for one ID \u2014 a paper, a drug label or a trial record: the same status JSON as fh_library_add, or level "missing" when there is no entry. Never fetches.',
6900
+ 'Read-only status of the library entry for one ID \u2014 an article, a drug label or a trial record: the same status JSON as fh_library_add, or level "missing" when there is no entry. Never fetches.',
6857
6901
  { id: idSchema },
6858
6902
  async ({ id }) => {
6859
6903
  const parsed = parseId(id);
@@ -6875,11 +6919,11 @@ function registerTools(server2) {
6875
6919
  );
6876
6920
  server2.tool(
6877
6921
  "fh_library_read",
6878
- `One piece of a stored document's Markdown, never the whole. No section/query: the outline (headings with word counts; full text or abstract only). section: that heading's own text (case-insensitive substring; a repeated heading as "Participants [3/12]"), capped at max_chars, its subsections listed. query: passages holding every term, each a window of at most 1000 chars with its section, best first, at most max_hits (more: how many further passages match); partial: true with missing_terms when no passage holds them all. section and query together: inside that section. A missing paper is added first (added: true). abstract_only: true reads only the abstract, at once \u2014 use it whenever the abstract is enough (screening, design, size, main finding); without it, a paper not yet searched for its full text is first looked up at every source, up to a minute.`,
6922
+ `One piece of a stored document's Markdown, never the whole. No section/query: the outline (headings with word counts; full text or abstract only). section: that heading's own text (case-insensitive substring; a repeated heading as "Participants [3/12]"), capped at max_chars, its subsections listed. query: passages holding every term, each a window of at most 1000 chars with its section, best first, at most max_hits (more: how many further passages match); partial: true with missing_terms when no passage holds them all. section and query together: inside that section. A missing article is added first (added: true). abstract_only: true reads only the abstract, at once \u2014 use it whenever the abstract is enough (screening, design, size, main finding); without it, an article not yet searched for its full text is searched first (seconds, up to a minute, once).`,
6879
6923
  {
6880
6924
  id: idSchema,
6881
6925
  section: z.string().optional().describe("Heading from the outline (case-insensitive substring)."),
6882
- query: z.string().optional().describe("Two or three distinctive terms the paper itself would use \u2014 a measure and a unit, an outcome and a group, a compound name \u2014 not the claim. Passages holding all of them are returned, else the best partial matches. With section: inside that section."),
6926
+ query: z.string().optional().describe("Two or three distinctive terms the article itself would use \u2014 a measure and a unit, an outcome and a group, a compound name \u2014 not the claim. Passages holding all of them are returned, else the best partial matches. With section: inside that section."),
6883
6927
  max_chars: z.number().int().positive().optional().describe("Cap for section text (default 6000); passages are capped at 1000 chars each regardless."),
6884
6928
  max_hits: z.number().int().positive().optional().describe("Cap for query passages (default 5)."),
6885
6929
  abstract_only: z.boolean().optional().describe('true: the abstract only, at once, no full-text download; section and query search the abstract. A missing pmid: is stored from PubMed alone; a missing doi: is added normally first; dailymed: and nct: ignore it. Use it whenever the abstract answers the question (topic, design, population, size, main result, worth reading?); not for details only the full text holds, nor for checking a claim. fulltext "stored" or "not tried": a read without the flag gets more.')
@@ -6984,7 +7028,7 @@ ${st.funding.map((f) => `- ${f}`).join("\n")}` : ""].filter(Boolean).join("\n\n"
6984
7028
  );
6985
7029
  server2.tool(
6986
7030
  "fh_verify_claim",
6987
- `Does one source state one finding of a review? claim: the finding as a complete statement (subject, intervention, outcome, number), without citations or the review's framing, and only what this source reports. id: one source the review cites for it \u2014 paper, drug label (dailymed:\u2026) or trial record (nct:\u2026); added first when missing. fulltext "not tried": the full text is searched first (seconds, once). The server reads the stored text and asks a decision model; nothing enters your context. verdict: pass (score is the probability) | fail (the full text does not state it; or only the title is stored \u2014 reason says so) | unverifiable (only the abstract is stored and does not state it \u2014 reason says so) | error (claim refused: under four words, a fragment, carrying citations; add failed; no model; model failure). basis: full_text | abstract | title. glyphs_unresolved: symbols the PDF font lost; above 0 a failed number may be the font. superseded: true when a stored correction replaced the claim's figure.`,
7031
+ `Does one source state one finding of a review? claim: the finding as a complete statement (subject, intervention, outcome, number), without citations or the review's framing, and only what this source reports. id: one source the review cites for it \u2014 article, drug label (dailymed:\u2026) or trial record (nct:\u2026); added first when missing. fulltext "not tried": the full text is searched first (seconds, up to a minute, once). The server reads the stored text and asks a decision model; nothing enters your context. verdict: supported (score is the probability) | not_supported (the full text does not state it; or only the title is stored \u2014 reason says so) | unverifiable (only the abstract is stored and does not state it \u2014 reason says so) | error (claim refused: under four words, a fragment, carrying citations; add failed; no model; model failure). basis: full_text | abstract | title. glyphs_unresolved: symbols the PDF font lost; above 0 a failed number may be the font. superseded: true when a stored correction replaced the claim's figure.`,
6988
7032
  {
6989
7033
  claim: z.string().describe("One finding as a complete statement (subject, intervention, outcome, number), built from the review's words, without its citations and framing."),
6990
7034
  id: idSchema
@@ -7101,7 +7145,7 @@ ${(md.split("\n").find((l) => l.trim()) ?? "").trim()}` : fetchAnswer(url, md, "
7101
7145
  );
7102
7146
  server2.tool(
7103
7147
  "fh_pubmed_fetch_articles",
7104
- `Title, first author, year, publication types, retracted and library level for up to ${MAX_PMIDS} PubMed IDs in one call. Faster and far smaller than asking PubMed: known papers come from disk, the rest in one request, stored for every later call; rows as arrays in columns order, ~120 characters a paper. Level "not found": PubMed has no such record. For abstract or full text: fh_library_read.`,
7148
+ `Title, first author, year, publication types, retracted and library level for up to ${MAX_PMIDS} PubMed IDs in one call. Faster and far smaller than asking PubMed: known articles come from disk, the rest in one request, stored for every later call; rows as arrays in columns order, ~120 characters an article. Level "not found": PubMed has no such record. For abstract or full text: fh_library_read.`,
7105
7149
  { pmids: z.array(z.string()).min(1).max(MAX_PMIDS).describe('PubMed IDs, "30955454" or "pmid:30955454", up to 200.') },
7106
7150
  async ({ pmids }) => {
7107
7151
  const t0 = Date.now();
@@ -7115,7 +7159,7 @@ ${(md.split("\n").find((l) => l.trim()) ?? "").trim()}` : fetchAnswer(url, md, "
7115
7159
  );
7116
7160
  server2.tool(
7117
7161
  "fh_pubmed_search_articles",
7118
- `Search PubMed with its own query syntax (AND / OR, field tags like [pt], [ti], [mesh]); sort relevance | newest; years "2020-2026". Faster and far smaller than asking PubMed: the total and up to ${MAX_RESULTS2} rows as arrays in columns order \u2014 PMID, title, first author, year, journal, publication types, PMCID when free full text exists, and the library level when the paper is already stored. The same search is answered from disk for ${searchCacheDays()} days. For a batch of PMIDs: fh_pubmed_fetch_articles; for abstract or full text: fh_library_read.`,
7162
+ `Search PubMed with its own query syntax (AND / OR, field tags like [pt], [ti], [mesh]); sort relevance | newest; years "2020-2026". Faster and far smaller than asking PubMed: the total and up to ${MAX_RESULTS2} rows as arrays in columns order \u2014 PMID, title, first author, year, journal, publication types, PMCID when free full text exists, and the library level when the article is already stored. The same search is answered from disk for ${searchCacheDays()} days. For a batch of PMIDs: fh_pubmed_fetch_articles; for abstract or full text: fh_library_read.`,
7119
7163
  {
7120
7164
  query: z.string().describe('PubMed query, full syntax: "tadalafil AND (systematic review[pt] OR meta-analysis[pt])".'),
7121
7165
  max_results: z.number().int().min(1).max(MAX_RESULTS2).default(20).describe("Rows to return (1\u2013100)."),
@@ -7138,16 +7182,16 @@ ${(md.split("\n").find((l) => l.trim()) ?? "").trim()}` : fetchAnswer(url, md, "
7138
7182
  );
7139
7183
  if (citationsEnabled()) server2.tool(
7140
7184
  "fh_pubmed_citing_articles",
7141
- `The papers that cite a paper, as rows in fh_pubmed_search_articles' columns: PMID, title, first author, year, journal, publication types, PMCID, library level. Use it for a trial's follow-ups, later meta-analyses that include it, guidelines (sort: cited) and comments on it.
7142
- - types: PubMed publication types, any of them; a paper without one (many plain articles, some guidelines) never matches.
7143
- - Comments: with comment, letter or editorial in types, the comments PubMed links to the paper come first, of any year and type, and comments_on lists their PMIDs. The other rows only cite the paper and are mostly about something else.
7185
+ `The articles that cite an article, as rows in fh_pubmed_search_articles' columns: PMID, title, first author, year, journal, publication types, PMCID, library level. Use it for a trial's follow-ups, later meta-analyses that include it, guidelines (sort: cited) and comments on it.
7186
+ - types: PubMed publication types, any of them; an article without one (many plain articles, some guidelines) never matches.
7187
+ - Comments: with comment, letter or editorial in types, the comments PubMed links to the article come first, of any year and type, and comments_on lists their PMIDs. The other rows only cite the article and are mostly about something else.
7144
7188
  - years and sort newest go by the year column.
7145
7189
  - At most ${MAX_RESULTS4} rows, no paging: for more, narrow with types or years, or sort: cited. total counts every match.
7146
7190
  Citations from OpenAlex. Cached ${searchCacheDays()} days.`,
7147
7191
  {
7148
- id: z.string().describe('The cited paper: "pmid:18378520" or "doi:10.1056/NEJMoa0801317".'),
7192
+ id: z.string().describe('The cited article: "pmid:18378520" or "doi:10.1056/NEJMoa0801317".'),
7149
7193
  types: z.array(z.string()).optional().describe('Publication types, any of them: "meta-analysis", "systematic review", "randomized controlled trial", "review", "guideline", "comment", "letter", "editorial".'),
7150
- years: z.string().optional().describe('Publication years of the citing papers, as in the year column: "2020-2026", "2022-", "-2019" or "2022". Not applied to the comments PubMed links.'),
7194
+ years: z.string().optional().describe('Publication years of the citing articles, as in the year column: "2020-2026", "2022-", "-2019" or "2022". Not applied to the comments PubMed links.'),
7151
7195
  sort: z.enum(["newest", "cited"]).default("newest").describe("newest (latest year first) or cited (most cited first)."),
7152
7196
  max_results: z.number().int().min(1).max(MAX_RESULTS4).default(20).describe("Rows to return (1\u2013100).")
7153
7197
  },
@@ -7209,7 +7253,7 @@ Citations from OpenAlex. Cached ${searchCacheDays()} days.`,
7209
7253
  "Store an object in an EVID. name: lowercase letters, digits, _ and -, then the extension, which sets the type: .json, .csv (RFC 4180, a header row), .txt, .md; at most 64 characters, no folders. An invalid name is refused with the valid form; content that does not parse as its type is refused. An existing object of that name is replaced and kept as its previous version (one only). Nothing can be deleted.",
7210
7254
  {
7211
7255
  evid: z.string().describe("The EVID."),
7212
- name: z.string().describe(`The object's name, e.g. "lit-papers.csv", "notes.md".`),
7256
+ name: z.string().describe(`The object's name, e.g. "lit-map.csv", "notes.md".`),
7213
7257
  content: z.string().describe("The whole object as text.")
7214
7258
  },
7215
7259
  async ({ evid, name, content }) => {
@@ -7220,34 +7264,35 @@ Citations from OpenAlex. Cached ${searchCacheDays()} days.`,
7220
7264
  );
7221
7265
  server2.tool(
7222
7266
  "fh_evid_get",
7223
- `Read an object of an EVID, whole or in pieces, as fh_library_read reads a document. No section/query: the object, when it fits max_chars (default ${DEFAULT_MAX_CHARS}); else its outline (.md: headings with word counts; .csv: columns and row count; .json: keys; .txt: lines and words). section (.md): that heading's own text, its subsections listed. query: .md/.txt the passages holding every term, best first; .csv the rows holding every term, with the columns. previous: true reads the version before the last put. name metadata.json: the metadata.`,
7267
+ `Read an object of an EVID, whole or in pieces, as fh_library_read reads a document. No section/query: the object, when it fits max_chars (default ${DEFAULT_MAX_CHARS}); else its outline (.md: headings with word counts; .csv: columns and row count; .json: keys; .txt: lines and words). section (.md): that heading's own text, its subsections listed. query: .md/.txt the passages holding every term, best first; .csv the rows holding every term, with the columns. lines "a-b": .md/.txt those lines, .csv those data rows (lit-map.csv is ranked: "1-50" the top 50). previous: true reads the version before the last put. name metadata.json: the metadata.`,
7224
7268
  {
7225
7269
  evid: z.string().describe("The EVID."),
7226
- name: z.string().describe(`The object's name, e.g. "lit-papers.csv".`),
7270
+ name: z.string().describe(`The object's name, e.g. "lit-map.csv".`),
7227
7271
  section: z.string().optional().describe(".md only: a heading, case-insensitive substring."),
7228
7272
  query: z.string().optional().describe("Two or three distinctive terms."),
7229
7273
  max_chars: z.number().int().positive().optional().describe(`Cap for the object or section text (default ${DEFAULT_MAX_CHARS}).`),
7230
7274
  max_hits: z.number().int().positive().optional().describe("With query: passages (default 5) or csv rows (default 50)."),
7231
- previous: z.boolean().optional().describe("true: the previous version.")
7275
+ previous: z.boolean().optional().describe("true: the previous version."),
7276
+ lines: z.string().optional().describe('"a-b", "a" or "a-" (1-based): .md/.txt lines; .csv data rows, header as columns. Answer: first, last, total; cut when max_chars is reached.')
7232
7277
  },
7233
7278
  async ({ evid, name, ...opts }) => {
7234
7279
  const r = getObject(FH_EVIDENCE_DIR, evid, name, opts);
7235
- log("evid", evid, r.ok ? `get ${name}${opts.previous ? " previous" : ""}${opts.section ? ` section=${opts.section}` : ""}${opts.query ? ` query=${opts.query}` : ""}${"too_large" in r ? " outline" : ""}` : `get error ${r.error}`);
7280
+ log("evid", evid, r.ok ? `get ${name}${opts.previous ? " previous" : ""}${opts.section ? ` section=${opts.section}` : ""}${opts.query ? ` query=${opts.query}` : ""}${opts.lines ? ` lines=${opts.lines}` : ""}${"too_large" in r ? " outline" : ""}` : `get error ${r.error}`);
7236
7281
  return answer(r);
7237
7282
  }
7238
7283
  );
7239
7284
  }
7240
7285
  if (literatureEnabled()) server2.tool(
7241
- "fh_literature_do_research",
7242
- `The literature research for an EVID: the server runs your PubMed queries (at most ${maxQueries()}), screens each abstract found with your screening prompt ({{topic}} from the EVID's metadata, {{paper}} each paper), and stores the result in the EVID as lit-papers.csv; read it with fh_evid_get. Also stored: lit-screening.md (your prompt), lit-queries.json (the queries), lit-run.json. The papers found are merged, retracted ones dropped, each stored in the library with its abstract; a model screens every abstract, off-topic papers are dropped, the rest ranked by score (evidence level, relevance, outcome, size, how many queries found it). Every screening answer, kept or not, in lit-screened.csv. Takes a minute or two.`,
7286
+ "fh_literature_map_evidence",
7287
+ `The evidence map for an EVID: the server runs your PubMed queries (at most ${maxQueries()}), screens each abstract found with your screening prompt ({{topic}} from the EVID's metadata, {{article}} each article), and stores the result in the EVID as lit-map.csv; read it with fh_evid_get. Also stored: lit-screening.md (your prompt), lit-queries.json (the queries), lit-run.json. The articles found are merged, retracted ones dropped, each stored in the library with its abstract; a model screens every abstract, off-topic articles are dropped, the rest ranked by score (evidence level, relevance, outcome, size, how many queries found it). Every screening answer, kept or not, in lit-screened.csv. Takes a minute or two.`,
7243
7288
  {
7244
7289
  evid: z.string().describe("The EVID."),
7245
7290
  queries: z.array(z.string()).min(1).describe("PubMed queries in PubMed's syntax."),
7246
- screening: z.string().describe("The prompt for the screening model, with {{topic}} (the server puts in the EVID's metadata topic) and {{paper}} (the server puts in each paper: PMID, title, year, publication types, abstract).")
7291
+ screening: z.string().describe("The prompt for the screening model, with {{topic}} (the server puts in the EVID's metadata topic) and {{article}} (the server puts in each article: PMID, title, year, publication types, abstract).")
7247
7292
  },
7248
7293
  async ({ evid, queries, screening }) => {
7249
7294
  const r = await doResearch(FH_EVIDENCE_DIR, evid, queries, screening);
7250
- log("literature", evid, r.ok ? `${r.state} queries=${queries.length} papers=${r.papers}${r.screening_errors ? ` screening_errors=${r.screening_errors}` : ""}` : `${r.failed ? "failed" : "error"} ${r.error}`);
7295
+ log("lit", evid, r.ok ? `${r.state} queries=${queries.length} articles=${r.included}${r.screening_errors ? ` screening_errors=${r.screening_errors}` : ""}` : `${r.failed ? "failed" : "error"} ${r.error}`);
7251
7296
  const { ok, ...rest } = r;
7252
7297
  return { content: [{ type: "text", text: compact2(rest) }], ...ok ? {} : { isError: true } };
7253
7298
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evidence-mcp-dev",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "Internal development build of evidence-mcp. Not for public use.",
5
5
  "type": "module",
6
6
  "bin": {