evidence-mcp-dev 1.0.19 → 1.0.20

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 +45 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6126,6 +6126,11 @@ function getObject(lib, evid, name, opts = {}, env = process.env) {
6126
6126
  const text4 = readFileSync15(file3, "utf8");
6127
6127
  const type = typeOf(name);
6128
6128
  const maxChars = opts.max_chars ?? DEFAULT_MAX_CHARS;
6129
+ if (opts.lines !== void 0) {
6130
+ if (opts.section !== void 0 || opts.query !== void 0) return fail("lines: alone, not with section or query");
6131
+ if (type === "json") return fail("lines: .md, .txt and .csv objects; a .json object is read whole");
6132
+ return byLines(type, text4, opts.lines, maxChars);
6133
+ }
6129
6134
  if (opts.section !== void 0) {
6130
6135
  if (type !== "md") return fail(`section: .md objects only; ${name} is .${type}`);
6131
6136
  if (opts.query === void 0) {
@@ -6147,7 +6152,7 @@ function getObject(lib, evid, name, opts = {}, env = process.env) {
6147
6152
  return { ok: true, ...r };
6148
6153
  }
6149
6154
  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) };
6155
+ 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
6156
  }
6152
6157
  function outlineOf(type, text4) {
6153
6158
  if (type === "md") {
@@ -6164,6 +6169,38 @@ function outlineOf(type, text4) {
6164
6169
  }
6165
6170
  return { lines: text4.split("\n").length, words: (text4.match(/\S+/g) ?? []).length };
6166
6171
  }
6172
+ function parseLines(spec) {
6173
+ const m = /^\s*(\d+)\s*(?:(-)\s*(\d*))?\s*$/.exec(spec);
6174
+ if (!m) return null;
6175
+ const from = Number(m[1]);
6176
+ const to = m[2] ? m[3] ? Number(m[3]) : null : from;
6177
+ return from >= 1 && (to === null || to >= from) ? { from, to } : null;
6178
+ }
6179
+ function byLines(type, text4, spec, maxChars) {
6180
+ const range = parseLines(spec);
6181
+ if (!range) return fail(`lines: "${spec}" \u2014 give "a-b", "a" or "a-" (1-based)`);
6182
+ let columns2;
6183
+ let items;
6184
+ if (type === "csv") {
6185
+ const r = parseCsv(text4);
6186
+ if (!r.ok) return fail(r.error);
6187
+ [columns2] = r.rows;
6188
+ const physical = text4.replace(/\r?\n$/, "").split(/\r?\n/);
6189
+ 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(","));
6190
+ } else items = text4.replace(/\n$/, "").split("\n");
6191
+ const total = items.length;
6192
+ if (range.from > total) return fail(`lines: from ${range.from}, but there are ${total}${type === "csv" ? " data rows" : " lines"}`);
6193
+ const want = items.slice(range.from - 1, range.to === null ? total : Math.min(range.to, total));
6194
+ const out = [];
6195
+ let used = 0;
6196
+ for (const l of want) {
6197
+ if (out.length && used + l.length + 1 > maxChars) break;
6198
+ out.push(l);
6199
+ used += l.length + 1;
6200
+ }
6201
+ const last = range.from + out.length - 1;
6202
+ 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}-"` } : {} };
6203
+ }
6167
6204
  function csvQuery(text4, query, maxHits) {
6168
6205
  const r = parseCsv(text4);
6169
6206
  if (!r.ok) return { error: r.error };
@@ -6518,7 +6555,7 @@ Tools
6518
6555
  - 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
6556
  - 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.
6520
6557
  - 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.
6558
+ ${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?, 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_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.
6522
6559
  - 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
6560
  ${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
6561
  - 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.
@@ -6875,7 +6912,7 @@ function registerTools(server2) {
6875
6912
  );
6876
6913
  server2.tool(
6877
6914
  "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.`,
6915
+ `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 searched first (seconds, up to a minute, once).`,
6879
6916
  {
6880
6917
  id: idSchema,
6881
6918
  section: z.string().optional().describe("Heading from the outline (case-insensitive substring)."),
@@ -6984,7 +7021,7 @@ ${st.funding.map((f) => `- ${f}`).join("\n")}` : ""].filter(Boolean).join("\n\n"
6984
7021
  );
6985
7022
  server2.tool(
6986
7023
  "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.`,
7024
+ `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, up to a minute, 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.`,
6988
7025
  {
6989
7026
  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
7027
  id: idSchema
@@ -7220,7 +7257,7 @@ Citations from OpenAlex. Cached ${searchCacheDays()} days.`,
7220
7257
  );
7221
7258
  server2.tool(
7222
7259
  "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.`,
7260
+ `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-papers.csv is ranked: "1-50" the top 50). previous: true reads the version before the last put. name metadata.json: the metadata.`,
7224
7261
  {
7225
7262
  evid: z.string().describe("The EVID."),
7226
7263
  name: z.string().describe(`The object's name, e.g. "lit-papers.csv".`),
@@ -7228,11 +7265,12 @@ Citations from OpenAlex. Cached ${searchCacheDays()} days.`,
7228
7265
  query: z.string().optional().describe("Two or three distinctive terms."),
7229
7266
  max_chars: z.number().int().positive().optional().describe(`Cap for the object or section text (default ${DEFAULT_MAX_CHARS}).`),
7230
7267
  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.")
7268
+ previous: z.boolean().optional().describe("true: the previous version."),
7269
+ 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
7270
  },
7233
7271
  async ({ evid, name, ...opts }) => {
7234
7272
  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}`);
7273
+ 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
7274
  return answer(r);
7237
7275
  }
7238
7276
  );
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.20",
4
4
  "description": "Internal development build of evidence-mcp. Not for public use.",
5
5
  "type": "module",
6
6
  "bin": {