@cyanheads/biorxiv-mcp-server 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +6 -2
- package/CLAUDE.md +6 -2
- package/README.md +12 -6
- package/changelog/0.2.x/0.2.2.md +21 -0
- package/changelog/0.2.x/0.2.3.md +26 -0
- package/dist/config/server-config.d.ts +5 -4
- package/dist/config/server-config.d.ts.map +1 -1
- package/dist/config/server-config.js +12 -11
- package/dist/config/server-config.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.d.ts +35 -6
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.js +117 -23
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.d.ts +11 -0
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.js +50 -13
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.d.ts +10 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js +26 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts +16 -0
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js +54 -12
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts +12 -0
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js +57 -17
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/index.d.ts +46 -2
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
- package/dist/services/biorxiv/biorxiv-service.d.ts +7 -1
- package/dist/services/biorxiv/biorxiv-service.d.ts.map +1 -1
- package/dist/services/biorxiv/biorxiv-service.js +148 -92
- package/dist/services/biorxiv/biorxiv-service.js.map +1 -1
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.d.ts +29 -7
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.d.ts.map +1 -1
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.js +119 -15
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.js.map +1 -1
- package/dist/services/shared.d.ts +35 -2
- package/dist/services/shared.d.ts.map +1 -1
- package/dist/services/shared.js +64 -2
- package/dist/services/shared.js.map +1 -1
- package/package.json +1 -1
- package/server.json +31 -3
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
* @fileoverview BiorxivApiService — wraps api.biorxiv.org endpoints for
|
|
3
3
|
* preprint details (/details), date-range listing (/details with date interval),
|
|
4
4
|
* and crosswalk (/pubs). All methods retry with exponential backoff. Parses
|
|
5
|
-
* and normalizes raw JSON into domain types. Detects HTML error pages
|
|
5
|
+
* and normalizes raw JSON into domain types. Detects HTML error pages, and
|
|
6
|
+
* classifies an origin rate limit (HTTP 429) as its own retryable
|
|
7
|
+
* `rate_limited` condition carrying the parsed `Retry-After` wait — never the
|
|
8
|
+
* upstream response body.
|
|
6
9
|
* @module services/biorxiv/biorxiv-service
|
|
7
10
|
*/
|
|
8
|
-
import { serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
|
|
11
|
+
import { McpError, rateLimited, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
|
|
9
12
|
import { fetchWithTimeout, withRetry } from '@cyanheads/mcp-ts-core/utils';
|
|
10
13
|
import { getServerConfig } from '../../config/server-config.js';
|
|
11
|
-
import { asRc, detectHtmlError, normalizeUpstreamText, SERVER_VERSION } from '../../services/shared.js';
|
|
14
|
+
import { asRc, describeWait, detectHtmlError, normalizeUpstreamText, parseRetryAfterSeconds, SERVER_VERSION, } from '../../services/shared.js';
|
|
12
15
|
// ─── Hardcoded category taxonomy ─────────────────────────────────────────────
|
|
13
16
|
// No API endpoint provides this; it changes infrequently. Maintained here.
|
|
14
17
|
const CATEGORIES = {
|
|
@@ -100,6 +103,44 @@ const CATEGORIES = {
|
|
|
100
103
|
const BIORXIV_CATEGORIES = new Set(CATEGORIES.biorxiv);
|
|
101
104
|
const MEDRXIV_CATEGORIES = new Set(CATEGORIES.medrxiv);
|
|
102
105
|
const ALL_CATEGORIES = new Set([...CATEGORIES.biorxiv, ...CATEGORIES.medrxiv]);
|
|
106
|
+
/**
|
|
107
|
+
* The one status this service classifies itself rather than treating as a bug.
|
|
108
|
+
* Passing it to `fetchWithTimeout` only lowers the log severity from `error` to
|
|
109
|
+
* `debug`; the thrown error and its classification are unchanged.
|
|
110
|
+
*/
|
|
111
|
+
const EXPECTED_STATUSES = [429];
|
|
112
|
+
/**
|
|
113
|
+
* Re-throws a failed api.biorxiv.org call, classifying HTTP 429 as its own
|
|
114
|
+
* retryable `rate_limited` condition. Everything else — 5xx, timeout, network
|
|
115
|
+
* error, the HTML-error guard below — re-throws untouched for the framework's
|
|
116
|
+
* auto-classifier.
|
|
117
|
+
*
|
|
118
|
+
* `fetchWithTimeout` attaches the upstream response body to `err.data`
|
|
119
|
+
* (`body`/`responseBody`), so the replacement payload is built from scratch
|
|
120
|
+
* rather than spread: only the parsed `Retry-After` crosses into it. Retry is
|
|
121
|
+
* not this function's concern — `withRetry` already honors `data.retryAfter`
|
|
122
|
+
* and fails fast when the requested wait exceeds its cap, so by the time a 429
|
|
123
|
+
* reaches here the waiting is over and only classification is left.
|
|
124
|
+
*/
|
|
125
|
+
function rethrowClassified(err) {
|
|
126
|
+
const data = err instanceof McpError
|
|
127
|
+
? err.data
|
|
128
|
+
: undefined;
|
|
129
|
+
if (data?.status !== 429)
|
|
130
|
+
throw err;
|
|
131
|
+
const retryAfter = parseRetryAfterSeconds(data.retryAfter);
|
|
132
|
+
const wait = describeWait(retryAfter);
|
|
133
|
+
throw rateLimited(retryAfter === undefined
|
|
134
|
+
? 'api.biorxiv.org is rate-limiting this host (HTTP 429).'
|
|
135
|
+
: `api.biorxiv.org is rate-limiting this host (HTTP 429) and asked for a ${retryAfter}-second wait before the next request.`, {
|
|
136
|
+
reason: 'rate_limited',
|
|
137
|
+
retryable: true,
|
|
138
|
+
...(retryAfter !== undefined && { retryAfter }),
|
|
139
|
+
recovery: {
|
|
140
|
+
hint: `Wait ${wait} before querying api.biorxiv.org again — every preprint metadata tool shares this origin, so they are all limited together.`,
|
|
141
|
+
},
|
|
142
|
+
}, { cause: err });
|
|
143
|
+
}
|
|
103
144
|
// ─── Normalization helpers ───────────────────────────────────────────────────
|
|
104
145
|
function normalizeRevision(raw) {
|
|
105
146
|
const rev = { doi: raw.doi };
|
|
@@ -175,35 +216,41 @@ export class BiorxivApiService {
|
|
|
175
216
|
/**
|
|
176
217
|
* Fetch all revisions for a DOI from a single server.
|
|
177
218
|
* Returns an empty collection if the DOI is not found on this server.
|
|
219
|
+
* Throws a retryable `rate_limited` error when the origin returns HTTP 429.
|
|
178
220
|
*/
|
|
179
221
|
async getDetails(doi, server, ctx) {
|
|
180
222
|
const encodedDoi = doi.split('/').map(encodeURIComponent).join('/');
|
|
181
223
|
const url = `${this.baseUrl}/details/${server}/${encodedDoi}/0/json`;
|
|
182
224
|
const rc = asRc(ctx);
|
|
183
|
-
|
|
184
|
-
|
|
225
|
+
try {
|
|
226
|
+
return await withRetry(async () => {
|
|
227
|
+
const response = await fetchWithTimeout(url, 15_000, rc, {
|
|
228
|
+
signal: ctx.signal,
|
|
229
|
+
headers: { 'User-Agent': this.userAgent },
|
|
230
|
+
expectedStatuses: EXPECTED_STATUSES,
|
|
231
|
+
});
|
|
232
|
+
const text = await response.text();
|
|
233
|
+
if (detectHtmlError(text)) {
|
|
234
|
+
throw serviceUnavailable('api.biorxiv.org returned HTML — likely rate-limited or down.', { url });
|
|
235
|
+
}
|
|
236
|
+
const data = JSON.parse(text);
|
|
237
|
+
return (data.collection ?? []).map(normalizeRevision);
|
|
238
|
+
}, {
|
|
239
|
+
operation: 'BiorxivApiService.getDetails',
|
|
240
|
+
context: rc,
|
|
241
|
+
baseDelayMs: 500,
|
|
185
242
|
signal: ctx.signal,
|
|
186
|
-
headers: { 'User-Agent': this.userAgent },
|
|
187
243
|
});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
const data = JSON.parse(text);
|
|
195
|
-
return (data.collection ?? []).map(normalizeRevision);
|
|
196
|
-
}, {
|
|
197
|
-
operation: 'BiorxivApiService.getDetails',
|
|
198
|
-
context: rc,
|
|
199
|
-
baseDelayMs: 500,
|
|
200
|
-
signal: ctx.signal,
|
|
201
|
-
});
|
|
244
|
+
}
|
|
245
|
+
catch (err) {
|
|
246
|
+
rethrowClassified(err);
|
|
247
|
+
}
|
|
202
248
|
}
|
|
203
249
|
/**
|
|
204
250
|
* Fetch preprints posted or revised within a date interval from a single server.
|
|
205
251
|
* `cursor` is an integer offset (0, 30, 60, …). Page size is always 30.
|
|
206
252
|
* Returns listing result with pagination state.
|
|
253
|
+
* Throws a retryable `rate_limited` error when the origin returns HTTP 429.
|
|
207
254
|
*/
|
|
208
255
|
async getListing(server, startDate, endDate, cursor, category, ctx) {
|
|
209
256
|
let url = `${this.baseUrl}/details/${server}/${startDate}/${endDate}/${cursor}/json`;
|
|
@@ -211,91 +258,100 @@ export class BiorxivApiService {
|
|
|
211
258
|
url += `?category=${encodeURIComponent(category)}`;
|
|
212
259
|
}
|
|
213
260
|
const rc = asRc(ctx);
|
|
214
|
-
|
|
215
|
-
|
|
261
|
+
try {
|
|
262
|
+
return await withRetry(async () => {
|
|
263
|
+
const response = await fetchWithTimeout(url, 20_000, rc, {
|
|
264
|
+
signal: ctx.signal,
|
|
265
|
+
headers: { 'User-Agent': this.userAgent },
|
|
266
|
+
expectedStatuses: EXPECTED_STATUSES,
|
|
267
|
+
});
|
|
268
|
+
const text = await response.text();
|
|
269
|
+
if (detectHtmlError(text)) {
|
|
270
|
+
throw serviceUnavailable('api.biorxiv.org returned HTML — likely rate-limited or down.', { url });
|
|
271
|
+
}
|
|
272
|
+
const data = JSON.parse(text);
|
|
273
|
+
const msg = data.messages?.[0];
|
|
274
|
+
const rawTotal = msg?.total;
|
|
275
|
+
const total = typeof rawTotal === 'number'
|
|
276
|
+
? rawTotal
|
|
277
|
+
: typeof rawTotal === 'string'
|
|
278
|
+
? parseInt(rawTotal, 10) || 0
|
|
279
|
+
: 0;
|
|
280
|
+
const preprints = (data.collection ?? []).map(normalizeRevision);
|
|
281
|
+
return {
|
|
282
|
+
preprints,
|
|
283
|
+
pagination: { cursor, total },
|
|
284
|
+
};
|
|
285
|
+
}, {
|
|
286
|
+
operation: 'BiorxivApiService.getListing',
|
|
287
|
+
context: rc,
|
|
288
|
+
baseDelayMs: 500,
|
|
216
289
|
signal: ctx.signal,
|
|
217
|
-
headers: { 'User-Agent': this.userAgent },
|
|
218
290
|
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
const data = JSON.parse(text);
|
|
226
|
-
const msg = data.messages?.[0];
|
|
227
|
-
const rawTotal = msg?.total;
|
|
228
|
-
const total = typeof rawTotal === 'number'
|
|
229
|
-
? rawTotal
|
|
230
|
-
: typeof rawTotal === 'string'
|
|
231
|
-
? parseInt(rawTotal, 10) || 0
|
|
232
|
-
: 0;
|
|
233
|
-
const preprints = (data.collection ?? []).map(normalizeRevision);
|
|
234
|
-
return {
|
|
235
|
-
preprints,
|
|
236
|
-
pagination: { cursor, total },
|
|
237
|
-
};
|
|
238
|
-
}, {
|
|
239
|
-
operation: 'BiorxivApiService.getListing',
|
|
240
|
-
context: rc,
|
|
241
|
-
baseDelayMs: 500,
|
|
242
|
-
signal: ctx.signal,
|
|
243
|
-
});
|
|
291
|
+
}
|
|
292
|
+
catch (err) {
|
|
293
|
+
rethrowClassified(err);
|
|
294
|
+
}
|
|
244
295
|
}
|
|
245
296
|
/**
|
|
246
297
|
* Resolve a preprint DOI to its published journal record via /pubs endpoint.
|
|
247
298
|
* Returns undefined when the preprint is not yet published.
|
|
299
|
+
* Throws a retryable `rate_limited` error when the origin returns HTTP 429.
|
|
248
300
|
*/
|
|
249
301
|
async getPublishedVersion(doi, server, ctx) {
|
|
250
302
|
const encodedDoi = doi.split('/').map(encodeURIComponent).join('/');
|
|
251
303
|
const url = `${this.baseUrl}/pubs/${server}/${encodedDoi}/json`;
|
|
252
304
|
const rc = asRc(ctx);
|
|
253
|
-
|
|
254
|
-
|
|
305
|
+
try {
|
|
306
|
+
return await withRetry(async () => {
|
|
307
|
+
const response = await fetchWithTimeout(url, 15_000, rc, {
|
|
308
|
+
signal: ctx.signal,
|
|
309
|
+
headers: { 'User-Agent': this.userAgent },
|
|
310
|
+
expectedStatuses: EXPECTED_STATUSES,
|
|
311
|
+
});
|
|
312
|
+
const text = await response.text();
|
|
313
|
+
if (detectHtmlError(text)) {
|
|
314
|
+
throw serviceUnavailable('api.biorxiv.org returned HTML — likely rate-limited or down.', { url });
|
|
315
|
+
}
|
|
316
|
+
const data = JSON.parse(text);
|
|
317
|
+
const record = data.collection?.[0];
|
|
318
|
+
if (!record?.preprint_doi)
|
|
319
|
+
return;
|
|
320
|
+
const pv = { preprintDoi: record.preprint_doi };
|
|
321
|
+
if (record.published_doi)
|
|
322
|
+
pv.publishedDoi = record.published_doi;
|
|
323
|
+
if (record.published_journal)
|
|
324
|
+
pv.publishedJournal = record.published_journal;
|
|
325
|
+
if (record.published_date)
|
|
326
|
+
pv.publishedDate = record.published_date;
|
|
327
|
+
const preprintTitle = normalizeUpstreamText(record.preprint_title);
|
|
328
|
+
if (preprintTitle)
|
|
329
|
+
pv.preprintTitle = preprintTitle;
|
|
330
|
+
if (record.preprint_authors)
|
|
331
|
+
pv.preprintAuthors = record.preprint_authors;
|
|
332
|
+
if (record.preprint_category)
|
|
333
|
+
pv.preprintCategory = record.preprint_category;
|
|
334
|
+
if (record.preprint_date)
|
|
335
|
+
pv.preprintDate = record.preprint_date;
|
|
336
|
+
const preprintAbstract = normalizeUpstreamText(record.preprint_abstract);
|
|
337
|
+
if (preprintAbstract)
|
|
338
|
+
pv.preprintAbstract = preprintAbstract;
|
|
339
|
+
if (record.preprint_author_corresponding)
|
|
340
|
+
pv.preprintAuthorCorresponding = record.preprint_author_corresponding;
|
|
341
|
+
if (record.preprint_author_corresponding_institution)
|
|
342
|
+
pv.preprintAuthorCorrespondingInstitution =
|
|
343
|
+
record.preprint_author_corresponding_institution;
|
|
344
|
+
return pv;
|
|
345
|
+
}, {
|
|
346
|
+
operation: 'BiorxivApiService.getPublishedVersion',
|
|
347
|
+
context: rc,
|
|
348
|
+
baseDelayMs: 500,
|
|
255
349
|
signal: ctx.signal,
|
|
256
|
-
headers: { 'User-Agent': this.userAgent },
|
|
257
350
|
});
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
const data = JSON.parse(text);
|
|
265
|
-
const record = data.collection?.[0];
|
|
266
|
-
if (!record?.preprint_doi)
|
|
267
|
-
return;
|
|
268
|
-
const pv = { preprintDoi: record.preprint_doi };
|
|
269
|
-
if (record.published_doi)
|
|
270
|
-
pv.publishedDoi = record.published_doi;
|
|
271
|
-
if (record.published_journal)
|
|
272
|
-
pv.publishedJournal = record.published_journal;
|
|
273
|
-
if (record.published_date)
|
|
274
|
-
pv.publishedDate = record.published_date;
|
|
275
|
-
const preprintTitle = normalizeUpstreamText(record.preprint_title);
|
|
276
|
-
if (preprintTitle)
|
|
277
|
-
pv.preprintTitle = preprintTitle;
|
|
278
|
-
if (record.preprint_authors)
|
|
279
|
-
pv.preprintAuthors = record.preprint_authors;
|
|
280
|
-
if (record.preprint_category)
|
|
281
|
-
pv.preprintCategory = record.preprint_category;
|
|
282
|
-
if (record.preprint_date)
|
|
283
|
-
pv.preprintDate = record.preprint_date;
|
|
284
|
-
const preprintAbstract = normalizeUpstreamText(record.preprint_abstract);
|
|
285
|
-
if (preprintAbstract)
|
|
286
|
-
pv.preprintAbstract = preprintAbstract;
|
|
287
|
-
if (record.preprint_author_corresponding)
|
|
288
|
-
pv.preprintAuthorCorresponding = record.preprint_author_corresponding;
|
|
289
|
-
if (record.preprint_author_corresponding_institution)
|
|
290
|
-
pv.preprintAuthorCorrespondingInstitution =
|
|
291
|
-
record.preprint_author_corresponding_institution;
|
|
292
|
-
return pv;
|
|
293
|
-
}, {
|
|
294
|
-
operation: 'BiorxivApiService.getPublishedVersion',
|
|
295
|
-
context: rc,
|
|
296
|
-
baseDelayMs: 500,
|
|
297
|
-
signal: ctx.signal,
|
|
298
|
-
});
|
|
351
|
+
}
|
|
352
|
+
catch (err) {
|
|
353
|
+
rethrowClassified(err);
|
|
354
|
+
}
|
|
299
355
|
}
|
|
300
356
|
}
|
|
301
357
|
// ─── Init / accessor ─────────────────────────────────────────────────────────
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"biorxiv-service.js","sourceRoot":"","sources":["../../../src/services/biorxiv/biorxiv-service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"biorxiv-service.js","sourceRoot":"","sources":["../../../src/services/biorxiv/biorxiv-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAE1F,OAAO,EAAE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,gBAAgB,GAAG,qBAAqB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;gBACzE,IAAI,gBAAgB;oBAAE,EAAE,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;gBAC7D,IAAI,MAAM,CAAC,6BAA6B;oBACtC,EAAE,CAAC,2BAA2B,GAAG,MAAM,CAAC,6BAA6B,CAAC;gBACxE,IAAI,MAAM,CAAC,yCAAyC;oBAClD,EAAE,CAAC,sCAAsC;wBACvC,MAAM,CAAC,yCAAyC,CAAC;gBACrD,OAAO,EAAE,CAAC;YACZ,CAAC,EACD;gBACE,SAAS,EAAE,uCAAuC;gBAClD,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,GAAG;gBAChB,MAAM,EAAE,GAAG,CAAC,MAAM;aACnB,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;CACF;AAED,gFAAgF;AAEhF,IAAI,QAAuC,CAAC;AAE5C,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,OAAuB;IAC9E,QAAQ,GAAG,IAAI,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,IAAI,CAAC,QAAQ;QACX,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;IACjG,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -5,9 +5,20 @@
|
|
|
5
5
|
*
|
|
6
6
|
* This is a DISTINCT fetch path from BiorxivApiService: it EXPECTS an HTML
|
|
7
7
|
* document (the rendered article page), so it never routes through the JSON
|
|
8
|
-
* API's "HTML response = upstream error" guard. Cloudflare challenge/block pages
|
|
9
|
-
* and empty extractions are surfaced as a typed
|
|
10
|
-
* crashing or feeding interstitial garbage to
|
|
8
|
+
* API's "HTML response = upstream error" guard. Cloudflare challenge/block pages,
|
|
9
|
+
* origin rate limiting (HTTP 429), and empty extractions are surfaced as a typed
|
|
10
|
+
* `unavailable` result rather than crashing or feeding interstitial garbage to
|
|
11
|
+
* the extractor.
|
|
12
|
+
*
|
|
13
|
+
* Extracted articles are cached in `ctx.state` under
|
|
14
|
+
* `fulltext/v1/{server}/{doi}/{version}` for {@link FULLTEXT_CACHE_TTL_SECONDS}
|
|
15
|
+
* seconds, so paging a long article with offset/limit costs one origin fetch and
|
|
16
|
+
* one extraction instead of one per chunk. `ctx.state` is tenant-scoped, which is
|
|
17
|
+
* the intended blast radius — no cross-tenant or process-wide sharing. Only
|
|
18
|
+
* `kind: 'article'` results are written: a blocked, rate-limited, or empty page
|
|
19
|
+
* must be able to recover on a later call. The cache is an optimization and never
|
|
20
|
+
* a dependency — a storage backend that refuses a read or a write degrades to an
|
|
21
|
+
* origin fetch instead of failing the caller.
|
|
11
22
|
* @module services/biorxiv-fulltext/biorxiv-fulltext-service
|
|
12
23
|
*/
|
|
13
24
|
import type { Context } from '@cyanheads/mcp-ts-core';
|
|
@@ -28,8 +39,15 @@ export type FullTextFetchResult = {
|
|
|
28
39
|
sourceUrl: string;
|
|
29
40
|
} | {
|
|
30
41
|
kind: 'unavailable';
|
|
31
|
-
reason: 'blocked' | 'empty';
|
|
42
|
+
reason: 'blocked' | 'empty' | 'rate_limited';
|
|
32
43
|
detail: string;
|
|
44
|
+
/**
|
|
45
|
+
* Wait in whole seconds parsed from the origin's `Retry-After`, on
|
|
46
|
+
* `rate_limited` results that carried a usable one. Seconds rather than the
|
|
47
|
+
* raw header because the header's two RFC 9110 forms are not interchangeable
|
|
48
|
+
* in prose — an HTTP-date read as seconds renders nonsense.
|
|
49
|
+
*/
|
|
50
|
+
retryAfter?: number;
|
|
33
51
|
sourceUrl: string;
|
|
34
52
|
};
|
|
35
53
|
export declare class BiorxivFullTextService {
|
|
@@ -41,9 +59,13 @@ export declare class BiorxivFullTextService {
|
|
|
41
59
|
*
|
|
42
60
|
* Resolves to `{ kind: 'article', markdown, ... }` on success, or
|
|
43
61
|
* `{ kind: 'unavailable', reason }` when the page is blocked (Cloudflare 403 /
|
|
44
|
-
* challenge), missing, or yields no extractable text
|
|
45
|
-
* Transient failures (5xx, timeout, network) bubble as
|
|
46
|
-
* after retry so the framework classifies them as retryable.
|
|
62
|
+
* challenge), rate-limited (429), missing, or yields no extractable text
|
|
63
|
+
* (PDF-only preprints). Transient failures (5xx, timeout, network) bubble as
|
|
64
|
+
* `ServiceUnavailable` after retry so the framework classifies them as retryable.
|
|
65
|
+
*
|
|
66
|
+
* A successful extraction is served from the tenant-scoped `ctx.state` cache on
|
|
67
|
+
* subsequent calls for the same server/DOI/version, so offset paging does not
|
|
68
|
+
* refetch the origin per chunk.
|
|
47
69
|
*/
|
|
48
70
|
fetchFullText(server: BiorxivServer, doi: string, version: string, ctx: Context): Promise<FullTextFetchResult>;
|
|
49
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"biorxiv-fulltext-service.d.ts","sourceRoot":"","sources":["../../../src/services/biorxiv-fulltext/biorxiv-fulltext-service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"biorxiv-fulltext-service.d.ts","sourceRoot":"","sources":["../../../src/services/biorxiv-fulltext/biorxiv-fulltext-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAsGjE;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,cAAc,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAKN,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgC;IAC5D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC,YAAY,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EASvD;IAED;;;;;;;;;;;;OAYG;IACG,aAAa,CACjB,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,mBAAmB,CAAC,CAuH9B;CACF;AAMD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAE3F;AAED,wBAAgB,yBAAyB,IAAI,sBAAsB,CAMlE"}
|
|
@@ -5,15 +5,26 @@
|
|
|
5
5
|
*
|
|
6
6
|
* This is a DISTINCT fetch path from BiorxivApiService: it EXPECTS an HTML
|
|
7
7
|
* document (the rendered article page), so it never routes through the JSON
|
|
8
|
-
* API's "HTML response = upstream error" guard. Cloudflare challenge/block pages
|
|
9
|
-
* and empty extractions are surfaced as a typed
|
|
10
|
-
* crashing or feeding interstitial garbage to
|
|
8
|
+
* API's "HTML response = upstream error" guard. Cloudflare challenge/block pages,
|
|
9
|
+
* origin rate limiting (HTTP 429), and empty extractions are surfaced as a typed
|
|
10
|
+
* `unavailable` result rather than crashing or feeding interstitial garbage to
|
|
11
|
+
* the extractor.
|
|
12
|
+
*
|
|
13
|
+
* Extracted articles are cached in `ctx.state` under
|
|
14
|
+
* `fulltext/v1/{server}/{doi}/{version}` for {@link FULLTEXT_CACHE_TTL_SECONDS}
|
|
15
|
+
* seconds, so paging a long article with offset/limit costs one origin fetch and
|
|
16
|
+
* one extraction instead of one per chunk. `ctx.state` is tenant-scoped, which is
|
|
17
|
+
* the intended blast radius — no cross-tenant or process-wide sharing. Only
|
|
18
|
+
* `kind: 'article'` results are written: a blocked, rate-limited, or empty page
|
|
19
|
+
* must be able to recover on a later call. The cache is an optimization and never
|
|
20
|
+
* a dependency — a storage backend that refuses a read or a write degrades to an
|
|
21
|
+
* origin fetch instead of failing the caller.
|
|
11
22
|
* @module services/biorxiv-fulltext/biorxiv-fulltext-service
|
|
12
23
|
*/
|
|
13
24
|
import { McpError } from '@cyanheads/mcp-ts-core/errors';
|
|
14
25
|
import { fetchWithTimeout, htmlExtractor, withRetry } from '@cyanheads/mcp-ts-core/utils';
|
|
15
26
|
import { getServerConfig } from '../../config/server-config.js';
|
|
16
|
-
import { asRc, SERVER_VERSION } from '../../services/shared.js';
|
|
27
|
+
import { asRc, parseRetryAfterSeconds, SERVER_VERSION } from '../../services/shared.js';
|
|
17
28
|
/**
|
|
18
29
|
* bioRxiv/medRxiv render their article pages on the Highwire platform, whose
|
|
19
30
|
* main full-text container is `<div class="article fulltext-view">`. Defuddle's
|
|
@@ -31,6 +42,58 @@ const FULLTEXT_CONTENT_SELECTOR = '.fulltext-view';
|
|
|
31
42
|
* is what medRxiv's Cloudflare edge returns for programmatic access.
|
|
32
43
|
*/
|
|
33
44
|
const DETERMINISTIC_UNAVAILABLE_STATUSES = new Set([401, 403, 404, 410, 451]);
|
|
45
|
+
/**
|
|
46
|
+
* Statuses this service classifies itself rather than treating as a bug — the
|
|
47
|
+
* deterministic set plus 429, which becomes a `rate_limited` result. Passing them
|
|
48
|
+
* to `fetchWithTimeout` only lowers the log severity from `error` to `debug`; the
|
|
49
|
+
* thrown error and its classification are unchanged.
|
|
50
|
+
*/
|
|
51
|
+
const EXPECTED_STATUSES = [...DETERMINISTIC_UNAVAILABLE_STATUSES, 429];
|
|
52
|
+
/**
|
|
53
|
+
* Lifetime of a cached extraction. A published version's rendered page is
|
|
54
|
+
* effectively immutable (a revision gets a new version, hence a new cache key),
|
|
55
|
+
* so this only bounds how long a re-render or a corrected page goes unseen. An
|
|
56
|
+
* hour comfortably covers paging through even the longest article.
|
|
57
|
+
*/
|
|
58
|
+
const FULLTEXT_CACHE_TTL_SECONDS = 3_600;
|
|
59
|
+
/**
|
|
60
|
+
* Cache key: `fulltext/v1/{server}/{doi}/{version}`. Slash-delimited because the
|
|
61
|
+
* storage layer validates keys against `[a-zA-Z0-9_.\-/]` — a colon separator is
|
|
62
|
+
* rejected outright, and a DOI's own `/` and `.` are already inside the allowed
|
|
63
|
+
* set. The `v1` segment is the cached-value schema generation — bump it when
|
|
64
|
+
* {@link CachedArticle} changes so entries written by an older build are never
|
|
65
|
+
* read back under the new shape.
|
|
66
|
+
*/
|
|
67
|
+
const cacheKeyFor = (server, doi, version) => `fulltext/v1/${server}/${doi}/${version}`;
|
|
68
|
+
/**
|
|
69
|
+
* Reads a cached extraction, treating any storage failure as a miss. A key the
|
|
70
|
+
* backend rejects, an unreachable provider, or an in-memory store at capacity
|
|
71
|
+
* must cost an origin fetch, not the caller's request.
|
|
72
|
+
*/
|
|
73
|
+
async function readCachedArticle(ctx, key) {
|
|
74
|
+
try {
|
|
75
|
+
return (await ctx.state.get(key)) ?? undefined;
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
ctx.log.warning('Full-text cache read failed — falling through to the origin', {
|
|
79
|
+
key,
|
|
80
|
+
error: err instanceof Error ? err.message : String(err),
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Writes an extraction to the cache; a storage failure only costs the next page a refetch. */
|
|
86
|
+
async function writeCachedArticle(ctx, key, article) {
|
|
87
|
+
try {
|
|
88
|
+
await ctx.state.set(key, article, { ttl: FULLTEXT_CACHE_TTL_SECONDS });
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
ctx.log.warning('Full-text cache write failed — the next page will refetch the origin', {
|
|
92
|
+
key,
|
|
93
|
+
error: err instanceof Error ? err.message : String(err),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
34
97
|
/**
|
|
35
98
|
* Markers unique to Cloudflare's interstitial / block pages. Deliberately narrow:
|
|
36
99
|
* a genuine bioRxiv article page references `cloudflare-static/email-decode.min.js`
|
|
@@ -67,20 +130,36 @@ export class BiorxivFullTextService {
|
|
|
67
130
|
*
|
|
68
131
|
* Resolves to `{ kind: 'article', markdown, ... }` on success, or
|
|
69
132
|
* `{ kind: 'unavailable', reason }` when the page is blocked (Cloudflare 403 /
|
|
70
|
-
* challenge), missing, or yields no extractable text
|
|
71
|
-
* Transient failures (5xx, timeout, network) bubble as
|
|
72
|
-
* after retry so the framework classifies them as retryable.
|
|
133
|
+
* challenge), rate-limited (429), missing, or yields no extractable text
|
|
134
|
+
* (PDF-only preprints). Transient failures (5xx, timeout, network) bubble as
|
|
135
|
+
* `ServiceUnavailable` after retry so the framework classifies them as retryable.
|
|
136
|
+
*
|
|
137
|
+
* A successful extraction is served from the tenant-scoped `ctx.state` cache on
|
|
138
|
+
* subsequent calls for the same server/DOI/version, so offset paging does not
|
|
139
|
+
* refetch the origin per chunk.
|
|
73
140
|
*/
|
|
74
141
|
async fetchFullText(server, doi, version, ctx) {
|
|
75
142
|
const encodedDoi = doi.split('/').map(encodeURIComponent).join('/');
|
|
76
143
|
const sourceUrl = `${this.webBaseUrls[server]}/content/${encodedDoi}v${version}.full`;
|
|
77
144
|
const rc = asRc(ctx);
|
|
145
|
+
// ctx.state is tenant-scoped and throws without a tenant (HTTP + JWT whose
|
|
146
|
+
// token carries no `tid` claim), so a tenant-less caller runs uncached rather
|
|
147
|
+
// than losing full-text retrieval entirely.
|
|
148
|
+
const cacheKey = ctx.tenantId === undefined ? undefined : cacheKeyFor(server, doi, version);
|
|
149
|
+
if (cacheKey) {
|
|
150
|
+
const cached = await readCachedArticle(ctx, cacheKey);
|
|
151
|
+
if (cached) {
|
|
152
|
+
ctx.log.debug('Serving full text from cache', { cacheKey, sourceUrl });
|
|
153
|
+
return { kind: 'article', ...cached };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
78
156
|
let html;
|
|
79
157
|
try {
|
|
80
158
|
html = await withRetry(async () => {
|
|
81
159
|
const response = await fetchWithTimeout(sourceUrl, 30_000, rc, {
|
|
82
160
|
signal: ctx.signal,
|
|
83
161
|
headers: { 'User-Agent': this.userAgent, Accept: 'text/html' },
|
|
162
|
+
expectedStatuses: EXPECTED_STATUSES,
|
|
84
163
|
});
|
|
85
164
|
return await response.text();
|
|
86
165
|
}, {
|
|
@@ -91,13 +170,34 @@ export class BiorxivFullTextService {
|
|
|
91
170
|
});
|
|
92
171
|
}
|
|
93
172
|
catch (err) {
|
|
94
|
-
// fetchWithTimeout throws on non-2xx with data.
|
|
95
|
-
// access failures (403 block, 404 missing)
|
|
96
|
-
// transient codes (5xx / timeout / network)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
? err.data
|
|
173
|
+
// fetchWithTimeout throws on non-2xx with data.status set. Deterministic
|
|
174
|
+
// access failures (403 block, 404 missing) and origin rate limiting (429)
|
|
175
|
+
// become an `unavailable` result; transient codes (5xx / timeout / network)
|
|
176
|
+
// bubble unchanged as ServiceUnavailable.
|
|
177
|
+
const errData = err instanceof McpError
|
|
178
|
+
? err.data
|
|
100
179
|
: undefined;
|
|
180
|
+
const status = typeof errData?.status === 'number' ? errData.status : undefined;
|
|
181
|
+
if (status === 429) {
|
|
182
|
+
// Only the parsed Retry-After crosses into the result — err.data also
|
|
183
|
+
// carries the origin's block-page HTML (body/responseBody), which must
|
|
184
|
+
// never reach the client payload.
|
|
185
|
+
const retryAfter = parseRetryAfterSeconds(errData?.retryAfter);
|
|
186
|
+
ctx.log.info('Full-text origin rate-limited the request', {
|
|
187
|
+
sourceUrl,
|
|
188
|
+
status,
|
|
189
|
+
...(retryAfter !== undefined && { retryAfter }),
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
kind: 'unavailable',
|
|
193
|
+
reason: 'rate_limited',
|
|
194
|
+
detail: retryAfter === undefined
|
|
195
|
+
? 'The full-text origin is rate-limiting this host (HTTP 429).'
|
|
196
|
+
: `The full-text origin is rate-limiting this host (HTTP 429) and asked for a ${retryAfter}-second wait before the next request.`,
|
|
197
|
+
...(retryAfter !== undefined && { retryAfter }),
|
|
198
|
+
sourceUrl,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
101
201
|
if (status !== undefined && DETERMINISTIC_UNAVAILABLE_STATUSES.has(status)) {
|
|
102
202
|
ctx.log.info('Full-text HTML page unavailable', { sourceUrl, status });
|
|
103
203
|
return {
|
|
@@ -134,13 +234,17 @@ export class BiorxivFullTextService {
|
|
|
134
234
|
sourceUrl,
|
|
135
235
|
};
|
|
136
236
|
}
|
|
137
|
-
|
|
138
|
-
kind: 'article',
|
|
237
|
+
const article = {
|
|
139
238
|
markdown,
|
|
140
239
|
...(extracted.title && { title: extracted.title }),
|
|
141
240
|
...(typeof extracted.wordCount === 'number' && { wordCount: extracted.wordCount }),
|
|
142
241
|
sourceUrl,
|
|
143
242
|
};
|
|
243
|
+
// Success path only — an unavailable result must recover on a later call.
|
|
244
|
+
if (cacheKey) {
|
|
245
|
+
await writeCachedArticle(ctx, cacheKey, article);
|
|
246
|
+
}
|
|
247
|
+
return { kind: 'article', ...article };
|
|
144
248
|
}
|
|
145
249
|
}
|
|
146
250
|
// ─── Init / accessor ─────────────────────────────────────────────────────────
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"biorxiv-fulltext-service.js","sourceRoot":"","sources":["../../../src/services/biorxiv-fulltext/biorxiv-fulltext-service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"biorxiv-fulltext-service.js","sourceRoot":"","sources":["../../../src/services/biorxiv-fulltext/biorx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