@cyanheads/biorxiv-mcp-server 0.1.17 → 0.2.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.
Files changed (42) hide show
  1. package/AGENTS.md +1 -1
  2. package/CLAUDE.md +1 -1
  3. package/README.md +25 -8
  4. package/changelog/0.1.x/0.1.18.md +16 -0
  5. package/changelog/0.2.x/0.2.0.md +12 -0
  6. package/dist/config/server-config.d.ts +2 -0
  7. package/dist/config/server-config.d.ts.map +1 -1
  8. package/dist/config/server-config.js +14 -0
  9. package/dist/config/server-config.js.map +1 -1
  10. package/dist/index.js +2 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.d.ts +65 -0
  13. package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.d.ts.map +1 -0
  14. package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.js +209 -0
  15. package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.js.map +1 -0
  16. package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts.map +1 -1
  17. package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js +33 -21
  18. package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js.map +1 -1
  19. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts +7 -2
  20. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts.map +1 -1
  21. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js +59 -15
  22. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js.map +1 -1
  23. package/dist/mcp-server/tools/definitions/index.d.ts +58 -2
  24. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
  25. package/dist/mcp-server/tools/definitions/index.js +3 -0
  26. package/dist/mcp-server/tools/definitions/index.js.map +1 -1
  27. package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.d.ts +52 -0
  28. package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.d.ts.map +1 -0
  29. package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.js +156 -0
  30. package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.js.map +1 -0
  31. package/dist/services/europe-pmc/europe-pmc-service.d.ts +6 -1
  32. package/dist/services/europe-pmc/europe-pmc-service.d.ts.map +1 -1
  33. package/dist/services/europe-pmc/europe-pmc-service.js +20 -3
  34. package/dist/services/europe-pmc/europe-pmc-service.js.map +1 -1
  35. package/dist/services/europe-pmc/types.d.ts +6 -0
  36. package/dist/services/europe-pmc/types.d.ts.map +1 -1
  37. package/dist/services/shared.d.ts +12 -0
  38. package/dist/services/shared.d.ts.map +1 -1
  39. package/dist/services/shared.js +21 -0
  40. package/dist/services/shared.js.map +1 -1
  41. package/package.json +3 -1
  42. package/server.json +3 -3
package/AGENTS.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Agent Protocol
2
2
 
3
3
  **Server:** biorxiv-mcp-server
4
- **Version:** 0.1.17
4
+ **Version:** 0.2.0
5
5
  **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.10.14`
6
6
  **Engines:** Bun ≥1.3.2, Node ≥24.0.0
7
7
  **MCP SDK:** `@modelcontextprotocol/sdk` ^1.29.0
package/CLAUDE.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Agent Protocol
2
2
 
3
3
  **Server:** biorxiv-mcp-server
4
- **Version:** 0.1.17
4
+ **Version:** 0.2.0
5
5
  **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.10.14`
6
6
  **Engines:** Bun ≥1.3.2, Node ≥24.0.0
7
7
  **MCP SDK:** `@modelcontextprotocol/sdk` ^1.29.0
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  <div align="center">
2
2
  <h1>@cyanheads/biorxiv-mcp-server</h1>
3
3
  <p><b>Search and retrieve bioRxiv and medRxiv preprints — by DOI, date interval, or keyword — via MCP. STDIO or Streamable HTTP.</b>
4
- <div>5 Tools</div>
4
+ <div>6 Tools</div>
5
5
  </p>
6
6
  </div>
7
7
 
8
8
  <div align="center">
9
9
 
