@cyanheads/biorxiv-mcp-server 0.1.5

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 (63) hide show
  1. package/AGENTS.md +309 -0
  2. package/CLAUDE.md +309 -0
  3. package/Dockerfile +99 -0
  4. package/LICENSE +195 -0
  5. package/README.md +279 -0
  6. package/changelog/0.1.x/0.1.0.md +18 -0
  7. package/changelog/0.1.x/0.1.1.md +32 -0
  8. package/changelog/0.1.x/0.1.2.md +23 -0
  9. package/changelog/0.1.x/0.1.3.md +23 -0
  10. package/changelog/0.1.x/0.1.4.md +19 -0
  11. package/changelog/0.1.x/0.1.5.md +18 -0
  12. package/changelog/template.md +93 -0
  13. package/dist/biorxiv-mcp-server.mcpb +0 -0
  14. package/dist/config/server-config.d.ts +17 -0
  15. package/dist/config/server-config.d.ts.map +1 -0
  16. package/dist/config/server-config.js +34 -0
  17. package/dist/config/server-config.js.map +1 -0
  18. package/dist/index.d.ts +9 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +25 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.d.ts +54 -0
  23. package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.d.ts.map +1 -0
  24. package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.js +208 -0
  25. package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.js.map +1 -0
  26. package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.d.ts +39 -0
  27. package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.d.ts.map +1 -0
  28. package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js +99 -0
  29. package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js.map +1 -0
  30. package/dist/mcp-server/tools/definitions/biorxiv-list-categories.tool.d.ts +13 -0
  31. package/dist/mcp-server/tools/definitions/biorxiv-list-categories.tool.d.ts.map +1 -0
  32. package/dist/mcp-server/tools/definitions/biorxiv-list-categories.tool.js +40 -0
  33. package/dist/mcp-server/tools/definitions/biorxiv-list-categories.tool.js.map +1 -0
  34. package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts +65 -0
  35. package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts.map +1 -0
  36. package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js +269 -0
  37. package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js.map +1 -0
  38. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts +46 -0
  39. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts.map +1 -0
  40. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js +279 -0
  41. package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js.map +1 -0
  42. package/dist/mcp-server/tools/definitions/index.d.ts +171 -0
  43. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
  44. package/dist/mcp-server/tools/definitions/index.js +23 -0
  45. package/dist/mcp-server/tools/definitions/index.js.map +1 -0
  46. package/dist/services/biorxiv/biorxiv-service.d.ts +39 -0
  47. package/dist/services/biorxiv/biorxiv-service.d.ts.map +1 -0
  48. package/dist/services/biorxiv/biorxiv-service.js +307 -0
  49. package/dist/services/biorxiv/biorxiv-service.js.map +1 -0
  50. package/dist/services/biorxiv/types.d.ts +127 -0
  51. package/dist/services/biorxiv/types.d.ts.map +1 -0
  52. package/dist/services/biorxiv/types.js +9 -0
  53. package/dist/services/biorxiv/types.js.map +1 -0
  54. package/dist/services/europe-pmc/europe-pmc-service.d.ts +36 -0
  55. package/dist/services/europe-pmc/europe-pmc-service.d.ts.map +1 -0
  56. package/dist/services/europe-pmc/europe-pmc-service.js +100 -0
  57. package/dist/services/europe-pmc/europe-pmc-service.js.map +1 -0
  58. package/dist/services/europe-pmc/types.d.ts +33 -0
  59. package/dist/services/europe-pmc/types.d.ts.map +1 -0
  60. package/dist/services/europe-pmc/types.js +8 -0
  61. package/dist/services/europe-pmc/types.js.map +1 -0
  62. package/package.json +102 -0
  63. package/server.json +111 -0
