@pipeworx/mcp-crossref 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +33 -0
  3. package/package.json +18 -0
  4. package/src/index.ts +219 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pipeworx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # mcp-crossref
2
+
3
+ MCP server for searching academic papers, journals, and citations via the [Crossref API](https://api.crossref.org). No authentication required.
4
+
5
+ ## Tools
6
+
7
+ | Tool | Description |
8
+ |------|-------------|
9
+ | `search_works` | Search academic works (papers, books, datasets) by keyword |
10
+ | `get_work` | Get full metadata for a specific work by DOI |
11
+ | `get_journal` | Get the 5 most recent works published in a journal by ISSN |
12
+
13
+ ## Quickstart via Pipeworx Gateway
14
+
15
+ Call any tool through the hosted gateway with zero setup:
16
+
17
+ ```bash
18
+ curl -X POST https://gateway.pipeworx.io/mcp \
19
+ -H "Content-Type: application/json" \
20
+ -d '{
21
+ "jsonrpc": "2.0",
22
+ "id": 1,
23
+ "method": "tools/call",
24
+ "params": {
25
+ "name": "crossref_search_works",
26
+ "arguments": { "query": "machine learning climate change" }
27
+ }
28
+ }'
29
+ ```
30
+
31
+ ## License
32
+
33
+ MIT
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@pipeworx/mcp-crossref",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for searching academic papers, journals, and citations via the Crossref API",
5
+ "main": "src/index.ts",
6
+ "types": "src/index.ts",
7
+ "files": ["src"],
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "typecheck": "tsc --noEmit"
11
+ },
12
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "crossref", "academic", "papers", "doi"],
13
+ "author": "Pipeworx <hello@pipeworx.io>",
14
+ "license": "MIT",
15
+ "devDependencies": {
16
+ "typescript": "^5.0.0"
17
+ }
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Crossref MCP — wraps the Crossref REST API (academic papers, free, no auth)
3
+ *
4
+ * Tools:
5
+ * - search_works: search academic works by keyword
6
+ * - get_work: get full metadata for a work by DOI
7
+ * - get_journal: get recent works published in a journal by ISSN
8
+ */
9
+
10
+ interface McpToolDefinition {
11
+ name: string;
12
+ description: string;
13
+ inputSchema: {
14
+ type: 'object';
15
+ properties: Record<string, unknown>;
16
+ required?: string[];
17
+ };
18
+ }
19
+
20
+ interface McpToolExport {
21
+ tools: McpToolDefinition[];
22
+ callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
23
+ }
24
+
25
+ const BASE = 'https://api.crossref.org';
26
+ const HEADERS = {
27
+ 'User-Agent': 'pipeworx-mcp/1.0 (mailto:hello@pipeworx.io)',
28
+ };
29
+
30
+ // ── API Response Types ────────────────────────────────────────────────
31
+
32
+ type CrossrefAuthor = {
33
+ given?: string;
34
+ family?: string;
35
+ name?: string;
36
+ ORCID?: string;
37
+ };
38
+
39
+ type CrossrefDate = {
40
+ 'date-parts': number[][];
41
+ 'date-time'?: string;
42
+ timestamp?: number;
43
+ };
44
+
45
+ type CrossrefWork = {
46
+ DOI: string;
47
+ title?: string[];
48
+ 'container-title'?: string[];
49
+ author?: CrossrefAuthor[];
50
+ published?: CrossrefDate;
51
+ 'published-print'?: CrossrefDate;
52
+ 'published-online'?: CrossrefDate;
53
+ abstract?: string;
54
+ type?: string;
55
+ publisher?: string;
56
+ URL?: string;
57
+ 'is-referenced-by-count'?: number;
58
+ score?: number;
59
+ subject?: string[];
60
+ ISSN?: string[];
61
+ volume?: string;
62
+ issue?: string;
63
+ page?: string;
64
+ };
65
+
66
+ type CrossrefMessage<T> = {
67
+ status: string;
68
+ 'message-type': string;
69
+ message: T;
70
+ };
71
+
72
+ type CrossrefWorksMessage = {
73
+ 'total-results': number;
74
+ items: CrossrefWork[];
75
+ query?: { 'search-terms': string; 'start-index': number };
76
+ };
77
+
78
+ type CrossrefSingleWorkMessage = CrossrefWork;
79
+
80
+ type CrossrefJournalWorksMessage = {
81
+ 'total-results': number;
82
+ items: CrossrefWork[];
83
+ };
84
+
85
+ // ── Helpers ───────────────────────────────────────────────────────────
86
+
87
+ function formatAuthor(a: CrossrefAuthor): string {
88
+ if (a.family && a.given) return `${a.given} ${a.family}`;
89
+ if (a.family) return a.family;
90
+ return a.name ?? 'Unknown';
91
+ }
92
+
93
+ function formatDate(d?: CrossrefDate): string | null {
94
+ if (!d) return null;
95
+ const parts = d['date-parts']?.[0];
96
+ if (!parts) return null;
97
+ return parts.filter(Boolean).join('-');
98
+ }
99
+
100
+ function mapWork(w: CrossrefWork) {
101
+ return {
102
+ doi: w.DOI,
103
+ title: w.title?.[0] ?? null,
104
+ journal: w['container-title']?.[0] ?? null,
105
+ authors: (w.author ?? []).map(formatAuthor),
106
+ published: formatDate(w.published ?? w['published-print'] ?? w['published-online']),
107
+ type: w.type ?? null,
108
+ publisher: w.publisher ?? null,
109
+ abstract: w.abstract ?? null,
110
+ citations: w['is-referenced-by-count'] ?? null,
111
+ subjects: w.subject ?? [],
112
+ url: w.URL ?? `https://doi.org/${w.DOI}`,
113
+ };
114
+ }
115
+
116
+ // ── Tool Definitions ──────────────────────────────────────────────────
117
+
118
+ const tools: McpToolExport['tools'] = [
119
+ {
120
+ name: 'search_works',
121
+ description:
122
+ 'Search academic works (papers, books, datasets) in the Crossref index by keyword. Returns title, authors, journal, DOI, and citation count.',
123
+ inputSchema: {
124
+ type: 'object',
125
+ properties: {
126
+ query: { type: 'string', description: 'Search query (e.g., "climate change machine learning")' },
127
+ limit: {
128
+ type: 'number',
129
+ description: 'Number of results to return (1-100, default 10)',
130
+ },
131
+ },
132
+ required: ['query'],
133
+ },
134
+ },
135
+ {
136
+ name: 'get_work',
137
+ description:
138
+ 'Get full metadata for a specific academic work by its DOI. Returns title, authors, abstract, journal, publisher, citation count, and subjects.',
139
+ inputSchema: {
140
+ type: 'object',
141
+ properties: {
142
+ doi: { type: 'string', description: 'DOI of the work (e.g., "10.1038/nature12373")' },
143
+ },
144
+ required: ['doi'],
145
+ },
146
+ },
147
+ {
148
+ name: 'get_journal',
149
+ description:
150
+ 'Get the 5 most recent works published in a journal by its ISSN. Returns title, authors, DOI, and publication date.',
151
+ inputSchema: {
152
+ type: 'object',
153
+ properties: {
154
+ issn: { type: 'string', description: 'Journal ISSN (e.g., "1476-4687" for Nature)' },
155
+ },
156
+ required: ['issn'],
157
+ },
158
+ },
159
+ ];
160
+
161
+ // ── Tool Implementations ──────────────────────────────────────────────
162
+
163
+ async function searchWorks(query: string, limit: number) {
164
+ const rows = Math.min(100, Math.max(1, limit));
165
+ const params = new URLSearchParams({ query, rows: String(rows) });
166
+
167
+ const res = await fetch(`${BASE}/works?${params}`, { headers: HEADERS });
168
+ if (!res.ok) throw new Error(`Crossref search error: ${res.status}`);
169
+
170
+ const data = (await res.json()) as CrossrefMessage<CrossrefWorksMessage>;
171
+
172
+ return {
173
+ total_results: data.message['total-results'],
174
+ results: data.message.items.map(mapWork),
175
+ };
176
+ }
177
+
178
+ async function getWork(doi: string) {
179
+ const encoded = encodeURIComponent(doi);
180
+ const res = await fetch(`${BASE}/works/${encoded}`, { headers: HEADERS });
181
+ if (res.status === 404) throw new Error(`Work not found for DOI: ${doi}`);
182
+ if (!res.ok) throw new Error(`Crossref work error: ${res.status}`);
183
+
184
+ const data = (await res.json()) as CrossrefMessage<CrossrefSingleWorkMessage>;
185
+
186
+ return mapWork(data.message);
187
+ }
188
+
189
+ async function getJournal(issn: string) {
190
+ const params = new URLSearchParams({ rows: '5' });
191
+ const res = await fetch(`${BASE}/journals/${issn}/works?${params}`, { headers: HEADERS });
192
+ if (res.status === 404) throw new Error(`Journal not found for ISSN: ${issn}`);
193
+ if (!res.ok) throw new Error(`Crossref journal error: ${res.status}`);
194
+
195
+ const data = (await res.json()) as CrossrefMessage<CrossrefJournalWorksMessage>;
196
+
197
+ return {
198
+ issn,
199
+ total_results: data.message['total-results'],
200
+ recent_works: data.message.items.map(mapWork),
201
+ };
202
+ }
203
+
204
+ // ── Dispatcher ────────────────────────────────────────────────────────
205
+
206
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
207
+ switch (name) {
208
+ case 'search_works':
209
+ return searchWorks(args.query as string, (args.limit as number) ?? 10);
210
+ case 'get_work':
211
+ return getWork(args.doi as string);
212
+ case 'get_journal':
213
+ return getJournal(args.issn as string);
214
+ default:
215
+ throw new Error(`Unknown tool: ${name}`);
216
+ }
217
+ }
218
+
219
+ export default { tools, callTool } satisfies McpToolExport;