@cyanheads/biorxiv-mcp-server 0.2.7 → 0.2.8
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 +7 -6
- package/CLAUDE.md +7 -6
- package/README.md +11 -7
- package/changelog/0.2.x/0.2.7.md +3 -2
- package/changelog/0.2.x/0.2.8.md +26 -0
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.d.ts +18 -5
- 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 +87 -33
- 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 +4 -2
- 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 +19 -12
- 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 +19 -9
- 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 +125 -40
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-list-categories.tool.js +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-list-categories.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts +5 -2
- 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 +74 -47
- 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 -1
- 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 +31 -6
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/index.d.ts +30 -11
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
- package/dist/services/biorxiv/biorxiv-service.d.ts +27 -4
- package/dist/services/biorxiv/biorxiv-service.d.ts.map +1 -1
- package/dist/services/biorxiv/biorxiv-service.js +104 -46
- package/dist/services/biorxiv/biorxiv-service.js.map +1 -1
- package/dist/services/biorxiv/types.d.ts +5 -0
- package/dist/services/biorxiv/types.d.ts.map +1 -1
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.d.ts +5 -2
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.d.ts.map +1 -1
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.js +5 -6
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.js.map +1 -1
- package/dist/services/europe-pmc/europe-pmc-service.d.ts +7 -3
- package/dist/services/europe-pmc/europe-pmc-service.d.ts.map +1 -1
- package/dist/services/europe-pmc/europe-pmc-service.js +54 -12
- package/dist/services/europe-pmc/europe-pmc-service.js.map +1 -1
- package/dist/services/shared.d.ts +23 -1
- package/dist/services/shared.d.ts.map +1 -1
- package/dist/services/shared.js +45 -1
- package/dist/services/shared.js.map +1 -1
- package/package.json +4 -4
- package/server.json +3 -3
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* for preprint keyword search. Returns ranked DOI lists used by
|
|
4
4
|
* biorxiv_search_preprints for bioRxiv/medRxiv enrichment. All requests
|
|
5
5
|
* include a polite User-Agent and are retried with exponential backoff.
|
|
6
|
-
* Detects HTML error pages,
|
|
7
|
-
*
|
|
8
|
-
* wait — never the
|
|
6
|
+
* Detects HTML error pages, retries an HTTP 200 body that carries no result
|
|
7
|
+
* list, and classifies an origin rate limit (HTTP 429) as its own retryable
|
|
8
|
+
* `rate_limited` condition carrying the parsed `Retry-After` wait — never the
|
|
9
|
+
* upstream response body.
|
|
9
10
|
* @module services/europe-pmc/europe-pmc-service
|
|
10
11
|
*/
|
|
11
|
-
import { McpError, rateLimited, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
|
|
12
|
+
import { McpError, rateLimited, serviceUnavailable, validationError, } from '@cyanheads/mcp-ts-core/errors';
|
|
12
13
|
import { fetchWithTimeout, withRetry } from '@cyanheads/mcp-ts-core/utils';
|
|
13
14
|
import { getServerConfig } from '../../config/server-config.js';
|
|
14
15
|
import { describeWait, detectHtmlError, normalizeUpstreamText, parseRetryAfterSeconds, SERVER_VERSION, } from '../shared.js';
|
|
@@ -19,10 +20,29 @@ import { describeWait, detectHtmlError, normalizeUpstreamText, parseRetryAfterSe
|
|
|
19
20
|
*/
|
|
20
21
|
const EXPECTED_STATUSES = [429];
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* `data.reason` on the error thrown for an HTTP 200 body with no `resultList`.
|
|
24
|
+
* EuropePMC answers some requests with only `{"version":"6.9"}` — intermittently
|
|
25
|
+
* for a valid first page or cursor page, and on every attempt for a malformed
|
|
26
|
+
* `cursorMark`. Read as data, the body becomes a zero-result page, so it is
|
|
27
|
+
* thrown as a transient `ServiceUnavailable` inside `withRetry` instead.
|
|
28
|
+
*/
|
|
29
|
+
const EMPTY_BODY_REASON = 'empty_response_body';
|
|
30
|
+
/**
|
|
31
|
+
* Re-throws a failed EuropePMC call with the two conditions this service
|
|
32
|
+
* classifies itself:
|
|
33
|
+
*
|
|
34
|
+
* - an empty body that outlasted every retry — a caller error when a cursor
|
|
35
|
+
* page was requested (`invalid_cursor_mark`), an upstream failure on a first
|
|
36
|
+
* page, which has no caller input to blame;
|
|
37
|
+
* - HTTP 429, as its own retryable `rate_limited` condition.
|
|
38
|
+
*
|
|
39
|
+
* Everything else — 5xx, timeout, network error, the HTML-error guard below —
|
|
40
|
+
* re-throws untouched for the framework's auto-classifier.
|
|
41
|
+
*
|
|
42
|
+
* The empty-body errors are built fresh rather than re-thrown: `withRetry`
|
|
43
|
+
* suffixes an exhausted error's message with `(failed after N attempts)`, and
|
|
44
|
+
* that wording would otherwise reach the caller inside the tool's message. The
|
|
45
|
+
* attempt count moves to `data.retryAttempts`.
|
|
26
46
|
*
|
|
27
47
|
* `fetchWithTimeout` attaches the upstream response body to `err.data`
|
|
28
48
|
* (`body`/`responseBody`), so the replacement payload is built from scratch
|
|
@@ -31,10 +51,20 @@ const EXPECTED_STATUSES = [429];
|
|
|
31
51
|
* and fails fast when the requested wait exceeds its cap, so by the time a 429
|
|
32
52
|
* reaches here the waiting is over and only classification is left.
|
|
33
53
|
*/
|
|
34
|
-
function rethrowClassified(err) {
|
|
54
|
+
function rethrowClassified(err, cursorMark) {
|
|
35
55
|
const data = err instanceof McpError
|
|
36
56
|
? err.data
|
|
37
57
|
: undefined;
|
|
58
|
+
if (data?.reason === EMPTY_BODY_REASON) {
|
|
59
|
+
// Always set: the empty body is transient, so it only escapes `withRetry`
|
|
60
|
+
// exhausted, and exhaustion is what attaches the count.
|
|
61
|
+
const retryAttempts = data.retryAttempts;
|
|
62
|
+
const tries = `${retryAttempts} consecutive attempts`;
|
|
63
|
+
if (cursorMark !== '*') {
|
|
64
|
+
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 });
|
|
65
|
+
}
|
|
66
|
+
throw serviceUnavailable(`EuropePMC answered ${tries} with HTTP 200 and no result list.`, { reason: EMPTY_BODY_REASON, retryAttempts }, { cause: err });
|
|
67
|
+
}
|
|
38
68
|
if (data?.status !== 429)
|
|
39
69
|
throw err;
|
|
40
70
|
const retryAfter = parseRetryAfterSeconds(data.retryAfter);
|
|
@@ -66,6 +96,9 @@ export class EuropePmcService {
|
|
|
66
96
|
* enrichment. Requests the minimal field set (doi, title, authorString,
|
|
67
97
|
* firstPublicationDate, abstractText).
|
|
68
98
|
* Throws a retryable `rate_limited` error when the origin returns HTTP 429.
|
|
99
|
+
* A body with no result list is retried; if every attempt returns one, throws
|
|
100
|
+
* `ValidationError` (`invalid_cursor_mark`) when a cursor page other than `*`
|
|
101
|
+
* was requested, and `ServiceUnavailable` (`empty_response_body`) otherwise.
|
|
69
102
|
*/
|
|
70
103
|
async search(options, ctx) {
|
|
71
104
|
const limit = Math.min(options.limit ?? 25, 100);
|
|
@@ -99,11 +132,14 @@ export class EuropePmcService {
|
|
|
99
132
|
}
|
|
100
133
|
const filterParam = 'source:PPR';
|
|
101
134
|
const fields = 'doi,title,authorString,firstPublicationDate,abstractText';
|
|
135
|
+
// A blank cursor (a form client's empty field) is a first page, as it is
|
|
136
|
+
// upstream. Tokens are base64, so surrounding whitespace is never part of one.
|
|
137
|
+
const cursorMark = options.cursorMark?.trim() || '*';
|
|
102
138
|
const params = new URLSearchParams({
|
|
103
139
|
query: q,
|
|
104
140
|
resulttype: 'lite',
|
|
105
141
|
synonym: 'FALSE',
|
|
106
|
-
cursorMark
|
|
142
|
+
cursorMark,
|
|
107
143
|
pageSize: String(limit),
|
|
108
144
|
format: 'json',
|
|
109
145
|
fields,
|
|
@@ -121,7 +157,13 @@ export class EuropePmcService {
|
|
|
121
157
|
throw serviceUnavailable('EuropePMC returned HTML instead of JSON — service may be degraded.', { url });
|
|
122
158
|
}
|
|
123
159
|
const data = JSON.parse(text);
|
|
124
|
-
|
|
160
|
+
// A genuine zero-hit answer still carries an empty `resultList`.
|
|
161
|
+
if (!data.resultList) {
|
|
162
|
+
throw serviceUnavailable('EuropePMC answered HTTP 200 with no result list.', {
|
|
163
|
+
reason: EMPTY_BODY_REASON,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
const results = (data.resultList.result ?? [])
|
|
125
167
|
.filter((raw) => raw.doi != null)
|
|
126
168
|
.map((raw) => {
|
|
127
169
|
const title = normalizeUpstreamText(raw.title);
|
|
@@ -149,7 +191,7 @@ export class EuropePmcService {
|
|
|
149
191
|
});
|
|
150
192
|
}
|
|
151
193
|
catch (err) {
|
|
152
|
-
rethrowClassified(err);
|
|
194
|
+
rethrowClassified(err, cursorMark);
|
|
153
195
|
}
|
|
154
196
|
}
|
|
155
197
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"europe-pmc-service.js","sourceRoot":"","sources":["../../../src/services/europe-pmc/europe-pmc-service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"europe-pmc-service.js","sourceRoot":"","sources":["../../../src/services/europe-pmc/europe-pmc-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EACL,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,GAChB,MAAM,+BAA+B,CAAC;AAEvC,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,EACtB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAO9B;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,CAAC,GAAG,CAAC,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAS,iBAAiB,CAAC,GAAY,EAAE,UAAkB;IACzD,MAAM,IAAI,GACR,GAAG,YAAY,QAAQ;QACrB,CAAC,CAAE,GAAG,CAAC,IAES;QAChB,CAAC,CAAC,SAAS,CAAC;IAEhB,IAAI,IAAI,EAAE,MAAM,KAAK,iBAAiB,EAAE,CAAC;QACvC,0EAA0E;QAC1E,wDAAwD;QACxD,MAAM,aAAa,GAAG,IAAI,CAAC,aAAuB,CAAC;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G,EAAE,CAAC;YACb,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACrC,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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Shared utilities for biorxiv-mcp-server service layer. Provides
|
|
3
|
-
* HTML error detection, calendar-date and
|
|
3
|
+
* HTML error detection, DOI input normalization, calendar-date and
|
|
4
|
+
* upstream-text normalization,
|
|
4
5
|
* `Retry-After` parsing and rate-limit rejection lookup shared by every fetch
|
|
5
6
|
* path, and the server version string used in User-Agent headers across all
|
|
6
7
|
* services.
|
|
@@ -20,6 +21,27 @@ 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;
|
|
23
45
|
/**
|
|
24
46
|
* Strip Highwire/JATS export artifacts that bioRxiv/medRxiv and EuropePMC leak
|
|
25
47
|
* into raw title and abstract text, so no upstream markup reaches
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;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,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,CAWrE;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"}
|
package/dist/services/shared.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Shared utilities for biorxiv-mcp-server service layer. Provides
|
|
3
|
-
* HTML error detection, calendar-date and
|
|
3
|
+
* HTML error detection, DOI input normalization, calendar-date and
|
|
4
|
+
* upstream-text normalization,
|
|
4
5
|
* `Retry-After` parsing and rate-limit rejection lookup shared by every fetch
|
|
5
6
|
* path, and the server version string used in User-Agent headers across all
|
|
6
7
|
* services.
|
|
@@ -33,6 +34,49 @@ export function isValidCalendarDate(dateStr) {
|
|
|
33
34
|
const date = new Date(Date.UTC(year, month - 1, day));
|
|
34
35
|
return (date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day);
|
|
35
36
|
}
|
|
37
|
+
/** A doi.org resolver or bioRxiv/medRxiv article URL in front of the DOI, scheme optional. */
|
|
38
|
+
const DOI_URL_PREFIX = /^(?:https?:\/\/)?(?:(?:dx\.)?doi\.org\/|(?:www\.)?(?:bio|med)rxiv\.org\/content\/)/i;
|
|
39
|
+
/** The `doi:` scheme label, as in citations. */
|
|
40
|
+
const DOI_SCHEME_PREFIX = /^doi:\s*/i;
|
|
41
|
+
/**
|
|
42
|
+
* An article-page suffix after the DOI's final digit: an optional `vN` revision,
|
|
43
|
+
* then any article-tab suffix (`.full`, `.full.pdf`, `.full.pdf+html`,
|
|
44
|
+
* `.full-text`, `.article-metrics`, `.supplementary-material`, …), then an
|
|
45
|
+
* optional trailing slash, matched case-insensitively. Anchored after a digit,
|
|
46
|
+
* and each tab suffix starts with a letter, so neither a `v` inside a
|
|
47
|
+
* non-numeric identifier nor a `.`-separated digit group is ever stripped —
|
|
48
|
+
* bioRxiv and medRxiv identifiers are digits and dots, ending in a digit.
|
|
49
|
+
*/
|
|
50
|
+
const ARTICLE_SUFFIX = /(?<=\d)(?:v(\d+))?(?:\.[a-z][\w+-]*)*\/?$/i;
|
|
51
|
+
/** `10.` + a registrant code of four or more digits + `/` + a non-empty suffix. */
|
|
52
|
+
const BARE_DOI = /^10\.\d{4,}\/\S+$/;
|
|
53
|
+
/**
|
|
54
|
+
* Reduce a pasted preprint reference to its bare DOI. Accepts the bare DOI
|
|
55
|
+
* itself, a `https://doi.org/` or `http(s)://dx.doi.org/` resolver URL, a
|
|
56
|
+
* `doi:` label, or a `{www.}{biorxiv,medrxiv}.org/content/` article URL — any
|
|
57
|
+
* of them with a trailing `vN` revision and an article-tab suffix (`.full`,
|
|
58
|
+
* `.full.pdf`, `.article-metrics`, …).
|
|
59
|
+
* A URL's query string and fragment are dropped. Returns the revision the
|
|
60
|
+
* suffix named alongside the DOI, and `undefined` when what is left is not a
|
|
61
|
+
* DOI — callers raise their `invalid_doi_format` on that.
|
|
62
|
+
*
|
|
63
|
+
* A bare DOI passes through unchanged: stripping only ever removes text around
|
|
64
|
+
* a bioRxiv/medRxiv identifier, never characters of one.
|
|
65
|
+
*/
|
|
66
|
+
export function normalizeDoi(input) {
|
|
67
|
+
let text = input.trim();
|
|
68
|
+
const url = DOI_URL_PREFIX.exec(text);
|
|
69
|
+
text = url
|
|
70
|
+
? text.slice(url[0].length).replace(/[?#].*$/, '')
|
|
71
|
+
: text.replace(DOI_SCHEME_PREFIX, '');
|
|
72
|
+
const suffix = ARTICLE_SUFFIX.exec(text);
|
|
73
|
+
const version = suffix?.[1];
|
|
74
|
+
if (suffix)
|
|
75
|
+
text = text.slice(0, suffix.index);
|
|
76
|
+
if (!BARE_DOI.test(text))
|
|
77
|
+
return;
|
|
78
|
+
return version === undefined ? { doi: text } : { doi: text, version: String(Number(version)) };
|
|
79
|
+
}
|
|
36
80
|
/**
|
|
37
81
|
* Strip Highwire/JATS export artifacts that bioRxiv/medRxiv and EuropePMC leak
|
|
38
82
|
* into raw title and abstract text, so no upstream markup reaches
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,WAAW,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAEnE,yEAAyE;AACzE,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,mCAAmC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,MAAM,KAAK,GAAG,2BAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxD,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,GAAG,CA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
3
|
+
"version": "0.2.8",
|
|
4
4
|
"mcpName": "io.github.cyanheads/biorxiv-mcp-server",
|
|
5
5
|
"description": "Search and retrieve bioRxiv and medRxiv preprints — by DOI, date interval, or keyword — via MCP. STDIO or Streamable HTTP.",
|
|
6
6
|
"type": "module",
|
|
@@ -94,8 +94,8 @@
|
|
|
94
94
|
"postcss": "^8.5.23"
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@cyanheads/mcp-ts-core": "^0.13.
|
|
98
|
-
"defuddle": "^0.19.
|
|
97
|
+
"@cyanheads/mcp-ts-core": "^0.13.6",
|
|
98
|
+
"defuddle": "^0.19.4",
|
|
99
99
|
"linkedom": "^0.18.13",
|
|
100
100
|
"pino-pretty": "^13.1.3",
|
|
101
101
|
"zod": "^4.6.5"
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@biomejs/biome": "2.5.14",
|
|
105
105
|
"@socketsecurity/bun-security-scanner": "^1.1.2",
|
|
106
|
-
"@types/node": "26.6.
|
|
106
|
+
"@types/node": "26.6.2",
|
|
107
107
|
"depcheck": "^1.4.7",
|
|
108
108
|
"ignore": "^7.0.9",
|
|
109
109
|
"tsc-alias": "^1.9.5",
|
package/server.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"url": "https://github.com/cyanheads/biorxiv-mcp-server",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.8",
|
|
10
10
|
"remotes": [
|
|
11
11
|
{
|
|
12
12
|
"type": "streamable-http",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
20
20
|
"identifier": "@cyanheads/biorxiv-mcp-server",
|
|
21
21
|
"runtimeHint": "bun",
|
|
22
|
-
"version": "0.2.
|
|
22
|
+
"version": "0.2.8",
|
|
23
23
|
"packageArguments": [
|
|
24
24
|
{
|
|
25
25
|
"type": "positional",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
69
69
|
"identifier": "@cyanheads/biorxiv-mcp-server",
|
|
70
70
|
"runtimeHint": "bun",
|
|
71
|
-
"version": "0.2.
|
|
71
|
+
"version": "0.2.8",
|
|
72
72
|
"packageArguments": [
|
|
73
73
|
{
|
|
74
74
|
"type": "positional",
|