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.
- {article_mcp-0.2.0 → article_mcp-0.2.2}/CHANGELOG.md +37 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/CLAUDE.md +4 -3
- {article_mcp-0.2.0/src/article_mcp.egg-info → article_mcp-0.2.2}/PKG-INFO +2 -2
- {article_mcp-0.2.0 → article_mcp-0.2.2}/README.md +1 -1
- {article_mcp-0.2.0 → article_mcp-0.2.2}/pyproject.toml +1 -1
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/__init__.py +1 -1
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/cli.py +23 -11
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/resources/config_resources.py +2 -2
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/__init__.py +6 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2/src/article_mcp.egg-info}/PKG-INFO +2 -2
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp.egg-info/SOURCES.txt +5 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/__init__.py +1 -1
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/conftest.py +2 -1
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/test_relation_tools.py +5 -5
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_cli.py +1 -1
- article_mcp-0.2.2/tests/unit/test_cli_quality_services.py +140 -0
- article_mcp-0.2.2/tests/unit/test_cli_show_info.py +173 -0
- article_mcp-0.2.2/tests/unit/test_fastmcp_api_fix.py +165 -0
- article_mcp-0.2.2/tests/unit/test_performance_timer_naming.py +116 -0
- article_mcp-0.2.2/tests/unit/test_runtime_warning_fix.py +66 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_tool_core.py +22 -8
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/utils/test_helpers.py +9 -3
- {article_mcp-0.2.0 → article_mcp-0.2.2}/LICENSE +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/MANIFEST.in +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/glama.json +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/clean_pytest_cache.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/quick_test.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/run_all_tests.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/simulate_cherry_studio.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/sync_version.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_architecture_fixes.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_complete_literature_analysis.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_fastmcp_compliance.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_fixed_api_integration.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_module_imports.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_performance.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_pytest_suite.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_search_performance.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_simple_imports.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/scripts/test_working_functions.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/setup.cfg +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/__main__.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/middleware/__init__.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/middleware/logging.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/resources/__init__.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/resources/journal_resources.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/api_utils.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/arxiv_search.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/crossref_service.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/easyscholar_service.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/error_utils.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/europe_pmc.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/html_to_markdown.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/mcp_config.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/merged_results.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/openalex_metrics_service.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/openalex_service.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/pubmed_search.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/reference_service.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/services/similar_articles.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/__init__.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/__init__.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/article_tools.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/quality_tools.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/reference_tools.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/relation_tools.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp/tools/core/search_tools.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp.egg-info/dependency_links.txt +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp.egg-info/entry_points.txt +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp.egg-info/requires.txt +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/src/article_mcp.egg-info/top_level.txt +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/integration/test_mcp_integration.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/integration/test_real_api.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/integration/test_six_tools_integration.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/test_complete_http_client.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_arxiv_async.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_async_api_client.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_async_client_migration.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_crossref_openalex_async.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_pmc_fulltext_conversion.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/services/test_pubmed_async.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_crossref_service.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_easyscholar_service.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_merged_results.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_openalex_metrics_service.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_openalex_service.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_quality_tools_sorting.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_search_tools_improvements.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_services.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/test_six_tools.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_article_tools_format_param.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_article_tools_pmcid_normalization.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_article_tools_pmcid_only.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_cache_concurrency.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_closure_services.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_quality_async_pure.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_reference_tools_async.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_relation_tools_async.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_relation_uses_reference.py +0 -0
- {article_mcp-0.2.0 → article_mcp-0.2.2}/tests/unit/tools/test_search_tools_async_integration.py +0 -0
- {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
|
|
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
|
-
|
|
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
|
|
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.
|
|
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
|
[](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
|
[](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
|
|
|
@@ -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.
|
|
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 = {
|
|
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(" 参数:
|
|
269
|
-
print(" 标识符:
|
|
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(" 参数:
|
|
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(" 参数:
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
[](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
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import logging
|
|
5
5
|
|
|
6
|
-
from
|
|
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
|
|
36
|
-
from
|
|
37
|
-
from
|
|
38
|
-
from
|
|
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.
|
|
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
|