@cyanheads/biorxiv-mcp-server 0.2.7 → 0.3.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 (58) hide show
  1. package/AGENTS.md +15 -11
  2. package/CLAUDE.md +15 -11
  3. package/README.md +22 -11
  4. package/changelog/0.2.x/0.2.7.md +3 -2
  5. package/changelog/0.2.x/0.2.8.md +26 -0
  6. package/changelog/0.3.x/0.3.0.md +22 -0
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.d.ts +18 -5
  10. package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.d.ts.map +1 -1
  11. package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.js +91 -34
  12. package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.js.map +1 -1
  13. package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.d.ts +5 -3
  14. package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.d.ts.map +1 -1
  15. package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.js +36 -24
  16. package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.js.map +1 -1
  17. package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.d.ts +19 -9
  18. package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.d.ts.map +1 -1
  19. package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js +135 -47
  20. package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js.map +1 -1
  21. package/dist/mcp-server/tools/definitions/biorxiv-list-categories.tool.js +1 -1
  22. package/dist/mcp-server/tools/definitions/biorxiv-list-categories.tool.js.map +1 -1
  23. package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts +21 -3
  24. package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts.map +1 -1
  25. package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js +171 -76
  26. package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js.map +1 -1
  27. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts +21 -2
  28. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts.map +1 -1
  29. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js +99 -25
  30. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js.map +1 -1
  31. package/dist/mcp-server/tools/definitions/index.d.ts +41 -14
  32. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
  33. package/dist/services/biorxiv/biorxiv-service.d.ts +35 -7
  34. package/dist/services/biorxiv/biorxiv-service.d.ts.map +1 -1
  35. package/dist/services/biorxiv/biorxiv-service.js +137 -61
  36. package/dist/services/biorxiv/biorxiv-service.js.map +1 -1
  37. package/dist/services/biorxiv/types.d.ts +27 -2
  38. package/dist/services/biorxiv/types.d.ts.map +1 -1
  39. package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.d.ts +5 -2
  40. package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.d.ts.map +1 -1
  41. package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.js +5 -6
  42. package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.js.map +1 -1
  43. package/dist/services/europe-pmc/europe-pmc-service.d.ts +23 -6
  44. package/dist/services/europe-pmc/europe-pmc-service.d.ts.map +1 -1
  45. package/dist/services/europe-pmc/europe-pmc-service.js +118 -19
  46. package/dist/services/europe-pmc/europe-pmc-service.js.map +1 -1
  47. package/dist/services/europe-pmc/types.d.ts +9 -3
  48. package/dist/services/europe-pmc/types.d.ts.map +1 -1
  49. package/dist/services/shared.d.ts +83 -10
  50. package/dist/services/shared.d.ts.map +1 -1
  51. package/dist/services/shared.js +287 -16
  52. package/dist/services/shared.js.map +1 -1
  53. package/dist/services/upstream-text-tables.d.ts +44 -0
  54. package/dist/services/upstream-text-tables.d.ts.map +1 -0
  55. package/dist/services/upstream-text-tables.js +296 -0
  56. package/dist/services/upstream-text-tables.js.map +1 -0
  57. package/package.json +4 -4
  58. package/server.json +3 -3
@@ -1,14 +1,18 @@
1
1
  /**
2
2
  * @fileoverview EuropePmcService — wraps the EuropePMC REST search endpoint
3
3
  * for preprint keyword search. Returns ranked DOI lists used by
4
- * biorxiv_search_preprints for bioRxiv/medRxiv enrichment. All requests
4
+ * biorxiv_search_preprints for bioRxiv/medRxiv enrichment, and looks up
5
+ * abstracts for records that fall back to EuropePMC metadata: the ranked search
6
+ * uses the `lite` result type, which never carries `abstractText`, so abstracts
7
+ * come from one DOI-keyed `core` query instead. All requests
5
8
  * include a polite User-Agent and are retried with exponential backoff.
6
- * Detects HTML error pages, and classifies an origin rate limit (HTTP 429) as
7
- * its own retryable `rate_limited` condition carrying the parsed `Retry-After`
8
- * wait — never the upstream response body.
9
+ * Detects HTML error pages, retries an HTTP 200 body that carries no result
10
+ * list, and classifies an origin rate limit (HTTP 429) as its own retryable
11
+ * `rate_limited` condition carrying the parsed `Retry-After` wait — never the
12
+ * upstream response body.
9
13
  * @module services/europe-pmc/europe-pmc-service
10
14
  */
