@cyanheads/biorxiv-mcp-server 0.2.8 → 0.3.1
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 +42 -31
- package/CLAUDE.md +42 -31
- package/Dockerfile +85 -40
- package/README.md +21 -35
- package/changelog/0.3.x/0.3.0.md +22 -0
- package/changelog/0.3.x/0.3.1.md +33 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- 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 +7 -11
- 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 +1 -1
- 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 +21 -18
- 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.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js +14 -13
- 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 +17 -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 +109 -45
- 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 +9 -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 +73 -27
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/index.d.ts +11 -3
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
- package/dist/services/biorxiv/biorxiv-service.d.ts +11 -6
- package/dist/services/biorxiv/biorxiv-service.d.ts.map +1 -1
- package/dist/services/biorxiv/biorxiv-service.js +37 -19
- package/dist/services/biorxiv/biorxiv-service.js.map +1 -1
- package/dist/services/biorxiv/types.d.ts +22 -2
- package/dist/services/biorxiv/types.d.ts.map +1 -1
- package/dist/services/europe-pmc/europe-pmc-service.d.ts +16 -3
- package/dist/services/europe-pmc/europe-pmc-service.d.ts.map +1 -1
- package/dist/services/europe-pmc/europe-pmc-service.js +64 -7
- package/dist/services/europe-pmc/europe-pmc-service.js.map +1 -1
- package/dist/services/europe-pmc/types.d.ts +9 -3
- package/dist/services/europe-pmc/types.d.ts.map +1 -1
- package/dist/services/shared.d.ts +62 -11
- package/dist/services/shared.d.ts.map +1 -1
- package/dist/services/shared.js +244 -17
- package/dist/services/shared.js.map +1 -1
- package/dist/services/upstream-text-tables.d.ts +44 -0
- package/dist/services/upstream-text-tables.d.ts.map +1 -0
- package/dist/services/upstream-text-tables.js +296 -0
- package/dist/services/upstream-text-tables.js.map +1 -0
- package/package.json +10 -9
- package/server.json +10 -24
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
export type BiorxivServer = 'biorxiv' | 'medrxiv';
|
|
10
10
|
/** Broader "both" is accepted at tool level and fanned out by the service. */
|
|
11
11
|
export type ServerParam = BiorxivServer | 'both';
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* A funder entry in the bioRxiv API funder array. `name` and `id` are
|
|
14
|
+
* misattributed upstream — they name an unrelated organization — so only
|
|
15
|
+
* `award` is read.
|
|
16
|
+
*/
|
|
13
17
|
export interface RawFunderEntry {
|
|
14
18
|
award?: string;
|
|
15
19
|
id?: string;
|
|
@@ -50,6 +54,8 @@ export interface RawDetailsResponse {
|
|
|
50
54
|
cursor?: number | string;
|
|
51
55
|
message?: string;
|
|
52
56
|
category?: string;
|
|
57
|
+
/** Listing only: the applied funder filter (`"<name> : https://ror.org/<id>"`), or `"all"` */
|
|
58
|
+
funder?: string;
|
|
53
59
|
count_new_papers?: number | string;
|
|
54
60
|
}>;
|
|
55
61
|
}
|
|
@@ -82,10 +88,11 @@ export interface PreprintRevision {
|
|
|
82
88
|
authorCorresponding?: string;
|
|
83
89
|
authorCorrespondingInstitution?: string;
|
|
84
90
|
authors?: string;
|
|
91
|
+
/** Upstream `award` values, verbatim and deduplicated; absent when there are none */
|
|
92
|
+
awards?: string[];
|
|
85
93
|
category?: string;
|
|
86
94
|
date?: string;
|
|
87
95
|
doi: string;
|
|
88
|
-
funder?: string;
|
|
89
96
|
jatsxmlUrl?: string;
|
|
90
97
|
license?: string;
|
|
91
98
|
/** Non-null when the preprint has been published; "NA" is normalized to undefined */
|
|
@@ -100,6 +107,13 @@ export interface ServerPaginationState {
|
|
|
100
107
|
cursor: number;
|
|
101
108
|
total: number;
|
|
102
109
|
}
|
|
110
|
+
/** Server-side filters for the listing endpoint; both are sent when both are set */
|
|
111
|
+
export interface ListingFilters {
|
|
112
|
+
/** Subject category, in any spelling `isValidCategory` accepts */
|
|
113
|
+
category?: string | undefined;
|
|
114
|
+
/** Bare 9-character ROR ID, already normalized — bioRxiv only */
|
|
115
|
+
funder?: string | undefined;
|
|
116
|
+
}
|
|
103
117
|
/** Per-server result from the listing endpoint */
|
|
104
118
|
export interface ListingResult {
|
|
105
119
|
/**
|
|
@@ -107,6 +121,12 @@ export interface ListingResult {
|
|
|
107
121
|
* not apply the filter, so `preprints` is the unfiltered listing. Absent otherwise.
|
|
108
122
|
*/
|
|
109
123
|
categoryIgnored?: true;
|
|
124
|
+
/**
|
|
125
|
+
* True when a funder was sent and the API answered `status: "funder value not
|
|
126
|
+
* found"` with no collection — it holds no funder record for that ROR ID, so
|
|
127
|
+
* the empty `preprints` is not a result. Absent otherwise.
|
|
128
|
+
*/
|
|
129
|
+
funderNotFound?: true;
|
|
110
130
|
pagination: ServerPaginationState;
|
|
111
131
|
preprints: PreprintRevision[];
|
|
112
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/biorxiv/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oDAAoD;AACpD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC;AAElD,8EAA8E;AAC9E,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,MAAM,CAAC;AAIjD
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/biorxiv/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oDAAoD;AACpD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC;AAElD,8EAA8E;AAC9E,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,MAAM,CAAC;AAIjD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,SAAS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;IAClC,SAAS,EAAE,gBAAgB,EAAE,CAAC;CAC/B;AAED,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,kEAAkE;AAClE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
|
@@ -1,7 +1,10 @@
|
|
|
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
|
|
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
9
|
* Detects HTML error pages, retries an HTTP 200 body that carries no result
|
|
7
10
|
* list, and classifies an origin rate limit (HTTP 429) as its own retryable
|
|
@@ -36,14 +39,24 @@ export declare class EuropePmcService {
|
|
|
36
39
|
/**
|
|
37
40
|
* Search EuropePMC for preprints matching the query. Returns ranked results
|
|
38
41
|
* with DOIs plus the upstream hitCount grand total, used to drive bioRxiv API
|
|
39
|
-
* enrichment.
|
|
40
|
-
* firstPublicationDate,
|
|
42
|
+
* enrichment. Uses the `lite` result type (doi, title, authorString,
|
|
43
|
+
* firstPublicationDate), which carries no abstract — see `getAbstracts`.
|
|
41
44
|
* Throws a retryable `rate_limited` error when the origin returns HTTP 429.
|
|
42
45
|
* A body with no result list is retried; if every attempt returns one, throws
|
|
43
46
|
* `ValidationError` (`invalid_cursor_mark`) when a cursor page other than `*`
|
|
44
47
|
* was requested, and `ServiceUnavailable` (`empty_response_body`) otherwise.
|
|
45
48
|
*/
|
|
46
49
|
search(options: SearchOptions, ctx: Context): Promise<EuropePmcSearchResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Fetch the abstracts of preprints by DOI in one `resultType=core` query — the
|
|
52
|
+
* only EuropePMC result type that carries `abstractText`. The query is keyed
|
|
53
|
+
* by the given DOIs (`DOI:"…" OR …`, preprints only) and one page is sized to
|
|
54
|
+
* hold them, so the response is bounded by the input. Returns normalized
|
|
55
|
+
* abstracts keyed by lowercase DOI; a DOI EuropePMC holds no abstract for is
|
|
56
|
+
* absent from the map. Throws on failure — classified like `search`, with an
|
|
57
|
+
* HTTP 429 as a retryable `rate_limited` error carrying `Retry-After`.
|
|
58
|
+
*/
|
|
59
|
+
getAbstracts(dois: readonly string[], ctx: Context): Promise<Map<string, string>>;
|
|
47
60
|
}
|
|
48
61
|
export declare function initEuropePmcService(config: AppConfig, storage: StorageService): void;
|
|
49
62
|
export declare function getEuropePmcService(): EuropePmcService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"europe-pmc-service.d.ts","sourceRoot":"","sources":["../../../src/services/europe-pmc/europe-pmc-service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"europe-pmc-service.d.ts","sourceRoot":"","sources":["../../../src/services/europe-pmc/europe-pmc-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA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cAAc,GAAG,IAAI,CAErF;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAItD"}
|
|
@@ -1,7 +1,10 @@
|
|
|
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
|
|
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
9
|
* Detects HTML error pages, retries an HTTP 200 body that carries no result
|
|
7
10
|
* list, and classifies an origin rate limit (HTTP 429) as its own retryable
|
|
@@ -93,8 +96,8 @@ export class EuropePmcService {
|
|
|
93
96
|
/**
|
|
94
97
|
* Search EuropePMC for preprints matching the query. Returns ranked results
|
|
95
98
|
* with DOIs plus the upstream hitCount grand total, used to drive bioRxiv API
|
|
96
|
-
* enrichment.
|
|
97
|
-
* firstPublicationDate,
|
|
99
|
+
* enrichment. Uses the `lite` result type (doi, title, authorString,
|
|
100
|
+
* firstPublicationDate), which carries no abstract — see `getAbstracts`.
|
|
98
101
|
* Throws a retryable `rate_limited` error when the origin returns HTTP 429.
|
|
99
102
|
* A body with no result list is retried; if every attempt returns one, throws
|
|
100
103
|
* `ValidationError` (`invalid_cursor_mark`) when a cursor page other than `*`
|
|
@@ -131,7 +134,6 @@ export class EuropePmcService {
|
|
|
131
134
|
q += ' AND (PUBLISHER:bioRxiv OR PUBLISHER:medRxiv)';
|
|
132
135
|
}
|
|
133
136
|
const filterParam = 'source:PPR';
|
|
134
|
-
const fields = 'doi,title,authorString,firstPublicationDate,abstractText';
|
|
135
137
|
// A blank cursor (a form client's empty field) is a first page, as it is
|
|
136
138
|
// upstream. Tokens are base64, so surrounding whitespace is never part of one.
|
|
137
139
|
const cursorMark = options.cursorMark?.trim() || '*';
|
|
@@ -142,7 +144,6 @@ export class EuropePmcService {
|
|
|
142
144
|
cursorMark,
|
|
143
145
|
pageSize: String(limit),
|
|
144
146
|
format: 'json',
|
|
145
|
-
fields,
|
|
146
147
|
});
|
|
147
148
|
const url = `${this.baseUrl}/search?${params.toString()}&filter=${filterParam}`;
|
|
148
149
|
try {
|
|
@@ -167,13 +168,11 @@ export class EuropePmcService {
|
|
|
167
168
|
.filter((raw) => raw.doi != null)
|
|
168
169
|
.map((raw) => {
|
|
169
170
|
const title = normalizeUpstreamText(raw.title);
|
|
170
|
-
const abstract = normalizeUpstreamText(raw.abstractText);
|
|
171
171
|
return {
|
|
172
172
|
doi: raw.doi,
|
|
173
173
|
...(title && { title }),
|
|
174
174
|
...(raw.authorString && { authors: raw.authorString }),
|
|
175
175
|
...(raw.firstPublicationDate && { publishedDate: raw.firstPublicationDate }),
|
|
176
|
-
...(abstract && { abstract }),
|
|
177
176
|
};
|
|
178
177
|
});
|
|
179
178
|
return {
|
|
@@ -194,6 +193,64 @@ export class EuropePmcService {
|
|
|
194
193
|
rethrowClassified(err, cursorMark);
|
|
195
194
|
}
|
|
196
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, '*');
|
|
252
|
+
}
|
|
253
|
+
}
|
|
197
254
|
}
|
|
198
255
|
// ─── Init / accessor ─────────────────────────────────────────────────────────
|
|
199
256
|
let _service;
|
|
@@ -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;;;;;;;;;;;;;GAaG;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;QACnD,MAAM,KA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
* @module services/europe-pmc/types
|
|
6
6
|
*/
|
|
7
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Shared utilities for biorxiv-mcp-server service layer. Provides
|
|
3
|
-
* HTML error detection, DOI input normalization, calendar-date and
|
|
4
|
-
* upstream-text normalization,
|
|
5
|
-
* `Retry-After` parsing and rate-limit rejection lookup
|
|
6
|
-
* path, and the server version string used in User-Agent
|
|
7
|
-
* 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.
|
|
8
8
|
* @module services/shared
|
|
9
9
|
*/
|
|
10
10
|
/** Detect HTML error pages returned instead of JSON by upstream APIs. */
|
|
@@ -42,18 +42,48 @@ export interface NormalizedDoi {
|
|
|
42
42
|
* a bioRxiv/medRxiv identifier, never characters of one.
|
|
43
43
|
*/
|
|
44
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;
|
|
45
54
|
/**
|
|
46
55
|
* Strip Highwire/JATS export artifacts that bioRxiv/medRxiv and EuropePMC leak
|
|
47
56
|
* into raw title and abstract text, so no upstream markup reaches
|
|
48
|
-
* `structuredContent` or the rendered `content[]`.
|
|
57
|
+
* `structuredContent` or the rendered `content[]`. Handles:
|
|
49
58
|
*
|
|
50
|
-
* - whole
|
|
51
|
-
* `
|
|
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;
|
|
52
63
|
* - the small-caps "Abstract" heading sentinel (`A<O_SCPLOW>BSTRACT<C_SCPLOW>`),
|
|
53
64
|
* which upstream fuses directly onto the first sentence with no separator;
|
|
54
|
-
* -
|
|
55
|
-
*
|
|
56
|
-
* -
|
|
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}`, `{+/-}`, `[≥]`, `[~]`,
|
|
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.
|
|
57
87
|
*
|
|
58
88
|
* Applied at the service boundary rather than in a tool's `format()` because
|
|
59
89
|
* `structuredContent` is the handler's raw return value and bypasses `format()`;
|
|
@@ -62,6 +92,27 @@ export declare function normalizeDoi(input: string): NormalizedDoi | undefined;
|
|
|
62
92
|
* fields as absent rather than as empty strings.
|
|
63
93
|
*/
|
|
64
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;
|
|
65
116
|
/**
|
|
66
117
|
* Reads a `Retry-After` header value as a wait in whole seconds. RFC 9110 §10.2.3
|
|
67
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;;;;;;;;GAQG;
|
|
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;;;;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