@@ -0,0 +1,307 @@
1
+ /**
2
+ * @fileoverview BiorxivApiService — wraps api.biorxiv.org endpoints for
3
+ * preprint details (/details), date-range listing (/details with date interval),
4
+ * and crosswalk (/pubs). All methods retry with exponential backoff. Parses
5
+ * and normalizes raw JSON into domain types. Detects HTML error pages.
6
+ * @module services/biorxiv/biorxiv-service
7
+ */
8
+ import { serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
9
+ import { fetchWithTimeout, withRetry } from '@cyanheads/mcp-ts-core/utils';
10
+ import { getServerConfig } from '../../config/server-config.js';
11
+ // Context is structurally assignable to RequestContext but lacks the index
12
+ // signature — cast once per call site.
13
+ function asRc(ctx) {
14
+ return ctx;
15
+ }
16
+ const SERVER_VERSION = '0.1.0';
17
+ // ─── Hardcoded category taxonomy ─────────────────────────────────────────────
18
+ // No API endpoint provides this; it changes infrequently. Maintained here.
19
+ const CATEGORIES = {
20
+ biorxiv: [
21
+ 'Animal Behavior and Cognition',
22
+ 'Biochemistry',
23
+ 'Bioengineering',
24
+ 'Bioinformatics',
25
+ 'Biophysics',
26
+ 'Cancer Biology',
27
+ 'Cell Biology',
28
+ 'Clinical Trials',
29
+ 'Developmental Biology',
30
+ 'Ecology',
31
+ 'Epidemiology',
32
+ 'Evolutionary Biology',
33
+ 'Genetics',
34
+ 'Genomics',
35
+ 'Immunology',
36
+ 'Microbiology',
37
+ 'Molecular Biology',
38
+ 'Neuroscience',
39
+ 'Paleontology',
40
+ 'Pathology',
41
+ 'Pharmacology and Toxicology',
42
+ 'Physiology',
43
+ 'Plant Biology',
44
+ 'Scientific Communication and Education',
45
+ 'Synthetic Biology',
46
+ 'Systems Biology',
47
+ 'Zoology',
48
+ ],
49
+ medrxiv: [
50
+ 'Addiction Medicine',
51
+ 'Allergy and Immunology',
52
+ 'Anesthesia',
53
+ 'Cardiovascular Medicine',
54
+ 'Dentistry and Oral Medicine',
55
+ 'Dermatology',
56
+ 'Emergency Medicine',
57
+ 'Endocrinology',
58
+ 'Epidemiology',
59
+ 'Forensic Medicine',
60
+ 'Gastroenterology',
61
+ 'Genetic and Genomic Medicine',
62
+ 'Geriatric Medicine',
63
+ 'Health Economics',
64
+ 'Health Informatics',
65
+ 'Health Policy',
66
+ 'Health Systems and Quality Improvement',
67
+ 'Hematology',
68
+ 'HIV/AIDS',
69
+ 'Infectious Diseases',
70
+ 'Intensive Care and Critical Care Medicine',
71
+ 'Medical Education',
72
+ 'Medical Ethics',
73
+ 'Nephrology',
74
+ 'Neurology',
75
+ 'Nursing',
76
+ 'Nutrition',
77
+ 'Obstetrics and Gynecology',
78
+ 'Occupational and Environmental Health',
79
+ 'Oncology',
80
+ 'Ophthalmology',
81
+ 'Orthopedics',
82
+ 'Otolaryngology',
83
+ 'Pain Medicine',
84
+ 'Palliative Medicine',
85
+ 'Pathology',
86
+ 'Pediatrics',
87
+ 'Pharmacology and Therapeutics',
88
+ 'Primary Care Research',
89
+ 'Psychiatry and Clinical Psychology',
90
+ 'Public and Global Health',
91
+ 'Radiology and Imaging',
92
+ 'Rehabilitation Medicine and Physical Therapy',
93
+ 'Respiratory Medicine',
94
+ 'Rheumatology',
95
+ 'Sexual and Reproductive Health',
96
+ 'Sports Medicine',
97
+ 'Surgery',
98
+ 'Toxicology',
99
+ 'Transplantation',
100
+ 'Urology',
101
+ 'Vascular Medicine',
102
+ ],
103
+ };
104
+ // All valid category strings in one flat set for quick validation
105
+ const ALL_CATEGORIES = new Set([...CATEGORIES.biorxiv, ...CATEGORIES.medrxiv]);
106
+ // ─── Normalization helpers ────────────────────────────────────────────────────
107
+ function normalizeRevision(raw) {
108
+ const rev = { doi: raw.doi };
109
+ if (raw.title)
110
+ rev.title = raw.title;
111
+ if (raw.authors)
112
+ rev.authors = raw.authors;
113
+ if (raw.author_corresponding)
114
+ rev.authorCorresponding = raw.author_corresponding;
115
+ if (raw.author_corresponding_institution)
116
+ rev.authorCorrespondingInstitution = raw.author_corresponding_institution;
117
+ if (raw.date)
118
+ rev.date = raw.date;
119
+ if (raw.version)
120
+ rev.version = raw.version;
121
+ if (raw.type)
122
+ rev.type = raw.type;
123
+ if (raw.license)
124
+ rev.license = raw.license;
125
+ if (raw.category)
126
+ rev.category = raw.category;
127
+ if (raw.jatsxml)
128
+ rev.jatsxmlUrl = raw.jatsxml;
129
+ if (raw.abstract)
130
+ rev.abstract = raw.abstract;
131
+ if (raw.funder) {
132
+ if (Array.isArray(raw.funder)) {
133
+ const names = raw.funder
134
+ .map((f) => f.name ?? '')
135
+ .filter(Boolean)
136
+ .join('; ');
137
+ if (names)
138
+ rev.funder = names;
139
+ }
140
+ else {
141
+ rev.funder = raw.funder;
142
+ }
143
+ }
144
+ // Normalize "NA" to absent — callers should check undefined, not "NA"
145
+ if (raw.published && raw.published !== 'NA')
146
+ rev.publishedJournalDoi = raw.published;
147
+ if (raw.server)
148
+ rev.server = raw.server;
149
+ return rev;
150
+ }
151
+ function detectHtmlError(text) {
152
+ return /^\s*<(!DOCTYPE\s+html|html[\s>])/i.test(text);
153
+ }
154
+ // ─── Service class ────────────────────────────────────────────────────────────
155
+ export class BiorxivApiService {
156
+ baseUrl;
157
+ userAgent;
158
+ constructor(_config, _storage) {
159
+ const serverCfg = getServerConfig();
160
+ this.baseUrl = serverCfg.apiBaseUrl;
161
+ this.userAgent = serverCfg.mailto
162
+ ? `biorxiv-mcp-server/${SERVER_VERSION} (mailto:${serverCfg.mailto})`
163
+ : `biorxiv-mcp-server/${SERVER_VERSION}`;
164
+ }
165
+ /** Returns the hardcoded subject category taxonomy. No API call. */
166
+ getCategories() {
167
+ return CATEGORIES;
168
+ }
169
+ /** Returns true if the given category string is in the taxonomy. */
170
+ isValidCategory(category) {
171
+ return ALL_CATEGORIES.has(category);
172
+ }
173
+ /**
174
+ * Fetch all revisions for a DOI from a single server.
175
+ * Returns an empty collection if the DOI is not found on this server.
176
+ */
177
+ async getDetails(doi, server, ctx) {
178
+ const encodedDoi = doi.split('/').map(encodeURIComponent).join('/');
179
+ const url = `${this.baseUrl}/details/${server}/${encodedDoi}/0/json`;
180
+ const rc = asRc(ctx);
181
+ return withRetry(async () => {
182
+ const response = await fetchWithTimeout(url, 15_000, rc, {
183
+ signal: ctx.signal,
184
+ headers: { 'User-Agent': this.userAgent },
185
+ });
186
+ const text = await response.text();
187
+ if (detectHtmlError(text)) {
188
+ throw serviceUnavailable('api.biorxiv.org returned HTML — likely rate-limited or down.', {
189
+ url,
190
+ });
191
+ }
192
+ const data = JSON.parse(text);
193
+ return (data.collection ?? []).map(normalizeRevision);
194
+ }, {
195
+ operation: 'BiorxivApiService.getDetails',
196
+ context: rc,
197
+ baseDelayMs: 500,
198
+ signal: ctx.signal,
199
+ });
200
+ }
201
+ /**
202
+ * Fetch preprints posted or revised within a date interval from a single server.
203
+ * `cursor` is an integer offset (0, 30, 60, …). Page size is always 30.
204
+ * Returns listing result with pagination state.
205
+ */
206
+ async getListing(server, startDate, endDate, cursor, category, ctx) {
207
+ let url = `${this.baseUrl}/details/${server}/${startDate}/${endDate}/${cursor}/json`;
208
+ if (category) {
209
+ url += `?category=${encodeURIComponent(category)}`;
210
+ }
211
+ const rc = asRc(ctx);
212
+ return withRetry(async () => {
213
+ const response = await fetchWithTimeout(url, 20_000, rc, {
214
+ signal: ctx.signal,
215
+ headers: { 'User-Agent': this.userAgent },
216
+ });
217
+ const text = await response.text();
218
+ if (detectHtmlError(text)) {
219
+ throw serviceUnavailable('api.biorxiv.org returned HTML — likely rate-limited or down.', {
220
+ url,
221
+ });
222
+ }
223
+ const data = JSON.parse(text);
224
+ const msg = data.messages?.[0];
225
+ const rawTotal = msg?.total;
226
+ const total = typeof rawTotal === 'number'
227
+ ? rawTotal
228
+ : typeof rawTotal === 'string'
229
+ ? parseInt(rawTotal, 10) || 0
230
+ : 0;
231
+ const preprints = (data.collection ?? []).map(normalizeRevision);
232
+ return {
233
+ preprints,
234
+ pagination: { cursor, total },
235
+ };
236
+ }, {
237
+ operation: 'BiorxivApiService.getListing',
238
+ context: rc,
239
+ baseDelayMs: 500,
240
+ signal: ctx.signal,
241
+ });
242
+ }
243
+ /**
244
+ * Resolve a preprint DOI to its published journal record via /pubs endpoint.
245
+ * Returns undefined when the preprint is not yet published.
246
+ */
247
+ async getPublishedVersion(doi, server, ctx) {
248
+ const encodedDoi = doi.split('/').map(encodeURIComponent).join('/');
249
+ const url = `${this.baseUrl}/pubs/${server}/${encodedDoi}/json`;
250
+ const rc = asRc(ctx);
251
+ return withRetry(async () => {
252
+ const response = await fetchWithTimeout(url, 15_000, rc, {
253
+ signal: ctx.signal,
254
+ headers: { 'User-Agent': this.userAgent },
255
+ });
256
+ const text = await response.text();
257
+ if (detectHtmlError(text)) {
258
+ throw serviceUnavailable('api.biorxiv.org returned HTML — likely rate-limited or down.', {
259
+ url,
260
+ });
261
+ }
262
+ const data = JSON.parse(text);
263
+ const record = data.collection?.[0];
264
+ if (!record?.preprint_doi)
265
+ return;
266
+ const pv = { preprintDoi: record.preprint_doi };
267
+ if (record.published_doi)
268
+ pv.publishedDoi = record.published_doi;
269
+ if (record.published_journal)
270
+ pv.publishedJournal = record.published_journal;
271
+ if (record.published_date)
272
+ pv.publishedDate = record.published_date;
273
+ if (record.preprint_title)
274
+ pv.preprintTitle = record.preprint_title;
275
+ if (record.preprint_authors)
276
+ pv.preprintAuthors = record.preprint_authors;
277
+ if (record.preprint_category)
278
+ pv.preprintCategory = record.preprint_category;
279
+ if (record.preprint_date)
280
+ pv.preprintDate = record.preprint_date;
281
+ if (record.preprint_abstract)
282
+ pv.preprintAbstract = record.preprint_abstract;
283
+ if (record.preprint_author_corresponding)
284
+ pv.preprintAuthorCorresponding = record.preprint_author_corresponding;
285
+ if (record.preprint_author_corresponding_institution)
286
+ pv.preprintAuthorCorrespondingInstitution =
287
+ record.preprint_author_corresponding_institution;
288
+ return pv;
289
+ }, {
290
+ operation: 'BiorxivApiService.getPublishedVersion',
291
+ context: rc,
292
+ baseDelayMs: 500,
293
+ signal: ctx.signal,
294
+ });
295
+ }
296
+ }
297
+ // ─── Init / accessor ─────────────────────────────────────────────────────────
298
+ let _service;
299
+ export function initBiorxivApiService(config, storage) {
300
+ _service = new BiorxivApiService(config, storage);
301
+ }
302
+ export function getBiorxivApiService() {
303
+ if (!_service)
304
+ throw new Error('BiorxivApiService not initialized — call initBiorxivApiService() in setup()');
305
+ return _service;
306
+ }
307
+ //# sourceMappingURL=biorxiv-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"biorxiv-service.js","sourceRoot":"","sources":["../../../src/services/biorxiv/biorxiv-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAuB,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAY5D,2EAA2E;AAC3E,uCAAuC;AACvC,SAAS,IAAI,CAAC,GAAY;IACxB,OAAO,GAAgC,CAAC;AAC1C,CAAC;AAED,MAAM,cAAc,GAAG,OAAO,CAAC;AAE/B,gFAAgF;AAChF,2EAA2E;AAC3E,MAAM,UAAU,GAAqB;IACnC,OAAO,EAAE;QACP,+BAA+B;QAC/B,cAAc;QACd,gBAAgB;QAChB,gBAAgB;QAChB,YAAY;QACZ,gBAAgB;QAChB,cAAc;QACd,iBAAiB;QACjB,uBAAuB;QACvB,SAAS;QACT,cAAc;QACd,sBAAsB;QACtB,UAAU;QACV,UAAU;QACV,YAAY;QACZ,cAAc;QACd,mBAAmB;QACnB,cAAc;QACd,cAAc;QACd,WAAW;QACX,6BAA6B;QAC7B,YAAY;QACZ,eAAe;QACf,wCAAwC;QACxC,mBAAmB;QACnB,iBAAiB;QACjB,SAAS;KACV;IACD,OAAO,EAAE;QACP,oBAAoB;QACpB,wBAAwB;QACxB,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;YAC1E,IAAI,MAAM,CAAC,iBAAiB;gBAAE,EAAE,CAAC,gBAAgB,GAAG,MAAM,CAAC,iBAAiB,CAAC;YAC7E,IAAI,MAAM,CAAC,aAAa;gBAAE,EAAE,CAAC,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC;YACjE,IAAI,MAAM,CAAC,iBAAiB;gBAAE,EAAE,CAAC,gBAAgB,GAAG,MAAM,CAAC,iBAAiB,CAAC;YAC7E,IAAI,MAAM,CAAC,6BAA6B;gBACtC,EAAE,CAAC,2BAA2B,GAAG,MAAM,CAAC,6BAA6B,CAAC;YACxE,IAAI,MAAM,CAAC,yCAAyC;gBAClD,EAAE,CAAC,sCAAsC;oBACvC,MAAM,CAAC,yCAAyC,CAAC;YACrD,OAAO,EAAE,CAAC;QACZ,CAAC,EACD;YACE,SAAS,EAAE,uCAAuC;YAClD,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,GAAG;YAChB,MAAM,EAAE,GAAG,CAAC,MAAM;SACnB,CACF,CAAC;IACJ,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"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * @fileoverview Domain types for the bioRxiv API service. Covers raw JSON
3
+ * shapes returned by the API alongside normalized domain types used by tool
4
+ * handlers. Raw types default fields to optional to faithfully represent
5
+ * the API's sparsity — absence is preserved rather than fabricated.
6
+ * @module services/biorxiv/types
7
+ */
8
+ /** Server identifier accepted by api.biorxiv.org */
9
+ export type BiorxivServer = 'biorxiv' | 'medrxiv';
10
+ /** Broader "both" is accepted at tool level and fanned out by the service. */
11
+ export type ServerParam = BiorxivServer | 'both';
12
+ /** A funder entry in the bioRxiv API funder array */
13
+ export interface RawFunderEntry {
14
+ award?: string;
15
+ id?: string;
16
+ 'id-type'?: string;
17
+ name?: string;
18
+ }
19
+ /**
20
+ * A single preprint revision as returned by the /details endpoint.
21
+ * Fields marked optional may be absent from real upstream payloads.
22
+ */
23
+ export interface RawPreprintRevision {
24
+ abstract?: string;
25
+ author_corresponding?: string;
26
+ author_corresponding_institution?: string;
27
+ authors?: string;
28
+ category?: string;
29
+ date?: string;
30
+ doi: string;
31
+ /** Either a plain string ("NA"), an array of funder objects, or absent */
32
+ funder?: string | RawFunderEntry[];
33
+ jatsxml?: string;
34
+ license?: string;
35
+ /** Journal DOI after publication, or "NA" when not yet published */
36
+ published?: string;
37
+ server?: string;
38
+ title?: string;
39
+ type?: string;
40
+ version?: string;
41
+ }
42
+ /** Envelope returned by /details/{server}/{doi} */
43
+ export interface RawDetailsResponse {
44
+ collection?: RawPreprintRevision[];
45
+ messages?: Array<{
46
+ status?: string;
47
+ /** API returns total as a string (e.g. "915"), not a number */
48
+ total?: number | string;
49
+ count?: number;
50
+ cursor?: number | string;
51
+ message?: string;
52
+ category?: string;
53
+ count_new_papers?: number | string;
54
+ }>;
55
+ }
56
+ /** A single crosswalk record from /pubs/{server}/{doi} */
57
+ export interface RawPublishedRecord {
58
+ preprint_abstract?: string;
59
+ preprint_author_corresponding?: string;
60
+ preprint_author_corresponding_institution?: string;
61
+ preprint_authors?: string;
62
+ preprint_category?: string;
63
+ preprint_date?: string;
64
+ preprint_doi?: string;
65
+ preprint_title?: string;
66
+ published_date?: string;
67
+ published_doi?: string;
68
+ published_journal?: string;
69
+ }
70
+ /** Envelope returned by /pubs/{server}/{doi} */
71
+ export interface RawPublishedResponse {
72
+ collection?: RawPublishedRecord[];
73
+ messages?: Array<{
74
+ status?: string;
75
+ total?: number;
76
+ count?: number;
77
+ }>;
78
+ }
79
+ /** A single preprint revision with normalized optional fields */
80
+ export interface PreprintRevision {
81
+ abstract?: string;
82
+ authorCorresponding?: string;
83
+ authorCorrespondingInstitution?: string;
84
+ authors?: string;
85
+ category?: string;
86
+ date?: string;
87
+ doi: string;
88
+ funder?: string;
89
+ jatsxmlUrl?: string;
90
+ license?: string;
91
+ /** Non-null when the preprint has been published; "NA" is normalized to undefined */
92
+ publishedJournalDoi?: string;
93
+ server?: string;
94
+ title?: string;
95
+ type?: string;
96
+ version?: string;
97
+ }
98
+ /** Pagination metadata for a single server */
99
+ export interface ServerPaginationState {
100
+ cursor: number;
101
+ total: number;
102
+ }
103
+ /** Per-server result from the listing endpoint */
104
+ export interface ListingResult {
105
+ pagination: ServerPaginationState;
106
+ preprints: PreprintRevision[];
107
+ }
108
+ /** Crosswalk record from the /pubs endpoint */
109
+ export interface PublishedVersion {
110
+ preprintAbstract?: string;
111
+ preprintAuthorCorresponding?: string;
112
+ preprintAuthorCorrespondingInstitution?: string;
113
+ preprintAuthors?: string;
114
+ preprintCategory?: string;
115
+ preprintDate?: string;
116
+ preprintDoi: string;
117
+ preprintTitle?: string;
118
+ publishedDate?: string;
119
+ publishedDoi?: string;
120
+ publishedJournal?: string;
121
+ }
122
+ /** Hardcoded subject category taxonomy for bioRxiv and medRxiv */
123
+ export interface CategoryTaxonomy {
124
+ biorxiv: string[];
125
+ medrxiv: string[];
126
+ }
127
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,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OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,kDAAkD;AAClD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,qBAAqB,CAAC;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"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @fileoverview Domain types for the bioRxiv API service. Covers raw JSON
3
+ * shapes returned by the API alongside normalized domain types used by tool
4
+ * handlers. Raw types default fields to optional to faithfully represent
5
+ * the API's sparsity — absence is preserved rather than fabricated.
6
+ * @module services/biorxiv/types
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/biorxiv/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @fileoverview EuropePmcService — wraps the EuropePMC REST search endpoint
3
+ * for preprint keyword search. Returns ranked DOI lists used by
4
+ * biorxiv_search_preprints for bioRxiv/medRxiv enrichment. All requests
5
+ * include a polite User-Agent and are retried with exponential backoff.
6
+ * @module services/europe-pmc/europe-pmc-service
7
+ */
8
+ import type { Context } from '@cyanheads/mcp-ts-core';
9
+ import type { AppConfig } from '@cyanheads/mcp-ts-core/config';
10
+ import type { StorageService } from '@cyanheads/mcp-ts-core/storage';
11
+ import type { EuropePmcResult } from './types.js';
12
+ export interface SearchOptions {
13
+ /** Optional date filter — format YYYY-MM-DD */
14
+ dateFrom?: string | undefined;
15
+ /** Optional date filter — format YYYY-MM-DD */
16
+ dateTo?: string | undefined;
17
+ /** Maximum number of results to return (capped at 100) */
18
+ limit?: number | undefined;
19
+ query: string;
20
+ /** Server filter: 'biorxiv' | 'medrxiv' | 'both' */
21
+ server?: string | undefined;
22
+ }
23
+ export declare class EuropePmcService {
24
+ private readonly baseUrl;
25
+ private readonly userAgent;
26
+ constructor(_config: AppConfig, _storage: StorageService);
27
+ /**
28
+ * Search EuropePMC for preprints matching the query. Returns ranked results
29
+ * with DOIs, used to drive bioRxiv API enrichment. Requests the minimal field
30
+ * set (doi, title, authorString, firstPublicationDate, abstractText).
31
+ */
32
+ search(options: SearchOptions, ctx: Context): Promise<EuropePmcResult[]>;
33
+ }
34
+ export declare function initEuropePmcService(config: AppConfig, storage: StorageService): void;
35
+ export declare function getEuropePmcService(): EuropePmcService;
36
+ //# sourceMappingURL=europe-pmc-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"europe-pmc-service.d.ts","sourceRoot":"","sources":["../../../src/services/europe-pmc/europe-pmc-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;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,eAAe,EAA8B,MAAM,YAAY,CAAC;AAc9E,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc;IAQxD;;;;OAIG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAmE/E;AAMD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAErF;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAItD"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * @fileoverview EuropePmcService — wraps the EuropePMC REST search endpoint
3
+ * for preprint keyword search. Returns ranked DOI lists used by
4
+ * biorxiv_search_preprints for bioRxiv/medRxiv enrichment. All requests
5
+ * include a polite User-Agent and are retried with exponential backoff.
6
+ * @module services/europe-pmc/europe-pmc-service
7
+ */
8
+ import { serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
9
+ import { fetchWithTimeout, withRetry } from '@cyanheads/mcp-ts-core/utils';
10
+ import { getServerConfig } from '../../config/server-config.js';
11
+ // Context is structurally assignable to RequestContext but lacks the index
12
+ // signature — cast once per call site.
13
+ function asRc(ctx) {
14
+ return ctx;
15
+ }
16
+ const SERVER_VERSION = '0.1.0';
17
+ function detectHtmlError(text) {
18
+ return /^\s*<(!DOCTYPE\s+html|html[\s>])/i.test(text);
19
+ }
20
+ export class EuropePmcService {
21
+ baseUrl;
22
+ userAgent;
23
+ constructor(_config, _storage) {
24
+ const serverCfg = getServerConfig();
25
+ this.baseUrl = serverCfg.europePmcBaseUrl;
26
+ this.userAgent = serverCfg.mailto
27
+ ? `biorxiv-mcp-server/${SERVER_VERSION} (mailto:${serverCfg.mailto})`
28
+ : `biorxiv-mcp-server/${SERVER_VERSION}`;
29
+ }
30
+ /**
31
+ * Search EuropePMC for preprints matching the query. Returns ranked results
32
+ * with DOIs, used to drive bioRxiv API enrichment. Requests the minimal field
33
+ * set (doi, title, authorString, firstPublicationDate, abstractText).
34
+ */
35
+ async search(options, ctx) {
36
+ const limit = Math.min(options.limit ?? 25, 100);
37
+ let q = options.query;
38
+ if (options.dateFrom || options.dateTo) {
39
+ const from = options.dateFrom ?? '1900-01-01';
40
+ const to = options.dateTo ?? '9999-12-31';
41
+ q += ` AND FIRST_PDATE:[${from} TO ${to}]`;
42
+ }
43
+ // Scope to preprints; narrow to the specific server publisher when requested
44
+ if (options.server === 'biorxiv') {
45
+ q += ' AND PUBLISHER:bioRxiv';
46
+ }
47
+ else if (options.server === 'medrxiv') {
48
+ q += ' AND PUBLISHER:medRxiv';
49
+ }
50
+ const filterParam = 'source:PPR';
51
+ const fields = 'doi,title,authorString,firstPublicationDate,abstractText';
52
+ const params = new URLSearchParams({
53
+ query: q,
54
+ resulttype: 'lite',
55
+ synonym: 'FALSE',
56
+ cursorMark: '*',
57
+ pageSize: String(limit),
58
+ format: 'json',
59
+ fields,
60
+ });
61
+ const url = `${this.baseUrl}/search?${params.toString()}&filter=${filterParam}`;
62
+ const rc = asRc(ctx);
63
+ return withRetry(async () => {
64
+ const response = await fetchWithTimeout(url, 20_000, rc, {
65
+ signal: ctx.signal,
66
+ headers: { 'User-Agent': this.userAgent },
67
+ });
68
+ const text = await response.text();
69
+ if (detectHtmlError(text)) {
70
+ throw serviceUnavailable('EuropePMC returned HTML instead of JSON — service may be degraded.', { url });
71
+ }
72
+ const data = JSON.parse(text);
73
+ return (data.resultList?.result ?? [])
74
+ .filter((raw) => raw.doi != null)
75
+ .map((raw) => ({
76
+ doi: raw.doi,
77
+ ...(raw.title && { title: raw.title }),
78
+ ...(raw.authorString && { authors: raw.authorString }),
79
+ ...(raw.firstPublicationDate && { publishedDate: raw.firstPublicationDate }),
80
+ ...(raw.abstractText && { abstract: raw.abstractText }),
81
+ }));
82
+ }, {
83
+ operation: 'EuropePmcService.search',
84
+ context: rc,
85
+ baseDelayMs: 300,
86
+ signal: ctx.signal,
87
+ });
88
+ }
89
+ }
90
+ // ─── Init / accessor ─────────────────────────────────────────────────────────
91
+ let _service;
92
+ export function initEuropePmcService(config, storage) {
93
+ _service = new EuropePmcService(config, storage);
94
+ }
95
+ export function getEuropePmcService() {
96
+ if (!_service)
97
+ throw new Error('EuropePmcService not initialized — call initEuropePmcService() in setup()');
98
+ return _service;
99
+ }
100
+ //# sourceMappingURL=europe-pmc-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"europe-pmc-service.js","sourceRoot":"","sources":["../../../src/services/europe-pmc/europe-pmc-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAuB,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D,2EAA2E;AAC3E,uCAAuC;AACvC,SAAS,IAAI,CAAC,GAAY;IACxB,OAAO,GAAgC,CAAC;AAC1C,CAAC;AAED,MAAM,cAAc,GAAG,OAAO,CAAC;AAE/B,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,mCAAmC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC;AA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GAAG,CAAC,oBAAoB,IAAI,EAAE,aAAa,EAAE,GAAG,CAAC,oBAAoB,EAAE,CAAC;gBAC5E,GAAG,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC;aACxD,CAAC,CACH,CAAC;QACN,CAAC,EACD;YACE,SAAS,EAAE,yBAAyB;YACpC,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,GAAG;YAChB,MAAM,EAAE,GAAG,CAAC,MAAM;SACnB,CACF,CAAC;IACJ,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"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @fileoverview Domain types for the EuropePMC service. Covers raw API shapes
3
+ * from the EuropePMC REST search endpoint and normalized domain types used by
4
+ * the search_preprints tool handler.
5
+ * @module services/europe-pmc/types
6
+ */
7
+ /** A single result from the EuropePMC search endpoint */
8
+ export interface RawEuropePmcResult {
9
+ abstractText?: string;
10
+ authorString?: string;
11
+ doi?: string;
12
+ firstPublicationDate?: string;
13
+ id?: string;
14
+ source?: string;
15
+ title?: string;
16
+ }
17
+ /** Envelope returned by the EuropePMC search endpoint */
18
+ export interface RawEuropePmcSearchResponse {
19
+ hitCount?: number;
20
+ nextCursorMark?: string;
21
+ resultList?: {
22
+ result?: RawEuropePmcResult[];
23
+ };
24
+ }
25
+ /** A preprint search result from EuropePMC, used for enrichment */
26
+ export interface EuropePmcResult {
27
+ abstract?: string;
28
+ authors?: string;
29
+ doi: string;
30
+ publishedDate?: string;
31
+ title?: string;
32
+ }
33
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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"}