openalex-mcp-server 1.0.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/README.md ADDED
@@ -0,0 +1,525 @@
1
+ # OpenAlex + PubMed MCP Server
2
+
3
+ **发布简介(中文)**
4
+ OpenAlex MCP Server 是一个轻量的 MCP(Model Context Protocol)服务端,提供学术文献检索、论文详情、批量查询、全文检测与下载能力。适合作为 AI Agent 的学术检索基础设施,可与 PubMed MCP 组合形成更完整的生物医学检索链路。
5
+
6
+ **Release Summary (English)**
7
+ OpenAlex MCP Server is a lightweight MCP (Model Context Protocol) server for academic search. It supports paper search, detailed metadata, batch queries, full-text detection, and downloads. It works great as an AI Agent research backend and can be paired with PubMed MCP for biomedical pipelines.
8
+
9
+ 一个轻量化的 OpenAlex MCP 服务器,可与 PubMed MCP 搭配使用,为 AI Agent 提供快速学术文献检索、详细摘要信息和全文下载能力。
10
+
11
+ ## 功能特性
12
+
13
+ - **论文搜索**: 通过关键词搜索学术文献,支持多种过滤和排序选项
14
+ - **论文详情**: 获取单篇论文的完整信息,包括摘要、作者、主题等
15
+ - **批量查询**: 一次性获取多篇论文的信息,提高效率
16
+ - **全文下载**: 检测并下载开放获取论文的 PDF 全文
17
+ - **章节提取**: 从 PDF 中提取并识别论文章节(摘要、引言、方法、结果等)
18
+ - **智能缓存**: 本地缓存论文元数据,减少 API 调用
19
+ - **速率限制**: 内置速率限制和指数退避重试机制
20
+
21
+ ## 快速开始
22
+
23
+ ### 安装
24
+
25
+ ```bash
26
+ # 克隆仓库
27
+ git clone https://github.com/SecretRichGarden/openAlex-mcp.git
28
+ cd openAlex-mcp
29
+
30
+ # 安装依赖
31
+ npm install
32
+ ```
33
+
34
+ ### 配置
35
+
36
+ 1. 复制 `.env.example` 到 `.env`:
37
+
38
+ ```bash
39
+ cp .env.example .env
40
+ ```
41
+
42
+ 2. 编辑 `.env` 文件(可选):
43
+
44
+ ```env
45
+ # OpenAlex API 密钥(可选,但推荐获取以获得更高的速率限制)
46
+ # 在 https://openalex.org/register 免费获取
47
+ OPENALEX_API_KEY=your-api-key-here
48
+
49
+ # 启用缓存(默认:true)
50
+ CACHE_ENABLED=true
51
+
52
+ # 摘要处理模式(默认:quick)
53
+ ABSTRACT_MODE=quick
54
+ ```
55
+
56
+ ### 运行(本地)
57
+
58
+ ```bash
59
+ npm start
60
+ ```
61
+
62
+ ### 运行(npx 一键)
63
+
64
+ ```bash
65
+ npx -y openalex-mcp-server
66
+ ```
67
+
68
+ **One-Command Run (npx)**
69
+
70
+ ```bash
71
+ npx -y openalex-mcp-server
72
+ ```
73
+
74
+ ### 魔搭社区 / Smithery 发布用配置(STDIO)
75
+
76
+ 将以下内容复制到 MCP 客户端配置中即可(包含必填 API Key,适合发布页面展示):
77
+
78
+ ```json
79
+ {
80
+ "mcpServers": {
81
+ "openalex-mcp-server": {
82
+ "args": [
83
+ "openalex-mcp-server"
84
+ ],
85
+ "command": "npx",
86
+ "env": {
87
+ "OPENALEX_API_KEY": "your-api-key-here"
88
+ }
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ **ModelScope / Smithery STDIO Config (English)**
95
+
96
+ Copy this config into your MCP client configuration (API key required):
97
+
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "openalex-mcp-server": {
102
+ "args": [
103
+ "openalex-mcp-server"
104
+ ],
105
+ "command": "npx",
106
+ "env": {
107
+ "OPENALEX_API_KEY": "your-api-key-here"
108
+ }
109
+ }
110
+ }
111
+ }
112
+ ```
113
+
114
+ ### 配置 Claude Desktop
115
+
116
+ 将以下配置添加到 Claude Desktop 的配置文件中:
117
+
118
+ **macOS/Linux**: `~/.claude/desktop_config.json`
119
+ **Windows**: `%APPDATA%\Claude\desktop_config.json`
120
+
121
+ ```json
122
+ {
123
+ "mcpServers": {
124
+ "openalex-mcp-server": {
125
+ "command": "node",
126
+ "args": [
127
+ "/path/to/openAlex-mcp/src/cli.js"
128
+ ],
129
+ "env": {
130
+ "OPENALEX_API_KEY": "your-api-key-here",
131
+ "CACHE_ENABLED": "true"
132
+ }
133
+ }
134
+ }
135
+ }
136
+ ```
137
+
138
+ 或者使用 `npx`(无需安装):
139
+
140
+ ```json
141
+ {
142
+ "mcpServers": {
143
+ "openalex-mcp-server": {
144
+ "command": "npx",
145
+ "args": ["-y", "openalex-mcp-server"],
146
+ "env": {
147
+ "OPENALEX_API_KEY": "your-api-key-here"
148
+ }
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ ### 配置 Cherry / 其他 MCP 客户端
155
+
156
+ 以下为通用 stdio 配置,适用于 Cherry Studio 或其它支持 MCP 的 Agent 工具。将 `command` / `args` 按客户端要求填写即可。
157
+
158
+ ```json
159
+ {
160
+ "mcpServers": {
161
+ "openalex-mcp-server": {
162
+ "command": "npx",
163
+ "args": ["-y", "openalex-mcp-server"],
164
+ "env": {
165
+ "OPENALEX_API_KEY": "your-api-key-here",
166
+ "CACHE_ENABLED": "true"
167
+ }
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ **Cherry / Other MCP Clients (English)**
174
+
175
+ Use the following stdio configuration for Cherry Studio or any MCP-capable client. Copy and adjust `command` / `args` based on your client’s config format.
176
+
177
+ ```json
178
+ {
179
+ "mcpServers": {
180
+ "openalex-mcp-server": {
181
+ "command": "npx",
182
+ "args": ["-y", "openalex-mcp-server"],
183
+ "env": {
184
+ "OPENALEX_API_KEY": "your-api-key-here",
185
+ "CACHE_ENABLED": "true"
186
+ }
187
+ }
188
+ }
189
+ }
190
+ ```
191
+
192
+ ## 可用工具
193
+
194
+ ### `openalex_search`
195
+
196
+ 搜索学术文献。
197
+
198
+ **参数**:
199
+ - `query` (必需): 搜索关键词
200
+ - `max_results` (可选): 每页结果数,默认 20,最大 200
201
+ - `page` (可选): 页码,默认 1
202
+ - `sort_by` (可选): 排序字段,如 "cited_by_count:desc"
203
+ - `filters` (可选): 过滤器对象
204
+ - `publication_year`: 发表年份
205
+ - `is_oa`: 是否为开放获取
206
+ - `type`: 文献类型
207
+
208
+ **返回格式**:
209
+ ```json
210
+ {
211
+ "meta": {
212
+ "total_count": 1000,
213
+ "page": 1,
214
+ "per_page": 20
215
+ },
216
+ "papers": [
217
+ {
218
+ "id": "W3128609807",
219
+ "title": "论文标题",
220
+ "authors": [...],
221
+ "publication_year": 2023,
222
+ "venue": {...},
223
+ "cited_by_count": 42,
224
+ "open_access": {...}
225
+ }
226
+ ]
227
+ }
228
+ ```
229
+
230
+ ### `openalex_get_work`
231
+
232
+ 获取单篇论文的详细信息。
233
+
234
+ **参数**:
235
+ - `work_id` (必需): 论文 ID(OpenAlex ID、DOI 或 PMID)
236
+ - `include_abstract` (可选): 是否包含摘要,默认 true
237
+ - `abstract_mode` (可选): 摘要模式(quick/deep),默认 quick
238
+
239
+ **示例**:
240
+ ```json
241
+ {
242
+ "work_id": "W3128609807"
243
+ }
244
+ ```
245
+
246
+ ### `openalex_batch_get_works`
247
+
248
+ 批量获取多篇论文信息。
249
+
250
+ **参数**:
251
+ - `work_ids` (必需): 论文 ID 数组(最多 50 个)
252
+ - `include_abstract` (可选): 是否包含摘要,默认 false
253
+
254
+ **示例**:
255
+ ```json
256
+ {
257
+ "work_ids": ["W3128609807", "W2741809807", "W2105678901"]
258
+ }
259
+ ```
260
+
261
+ ### `openalex_detect_fulltext`
262
+
263
+ 检测论文是否有可用的全文。
264
+
265
+ **参数**:
266
+ - `work_id` (必需): 论文 ID
267
+
268
+ **返回**:
269
+ ```json
270
+ {
271
+ "work_id": "W3128609807",
272
+ "is_oa": true,
273
+ "oa_status": "gold",
274
+ "oa_url": "https://arxiv.org/pdf/2301.xxxxx.pdf",
275
+ "fulltext_available": true
276
+ }
277
+ ```
278
+
279
+ ### `openalex_download_fulltext`
280
+
281
+ 下载论文全文 PDF。
282
+
283
+ **参数**:
284
+ - `work_id` (必需): 论文 ID
285
+ - `force_download` (可选): 强制重新下载,默认 false
286
+
287
+ **返回**:
288
+ ```json
289
+ {
290
+ "work_id": "W3128609807",
291
+ "status": "downloaded",
292
+ "cache_path": "/path/to/cache/W3128609807.pdf",
293
+ "file_size": 1234567
294
+ }
295
+ ```
296
+
297
+ ### `openalex_get_fulltext_sections`
298
+
299
+ 获取论文的章节内容。
300
+
301
+ **参数**:
302
+ - `work_id` (必需): 论文 ID
303
+ - `sections` (可选): 要获取的章节列表
304
+
305
+ **可用章节**:
306
+ - `abstract`
307
+ - `introduction`
308
+ - `methods`
309
+ - `results`
310
+ - `discussion`
311
+ - `conclusion`
312
+ - `references`
313
+
314
+ ### `openalex_cache_stats`
315
+
316
+ 查看缓存统计信息。
317
+
318
+ **参数**:
319
+ - `action` (可选): "stats" 或 "clear",默认 stats
320
+
321
+ ### `openalex_system_check`
322
+
323
+ 检查系统状态和 API 连接。
324
+
325
+ **参数**: 无
326
+
327
+ ## 使用示例
328
+
329
+ ### 示例 1: 搜索机器学习相关的高被引论文
330
+
331
+ ```json
332
+ {
333
+ "tool": "openalex_search",
334
+ "arguments": {
335
+ "query": "machine learning",
336
+ "max_results": 10,
337
+ "sort_by": "cited_by_count:desc",
338
+ "filters": {
339
+ "publication_year": 2023,
340
+ "is_oa": true
341
+ }
342
+ }
343
+ }
344
+ ```
345
+
346
+ ### 示例 2: 获取论文详情并下载全文
347
+
348
+ ```json
349
+ {
350
+ "tool": "openalex_get_work",
351
+ "arguments": {
352
+ "work_id": "W3128609807",
353
+ "include_abstract": true
354
+ }
355
+ }
356
+ ```
357
+
358
+ ```json
359
+ {
360
+ "tool": "openalex_download_fulltext",
361
+ "arguments": {
362
+ "work_id": "W3128609807"
363
+ }
364
+ }
365
+ ```
366
+
367
+ ```json
368
+ {
369
+ "tool": "openalex_get_fulltext_sections",
370
+ "arguments": {
371
+ "work_id": "W3128609807",
372
+ "sections": ["abstract", "introduction", "methods"]
373
+ }
374
+ }
375
+ ```
376
+
377
+ ### 示例 3: 批量获取论文信息
378
+
379
+ ```json
380
+ {
381
+ "tool": "openalex_batch_get_works",
382
+ "arguments": {
383
+ "work_ids": [
384
+ "W3128609807",
385
+ "W2741809807",
386
+ "W2105678901"
387
+ ]
388
+ }
389
+ }
390
+ ```
391
+
392
+ ### 示例 4: 与 PubMed MCP 配合使用
393
+
394
+ 配置两个 MCP 服务器可以同时使用:
395
+
396
+ ```json
397
+ {
398
+ "mcpServers": {
399
+ "openalex-mcp-server": {
400
+ "command": "node",
401
+ "args": ["/path/to/openAlex-mcp/src/cli.js"],
402
+ "env": {
403
+ "OPENALEX_API_KEY": "your-key"
404
+ }
405
+ },
406
+ "pubmed-mcp-server": {
407
+ "command": "npx",
408
+ "args": ["-y", "@your-org/pubmed-mcp"]
409
+ }
410
+ }
411
+ }
412
+ ```
413
+
414
+ 工作流程:
415
+ 1. 使用 OpenAlex 搜索论文获取广泛的学术文献
416
+ 2. 使用 PubMed 获取生物医学领域的详细元数据
417
+ 3. 使用 OpenAlex 下载全文并提取章节
418
+
419
+ ## 配置选项
420
+
421
+ ### 环境变量
422
+
423
+ | 变量 | 类型 | 默认值 | 描述 |
424
+ |------|------|--------|------|
425
+ | `OPENALEX_API_KEY` | string | - | OpenAlex API 密钥(可选) |
426
+ | `CACHE_ENABLED` | boolean | true | 是否启用本地缓存 |
427
+ | `ABSTRACT_MODE` | string | quick | 摘要处理模式 |
428
+
429
+ **Environment Variables (English)**
430
+
431
+ | Variable | Type | Default | Description |
432
+ |------|------|--------|------|
433
+ | `OPENALEX_API_KEY` | string | - | OpenAlex API key (optional) |
434
+ | `CACHE_ENABLED` | boolean | true | Enable local cache |
435
+ | `ABSTRACT_MODE` | string | quick | Abstract processing mode |
436
+
437
+ ### API 密钥
438
+
439
+ 虽然不需要 API 密钥也可以使用 OpenAlex API,但注册并使用 API 密钥可以获得:
440
+ - 更高的速率限制(有密钥:10 请求/秒,无密钥:5 请求/秒)
441
+ - 更稳定的服务体验
442
+
443
+ 在 [https://openalex.org/register](https://openalex.org/register) 免费获取 API 密钥。
444
+
445
+ **API Key (English)**
446
+
447
+ You can use OpenAlex without a key, but a key increases rate limits and stability. Get a free API key at https://openalex.org/register.
448
+
449
+ ## 项目结构
450
+
451
+ ```
452
+ openalex-mcp/
453
+ ├── src/
454
+ │ ├── index.js # MCP 服务器入口
455
+ │ ├── openalex-client.js # OpenAlex API 客户端
456
+ │ ├── cache-manager.js # 缓存管理器
457
+ │ ├── fulltext-downloader.js # 全文下载器
458
+ │ ├── json-optimizer.js # JSON 格式优化器
459
+ │ └── utils.js # 工具函数
460
+ ├── config/
461
+ │ └── mcp-config.json # MCP 配置模板
462
+ ├── cache/
463
+ │ ├── papers/ # 论文元数据缓存
464
+ │ └── fulltext/ # 全文 PDF 和文本缓存
465
+ ├── package.json
466
+ ├── .env.example
467
+ └── README.md
468
+ ```
469
+
470
+ ## 开发
471
+
472
+ ### 类型检查
473
+
474
+ ```bash
475
+ npm run typecheck
476
+ ```
477
+
478
+ ### 运行测试
479
+
480
+ ```bash
481
+ npm test
482
+ ```
483
+
484
+ ## 常见问题
485
+
486
+ ### Q: 为什么搜索结果为空?
487
+
488
+ A: 可能的原因:
489
+ 1. 搜索关键词太具体或拼写错误
490
+ 2. 应用了过于严格的过滤条件
491
+ 3. 网络连接问题
492
+
493
+ ### Q: 全文下载失败怎么办?
494
+
495
+ A: 检查以下几点:
496
+ 1. 论文是否为开放获取(OA)
497
+ 2. OA URL 是否有效
498
+ 3. 网络连接是否正常
499
+ 4. 使用 `openalex_detect_fulltext` 工具检查可用性
500
+
501
+ ### Q: 如何提高 API 请求速率?
502
+
503
+ A: 注册并配置 OpenAlex API 密钥可以将速率从 5 请求/秒提高到 10 请求/秒。
504
+
505
+ ### Q: 缓存占用空间太大怎么办?
506
+
507
+ A: 使用 `openalex_cache_stats` 工具查看缓存大小,并定期清理 `cache/` 目录。
508
+
509
+ ## 许可证
510
+
511
+ ISC
512
+
513
+ ## 贡献
514
+
515
+ 欢迎提交 Issue 和 Pull Request!
516
+
517
+ ## 相关链接
518
+
519
+ - [OpenAlex API 文档](https://docs.openalex.org/)
520
+ - [MCP 协议规范](https://modelcontextprotocol.io/)
521
+ - [Claude Desktop 配置指南](https://docs.anthropic.com/claude/docs/mcp)
522
+
523
+ ---
524
+
525
+ Made with ❤️ for the AI research community
@@ -0,0 +1,77 @@
1
+ {
2
+ "_comment": "OpenAlex MCP Server Configuration Template",
3
+ "_description": "Copy this configuration to your Claude Desktop or other MCP client configuration file",
4
+
5
+ "_claude_desktop_config": {
6
+ "_location": "~/.claude/desktop_config.json (macOS/Linux) or %APPDATA%\\Claude\\desktop_config.json (Windows)",
7
+ "_instructions": "Add the 'openalex-mcp-server' entry to the 'mcpServers' section in your config file"
8
+ },
9
+
10
+ "example_configuration": {
11
+ "mcpServers": {
12
+ "openalex-mcp-server": {
13
+ "_comment_option1": "Option 1: Run directly with node (requires npm install)",
14
+ "command": "node",
15
+ "args": [
16
+ "E:\\Development\\openAlex-mcp\\src\\index.js"
17
+ ],
18
+ "env": {
19
+ "OPENALEX_API_KEY": "your-api-key-here",
20
+ "CACHE_ENABLED": "true",
21
+ "ABSTRACT_MODE": "quick"
22
+ },
23
+
24
+ "_comment_option2": "Option 2: Run with npx (no install required, but slower)",
25
+ "command": "npx",
26
+ "args": [
27
+ "-y",
28
+ "openalex-mcp-server"
29
+ ],
30
+ "env": {
31
+ "OPENALEX_API_KEY": "your-api-key-here",
32
+ "CACHE_ENABLED": "true",
33
+ "ABSTRACT_MODE": "quick"
34
+ }
35
+ }
36
+ }
37
+ },
38
+
39
+ "_environment_variables": {
40
+ "OPENALEX_API_KEY": {
41
+ "description": "Optional OpenAlex API key for higher rate limits",
42
+ "required": false,
43
+ "how_to_get": "Get your free API key at https://openalex.org/register"
44
+ },
45
+ "CACHE_ENABLED": {
46
+ "description": "Enable/disable local caching of paper metadata",
47
+ "type": "boolean",
48
+ "default": "true",
49
+ "options": ["true", "false"]
50
+ },
51
+ "ABSTRACT_MODE": {
52
+ "description": "Abstract processing mode (currently for future use)",
53
+ "type": "string",
54
+ "default": "quick",
55
+ "options": ["quick", "deep"]
56
+ }
57
+ },
58
+
59
+ "_complete_example_for_claude_desktop": {
60
+ "mcpServers": {
61
+ "openalex-mcp-server": {
62
+ "command": "node",
63
+ "args": [
64
+ "E:\\Development\\openAlex-mcp\\src\\index.js"
65
+ ],
66
+ "env": {
67
+ "OPENALEX_API_KEY": "",
68
+ "CACHE_ENABLED": "true"
69
+ }
70
+ },
71
+ "pubmed-mcp-server": {
72
+ "command": "npx",
73
+ "args": ["-y", "@your-org/pubmed-mcp"]
74
+ }
75
+ }
76
+ }
77
+ }