11
- import { McpError, rateLimited, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
15
+ import { McpError, rateLimited, serviceUnavailable, validationError, } from '@cyanheads/mcp-ts-core/errors';
12
16
  import { fetchWithTimeout, withRetry } from '@cyanheads/mcp-ts-core/utils';
13
17
  import { getServerConfig } from '../../config/server-config.js';
14
18
  import { describeWait, detectHtmlError, normalizeUpstreamText, parseRetryAfterSeconds, SERVER_VERSION, } from '../shared.js';
@@ -19,10 +23,29 @@ import { describeWait, detectHtmlError, normalizeUpstreamText, parseRetryAfterSe
19
23
  */
20
24
  const EXPECTED_STATUSES = [429];
21
25
  /**
22
- * Re-throws a failed EuropePMC call, classifying HTTP 429 as its own retryable
23
- * `rate_limited` condition. Everything else — 5xx, timeout, network error, the
24
- * HTML-error guard below — re-throws untouched for the framework's
25
- * auto-classifier.
26
+ * `data.reason` on the error thrown for an HTTP 200 body with no `resultList`.
27
+ * EuropePMC answers some requests with only `{"version":"6.9"}` — intermittently
28
+ * for a valid first page or cursor page, and on every attempt for a malformed
29
+ * `cursorMark`. Read as data, the body becomes a zero-result page, so it is
30
+ * thrown as a transient `ServiceUnavailable` inside `withRetry` instead.
31
+ */
32
+ const EMPTY_BODY_REASON = 'empty_response_body';
33
+ /**
34
+ * Re-throws a failed EuropePMC call with the two conditions this service
35
+ * classifies itself:
36
+ *
37
+ * - an empty body that outlasted every retry — a caller error when a cursor
38
+ * page was requested (`invalid_cursor_mark`), an upstream failure on a first
39
+ * page, which has no caller input to blame;
40
+ * - HTTP 429, as its own retryable `rate_limited` condition.
41
+ *
42
+ * Everything else — 5xx, timeout, network error, the HTML-error guard below —
43
+ * re-throws untouched for the framework's auto-classifier.
44
+ *
45
+ * The empty-body errors are built fresh rather than re-thrown: `withRetry`
46
+ * suffixes an exhausted error's message with `(failed after N attempts)`, and
47
+ * that wording would otherwise reach the caller inside the tool's message. The
48
+ * attempt count moves to `data.retryAttempts`.
26
49
  *
27
50
  * `fetchWithTimeout` attaches the upstream response body to `err.data`
28
51
  * (`body`/`responseBody`), so the replacement payload is built from scratch
@@ -31,10 +54,20 @@ const EXPECTED_STATUSES = [429];
31
54
  * and fails fast when the requested wait exceeds its cap, so by the time a 429
32
55
  * reaches here the waiting is over and only classification is left.
33
56
  */
34
- function rethrowClassified(err) {
57
+ function rethrowClassified(err, cursorMark) {
35
58
  const data = err instanceof McpError
36
59
  ? err.data
37
60
  : undefined;
61
+ if (data?.reason === EMPTY_BODY_REASON) {
62
+ // Always set: the empty body is transient, so it only escapes `withRetry`
63
+ // exhausted, and exhaustion is what attaches the count.
64
+ const retryAttempts = data.retryAttempts;
65
+ const tries = `${retryAttempts} consecutive attempts`;
66
+ if (cursorMark !== '*') {
67
+ throw validationError(`EuropePMC did not recognize the supplied cursor_mark — ${tries} came back with no result list.`, { reason: 'invalid_cursor_mark', cursor_mark: cursorMark, retryAttempts }, { cause: err });
68
+ }
69
+ throw serviceUnavailable(`EuropePMC answered ${tries} with HTTP 200 and no result list.`, { reason: EMPTY_BODY_REASON, retryAttempts }, { cause: err });
70
+ }
38
71
  if (data?.status !== 429)
39
72
  throw err;
40
73
  const retryAfter = parseRetryAfterSeconds(data.retryAfter);
@@ -63,9 +96,12 @@ export class EuropePmcService {
63
96
  /**
64
97
  * Search EuropePMC for preprints matching the query. Returns ranked results
65
98
  * with DOIs plus the upstream hitCount grand total, used to drive bioRxiv API
66
- * enrichment. Requests the minimal field set (doi, title, authorString,
67
- * firstPublicationDate, abstractText).
99
+ * enrichment. Uses the `lite` result type (doi, title, authorString,
100
+ * firstPublicationDate), which carries no abstract — see `getAbstracts`.
68
101
  * Throws a retryable `rate_limited` error when the origin returns HTTP 429.
102
+ * A body with no result list is retried; if every attempt returns one, throws
103
+ * `ValidationError` (`invalid_cursor_mark`) when a cursor page other than `*`
104
+ * was requested, and `ServiceUnavailable` (`empty_response_body`) otherwise.
69
105
  */
70
106
  async search(options, ctx) {
71
107
  const limit = Math.min(options.limit ?? 25, 100);
@@ -98,15 +134,16 @@ export class EuropePmcService {
98
134
  q += ' AND (PUBLISHER:bioRxiv OR PUBLISHER:medRxiv)';
99
135
  }
100
136
  const filterParam = 'source:PPR';
101
- const fields = 'doi,title,authorString,firstPublicationDate,abstractText';
137
+ // A blank cursor (a form client's empty field) is a first page, as it is
138
+ // upstream. Tokens are base64, so surrounding whitespace is never part of one.
139
+ const cursorMark = options.cursorMark?.trim() || '*';
102
140
  const params = new URLSearchParams({
103
141
  query: q,
104
142
  resulttype: 'lite',
105
143
  synonym: 'FALSE',
106
- cursorMark: options.cursorMark ?? '*',
144
+ cursorMark,
107
145
  pageSize: String(limit),
108
146
  format: 'json',
109
- fields,
110
147
  });
111
148
  const url = `${this.baseUrl}/search?${params.toString()}&filter=${filterParam}`;
112
149
  try {
@@ -121,17 +158,21 @@ export class EuropePmcService {
121
158
  throw serviceUnavailable('EuropePMC returned HTML instead of JSON — service may be degraded.', { url });
122
159
  }
123
160
  const data = JSON.parse(text);
124
- const results = (data.resultList?.result ?? [])
161
+ // A genuine zero-hit answer still carries an empty `resultList`.
162
+ if (!data.resultList) {
163
+ throw serviceUnavailable('EuropePMC answered HTTP 200 with no result list.', {
164
+ reason: EMPTY_BODY_REASON,
165
+ });
166
+ }
167
+ const results = (data.resultList.result ?? [])
125
168
  .filter((raw) => raw.doi != null)
126
169
  .map((raw) => {
127
170
  const title = normalizeUpstreamText(raw.title);
128
- const abstract = normalizeUpstreamText(raw.abstractText);
129
171
  return {
130
172
  doi: raw.doi,
131
173
  ...(title && { title }),
132
174
  ...(raw.authorString && { authors: raw.authorString }),
133
175
  ...(raw.firstPublicationDate && { publishedDate: raw.firstPublicationDate }),
134
- ...(abstract && { abstract }),
135
176
  };
136
177
  });
137
178
  return {
@@ -149,7 +190,65 @@ export class EuropePmcService {
149
190
  });
150
191
  }
151
192
  catch (err) {
152
- rethrowClassified(err);
193
+ rethrowClassified(err, cursorMark);
194
+ }
195
+ }
196
+ /**
197
+ * Fetch the abstracts of preprints by DOI in one `resultType=core` query — the
198
+ * only EuropePMC result type that carries `abstractText`. The query is keyed
199
+ * by the given DOIs (`DOI:"…" OR …`, preprints only) and one page is sized to
200
+ * hold them, so the response is bounded by the input. Returns normalized
201
+ * abstracts keyed by lowercase DOI; a DOI EuropePMC holds no abstract for is
202
+ * absent from the map. Throws on failure — classified like `search`, with an
203
+ * HTTP 429 as a retryable `rate_limited` error carrying `Retry-After`.
204
+ */
205
+ async getAbstracts(dois, ctx) {
206
+ const unique = [...new Set(dois.map((doi) => doi.toLowerCase()))];
207
+ // Quotes are stripped so a stray one cannot end the DOI phrase early.
208
+ const clause = unique.map((doi) => `DOI:"${doi.replace(/"/g, '')}"`).join(' OR ');
209
+ const params = new URLSearchParams({
210
+ query: `(${clause}) AND SRC:PPR`,
211
+ resultType: 'core',
212
+ synonym: 'FALSE',
213
+ pageSize: String(unique.length),
214
+ format: 'json',
215
+ });
216
+ const url = `${this.baseUrl}/search?${params.toString()}`;
217
+ try {
218
+ return await withRetry(async () => {
219
+ const response = await fetchWithTimeout(url, 20_000, ctx, {
220
+ signal: ctx.signal,
221
+ headers: { 'User-Agent': this.userAgent },
222
+ expectedStatuses: EXPECTED_STATUSES,
223
+ });
224
+ const text = await response.text();
225
+ if (detectHtmlError(text)) {
226
+ throw serviceUnavailable('EuropePMC returned HTML instead of JSON — service may be degraded.', { url });
227
+ }
228
+ const data = JSON.parse(text);
229
+ if (!data.resultList) {
230
+ throw serviceUnavailable('EuropePMC answered HTTP 200 with no result list.', {
231
+ reason: EMPTY_BODY_REASON,
232
+ });
233
+ }
234
+ const abstracts = new Map();
235
+ for (const raw of data.resultList.result ?? []) {
236
+ const doi = raw.doi?.toLowerCase();
237
+ const abstract = normalizeUpstreamText(raw.abstractText);
238
+ if (doi && abstract && !abstracts.has(doi))
239
+ abstracts.set(doi, abstract);
240
+ }
241
+ return abstracts;
242
+ }, {
243
+ operation: 'EuropePmcService.getAbstracts',
244
+ context: ctx,
245
+ baseDelayMs: 300,
246
+ signal: ctx.signal,
247
+ });
248
+ }
249
+ catch (err) {
250
+ // No cursor: an empty body that outlasts the retries is an upstream failure.
251
+ rethrowClassified(err, '*');
153
252
  }
154
253
  }
155
254
  }
@@ -1 +1 @@
1
- {"version":3,"file":"europe-pmc-service.js","sourceRoot":"","sources":["../../../src/services/europe-pmc/europe-pmc-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAE1F,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACt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AAC,GAAG,CAAC,YAAY,CAAC,CAAC;oBACzD,IAAI,GAAG,IAAI,QAAQ,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC;wBAAE,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;gBAC3E,CAAC;gBACD,OAAO,SAAS,CAAC;YACnB,CAAC,EACD;gBACE,SAAS,EAAE,+BAA+B;gBAC1C,OAAO,EAAE,GAAG;gBACZ,WAAW,EAAE,GAAG;gBAChB,MAAM,EAAE,GAAG,CAAC,MAAM;aACnB,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,6EAA6E;YAC7E,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF;AAED,gFAAgF;AAEhF,IAAI,QAAsC,CAAC;AAE3C,MAAM,UAAU,oBAAoB,CAAC,MAAiB,EAAE,OAAuB;IAC7E,QAAQ,GAAG,IAAI,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC,QAAQ;QACX,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -4,7 +4,10 @@
4
4
  * the search_preprints tool handler.
5
5
  * @module services/europe-pmc/types
6
6
  */
7
- /** A single result from the EuropePMC search endpoint */
7
+ /**
8
+ * A single result from the EuropePMC search endpoint. `abstractText` appears only
9
+ * under `resultType=core`; the `lite` result type never carries it.
10
+ */
8
11
  export interface RawEuropePmcResult {
9
12
  abstractText?: string;
10
13
  authorString?: string;
@@ -22,9 +25,12 @@ export interface RawEuropePmcSearchResponse {
22
25
  result?: RawEuropePmcResult[];
23
26
  };
24
27
  }
25
- /** A preprint search result from EuropePMC, used for enrichment */
28
+ /**
29
+ * A preprint search result from EuropePMC, used for enrichment. Carries no
30
+ * abstract: the ranked search uses the `lite` result type, and abstracts come
31
+ * from `EuropePmcService.getAbstracts`.
32
+ */
26
33
  export interface EuropePmcResult {
27
- abstract?: string;
28
34
  authors?: string;
29
35
  doi: string;
30
36
  publishedDate?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/europe-pmc/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,yDAAyD;AACzD,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,yDAAyD;AACzD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE;QACX,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAC;KAC/B,CAAC;CACH;AAID,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,uGAAuG;AACvG,MAAM,WAAW,qBAAqB;IACpC,0FAA0F;IAC1F,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/europe-pmc/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,yDAAyD;AACzD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE;QACX,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAC;KAC/B,CAAC;CACH;AAID;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,uGAAuG;AACvG,MAAM,WAAW,qBAAqB;IACpC,0FAA0F;IAC1F,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B"}
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * @fileoverview Shared utilities for biorxiv-mcp-server service layer. Provides
3
- * HTML error detection, calendar-date and upstream-text normalization,
4
- * `Retry-After` parsing and rate-limit rejection lookup shared by every fetch
5
- * path, and the server version string used in User-Agent headers across all
6
- * services.
3
+ * HTML error detection, DOI and ROR ID input normalization, calendar-date and
4
+ * upstream-text normalization, the Markdown escaper every `format()` applies
5
+ * to upstream text, `Retry-After` parsing and rate-limit rejection lookup
6
+ * shared by every fetch path, and the server version string used in User-Agent
7
+ * headers across all services.
7
8
  * @module services/shared
8
9
  */
9
10
  /** Detect HTML error pages returned instead of JSON by upstream APIs. */
@@ -20,18 +21,69 @@ export declare function detectHtmlError(text: string): boolean;
20
21
  * without a prior regex gate.
21
22
  */
22
23
  export declare function isValidCalendarDate(dateStr: string): boolean;
24
+ /** A preprint DOI reduced to its bare form, plus the revision a version suffix named. */
25
+ export interface NormalizedDoi {
26
+ /** Bare DOI, e.g. `10.64898/2026.03.11.711201`. */
27
+ doi: string;
28
+ /** Revision named by a trailing `vN` (`"2"` for `…711201v2`); absent when none was given. */
29
+ version?: string;
30
+ }
31
+ /**
32
+ * Reduce a pasted preprint reference to its bare DOI. Accepts the bare DOI
33
+ * itself, a `https://doi.org/` or `http(s)://dx.doi.org/` resolver URL, a
34
+ * `doi:` label, or a `{www.}{biorxiv,medrxiv}.org/content/` article URL — any
35
+ * of them with a trailing `vN` revision and an article-tab suffix (`.full`,
36
+ * `.full.pdf`, `.article-metrics`, …).
37
+ * A URL's query string and fragment are dropped. Returns the revision the
38
+ * suffix named alongside the DOI, and `undefined` when what is left is not a
39
+ * DOI — callers raise their `invalid_doi_format` on that.
40
+ *
41
+ * A bare DOI passes through unchanged: stripping only ever removes text around
42
+ * a bioRxiv/medRxiv identifier, never characters of one.
43
+ */
44
+ export declare function normalizeDoi(input: string): NormalizedDoi | undefined;
45
+ /**
46
+ * Reduce a ROR ID to the bare 9-character form — the only one the bioRxiv
47
+ * listing endpoint's `funder` filter accepts. Accepts the bare ID or a
48
+ * `https://ror.org/` URL, in any case, with a trailing slash. Returns
49
+ * `undefined` unless what is left matches the ROR pattern and its ISO 7064
50
+ * Mod 97-10 checksum (the last two digits, over the base32 value of the six
51
+ * characters before them), so a mistyped ID is caught before any call.
52
+ */
53
+ export declare function normalizeRorId(input: string): string | undefined;
23
54
  /**
24
55
  * Strip Highwire/JATS export artifacts that bioRxiv/medRxiv and EuropePMC leak
25
56
  * into raw title and abstract text, so no upstream markup reaches
26
- * `structuredContent` or the rendered `content[]`. Removes:
57
+ * `structuredContent` or the rendered `content[]`. Handles:
27
58
  *
28
- * - whole figure blocks (`O_FIG … C_FIG`), which carry image refs, `SRC=` paths,
29
- * `org.highwire.dtl.*` object references, and "Graphical Abstract" boilerplate;
59
+ * - whole blocks removed with everything inside: figures (`O_FIG … C_FIG`),
60
+ * display figures (`O_FIG_DISPLAY_L … C_FIG_DISPLAY`), and tables
61
+ * (`O_TBL … C_TBL`, caption included) — image refs, `SRC=` paths,
62
+ * `org.highwire.dtl.*` object references, "Graphical Abstract" boilerplate;
30
63
  * - the small-caps "Abstract" heading sentinel (`A<O_SCPLOW>BSTRACT<C_SCPLOW>`),
31
64
  * which upstream fuses directly onto the first sentence with no separator;
32
- * - remaining small-caps markers around inline text (markers dropped, the wrapped
33
- * scientific text kept);
34
- * - inline HTML formatting tags (`<i>`, `<b>`, `<sub>`, `<sup>`, `<u>`, …).
65
+ * - markers dropped with the text inside them kept: small caps, text boxes
66
+ * (`O_TEXTBOX`), and display formulas (`O_FD`, `O_INLINEFIG`);
67
+ * - section headings rendered as `Heading: ` — from `O_ST_ABS … C_ST_ABS`
68
+ * markers, EuropePMC's `<h4>` headings, and a closed heading list at the
69
+ * start of a paragraph where upstream fused the heading onto the body
70
+ * (never before the digit of a gene symbol such as `AIM2`, and never taking
71
+ * the body's first capital into the heading). Paragraphs are read before
72
+ * whitespace collapses, since the line break is the only boundary left, and
73
+ * single-line text (a title) is never split;
74
+ * - list items (`O_LI … C_LI`) rendered as `• ` items;
75
+ * - Highwire symbol placeholders (`{beta}`, `{+/-}`, `[&ge;]`, `[~]`,
76
+ * `[x1D05]`, …) mapped to their characters through closed tables
77
+ * (`upstream-text-tables.ts`), and `[xHHHH]` read as a code point when it
78
+ * is a non-ASCII symbol. An unknown name, any other code point, LaTeX
79
+ * braces, and single-letter brackets stay verbatim;
80
+ * - inline HTML formatting tags (`<i>`, `<b>`, `<sub>`, `<sup>`, `<u>`, …),
81
+ * except where removing one would splice a new tag out of the text around it.
82
+ *
83
+ * The result is plain text, never Markdown: `format()` escapes it at
84
+ * interpolation (`escapeMarkdown`), so anything emitted here as syntax would
85
+ * render as literal characters. A `*` upstream (`A*T to G*C`, where EuropePMC
86
+ * has `A•T`) is left alone — it may be a lost bullet, but nothing says so.
35
87
  *
36
88
  * Applied at the service boundary rather than in a tool's `format()` because
37
89
  * `structuredContent` is the handler's raw return value and bypasses `format()`;
@@ -40,6 +92,27 @@ export declare function isValidCalendarDate(dateStr: string): boolean;
40
92
  * fields as absent rather than as empty strings.
41
93
  */
42
94
  export declare function normalizeUpstreamText(text: string | undefined): string | undefined;
95
+ /**
96
+ * Escape upstream text for interpolation into `format()` Markdown so it renders
97
+ * literally, inserting a backslash only where a character would otherwise
98
+ * change rendering: the inline metacharacters ``\ * _ ` ~ [ <`` in a position
99
+ * that can open syntax (see `changesRendering`), plus a line-initial `>`, a
100
+ * line-initial `#` run that opens a heading (a space, tab, or line end follows
101
+ * it — `#441914366` does not), or a list marker (`-`, `+`, `1.`, `1)`) — an
102
+ * abstract is interpolated at the start of a line in some tools, and a joined
103
+ * field (`awards`) starts with its first value. Agents read `content[]` as
104
+ * text and copy spans out of it, so an escape that changes nothing
105
+ * (`p\<0.05`, `cc\_by`) is noise.
106
+ * An apostrophe, a mid-line `#`, or a signed `-0.42` already renders as itself.
107
+ *
108
+ * Apply to each upstream field value where it is interpolated, never to the
109
+ * assembled text (the formatter's own `**Label:**` markup must survive), and
110
+ * never to `structuredContent`, identifiers an agent copies back into a call
111
+ * (DOIs, `jatsxmlUrl`, `sourceUrl`), or extractor-produced Markdown such as the
112
+ * `biorxiv_get_fulltext` `content`. Local because `@cyanheads/mcp-ts-core`
113
+ * exports an HTML escaper only.
114
+ */
115
+ export declare function escapeMarkdown(text: string): string;
43
116
  /**
44
117
  * Reads a `Retry-After` header value as a wait in whole seconds. RFC 9110 §10.2.3
45
118
  * allows either delta-seconds or an HTTP-date; the date form is converted to a
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAU5D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAuBlF;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOvE;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAiB7F;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEhE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,MAA4B,CAAC"}
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAU5D;AAED,yFAAyF;AACzF,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAuBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAWr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