一个用于作者消歧和学术研究的简化型模型上下文协议(MCP)服务器,使用OpenAlex.org API。特别设计用于具有优化数据结构和增强功能的AI代理。
详细的安装说明,请参见INSTALL.md。
克隆仓库:
git clone https://github.com/drAbreu/alex-mcp.git
cd alex-mcp
创建虚拟环境:
python3 -m venv venv
source venv/bin/activate # 在Windows上:venv\Scripts\activate
安装包:
pip install -e .
配置环境:
export OPENALEX_MAILTO=your-email@domain.com
运行服务器:
./run_alex_mcp.sh
# 或,如果作为CLI工具安装:
alex-mcp
添加到您的Claude Desktop配置文件中:
{
"mcpServers": {
"alex-mcp": {
"command": "/path/to/alex-mcp/run_alex_mcp.sh",
"env": {
"OPENALEX_MAILTO": "your-email@domain.com"
}
}
}
}
替换/path/to/alex-mcp为您系统上的实际仓库路径。
您可以在OpenAI代理工作流中使用此MCP服务器,通过agents.mcp.MCPServerStdio接口加载:
from agents.mcp import MCPServerStdio
async with MCPServerStdio(
name="OpenAlex MCP For Author disambiguation and works",
cache_tools_list=True,
params={
"command": "uvx",
"args": [
"--from", "git+https://github.com/drAbreu/alex-mcp.git@4.1.0",
"alex-mcp"
],
"env": {
"OPENALEX_MAILTO": "your-email@domain.com"
}
},
client_session_timeout_seconds=1
) as alex_mcp:
await alex_mcp.connect()
tools = await alex_mcp.list_tools()
print(f"可用工具: {[tool.name for tool in tools]}")
此MCP服务器专门针对学术研究工作流程进行了优化:
# 针对学术研究工作流程优化
from alex_agent import run_author_research
# 带有简化数据的增强功能
result = await run_author_research(
"查找在EMBO发表近期论文的J. Abreu"
)
# 清晰、结构化的输出以供AI处理
print(f"成功: {result['workflow_metadata']['success']}")
print(f"质量: {result['research_result']['metadata']['result_analysis']['quality_score']}/100")
# 标准启动
uvx --from git+https://github.com/drAbreu/alex-mcp.git@4.1.0 alex-mcp
# 带有环境变量
OPENALEX_MAILTO=your-email@domain.com uvx --from git+https://github.com/drAbreu/alex-mcp.git@4.1.0 alex-mcp
使用OpenAlex自动完成功能获取多个作者候选人以进行智能消歧。
参数:
name(必需):要搜索的作者姓名(例如,“James Briscoe”,“M. Ralser”)context(可选):消歧上下文(例如,“Francis Crick Institute发育生物学”)limit(可选):最大候选人数量(1-10,默认:5)关键特性:
简化输出:
{
"query": "James Briscoe",
"context": "Francis Crick Institute",
"total_candidates": 3,
"candidates": [
{
"openalex_id": "https://openalex.org/A5019391436",
"display_name": "James Briscoe",
"institution_hint": "The Francis Crick Institute, UK",
"works_count": 415,
"cited_by_count": 24623,
"external_id": "https://orcid.org/0000-0002-1020-5240"
}
]
}
使用模式:
# 获取多个候选人以进行消歧
candidates = await autocomplete_authors(
"James Briscoe",
context="Francis Crick Institute发育生物学"
)
# AI根据机构上下文选择最佳匹配
# 比单一搜索结果准确得多!
搜索作者并提供简化输出以供AI代理使用。
参数:
name(必需):要搜索的作者姓名institution(可选):机构名称过滤器topic(可选):研究主题过滤器country_code(可选):国家代码过滤器(例如,“US”,“DE”)limit(可选):最大结果数(1-25,默认:20)简化输出:
{
"query": "J. Abreu",
"total_count": 3,
"results": [
{
"id": "https://openalex.org/A123456789",
"display_name": "Jorge Abreu-Vicente",
"orcid": "https://orcid.org/0000-0000-0000-0000",
"display_name_alternatives": ["J. Abreu-Vicente", "Jorge Abreu Vicente"],
"affiliations": [
{
"institution": {
"display_name": "欧洲分子生物学组织",
"country_code": "DE"
},
"years": [2023, 2024, 2025]
}
],
"cited_by_count": 316,
"works_count": 25,
"summary_stats": {
"h_index": 9,
"i10_index": 5
},
"x_concepts": [
{
"display_name": "天体物理学",
"score": 0.8
},
{
"display_name": "机器学习",
"score": 0.6
}
]
}
]
}
特点:清晰的结构以优化AI推理和消歧
为给定作者检索作品,并具备增强的过滤能力。
参数:
author_id(必需):OpenAlex作者IDlimit(可选):最大结果数(1-50,默认:20)order_by(可选):“date”或“citations”(默认:“date”)publication_year(可选):按特定年份过滤type(可选):作品类型过滤器(例如,“journal-article”)authorships_institutions_id(可选):按机构过滤is_retracted(可选):过滤撤回的作品open_access_is_oa(可选):按开放访问状态过滤增强输出:
{
"author_id": "https://openalex.org/A123456789",
"total_count": 25,
"results": [
{
"id": "https://openalex.org/W123456789",
"title": "大型语言模型在生物医学应用中的平台",
"doi": "10.1038/s41587-024-02534-3",
"publication_year": 2025,
"type": "journal-article",
"cited_by_count": 42,
"authorships": [
{
"author": {
"display_name": "Jorge Abreu-Vicente"
},
"institutions": [
{
"display_name": "欧洲分子生物学组织"
}
]
}
],
"locations": [
{
"source": {
"display_name": "自然生物技术",
"type": "journal"
}
}
],
"open_access": {
"is_oa": true
},
"primary_topic": {
"display_name": "生物医学工程"
}
}
]
}
特点:全面的作品数据,灵活的过滤以支持有针对性的查询
此MCP服务器提供了聚焦且结构化的数据,特别设计用于AI代理消费:
# 目标高影响力的期刊文章
works = await retrieve_author_works(
author_id="https://openalex.org/A123456789",
type="journal-article", # 专注于期刊出版物
open_access_is_oa=True, # 仅开放访问
order_by="citations", # 引文最多优先
limit=15
)
# 职业过渡分析
authors = await search_authors(
name="J. Abreu",
institution="EMBO", # 当前机构
topic="机器学习", # 研究重点
limit=10
)
from alex_mcp.server import search_authors_core
# 综合作者搜索
results = search_authors_core(
name="J Abreu Vicente",
institution="EMBO",
topic="机器学习",
limit=20
)
print(f"找到 {results.total_count} 名候选人")
for author in results.results:
print(f"- {author.display_name}")
if author.affiliations:
current_inst = author.affiliations[0].institution.display_name
print(f" 机构: {current_inst}")
print(f" 指标: {author.cited_by_count} 引文,H指数 {author.summary_stats.h_index}")
if author.x_concepts:
fields = [c.display_name for c in author.x_concepts[:3]]
print(f" 研究: {', '.join(fields)}")
from alex_mcp.server import retrieve_author_works_core
# 综合作品检索
works = retrieve_author_works_core(
author_id="https://openalex.org/A5058921480",
type="journal-article", # 学术焦点
order_by="citations", # 影响力排序
limit=20
)
print(f"找到 {works.total_count} 篇出版物")
for work in works.results:
print(f"- {work.title}")
if work.locations:
journal = work.locations[0].source.display_name
print(f" 发表于: {journal} ({work.publication_year})")
print(f" 影响力: {work.cited_by_count} 引文")
if work.open_access and work.open_access.is_oa:
print(" ✓ 开放访问")
# 分析职业路径
def analyze_career_path(author_result):
affiliations = author_result.affiliations
if len(affiliations) > 1:
print("职业路径:")
for aff in sorted(affiliations, key=lambda x: min(x.years)):
years = f"{min(aff.years)}-{max(aff.years)}"
print(f" {years}: {aff.institution.display_name}")
# 研究演变
if author_result.x_concepts:
print("研究领域:")
for concept in author_result.x_concepts[:5]:
print(f" {concept.display_name} (得分: {concept.score:.2f})")
# 使用
results = search_authors_core("Jorge Abreu Vicente")
if results.results:
analyze_career_path(results.results[0])
# 必需
export OPENALEX_MAILTO=your-email@domain.com
# 可选设置
export OPENALEX_MAX_AUTHORS=100 # 每次查询的最大作者数
export OPENALEX_USER_AGENT=research-agent-v1.0
export ALEX_MCP_VERSION=4.1.0
# 速率限制(尊重使用)
export OPENALEX_RATE_PER_SEC=10
export OPENALEX_RATE_PER_DAY=100000
# 适用于综合研究应用
config = {
"max_authors_per_query": 25, # 详细的作者分析
"max_works_per_author": 50, # 完整的出版历史
"enable_all_filters": True, # 完整的过滤能力
"detailed_affiliations": True, # 完整的机构数据
"research_concepts": True # 详细的概念分析
}
alex-mcp/
├── src/alex_mcp/
│ ├── server.py # 主MCP服务器
│ ├── data_objects.py # 数据模型和结构
│ └── utils.py # 工具函数
├── examples/
│ ├── basic_usage.py # 简单示例
│ ├── advanced_queries.py # 复杂查询示例
│ └── integration_demo.py # AI代理集成
├── tests/
│ ├── test_server.py # 服务器功能测试
│ └── test_integration.py # 集成测试
└── docs/
└── api_reference.md # 详细的API文档
# 安装测试依赖
pip install -e ".[test]"
# 运行功能测试
pytest tests/test_server.py -v
# 使用真实查询测试
python examples/basic_usage.py
# 测试AI代理集成
python examples/integration_demo.py
# 测试作者消歧