article-mcp 0.2.0__tar.gz → 0.2.2__tar.gz

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 (101) hide show
  1. {article_mcp-0.2.0 → article_mcp-0.2.2}/CHANGELOG.md +37 -0
  2. {article_mcp-0.2.0 → article_mcp-0.2.2}/CLAUDE.md +4 -3
  3. {article_mcp-0.2.0/src/article_mcp.egg-info → article_mcp-0.2.2}/PKG-INFO +2 -2
  4. {article_mcp-0.2.0 → article_mcp-0.2.2}/README.md +1 -1
  5. {article_mcp-0.2.0 → article_mcp-0.2.2}/pyproject.toml +1 -1
  6. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/__init__.py +1 -1
  7. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/cli.py +23 -11
  8. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/resources/config_resources.py +2 -2
  9. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/__init__.py +6 -0
  10. {article_mcp-0.2.0 → article_mcp-0.2.2/src/article_mcp.egg-info}/PKG-INFO +2 -2
  11. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp.egg-info/SOURCES.txt +5 -0
  12. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/__init__.py +1 -1
  13. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/conftest.py +2 -1
  14. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/test_relation_tools.py +5 -5
  15. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_cli.py +1 -1
  16. article_mcp-0.2.2/tests/unit/test_cli_quality_services.py +140 -0
  17. article_mcp-0.2.2/tests/unit/test_cli_show_info.py +173 -0
  18. article_mcp-0.2.2/tests/unit/test_fastmcp_api_fix.py +165 -0
  19. article_mcp-0.2.2/tests/unit/test_performance_timer_naming.py +116 -0
  20. article_mcp-0.2.2/tests/unit/test_runtime_warning_fix.py +66 -0
  21. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_tool_core.py +22 -8
  22. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/utils/test_helpers.py +9 -3
  23. {article_mcp-0.2.0 → article_mcp-0.2.2}/LICENSE +0 -0
  24. {article_mcp-0.2.0 → article_mcp-0.2.2}/MANIFEST.in +0 -0
  25. {article_mcp-0.2.0 → article_mcp-0.2.2}/glama.json +0 -0
  26. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/clean_pytest_cache.py +0 -0
  27. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/quick_test.py +0 -0
  28. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/run_all_tests.py +0 -0
  29. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/simulate_cherry_studio.py +0 -0
  30. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/sync_version.py +0 -0
  31. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_architecture_fixes.py +0 -0
  32. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_complete_literature_analysis.py +0 -0
  33. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_fastmcp_compliance.py +0 -0
  34. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_fixed_api_integration.py +0 -0
  35. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_module_imports.py +0 -0
  36. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_performance.py +0 -0
  37. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_pytest_suite.py +0 -0
  38. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_search_performance.py +0 -0
  39. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_simple_imports.py +0 -0
  40. {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_working_functions.py +0 -0
  41. {article_mcp-0.2.0 → article_mcp-0.2.2}/setup.cfg +0 -0
  42. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/__main__.py +0 -0
  43. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/middleware/__init__.py +0 -0
  44. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/middleware/logging.py +0 -0
  45. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/resources/__init__.py +0 -0
  46. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/resources/journal_resources.py +0 -0
  47. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/api_utils.py +0 -0
  48. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/arxiv_search.py +0 -0
  49. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/crossref_service.py +0 -0
  50. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/easyscholar_service.py +0 -0
  51. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/error_utils.py +0 -0
  52. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/europe_pmc.py +0 -0
  53. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/html_to_markdown.py +0 -0
  54. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/mcp_config.py +0 -0
  55. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/merged_results.py +0 -0
  56. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/openalex_metrics_service.py +0 -0
  57. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/openalex_service.py +0 -0
  58. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/pubmed_search.py +0 -0
  59. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/reference_service.py +0 -0
  60. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/similar_articles.py +0 -0
  61. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/__init__.py +0 -0
  62. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/__init__.py +0 -0
  63. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/article_tools.py +0 -0
  64. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/quality_tools.py +0 -0
  65. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/reference_tools.py +0 -0
  66. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/relation_tools.py +0 -0
  67. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/search_tools.py +0 -0
  68. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp.egg-info/dependency_links.txt +0 -0
  69. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp.egg-info/entry_points.txt +0 -0
  70. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp.egg-info/requires.txt +0 -0
  71. {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp.egg-info/top_level.txt +0 -0
  72. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/integration/test_mcp_integration.py +0 -0
  73. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/integration/test_real_api.py +0 -0
  74. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/integration/test_six_tools_integration.py +0 -0
  75. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/test_complete_http_client.py +0 -0
  76. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_arxiv_async.py +0 -0
  77. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_async_api_client.py +0 -0
  78. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_async_client_migration.py +0 -0
  79. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_crossref_openalex_async.py +0 -0
  80. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_pmc_fulltext_conversion.py +0 -0
  81. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_pubmed_async.py +0 -0
  82. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_crossref_service.py +0 -0
  83. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_easyscholar_service.py +0 -0
  84. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_merged_results.py +0 -0
  85. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_openalex_metrics_service.py +0 -0
  86. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_openalex_service.py +0 -0
  87. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_quality_tools_sorting.py +0 -0
  88. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_search_tools_improvements.py +0 -0
  89. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_services.py +0 -0
  90. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_six_tools.py +0 -0
  91. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_article_tools_format_param.py +0 -0
  92. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_article_tools_pmcid_normalization.py +0 -0
  93. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_article_tools_pmcid_only.py +0 -0
  94. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_cache_concurrency.py +0 -0
  95. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_closure_services.py +0 -0
  96. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_quality_async_pure.py +0 -0
  97. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_reference_tools_async.py +0 -0
  98. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_relation_tools_async.py +0 -0
  99. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_relation_uses_reference.py +0 -0
  100. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_search_tools_async_integration.py +0 -0
  101. {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/verification/test_fastmcp_async.py +0 -0
@@ -1,5 +1,42 @@
1
1
  # 版本更新说明
2
2
 
3
+ ## v0.2.2 (2025-01-04) - 文档修正与代码质量提升
4
+
5
+ ### 文档修正 📚
6
+ - **CLAUDE.md**: 更正核心工具数量从 6 个改为 5 个
7
+ - 移除不存在的 `export_batch_results` (batch_tools.py)
8
+ - 添加 `test_six_tools.py` 命名遗留问题的说明
9
+ - **README.md**: 更新 FastMCP 版本描述为 v2.13+
10
+
11
+ ### 代码质量改进 🔧
12
+ - **FastMCP API 适配**: 修复 `.settings` 废弃警告,使用新的 API
13
+ - **性能计时器重构**: 重命名 `PerformanceTimer` 为 `PerfTimer`,提升代码一致性
14
+ - **服务依赖注入**: 修复 `quality_tools` 服务依赖注入问题
15
+ - **工具参数描述**: 修正 `show_info()` 工具参数描述(TDD 完成)
16
+
17
+ ### 测试改进 ✅
18
+ - 添加 `PerfTimer` 类命名问题的测试
19
+ - 添加 `RuntimeWarning` 协程未等待问题的测试
20
+ - 修复 `test_relation_tools.py` 中的导入路径问题
21
+ - 更新测试文件中的 `quality_services` Mock 定义以保持一致性
22
+ - 添加 `quality_tools` 服务依赖注入的失败测试
23
+
24
+ ### 提交记录
25
+ ```
26
+ 0b80ad2 docs: 修正文档与代码一致性
27
+ e44f44a refactor: 修复 FastMCP .settings 废弃警告
28
+ 4520411 refactor: 重命名 PerformanceTimer 为 PerfTimer
29
+ dc752c5 test: 添加 PerformanceTimer 类命名问题的测试
30
+ c3e6af1 fix: 修复 test_relation_tools.py 中的导入路径问题
31
+ 77412e2 test: 添加 RuntimeWarning 协程未等待问题的测试
32
+ 4986a03 test: 更新测试文件中的 quality_services Mock 定义以保持一致性
33
+ 286ee93 feat: 修复 quality_tools 服务依赖注入问题
34
+ 0c875f0 test: 添加 quality_tools 服务依赖注入的失败测试
35
+ 461998a feat: 修正 show_info() 工具参数描述(TDD 完成)
36
+ ```
37
+
38
+ ---
39
+
3
40
  ## v0.2.0 (2024-12-27) - 异步架构重大升级 🚀
4
41
 
5
42
  ### 重大变更 - 纯异步架构迁移
@@ -17,7 +17,7 @@ The project follows a standard Python src layout with layered architecture:
17
17
  - **Resource Layer** (`resources/`): MCP resources for config and journal data
18
18
  - **Compatibility Layer** (`main.py`): Backward-compatible CLI entry point
19
19
 
20
- ### The 6 Core Tools
20
+ ### The 5 Core Tools
21
21
 
22
22
  All tools are registered in `cli.py:create_mcp_server()` with their respective service dependencies:
23
23
 
@@ -26,7 +26,8 @@ All tools are registered in `cli.py:create_mcp_server()` with their respective s
26
26
  3. **get_references** (`tools/core/reference_tools.py`): Reference list retrieval
27
27
  4. **get_literature_relations** (`tools/core/relation_tools.py`): Citation relationship analysis
28
28
  5. **get_journal_quality** (`tools/core/quality_tools.py`): Journal quality assessment
29
- 6. **export_batch_results** (`tools/core/batch_tools.py`): Batch result export
29
+
30
+ Note: The test file `test_six_tools.py` is a legacy name - it tests these 5 core tools.
30
31
 
31
32
  ### Service Injection Pattern
32
33
 
@@ -99,7 +100,7 @@ pytest # Run all tests
99
100
  pytest tests/unit/ # Unit tests only
100
101
  pytest -m integration # Integration tests only
101
102
  pytest -m "not slow" # Exclude slow tests
102
- pytest tests/unit/test_six_tools.py # Test all 6 core tools
103
+ pytest tests/unit/test_six_tools.py # Test all 5 core tools (legacy filename)
103
104
  ```
104
105
 
105
106
  ### Code Quality
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: article-mcp
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Article MCP文献搜索服务器 - 基于Europe PMC、arXiv等多个数据源的学术文献搜索工具
5
5
  Author-email: gqy20 <qingyu_ge@foxmail.com>
6
6
  License-Expression: MIT
@@ -33,7 +33,7 @@ Dynamic: license-file
33
33
 
34
34
  [![MCP Server](https://glama.ai/mcp/servers/@gqy20/article-mcp/badge)](https://glama.ai/mcp/servers/@gqy20/article-mcp)
35
35
 
36
- 基于 FastMCP v2 的异步文献搜索工具,集成 Europe PMC、PubMed、arXiv、CrossRef、OpenAlex 等数据源。
36
+ 基于 FastMCP v2.13+ 的异步文献搜索工具,集成 Europe PMC、PubMed、arXiv、CrossRef、OpenAlex 等数据源。
37
37
 
38
38
  ## 快速开始
39
39
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![MCP Server](https://glama.ai/mcp/servers/@gqy20/article-mcp/badge)](https://glama.ai/mcp/servers/@gqy20/article-mcp)
4
4
 
5
- 基于 FastMCP v2 的异步文献搜索工具,集成 Europe PMC、PubMed、arXiv、CrossRef、OpenAlex 等数据源。
5
+ 基于 FastMCP v2.13+ 的异步文献搜索工具,集成 Europe PMC、PubMed、arXiv、CrossRef、OpenAlex 等数据源。
6
6
 
7
7
  ## 快速开始
8
8
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "article-mcp"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "Article MCP文献搜索服务器 - 基于Europe PMC、arXiv等多个数据源的学术文献搜索工具"
5
5
  authors = [
6
6
  {name = "gqy20", email = "qingyu_ge@foxmail.com"}
@@ -22,7 +22,7 @@ from typing import Any
22
22
  # 设置编码环境,确保emoji字符正确处理
23
23
  os.environ["PYTHONIOENCODING"] = "utf-8"
24
24
 
25
- __version__ = "0.2.0"
25
+ __version__ = "0.2.2"
26
26
  __author__ = "gqy20"
27
27
  __email__ = "qingyu_ge@foxmail.com"
28
28
 
@@ -40,9 +40,11 @@ def create_mcp_server() -> "FastMCP":
40
40
  from .services.crossref_service import CrossRefService
41
41
 
42
42
  # 导入新架构服务(使用新的包结构)
43
+ from .services.easyscholar_service import create_easyscholar_service
43
44
  from .services.europe_pmc import create_europe_pmc_service
44
45
 
45
46
  # from .services.literature_relation_service import create_literature_relation_service
47
+ from .services.openalex_metrics_service import create_openalex_metrics_service
46
48
  from .services.openalex_service import OpenAlexService
47
49
  from .services.pubmed_search import create_pubmed_service
48
50
  from .services.reference_service import create_unified_reference_service
@@ -55,7 +57,7 @@ def create_mcp_server() -> "FastMCP":
55
57
  from .tools.core.search_tools import register_search_tools
56
58
 
57
59
  # 创建 MCP 服务器实例
58
- mcp = FastMCP("Article MCP Server", version="0.2.0")
60
+ mcp = FastMCP("Article MCP Server", version="0.2.2")
59
61
 
60
62
  # 创建服务实例
61
63
  logger = logging.getLogger(__name__)
@@ -81,6 +83,8 @@ def create_mcp_server() -> "FastMCP":
81
83
  openalex_service = OpenAlexService(logger)
82
84
  arxiv_service = create_arxiv_service(logger)
83
85
  reference_service = create_unified_reference_service(logger)
86
+ easyscholar_service = create_easyscholar_service(logger)
87
+ openalex_metrics_service = create_openalex_metrics_service(logger)
84
88
  # literature_relation_service 在关系工具中使用,不需要单独创建
85
89
 
86
90
  # 注册新架构核心工具
@@ -123,7 +127,10 @@ def create_mcp_server() -> "FastMCP":
123
127
  register_relation_tools(mcp, relation_services, logger)
124
128
 
125
129
  # 工具5: 期刊质量评估工具
126
- quality_services = {"pubmed": pubmed_service}
130
+ quality_services = {
131
+ "easyscholar": easyscholar_service,
132
+ "openalex": openalex_metrics_service,
133
+ }
127
134
  register_quality_tools(mcp, quality_services, logger)
128
135
 
129
136
  return mcp
@@ -264,11 +271,11 @@ def show_info() -> None:
264
271
  print(" 特点:自动去重、智能排序、透明数据源标识")
265
272
  print(" 适用:文献检索、复杂查询、高性能需求")
266
273
  print("2. get_article_details")
267
- print(" 功能:统一文献详情获取工具")
268
- print(" 参数:identifier, id_type, sources, include_quality_metrics")
269
- print(" 标识符:DOI, PMID, PMCID, arXiv ID")
270
- print(" 特点:多源数据合并、自动类型识别、可选质量指标")
271
- print(" 适用:文献详情查询、大规模数据处理")
274
+ print(" 功能:获取文献全文内容(支持参数容错自动修正)")
275
+ print(" 参数:pmcid, sections, format")
276
+ print(" 标识符:PMCID(支持字符串化数组自动解析)")
277
+ print(" 特点:自动修正参数格式、sections 自动转数组")
278
+ print(" 适用:文献全文获取、指定章节提取")
272
279
  print("3. get_references")
273
280
  print(" 功能:参考文献获取工具")
274
281
  print(" 参数:identifier, id_type, sources, max_results, include_metadata")
@@ -277,16 +284,21 @@ def show_info() -> None:
277
284
  print(" 适用:参考文献获取、文献数据库构建")
278
285
  print("4. get_literature_relations")
279
286
  print(" 功能:文献关系分析工具")
280
- print(" 参数:identifiers, relation_types, max_depth, max_results")
287
+ print(" 参数:identifier, relation_types, max_results")
281
288
  print(" 关系类型:参考文献、相似文献、引用文献、合作网络")
282
289
  print(" 特点:网络分析、社区检测、可视化数据")
283
290
  print(" 适用:文献关联分析、学术研究综述、文献网络构建")
284
291
  print("5. get_journal_quality")
285
292
  print(" 功能:期刊质量评估工具")
286
- print(" 参数:journals, operation, evaluation_criteria, include_metrics")
287
- print(" 操作类型:质量评估、领域排名、批量评估")
288
- print(" 特点:EasyScholar集成、本地缓存、多维度评估")
293
+ print(" 参数:journal_name, include_metrics")
294
+ print(" 数据源:EasyScholar, OpenAlex")
295
+ print(" 特点:EasyScholar 集成、OpenAlex 指标、本地缓存")
289
296
  print(" 适用:期刊质量评估、投稿期刊选择、文献质量筛选")
297
+ safe_print("")
298
+ safe_print("[参数容错特性]:")
299
+ safe_print('- pmcid 支持字符串化数组自动解析:\'["PMC1", "PMC2"]\' -> ["PMC1", "PMC2"]')
300
+ safe_print("- sections 支持字符串自动转数组:'methods' -> ['methods']")
301
+ safe_print("- 提供友好的参数格式错误提示")
290
302
  print("\n使用 'python -m article_mcp --help' 查看更多选项")
291
303
 
292
304
 
@@ -12,7 +12,7 @@ def register_config_resources(mcp: FastMCP) -> None:
12
12
  @mcp.resource("config://version")
13
13
  def get_version() -> str:
14
14
  """获取服务器版本信息"""
15
- return "0.2.0"
15
+ return "0.2.2"
16
16
 
17
17
  @mcp.resource("config://status")
18
18
  def get_system_status() -> dict[str, Any]:
@@ -20,7 +20,7 @@ def register_config_resources(mcp: FastMCP) -> None:
20
20
  return {
21
21
  "status": "running",
22
22
  "server": "Article MCP Server",
23
- "version": "0.2.0",
23
+ "version": "0.2.2",
24
24
  "timestamp": time.time(),
25
25
  "uptime": "N/A", # 可以后续实现
26
26
  "supported_data_sources": ["europe_pmc", "pubmed", "arxiv", "crossref", "openalex"],
@@ -8,6 +8,10 @@ from .crossref_service import CrossRefService
8
8
  # 导入核心服务
9
9
  from .easyscholar_service import EasyScholarService, create_easyscholar_service
10
10
  from .europe_pmc import EuropePMCService, create_europe_pmc_service
11
+ from .openalex_metrics_service import (
12
+ OpenAlexMetricsService,
13
+ create_openalex_metrics_service,
14
+ )
11
15
  from .openalex_service import OpenAlexService
12
16
  from .pubmed_search import create_pubmed_service
13
17
  from .reference_service import (
@@ -21,6 +25,7 @@ __all__ = [
21
25
  "EuropePMCService",
22
26
  "CrossRefService",
23
27
  "OpenAlexService",
28
+ "OpenAlexMetricsService",
24
29
  "UnifiedReferenceService",
25
30
  "EasyScholarService",
26
31
  # 服务创建函数
@@ -29,6 +34,7 @@ __all__ = [
29
34
  "create_unified_reference_service",
30
35
  "create_arxiv_service",
31
36
  "create_easyscholar_service",
37
+ "create_openalex_metrics_service",
32
38
  # 工具函数
33
39
  "search_arxiv",
34
40
  "get_similar_articles_by_doi",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: article-mcp
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Article MCP文献搜索服务器 - 基于Europe PMC、arXiv等多个数据源的学术文献搜索工具
5
5
  Author-email: gqy20 <qingyu_ge@foxmail.com>
6
6
  License-Expression: MIT
@@ -33,7 +33,7 @@ Dynamic: license-file
33
33
 
34
34
  [![MCP Server](https://glama.ai/mcp/servers/@gqy20/article-mcp/badge)](https://glama.ai/mcp/servers/@gqy20/article-mcp)
35
35
 
36
- 基于 FastMCP v2 的异步文献搜索工具,集成 Europe PMC、PubMed、arXiv、CrossRef、OpenAlex 等数据源。
36
+ 基于 FastMCP v2.13+ 的异步文献搜索工具,集成 Europe PMC、PubMed、arXiv、CrossRef、OpenAlex 等数据源。
37
37
 
38
38
  ## 快速开始
39
39
 
@@ -64,12 +64,17 @@ tests/integration/test_mcp_integration.py
64
64
  tests/integration/test_real_api.py
65
65
  tests/integration/test_six_tools_integration.py
66
66
  tests/unit/test_cli.py
67
+ tests/unit/test_cli_quality_services.py
68
+ tests/unit/test_cli_show_info.py
67
69
  tests/unit/test_crossref_service.py
68
70
  tests/unit/test_easyscholar_service.py
71
+ tests/unit/test_fastmcp_api_fix.py
69
72
  tests/unit/test_merged_results.py
70
73
  tests/unit/test_openalex_metrics_service.py
71
74
  tests/unit/test_openalex_service.py
75
+ tests/unit/test_performance_timer_naming.py
72
76
  tests/unit/test_quality_tools_sorting.py
77
+ tests/unit/test_runtime_warning_fix.py
73
78
  tests/unit/test_search_tools_improvements.py
74
79
  tests/unit/test_services.py
75
80
  tests/unit/test_six_tools.py
@@ -1,3 +1,3 @@
1
1
  """Article MCP 测试套件"""
2
2
 
3
- __version__ = "0.2.0"
3
+ __version__ = "0.2.1"
@@ -277,7 +277,8 @@ def six_tool_services(logger):
277
277
  "pubmed": Mock(),
278
278
  },
279
279
  "quality_services": {
280
- "pubmed": Mock(),
280
+ "easyscholar": Mock(),
281
+ "openalex": Mock(),
281
282
  },
282
283
  "batch_services": {
283
284
  "europe_pmc": Mock(),
@@ -3,7 +3,7 @@
3
3
 
4
4
  import logging
5
5
 
6
- from src.article_mcp.tools.core import relation_tools
6
+ from article_mcp.tools.core import relation_tools
7
7
 
8
8
  # 设置日志
9
9
  logging.basicConfig(level=logging.INFO)
@@ -32,10 +32,10 @@ def test_relation_tools():
32
32
  # 创建服务实例
33
33
 
34
34
  # 获取实际的服务实例
35
- from src.article_mcp.services.crossref_service import CrossRefService
36
- from src.article_mcp.services.europe_pmc import create_europe_pmc_service
37
- from src.article_mcp.services.openalex_service import OpenAlexService
38
- from src.article_mcp.services.pubmed_search import create_pubmed_service
35
+ from article_mcp.services.crossref_service import CrossRefService
36
+ from article_mcp.services.europe_pmc import create_europe_pmc_service
37
+ from article_mcp.services.openalex_service import OpenAlexService
38
+ from article_mcp.services.pubmed_search import create_pubmed_service
39
39
 
40
40
  # 初始化服务
41
41
  crossref_service = CrossRefService(logger)
@@ -52,7 +52,7 @@ class TestCLIBasics:
52
52
  server = create_mcp_server()
53
53
 
54
54
  # 验证服务器创建
55
- mock_fastmcp.assert_called_once_with("Article MCP Server", version="0.2.0")
55
+ mock_fastmcp.assert_called_once_with("Article MCP Server", version="0.2.1")
56
56
  assert server is not None
57
57
 
58
58
  @pytest.mark.unit
@@ -0,0 +1,140 @@
1
+ """测试 cli.py 中 quality_tools 服务依赖注入是否完整
2
+
3
+ 测试目标:验证 create_mcp_server() 正确注入了 quality_tools 所需的服务
4
+
5
+ 问题分析:
6
+ - quality_tools.py 期望 services 包含 "easyscholar" 和 "openalex" 键
7
+ - cli.py:126 只传入了 {"pubmed": pubmed_service}
8
+ - 导致运行时 KeyError: 'easyscholar'
9
+ """
10
+
11
+ import logging
12
+ from unittest.mock import AsyncMock, Mock, patch
13
+
14
+ import pytest
15
+
16
+
17
+ @pytest.mark.unit
18
+ class TestCLICliQualityServicesInjection:
19
+ """测试 CLI 中 quality_tools 服务注入"""
20
+
21
+ def test_create_mcp_server_should_inject_easyscholar_service(self):
22
+ """验证:quality_tools 需要的服务字典结构"""
23
+
24
+ # Arrange: 准备模拟服务
25
+ mock_easyscholar = Mock()
26
+ mock_openalex_metrics = Mock()
27
+
28
+ # Act: 构建正确的服务字典(这应该是 cli.py 中应该传入的)
29
+ quality_services = {
30
+ "easyscholar": mock_easyscholar,
31
+ "openalex": mock_openalex_metrics,
32
+ }
33
+
34
+ # Assert: 验证服务字典包含必需的键
35
+ assert "easyscholar" in quality_services, (
36
+ "quality_services 必须包含 'easyscholar' 键,否则 quality_tools 会报 KeyError"
37
+ )
38
+ assert "openalex" in quality_services, (
39
+ "quality_services 必须包含 'openalex' 键,否则 quality_tools 会报 KeyError"
40
+ )
41
+
42
+ def test_quality_tools_requires_easyscholar_and_openalex(self):
43
+ """验证:quality_tools 运行时需要 easyscholar 和 openalex 服务"""
44
+
45
+ # Arrange: 模拟不完整的服务注入(当前 cli.py 的问题)
46
+ incomplete_services = {
47
+ "pubmed": Mock(), # ❌ 缺少 easyscholar 和 openalex
48
+ }
49
+ logger = logging.getLogger(__name__)
50
+
51
+ # Act & Assert: 尝试访问服务应该抛出 KeyError
52
+ with pytest.raises(KeyError, match="'easyscholar'"):
53
+ # 这是 quality_tools.py:330 的实际代码
54
+ _ = incomplete_services["easyscholar"]
55
+
56
+ @pytest.mark.asyncio
57
+ async def test_single_journal_quality_with_correct_services(self):
58
+ """验证:使用正确的服务字典,_single_journal_quality 可以正常调用"""
59
+
60
+ # Arrange: 创建正确的模拟服务
61
+ async def mock_easyscholar_get_quality(journal_name):
62
+ return {
63
+ "success": True,
64
+ "journal_name": journal_name,
65
+ "data_source": "easyscholar",
66
+ "quality_metrics": {
67
+ "impact_factor": 5.0,
68
+ "quartile": "Q1",
69
+ },
70
+ "ranking_info": {},
71
+ }
72
+
73
+ async def mock_openalex_enhance(result, use_cache):
74
+ result["quality_metrics"]["h_index"] = 400
75
+ return result
76
+
77
+ correct_services = {
78
+ "easyscholar": Mock(
79
+ get_journal_quality=AsyncMock(side_effect=mock_easyscholar_get_quality)
80
+ ),
81
+ "openalex": Mock(enhance_quality_result=AsyncMock(side_effect=mock_openalex_enhance)),
82
+ }
83
+
84
+ # Act: 调用 _single_journal_quality
85
+ from article_mcp.tools.core.quality_tools import _single_journal_quality
86
+
87
+ result = await _single_journal_quality(
88
+ journal_name="Nature",
89
+ include_metrics=["impact_factor", "quartile"],
90
+ use_cache=False,
91
+ services=correct_services,
92
+ logger=Mock(),
93
+ )
94
+
95
+ # Assert: 验证成功调用
96
+ assert result["success"] is True
97
+ assert result["journal_name"] == "Nature"
98
+ assert "quality_metrics" in result
99
+ assert "h_index" in result["quality_metrics"]
100
+
101
+ @pytest.mark.asyncio
102
+ async def test_single_journal_quality_with_incomplete_services_fails(self):
103
+ """验证:使用不完整的服务字典会触发 KeyError"""
104
+
105
+ # Arrange: 使用当前 cli.py 的不完整注入
106
+ incomplete_services = {
107
+ "pubmed": Mock(), # ❌ 只有 pubmed
108
+ }
109
+
110
+ # Act & Assert: 调用 _single_journal_quality 应该失败
111
+ from article_mcp.tools.core.quality_tools import _single_journal_quality
112
+
113
+ result = await _single_journal_quality(
114
+ journal_name="Nature",
115
+ include_metrics=["impact_factor"],
116
+ use_cache=False,
117
+ services=incomplete_services,
118
+ logger=Mock(),
119
+ )
120
+
121
+ # Assert: 验证失败并返回正确的错误信息
122
+ assert result["success"] is False
123
+ assert "'easyscholar'" in result["error"] or "easyscholar" in str(result["error"])
124
+
125
+
126
+ @pytest.mark.unit
127
+ class TestServicesInitExports:
128
+ """测试 services/__init__.py 导出是否完整"""
129
+
130
+ def test_services_init_exports_easyscholar(self):
131
+ """验证:services/__init__.py 导出了 create_easyscholar_service"""
132
+ from article_mcp.services import create_easyscholar_service
133
+
134
+ assert callable(create_easyscholar_service)
135
+
136
+ def test_services_init_exports_openalex_metrics(self):
137
+ """验证:services/__init__.py 导出了 create_openalex_metrics_service"""
138
+ from article_mcp.services import create_openalex_metrics_service
139
+
140
+ assert callable(create_openalex_metrics_service)
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env python3
2
+ """CLI show_info 输出验证测试
3
+ 验证 show_info() 输出与实际工具签名一致
4
+ """
5
+
6
+ # 添加src目录到Python路径
7
+ import sys
8
+ from pathlib import Path
9
+
10
+ project_root = Path(__file__).parent.parent
11
+ src_path = project_root / "src"
12
+ if str(src_path) not in sys.path:
13
+ sys.path.insert(0, str(src_path))
14
+
15
+ import pytest # noqa: E402
16
+
17
+ from article_mcp.cli import show_info # noqa: E402
18
+
19
+
20
+ class TestShowInfoOutput:
21
+ """show_info() 输出验证测试"""
22
+
23
+ @pytest.mark.unit
24
+ def test_show_info_displays_five_tools(self, capsys):
25
+ """测试 show_info 显示5个核心工具"""
26
+ show_info()
27
+ captured = capsys.readouterr()
28
+
29
+ # 验证5个工具都存在
30
+ assert "search_literature" in captured.out
31
+ assert "get_article_details" in captured.out
32
+ assert "get_references" in captured.out
33
+ assert "get_literature_relations" in captured.out
34
+ assert "get_journal_quality" in captured.out
35
+
36
+ @pytest.mark.unit
37
+ def test_get_article_details_params_correct(self, capsys):
38
+ """测试 get_article_details 参数描述正确
39
+
40
+ 实际签名: async def get_article_details_async(
41
+ pmcid: str | list[str],
42
+ sections: str | list[str] | None = None,
43
+ format: str = "markdown",
44
+ )
45
+ """
46
+ show_info()
47
+ captured = capsys.readouterr()
48
+
49
+ # 提取 get_article_details 部分
50
+ lines = captured.out.split("\n")
51
+ in_article_details = False
52
+ param_line = None
53
+
54
+ for line in lines:
55
+ if "2. get_article_details" in line:
56
+ in_article_details = True
57
+ elif in_article_details and "参数:" in line:
58
+ param_line = line
59
+ break
60
+ elif in_article_details and "3." in line:
61
+ break
62
+
63
+ assert param_line is not None, "未找到 get_article_details 参数行"
64
+
65
+ # 验证参数:应该包含 pmcid, sections, format
66
+ # 不应该包含 identifier, id_type, sources, include_quality_metrics
67
+ assert "pmcid" in param_line, f"参数行应包含 pmcid,实际: {param_line}"
68
+ assert "sections" in param_line, f"参数行应包含 sections,实际: {param_line}"
69
+ assert "format" in param_line, f"参数行应包含 format,实际: {param_line}"
70
+
71
+ # 验证不包含旧的错误参数
72
+ assert "identifier" not in param_line.lower() or "pmcid" in param_line
73
+ assert "id_type" not in param_line.lower()
74
+
75
+ @pytest.mark.unit
76
+ def test_get_literature_relations_params_correct(self, capsys):
77
+ """测试 get_literature_relations 参数描述正确
78
+
79
+ 实际签名: async def get_literature_relations(
80
+ identifier: str,
81
+ id_type: str = "auto",
82
+ relation_types: list[str] | None = None,
83
+ max_results: int = 20,
84
+ sources: list[str] | None = None,
85
+ )
86
+ """
87
+ show_info()
88
+ captured = capsys.readouterr()
89
+
90
+ # 提取 get_literature_relations 部分
91
+ lines = captured.out.split("\n")
92
+ in_relations = False
93
+ param_line = None
94
+
95
+ for line in lines:
96
+ if "4. get_literature_relations" in line:
97
+ in_relations = True
98
+ elif in_relations and "参数:" in line:
99
+ param_line = line
100
+ break
101
+ elif in_relations and "5." in line:
102
+ break
103
+
104
+ assert param_line is not None, "未找到 get_literature_relations 参数行"
105
+
106
+ # 验证关键参数存在
107
+ assert "identifier" in param_line, f"参数行应包含 identifier,实际: {param_line}"
108
+ assert "relation_types" in param_line, f"参数行应包含 relation_types,实际: {param_line}"
109
+
110
+ # 不应该有 max_depth
111
+ assert "max_depth" not in param_line, f"参数行不应包含 max_depth,实际: {param_line}"
112
+
113
+ @pytest.mark.unit
114
+ def test_get_journal_quality_params_correct(self, capsys):
115
+ """测试 get_journal_quality 参数描述正确
116
+
117
+ 实际签名: async def get_journal_quality_async(
118
+ journal_name: str,
119
+ include_metrics: list[str] | None = None,
120
+ use_cache: bool = True,
121
+ )
122
+ """
123
+ show_info()
124
+ captured = capsys.readouterr()
125
+
126
+ # 提取 get_journal_quality 部分
127
+ lines = captured.out.split("\n")
128
+ in_quality = False
129
+ param_line = None
130
+
131
+ for line in lines:
132
+ if "5. get_journal_quality" in line:
133
+ in_quality = True
134
+ elif in_quality and "参数:" in line:
135
+ param_line = line
136
+ break
137
+
138
+ assert param_line is not None, "未找到 get_journal_quality 参数行"
139
+
140
+ # 验证关键参数存在
141
+ assert "journal_name" in param_line, f"参数行应包含 journal_name,实际: {param_line}"
142
+ assert "include_metrics" in param_line, f"参数行应包含 include_metrics,实际: {param_line}"
143
+
144
+ # 不应该有旧的参数
145
+ assert "journals" not in param_line, f"参数行不应包含 journals,实际: {param_line}"
146
+ assert "operation" not in param_line, f"参数行不应包含 operation,实际: {param_line}"
147
+ assert "evaluation_criteria" not in param_line, (
148
+ f"参数行不应包含 evaluation_criteria,实际: {param_line}"
149
+ )
150
+
151
+ @pytest.mark.unit
152
+ def test_show_info_mentions_parameter_tolerance(self, capsys):
153
+ """测试 show_info 提及参数容错特性"""
154
+ show_info()
155
+ captured = capsys.readouterr()
156
+
157
+ # 验证参数容错特性被提及
158
+ assert "参数容错" in captured.out or "自动修正" in captured.out, (
159
+ "show_info 应该提及参数容错特性"
160
+ )
161
+
162
+ @pytest.mark.unit
163
+ def test_show_info_displays_data_sources(self, capsys):
164
+ """测试 show_info 显示数据源信息"""
165
+ show_info()
166
+ captured = capsys.readouterr()
167
+
168
+ # 验证主要数据源被提及
169
+ assert "Europe PMC" in captured.out or "europe_pmc" in captured.out
170
+ assert "PubMed" in captured.out or "pubmed" in captured.out
171
+ assert "arXiv" in captured.out or "arxiv" in captured.out
172
+ assert "CrossRef" in captured.out or "crossref" in captured.out
173
+ assert "OpenAlex" in captured.out or "openalex" in captured.out