10
- [![Version](https://img.shields.io/badge/Version-0.1.17-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/biorxiv-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/biorxiv-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/biorxiv-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.2-blueviolet.svg?style=flat-square)](https://bun.sh/)
10
+ [![Version](https://img.shields.io/badge/Version-0.2.0-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/biorxiv-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/biorxiv-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/biorxiv-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.2-blueviolet.svg?style=flat-square)](https://bun.sh/)
11
11
 
12
12
  </div>
13
13
 
@@ -23,14 +23,15 @@
23
23
 
24
24
  ## Tools
25
25
 
26
- Five tools for working with bioRxiv and medRxiv preprint data:
26
+ Six tools for working with bioRxiv and medRxiv preprint data:
27
27
 
28
28
  | Tool | Description |
29
29
  |:---|:---|
30
30
  | `biorxiv_get_preprint` | Fetch full metadata, abstract, revision history, and journal crosswalk for one or more preprints by DOI |
31
31
  | `biorxiv_list_recent` | List preprints posted or updated within a date interval, with optional server and category filters |
32
- | `biorxiv_search_preprints` | Search preprints by keyword via EuropePMC for relevance ranking, enriched with bioRxiv/medRxiv metadata |
32
+ | `biorxiv_search_preprints` | Search preprints by keyword and/or author via EuropePMC for relevance ranking, enriched with bioRxiv/medRxiv metadata |
33
33
  | `biorxiv_get_published_version` | Resolve a preprint DOI to its journal publication record (journal DOI, name, published date) |
34
+ | `biorxiv_get_fulltext` | Retrieve a preprint's full text as best-effort Markdown extracted from its rendered HTML article page |
34
35
  | `biorxiv_list_categories` | List valid subject category strings for bioRxiv and medRxiv |
35
36
 
36
37
  ### `biorxiv_get_preprint`
@@ -57,9 +58,10 @@ Page through preprints in a date interval.
57
58
 
58
59
  ### `biorxiv_search_preprints`
59
60
 
60
- Keyword search with relevance ranking.
61
+ Keyword and/or author search with relevance ranking.
61
62
 
62
63
  - EuropePMC powers relevance ranking (indexes new preprints within 1–2 days of posting); bioRxiv/medRxiv API provides canonical metadata enrichment
64
+ - Optional `author` maps to an EuropePMC `AUTH:"…"` field query, ANDed with the keyword query — supply `query`, `author`, or both
63
65
  - Covers both servers by default; scope down with `server`
64
66
  - Optional date range filters (`date_from`, `date_to`)
65
67
  - Enrichment failures degrade gracefully to EuropePMC-only metadata, surfaced via `partial_results`
@@ -76,6 +78,17 @@ Resolve a preprint DOI to its journal publication crosswalk.
76
78
 
77
79
  ---
78
80
 
81
+ ### `biorxiv_get_fulltext`
82
+
83
+ Retrieve a preprint's full text as best-effort Markdown.
84
+
85
+ - Fetches the rendered HTML article page (`www.{server}.org/content/{doi}v{N}.full`) and extracts Markdown — there is no keyless JATS source
86
+ - Resolves the latest version via the details API first, for the URL version and clean not-found handling
87
+ - Long articles page via `offset`/`limit` character chunking (`totalChars`, `remainingChars`, `hasMore`)
88
+ - PDF-only preprints and blocked/challenge pages return a typed `fulltext_unavailable` error routing to `biorxiv_get_preprint`
89
+
90
+ ---
91
+
79
92
  ### `biorxiv_list_categories`
80
93
 
81
94
  Return the static subject category taxonomy for both servers.
@@ -97,7 +110,8 @@ Built on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp
97
110
  bioRxiv-specific:
98
111
 
99
112
  - `BiorxivApiService` wraps `api.biorxiv.org` — details, publications, and crosswalk endpoints with retry and exponential backoff
100
- - `EuropePmcService` wraps the EuropePMC search endpoint for relevance-ranked keyword results
113
+ - `EuropePmcService` wraps the EuropePMC search endpoint for relevance-ranked keyword and/or author results
114
+ - `BiorxivFullTextService` fetches and extracts Markdown from the rendered HTML article pages on `www.biorxiv.org` / `www.medrxiv.org` — a distinct origin from the JSON API
101
115
  - Two-server fan-out via `Promise.allSettled` — both `biorxiv` and `medrxiv` queried in parallel when `server="both"`, results merged and deduplicated by DOI
102
116
  - Polite `User-Agent` header including a mailto address (`BIORXIV_MAILTO` env var) per Cold Spring Harbor Lab API guidelines
103
117
  - Pairs with **pubmed-mcp-server** (post-publication), **openalex-mcp-server** (citation analytics), and **crossref-mcp-server** (DOI metadata)
@@ -203,6 +217,8 @@ All configuration is validated at startup via Zod schemas in `src/config/server-
203
217
  | `BIORXIV_MAILTO` | Email address included in the `User-Agent` header for polite API access per Cold Spring Harbor Lab guidelines. Optional, but recommended. | — |
204
218
  | `BIORXIV_API_BASE_URL` | Override the bioRxiv API base URL. | `https://api.biorxiv.org` |
205
219
  | `EUROPEPMC_API_BASE_URL` | Override the EuropePMC base URL. | `https://www.ebi.ac.uk/europepmc/webservices/rest` |
220
+ | `BIORXIV_WEB_BASE_URL` | Override the bioRxiv website base URL (full-text HTML source for `biorxiv_get_fulltext`). | `https://www.biorxiv.org` |
221
+ | `MEDRXIV_WEB_BASE_URL` | Override the medRxiv website base URL (full-text HTML source for `biorxiv_get_fulltext`). | `https://www.medrxiv.org` |
206
222
  | `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |
207
223
  | `MCP_HTTP_PORT` | HTTP server port. | `3010` |
208
224
  | `MCP_HTTP_ENDPOINT_PATH` | HTTP endpoint path. | `/mcp` |
@@ -250,9 +266,10 @@ The Dockerfile defaults to HTTP transport, stateless session mode, and logs to `
250
266
  |:---|:---|
251
267
  | `src/index.ts` | `createApp()` entry point — registers tools and initializes services. |
252
268
  | `src/config` | Server-specific environment variable parsing and validation with Zod. |
253
- | `src/mcp-server/tools` | Tool definitions (`*.tool.ts`). Five tools across bioRxiv and medRxiv. |
269
+ | `src/mcp-server/tools` | Tool definitions (`*.tool.ts`). Six tools across bioRxiv and medRxiv. |
254
270
  | `src/services/biorxiv` | `BiorxivApiService` — details, publications, and crosswalk endpoint wrappers with retry. |
255
- | `src/services/europe-pmc` | `EuropePmcService` — preprint keyword search endpoint wrapper. |
271
+ | `src/services/biorxiv-fulltext` | `BiorxivFullTextService` — rendered HTML article page fetch and Markdown extraction. |
272
+ | `src/services/europe-pmc` | `EuropePmcService` — preprint keyword/author search endpoint wrapper. |
256
273
  | `tests/` | Unit and integration tests mirroring the `src/` structure. |
257
274
 
258
275
  ## Development guide
@@ -0,0 +1,16 @@
1
+ ---
2
+ summary: "Add EuropePMC cursor pagination to biorxiv_search_preprints, fix biorxiv_list_recent mixing unfiltered records into server-exclusive category results, and reject calendar-impossible dates before upstream calls (#27, #29, #30)"
3
+ breaking: false
4
+ security: false
5
+ ---
6
+
7
+ # 0.1.18 — 2026-07-11
8
+
9
+ ## Added
10
+
11
+ - **`biorxiv_search_preprints`** — optional `cursor_mark` input pages through ranked EuropePMC results; threads into `EuropePmcService.search()` as `SearchOptions.cursorMark` (defaults to `*`, EuropePMC's first-page cursor). `nextCursorMark` appears in `enrichment` (and echoed in `queryEcho.cursor_mark`) when more pages exist, absent on the last page — EuropePMC omits the field itself once results are exhausted. [#30](https://github.com/cyanheads/biorxiv-mcp-server/issues/30)
12
+
13
+ ## Fixed
14
+
15
+ - **`biorxiv_list_recent`** — under `server="both"`, a category exclusive to one taxonomy (e.g. `Neuroscience`) now queries only the owning server, instead of merging its filtered page with an unfiltered page from the other. Categories shared by both taxonomies (`Epidemiology`, `Pathology`) still fan out to both servers; `categoryNote` reworded to match. [#27](https://github.com/cyanheads/biorxiv-mcp-server/issues/27)
16
+ - **`biorxiv_list_recent`** and **`biorxiv_search_preprints`** — both reject calendar-impossible dates (`2024-02-30`, `2024-04-31`, `2023-02-29`) before any upstream call, via new `isValidCalendarDate()` (`src/services/shared.ts`), which round-trips `Date.UTC()` components against the parsed input. The existing `YYYY-MM-DD` shape regex accepted these, and `new Date()` silently rolled them into the following month rather than rejecting. Valid leap days (`2024-02-29`) are unaffected. [#29](https://github.com/cyanheads/biorxiv-mcp-server/issues/29)
@@ -0,0 +1,12 @@
1
+ ---
2
+ summary: "Add biorxiv_get_fulltext for full-text retrieval via HTML extraction and an author filter on biorxiv_search_preprints (#19)"
3
+ breaking: false
4
+ security: false
5
+ ---
6
+
7
+ # 0.2.0 — 2026-07-11
8
+
9
+ ## Added
10
+
11
+ - **`biorxiv_get_fulltext`** — retrieves a preprint's full text as best-effort Markdown extracted from the rendered HTML article page (`www.{server}.org/content/{doi}v{N}.full`); there's no keyless JATS source, so this extracts `contentFormat: "html-markdown"`, not structured JATS. Resolves the latest version via the details API, pages long articles with `offset`/`limit` character chunking, and routes PDF-only or blocked pages to a typed `fulltext_unavailable` error pointing at `biorxiv_get_preprint`. medRxiv's Cloudflare edge can block programmatic fetches from some hosts — bioRxiv coverage is more reliable. New deps: `defuddle` `^0.19.0`, `linkedom` `^0.18.12`. [#19](https://github.com/cyanheads/biorxiv-mcp-server/issues/19)
12
+ - **`biorxiv_search_preprints`** — optional `author` parameter maps to an EuropePMC `AUTH:"…"` field query, ANDed with the keyword query; `query` is now optional when `author` is supplied, so author-only searches work while existing query-only calls are unchanged. [#19](https://github.com/cyanheads/biorxiv-mcp-server/issues/19)
@@ -9,6 +9,8 @@ declare const ServerConfigSchema: z.ZodObject<{
9
9
  mailto: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
10
10
  apiBaseUrl: z.ZodDefault<z.ZodString>;
11
11
  europePmcBaseUrl: z.ZodDefault<z.ZodString>;
12
+ biorxivWebBaseUrl: z.ZodDefault<z.ZodString>;
13
+ medrxivWebBaseUrl: z.ZodDefault<z.ZodString>;
12
14
  }, z.core.$strip>;
13
15
  export type ServerConfig = z.infer<typeof ServerConfigSchema>;
14
16
  export declare function getServerConfig(): ServerConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAG3C,QAAA,MAAM,kBAAkB;;;;iBAetB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D,wBAAgB,eAAe,IAAI,YAAY,CAO9C;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
1
+ {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAG3C,QAAA,MAAM,kBAAkB;;;;;;iBA+BtB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D,wBAAgB,eAAe,IAAI,YAAY,CAS9C;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
@@ -18,6 +18,18 @@ const ServerConfigSchema = z.object({
18
18
  .url()
19
19
  .default('https://www.ebi.ac.uk/europepmc/webservices/rest')
20
20
  .describe('EuropePMC REST API base URL'),
21
+ // Full-text HTML lives on the public websites, not the JSON API host — a
22
+ // distinct origin per server. Overridable for testing or mirrors.
23
+ biorxivWebBaseUrl: z
24
+ .string()
25
+ .url()
26
+ .default('https://www.biorxiv.org')
27
+ .describe('bioRxiv website base URL — source of rendered full-text HTML pages for biorxiv_get_fulltext'),
28
+ medrxivWebBaseUrl: z
29
+ .string()
30
+ .url()
31
+ .default('https://www.medrxiv.org')
32
+ .describe('medRxiv website base URL — source of rendered full-text HTML pages for biorxiv_get_fulltext'),
21
33
  });
22
34
  let _config;
23
35
  export function getServerConfig() {
@@ -25,6 +37,8 @@ export function getServerConfig() {
25
37
  mailto: 'BIORXIV_MAILTO',
26
38
  apiBaseUrl: 'BIORXIV_API_BASE_URL',
27
39
  europePmcBaseUrl: 'EUROPEPMC_API_BASE_URL',
40
+ biorxivWebBaseUrl: 'BIORXIV_WEB_BASE_URL',
41
+ medrxivWebBaseUrl: 'MEDRXIV_WEB_BASE_URL',
28
42
  });
29
43
  return _config;
30
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server-config.js","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,+EAA+E;IAC/E,4EAA4E;IAC5E,MAAM,EAAE,CAAC;SACN,UAAU,CACT,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EACpE,CAA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AAC,4EAA4E,CAAC;IACzF,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,QAAQ,CAAC,sBAAsB,CAAC;IAChG,gBAAgB,EAAE,CAAC;SAChB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,OAAO,CAAC,kDAAkD,CAAC;SAC3D,QAAQ,CAAC,6BAA6B,CAAC;IAC1C,yEAAyE;IACzE,kEAAkE;IAClE,iBAAiB,EAAE,CAAC;SACjB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,OAAO,CAAC,yBAAyB,CAAC;SAClC,QAAQ,CACP,6FAA6F,CAC9F;IACH,iBAAiB,EAAE,CAAC;SACjB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,OAAO,CAAC,yBAAyB,CAAC;SAClC,QAAQ,CACP,6FAA6F,CAC9F;CACJ,CAAC,CAAC;AAIH,IAAI,OAAiC,CAAC;AAEtC,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,cAAc,CAAC,kBAAkB,EAAE;QAC7C,MAAM,EAAE,gBAAgB;QACxB,UAAU,EAAE,sBAAsB;QAClC,gBAAgB,EAAE,wBAAwB;QAC1C,iBAAiB,EAAE,sBAAsB;QACzC,iBAAiB,EAAE,sBAAsB;KAC1C,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,GAAG,SAAS,CAAC;AACtB,CAAC"}
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@
8
8
  import { createApp } from '@cyanheads/mcp-ts-core';
9
9
  import { allToolDefinitions } from './mcp-server/tools/definitions/index.js';
10
10
  import { initBiorxivApiService } from './services/biorxiv/biorxiv-service.js';
11
+ import { initBiorxivFullTextService } from './services/biorxiv-fulltext/biorxiv-fulltext-service.js';
11
12
  import { initEuropePmcService } from './services/europe-pmc/europe-pmc-service.js';
12
13
  await createApp({
13
14
  name: 'biorxiv-mcp-server',
@@ -24,6 +25,7 @@ await createApp({
24
25
  setup(core) {
25
26
  initBiorxivApiService(core.config, core.storage);
26
27
  initEuropePmcService(core.config, core.storage);
28
+ initBiorxivFullTextService(core.config, core.storage);
27
29
  },
28
30
  });
29
31
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,MAAM,SAAS,CAAC;IACd,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,CAAC,GAAG,kBAAkB,CAAC;IAC9B,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE;IACX,YAAY,EACV,mHAAmH;QACnH,wFAAwF;QACxF,0EAA0E;QAC1E,2GAA2G;IAC7G,0FAA0F;IAC1F,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;IAC/B,KAAK,CAAC,IAAI;QACR,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,oBAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,MAAM,SAAS,CAAC;IACd,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,CAAC,GAAG,kBAAkB,CAAC;IAC9B,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE;IACX,YAAY,EACV,mHAAmH;QACnH,wFAAwF;QACxF,0EAA0E;QAC1E,2GAA2G;IAC7G,0FAA0F;IAC1F,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;IAC/B,KAAK,CAAC,IAAI;QACR,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,oBAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAChD,0BAA0B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACxD,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @fileoverview biorxiv_get_fulltext tool — retrieves a preprint's full text by
3
+ * fetching its rendered HTML page (`www.{server}.org/content/{doi}v{N}.full`) and
4
+ * extracting readable Markdown. The latest version is resolved via the details
5
+ * API first (for the URL version and clean not-found handling), then the HTML is
6
+ * fetched and run through the framework extractor. Long articles are paged with
7
+ * offset/limit character chunking. Full text is best-effort HTML→Markdown, not
8
+ * structured JATS; preprints that are PDF-only or whose page is blocked return a
9
+ * typed `fulltext_unavailable` error routing to biorxiv_get_preprint.
10
+ * @module mcp-server/tools/definitions/biorxiv-get-fulltext.tool
11
+ */
12
+ import { z } from '@cyanheads/mcp-ts-core';
13
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
14
+ export declare const biorxivGetFulltextTool: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
15
+ doi: z.ZodString;
16
+ server: z.ZodDefault<z.ZodEnum<{
17
+ biorxiv: "biorxiv";
18
+ medrxiv: "medrxiv";
19
+ }>>;
20
+ offset: z.ZodDefault<z.ZodNumber>;
21
+ limit: z.ZodDefault<z.ZodNumber>;
22
+ }, z.core.$strip>, z.ZodObject<{
23
+ doi: z.ZodString;
24
+ server: z.ZodEnum<{
25
+ biorxiv: "biorxiv";
26
+ medrxiv: "medrxiv";
27
+ }>;
28
+ version: z.ZodString;
29
+ title: z.ZodOptional<z.ZodString>;
30
+ content: z.ZodString;
31
+ contentFormat: z.ZodLiteral<"html-markdown">;
32
+ wordCount: z.ZodOptional<z.ZodNumber>;
33
+ sourceUrl: z.ZodString;
34
+ offset: z.ZodNumber;
35
+ length: z.ZodNumber;
36
+ totalChars: z.ZodNumber;
37
+ remainingChars: z.ZodNumber;
38
+ hasMore: z.ZodBoolean;
39
+ }, z.core.$strip>, readonly [{
40
+ readonly reason: "invalid_doi_format";
41
+ readonly code: JsonRpcErrorCode.ValidationError;
42
+ readonly when: "The input DOI does not match the 10.NNNN/ pattern.";
43
+ readonly recovery: "Correct the DOI format — bioRxiv/medRxiv DOIs start with 10.1101/ or 10.64898/ followed by the manuscript ID.";
44
+ }, {
45
+ readonly reason: "doi_not_found";
46
+ readonly code: JsonRpcErrorCode.NotFound;
47
+ readonly when: "The DOI resolves to no preprint on the requested server.";
48
+ readonly recovery: "Find the correct DOI and server with biorxiv_search_preprints, or retry with the other server value.";
49
+ }, {
50
+ readonly reason: "fulltext_unavailable";
51
+ readonly code: JsonRpcErrorCode.NotFound;
52
+ readonly when: "The preprint exists but its full-text HTML page is blocked, missing, or yields no extractable text (PDF-only).";
53
+ readonly recovery: "Use biorxiv_get_preprint for the title, abstract, and metadata — a readable full-text page is not available for this preprint.";
54
+ }, {
55
+ readonly reason: "offset_out_of_range";
56
+ readonly code: JsonRpcErrorCode.ValidationError;
57
+ readonly when: "offset is greater than or equal to the total character length of the extracted text.";
58
+ readonly recovery: "Use an offset below totalChars — a prior response's remainingChars shows how much text is left.";
59
+ }], {
60
+ readonly truncated: z.ZodOptional<z.ZodBoolean>;
61
+ readonly shown: z.ZodOptional<z.ZodNumber>;
62
+ readonly cap: z.ZodOptional<z.ZodNumber>;
63
+ readonly notice: z.ZodOptional<z.ZodString>;
64
+ }>;
65
+ //# sourceMappingURL=biorxiv-get-fulltext.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"biorxiv-get-fulltext.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAMjE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmPjC,CAAC"}
@@ -0,0 +1,209 @@
1
+ /**
2
+ * @fileoverview biorxiv_get_fulltext tool — retrieves a preprint's full text by
3
+ * fetching its rendered HTML page (`www.{server}.org/content/{doi}v{N}.full`) and
4
+ * extracting readable Markdown. The latest version is resolved via the details
5
+ * API first (for the URL version and clean not-found handling), then the HTML is
6
+ * fetched and run through the framework extractor. Long articles are paged with
7
+ * offset/limit character chunking. Full text is best-effort HTML→Markdown, not
8
+ * structured JATS; preprints that are PDF-only or whose page is blocked return a
9
+ * typed `fulltext_unavailable` error routing to biorxiv_get_preprint.
10
+ * @module mcp-server/tools/definitions/biorxiv-get-fulltext.tool
11
+ */
12
+ import { tool, z } from '@cyanheads/mcp-ts-core';
13
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
14
+ import { getBiorxivApiService } from '../../../services/biorxiv/biorxiv-service.js';
15
+ import { getBiorxivFullTextService } from '../../../services/biorxiv-fulltext/biorxiv-fulltext-service.js';
16
+ const DOI_REGEX = /^10\.\d{4,}\//;
17
+ export const biorxivGetFulltextTool = tool('biorxiv_get_fulltext', {
18
+ title: 'Get Preprint Full Text',
19
+ description: "Retrieve a preprint's full text as best-effort Markdown, extracted from its rendered HTML article page. Resolves the latest version via the details API, then fetches and extracts the body — abstract, sections, and references. This is HTML-to-Markdown extraction, not structured JATS: section structure is approximate and not guaranteed. Long articles exceed a single response, so use offset and limit to page through them (the response reports totalChars, remainingChars, and hasMore). Not every preprint has an extractable HTML page — some are PDF-only and some origins block programmatic access — in which case a fulltext_unavailable error routes you to biorxiv_get_preprint for the title, abstract, and metadata. For a preprint that has been published in a journal, the journal's version may have richer full text elsewhere.",
20
+ annotations: { readOnlyHint: true, openWorldHint: true },
21
+ input: z.object({
22
+ doi: z
23
+ .string()
24
+ .describe('Preprint DOI (e.g. 10.1101/2024.05.28.596311 or 10.64898/2026.05.07.723463). The latest version is resolved automatically.'),
25
+ server: z
26
+ .enum(['biorxiv', 'medrxiv'])
27
+ .default('biorxiv')
28
+ .describe('Server the preprint was posted on. Defaults to biorxiv.'),
29
+ offset: z
30
+ .number()
31
+ .int()
32
+ .min(0)
33
+ .default(0)
34
+ .describe('Character offset into the full extracted text at which to start reading. 0 returns the beginning. To read the next chunk, use offset = prior_offset + prior_length (the length field from the previous response).'),
35
+ limit: z
36
+ .number()
37
+ .int()
38
+ .min(1)
39
+ .max(50000)
40
+ .default(20000)
41
+ .describe('Maximum number of characters to return in this chunk. Default 20,000; increase toward 50,000 for large context windows. Check the length field for the actual count returned.'),
42
+ }),
43
+ output: z.object({
44
+ doi: z.string().describe('The resolved preprint DOI.'),
45
+ server: z.enum(['biorxiv', 'medrxiv']).describe('Server the preprint was resolved on.'),
46
+ version: z
47
+ .string()
48
+ .describe('Preprint version whose full text was retrieved (the latest revision).'),
49
+ title: z
50
+ .string()
51
+ .optional()
52
+ .describe('Article title detected during extraction. Absent when the page exposed none.'),
53
+ content: z
54
+ .string()
55
+ .describe('The requested chunk of full text as best-effort Markdown extracted from the rendered HTML page. Section structure is approximate — this is not JATS.'),
56
+ contentFormat: z
57
+ .literal('html-markdown')
58
+ .describe('How content was produced: Markdown extracted from the rendered HTML article page (constant).'),
59
+ wordCount: z
60
+ .number()
61
+ .optional()
62
+ .describe('Approximate word count of the FULL extracted article as reported by the extractor (not just the returned chunk). Absent when the extractor reported none.'),
63
+ sourceUrl: z.string().describe('The full-text HTML page the content was extracted from.'),
64
+ offset: z
65
+ .number()
66
+ .describe('Character offset into the full extracted text where this chunk begins.'),
67
+ length: z.number().describe('Number of characters returned in this chunk.'),
68
+ totalChars: z
69
+ .number()
70
+ .describe('Total characters in the full extracted text. Use with offset and length to page through long articles.'),
71
+ remainingChars: z
72
+ .number()
73
+ .describe('Characters remaining after this chunk (totalChars - offset - length). 0 means this chunk reaches the end.'),
74
+ hasMore: z
75
+ .boolean()
76
+ .describe('True when more text follows this chunk. When true, call again with offset = offset + length.'),
77
+ }),
78
+ // Truncation disclosure on the enrichment channel (the framework capped-list
79
+ // convention) alongside the gutenberg-style paging fields in output. Populated
80
+ // via ctx.enrich.truncated only when the chunk was capped — optional so the
81
+ // final-chunk path leaves them absent.
82
+ enrichment: {
83
+ truncated: z
84
+ .boolean()
85
+ .optional()
86
+ .describe('True when this chunk was capped by limit and more text remains.'),
87
+ shown: z.number().optional().describe('Characters returned in this chunk.'),
88
+ cap: z.number().optional().describe('The limit (max characters) applied to this chunk.'),
89
+ notice: z
90
+ .string()
91
+ .optional()
92
+ .describe('Paging guidance when the content was truncated — how to fetch the next chunk.'),
93
+ },
94
+ errors: [
95
+ {
96
+ reason: 'invalid_doi_format',
97
+ code: JsonRpcErrorCode.ValidationError,
98
+ when: 'The input DOI does not match the 10.NNNN/ pattern.',
99
+ recovery: 'Correct the DOI format — bioRxiv/medRxiv DOIs start with 10.1101/ or 10.64898/ followed by the manuscript ID.',
100
+ },
101
+ {
102
+ reason: 'doi_not_found',
103
+ code: JsonRpcErrorCode.NotFound,
104
+ when: 'The DOI resolves to no preprint on the requested server.',
105
+ recovery: 'Find the correct DOI and server with biorxiv_search_preprints, or retry with the other server value.',
106
+ },
107
+ {
108
+ reason: 'fulltext_unavailable',
109
+ code: JsonRpcErrorCode.NotFound,
110
+ when: 'The preprint exists but its full-text HTML page is blocked, missing, or yields no extractable text (PDF-only).',
111
+ recovery: 'Use biorxiv_get_preprint for the title, abstract, and metadata — a readable full-text page is not available for this preprint.',
112
+ },
113
+ {
114
+ reason: 'offset_out_of_range',
115
+ code: JsonRpcErrorCode.ValidationError,
116
+ when: 'offset is greater than or equal to the total character length of the extracted text.',
117
+ recovery: "Use an offset below totalChars — a prior response's remainingChars shows how much text is left.",
118
+ },
119
+ ],
120
+ async handler(input, ctx) {
121
+ ctx.log.info('Executing biorxiv_get_fulltext', {
122
+ doi: input.doi,
123
+ server: input.server,
124
+ offset: input.offset,
125
+ limit: input.limit,
126
+ });
127
+ if (!DOI_REGEX.test(input.doi)) {
128
+ throw ctx.fail('invalid_doi_format', `Invalid DOI format: ${input.doi}`, {
129
+ ...ctx.recoveryFor('invalid_doi_format'),
130
+ });
131
+ }
132
+ // Resolve the preprint and its latest version via the JSON details API — this
133
+ // provides the version for the full-text URL and clean not-found handling.
134
+ // Transient failures here bubble as ServiceUnavailable.
135
+ const revisions = await getBiorxivApiService().getDetails(input.doi, input.server, ctx);
136
+ const latest = revisions.at(-1);
137
+ if (!latest) {
138
+ throw ctx.fail('doi_not_found', `No preprint found for ${input.doi} on ${input.server}.`, {
139
+ doi: input.doi,
140
+ server: input.server,
141
+ ...ctx.recoveryFor('doi_not_found'),
142
+ });
143
+ }
144
+ const version = latest.version ?? '1';
145
+ const result = await getBiorxivFullTextService().fetchFullText(input.server, input.doi, version, ctx);
146
+ if (result.kind === 'unavailable') {
147
+ throw ctx.fail('fulltext_unavailable', result.detail, {
148
+ doi: input.doi,
149
+ server: input.server,
150
+ version,
151
+ sourceUrl: result.sourceUrl,
152
+ ...ctx.recoveryFor('fulltext_unavailable'),
153
+ });
154
+ }
155
+ const totalChars = result.markdown.length;
156
+ if (input.offset >= totalChars) {
157
+ throw ctx.fail('offset_out_of_range', `Offset ${input.offset} is past the end of the text (totalChars: ${totalChars}).`, { offset: input.offset, totalChars, ...ctx.recoveryFor('offset_out_of_range') });
158
+ }
159
+ const end = Math.min(input.offset + input.limit, totalChars);
160
+ const content = result.markdown.slice(input.offset, end);
161
+ const length = content.length;
162
+ const remainingChars = totalChars - end;
163
+ const hasMore = remainingChars > 0;
164
+ if (hasMore) {
165
+ ctx.enrich.truncated({
166
+ shown: length,
167
+ cap: input.limit,
168
+ guidance: `Full text truncated at the ${input.limit}-character limit. Call biorxiv_get_fulltext again with offset=${end} to read the next chunk.`,
169
+ });
170
+ }
171
+ return {
172
+ doi: input.doi,
173
+ server: input.server,
174
+ version,
175
+ ...(result.title && { title: result.title }),
176
+ content,
177
+ contentFormat: 'html-markdown',
178
+ ...(result.wordCount !== undefined && { wordCount: result.wordCount }),
179
+ sourceUrl: result.sourceUrl,
180
+ offset: input.offset,
181
+ length,
182
+ totalChars,
183
+ remainingChars,
184
+ hasMore,
185
+ };
186
+ },
187
+ format: (result) => {
188
+ const lines = [];
189
+ lines.push(`## ${result.title ?? result.doi}`);
190
+ lines.push(`**DOI:** ${result.doi} | **Server:** ${result.server} | **Version:** v${result.version}`);
191
+ const end = result.offset + result.length;
192
+ lines.push(`**Characters ${result.offset.toLocaleString()}–${(end - 1).toLocaleString()} of ${result.totalChars.toLocaleString()}** | Length: ${result.length.toLocaleString()} | Remaining: ${result.remainingChars.toLocaleString()} | hasMore: ${result.hasMore}`);
193
+ if (result.wordCount !== undefined)
194
+ lines.push(`**Full-article word count:** ${result.wordCount}`);
195
+ lines.push(`**Source:** ${result.sourceUrl}`);
196
+ lines.push(`**Format:** ${result.contentFormat}`);
197
+ lines.push('\n> Extracted from the rendered HTML page — section structure is best-effort and not guaranteed (this is not JATS). Treat headings and reference formatting as approximate.');
198
+ lines.push('\n---\n');
199
+ lines.push(result.content);
200
+ if (result.hasMore) {
201
+ lines.push(`\n---\n_Call biorxiv_get_fulltext again with doi=${result.doi}, offset=${end} to read the next chunk._`);
202
+ }
203
+ else {
204
+ lines.push('\n---\n_End of extracted text._');
205
+ }
206
+ return [{ type: 'text', text: lines.join('\n') }];
207
+ },
208
+ });
209
+ //# sourceMappingURL=biorxiv-get-fulltext.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"biorxiv-get-fulltext.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,yDAAyD,CAAC;AAEpG,MAAM,SAAS,GAAG,eAAe,CAAC;AAElC,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,sBAAsB,EAAE;IACjE,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EACT,6zBAA6zB;IAC/zB,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;IAExD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,CAAC;aACH,MAAM,EAAE;aACR,QAAQ,CACP,4HAA4H,CAC7H;QACH,MAAM,EAAE,CAAC;aACN,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;aAC5B,OAAO,CAAC,SAAS,CAAC;aAClB,QAAQ,CAAC,yDAAyD,CAAC;QACtE,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,GAAG,EAAE;aACL,GAAG,CAAC,CAAC,CAAC;aACN,OAAO,CAAC,CAAC,CAAC;aACV,QAAQ,CACP,mNAAm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C,KAAK,CAAC,IAAI,CAAC,eAAe,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;QAClD,KAAK,CAAC,IAAI,CACR,6KAA6K,CAC9K,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CACR,oDAAoD,MAAM,CAAC,GAAG,YAAY,GAAG,2BAA2B,CACzG,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"biorxiv-list-recent.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/biorxiv-list-recent.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AA2BjE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyShC,CAAC"}
1
+ {"version":3,"file":"biorxiv-list-recent.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/biorxiv-list-recent.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AA4BjE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4ThC,CAAC"}
@@ -9,6 +9,7 @@
9
9
  import { tool, z } from '@cyanheads/mcp-ts-core';
10
10
  import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
11
11
  import { getBiorxivApiService } from '../../../services/biorxiv/biorxiv-service.js';
12
+ import { isValidCalendarDate } from '../../../services/shared.js';
12
13
  const DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
13
14
  function formatPreprint(p) {
14
15
  const lines = [];
@@ -124,7 +125,7 @@ export const biorxivListRecentTool = tool('biorxiv_list_recent', {
124
125
  categoryNote: z
125
126
  .string()
126
127
  .optional()
127
- .describe('Present when server="both" and the category belongs to only one server\'s taxonomy. Explains which server the filter was applied to.'),
128
+ .describe('Present when server="both" and the category exists in only one server\'s taxonomy. Explains which server was queried and why the other was excluded.'),
128
129
  },
129
130
  errors: [
130
131
  {
@@ -148,12 +149,18 @@ export const biorxivListRecentTool = tool('biorxiv_list_recent', {
148
149
  cursor: input.cursor,
149
150
  category: input.category,
150
151
  });
151
- // Validate dates
152
+ // Validate dates: shape first, then real-calendar-date (rejects overflow days
153
+ // like 2024-02-30 that the shape regex accepts but no calendar holds), then range.
152
154
  if (!DATE_REGEX.test(input.start_date) || !DATE_REGEX.test(input.end_date)) {
153
155
  throw ctx.fail('invalid_date_range', 'Date must be in YYYY-MM-DD format.', {
154
156
  ...ctx.recoveryFor('invalid_date_range'),
155
157
  });
156
158
  }
159
+ if (!isValidCalendarDate(input.start_date) || !isValidCalendarDate(input.end_date)) {
160
+ throw ctx.fail('invalid_date_range', 'Date must be a real calendar date (YYYY-MM-DD).', {
161
+ ...ctx.recoveryFor('invalid_date_range'),
162
+ });
163
+ }
157
164
  if (input.start_date > input.end_date) {
158
165
  throw ctx.fail('invalid_date_range', `start_date (${input.start_date}) must be on or before end_date (${input.end_date}).`, { ...ctx.recoveryFor('invalid_date_range') });
159
166
  }
@@ -177,29 +184,34 @@ export const biorxivListRecentTool = tool('biorxiv_list_recent', {
177
184
  }
178
185
  let allPreprints = [];
179
186
  // When server="both" and a category is given, check membership per-server once.
180
- // These booleans drive both the routing (pass vs. undefined) and the categoryNote enrichment.
187
+ // A category that exists in only one taxonomy (inBx !== inMx) collapses the
188
+ // request onto that server alone — querying the other would return an
189
+ // unfiltered page mixed in with the filtered one under a filtered-looking
190
+ // request. Shared categories (Epidemiology, Pathology) and no-category
191
+ // requests still fan out to both servers.
181
192
  const inBx = input.server === 'both' && !!category && service.isValidCategory(category, 'biorxiv');
182
193
  const inMx = input.server === 'both' && !!category && service.isValidCategory(category, 'medrxiv');
183
- if (input.server === 'both' && category) {
184
- if (inBx && !inMx) {
185
- ctx.enrich({
186
- categoryNote: `Category "${category}" is specific to bioRxiv — the filter was applied to bioRxiv only. medRxiv results are unfiltered.`,
187
- });
188
- }
189
- else if (inMx && !inBx) {
190
- ctx.enrich({
191
- categoryNote: `Category "${category}" is specific to medRxiv — the filter was applied to medRxiv only. bioRxiv results are unfiltered.`,
192
- });
193
- }
194
+ const exclusiveServer = inBx === inMx ? undefined : inBx ? 'biorxiv' : 'medrxiv';
195
+ if (input.server === 'both' && category && exclusiveServer) {
196
+ ctx.enrich({
197
+ categoryNote: exclusiveServer === 'biorxiv'
198
+ ? `Category "${category}" is specific to bioRxiv — only bioRxiv was queried. medRxiv was not included because its taxonomy has no such category.`
199
+ : `Category "${category}" is specific to medRxiv — only medRxiv was queried. bioRxiv was not included because its taxonomy has no such category.`,
200
+ });
201
+ }
202
+ if (exclusiveServer) {
203
+ // "both" request with a server-exclusive category → query only the owning
204
+ // server, so the page never mixes filtered with unfiltered records.
205
+ const r = await service.getListing(exclusiveServer, input.start_date, input.end_date, input.cursor, category, ctx);
206
+ pagination[exclusiveServer] = toPaginationEntry(r);
207
+ allPreprints = r.preprints;
194
208
  }
195
- if (input.server === 'both') {
196
- // Pass the category only to the server that recognises it; send undefined
197
- // to the other so it returns its normal unfiltered result.
198
- const bxCategory = inBx ? category : undefined;
199
- const mxCategory = inMx ? category : undefined;
209
+ else if (input.server === 'both') {
210
+ // Fan out to both servers. Any category here is shared by both taxonomies,
211
+ // so it applies to each; with no category both return unfiltered pages.
200
212
  const [bxResult, mxResult] = await Promise.allSettled([
201
- service.getListing('biorxiv', input.start_date, input.end_date, input.cursor, bxCategory, ctx),
202
- service.getListing('medrxiv', input.start_date, input.end_date, input.cursor, mxCategory, ctx),
213
+ service.getListing('biorxiv', input.start_date, input.end_date, input.cursor, category, ctx),
214
+ service.getListing('medrxiv', input.start_date, input.end_date, input.cursor, category, ctx),
203
215
  ]);
204
216
  if (bxResult.status === 'fulfilled') {
205
217
  pagination.biorxiv = toPaginationEntry(bxResult.value);