生物科学mcp
用于生命科学API的FastMCP包装,使LLM试剂能够查询生物数据库以进行药物发现和重新利用。部分 开放生物科学 平台。
状态
活动--第2波(平台)迁移完成。 12台FastMCP服务器,697+个测试(399个单元+294个集成+4个e2e),为FastMCP云部署准备好的统一网关。
此回购包含哪些内容
- 12个FastMCP服务器实现 涵盖HGNC、UniProt、ChEMBL、开放靶点、STRING、BioGRID、Ensembl、Entrez、PubChem、IUPHAR/GtoPdb、WikiPathways和ClinicalTrials.gov
- 13个异步客户端库 用于对所有服务器进行编程访问(基于httpx)
- Pydantic v2型号 包括响应信封、交叉引用模式和域实体
- 统一网关服务器 将所有12台服务器聚合到一个端点后面(
src/biosciences_mcp/servers/gateway.py) - 697+次测试 按pytest标记组织(单元、集成、e2e)
所有服务器都实现了模糊到事实协议(ADR-001§3):自然语言发现,然后是严格的基于CURIE的查找。
快速开始
# Install dependencies (including dev extras)
uv sync --extra dev
# Run unit tests (no network required)
uv run pytest -m unit -v服务器层
| 层 | 标签 | 服务器 |
|---|---|---|
| 0 | 药物发现核心 | ChEMBL,开放靶点 |
| 1 | 基因/蛋白质基金会 | HGNC、UniProt、STRING、BioGRID |
| 2 | 药理学 | IUPHAR/GtoPdb,PubChem |
| 3 | 路径与试验 | 维基路径,ClinicalTrials.gov |
| 4 | 基因组学和标识符 | 集合,输入 |
按服务器实现的工具
| 服务器 | 工具 | CURIE格式 |
|---|---|---|
| HGNC | search_genes, get_gene | HGNC:1100 |
| UniProt | search_proteins, get_protein | UniProtKB:P38398 |
| 中国 | search_compounds, get_compound, get_compounds_batch | CHEMBL:25 |
| 开放目标 | search_targets, get_target, get_associations | ENSG00000141510 |
| 字符串 | search_proteins, get_interactions, get_network_image_url | STRING:9606.ENSP* |
| 生物资源数据库 | search_genes, get_interactions | 基因符号 |
| 恩森布尔 | search_genes, get_gene, get_transcript | ENSG*, ENST* |
| 输入 | search_genes, get_gene, get_pubmed_links | NCBIGene:7157 |
| PubChem | search_compounds, get_compound | PubChem:CID2244 |
| IUPHAR/GtoPdb | search_ligands, get_ligand, search_targets, get_target | IUPHAR:2713 |
| 维基路径 | search_pathways, get_pathway, get_pathways_for_gene, get_pathway_components | WP:WP534 |
| ClinicalTrials.gov | search_trials, get_trial, get_trial_locations | NCT:00461032 |
模糊到事实协议
所有服务器都执行两阶段工作流程(ADR-001§3):
- 第一阶段——模糊发现:工具接受自然语言,返回排名靠前的CURIE考生
- 第二阶段——严格查找:工具只接受已解析的CURIE(例如。,
HGNC:1100,UniProtKB:P38398) - 故障模式:将原始字符串传递给严格工具返回
UNRESOLVED_ENTITY错误
# Example: fuzzy search -> CURIE resolution -> strict lookup
result = await client.call_tool("search_genes", {"query": "BRCA1"})
curie = result["items"][0]["id"] # "HGNC:1100"
gene = await client.call_tool("get_gene", {"hgnc_id": curie})FastMCP云
部署通过Prefect Horizon web UI进行管理,网址为 horizon.prefect.io — 没有 fastmcp deploy FastMCP 2.x中的CLI命令。请参阅 CLAUDE.md 获取分步说明。
部署后,网关端点为:
https://biosciences-mcp.fastmcp.app/mcp认证
FastMCP Cloud需要Bearer API密钥。集 BIOSCIENCES_API_KEY 在您的环境中 (从Prefect Horizon控制台获取)。不要提交此密钥。
通过克劳德代码(.mcp.json)连接
{
"mcpServers": {
"biosciences-mcp": {
"type": "http",
"url": "https://biosciences-mcp.fastmcp.app/mcp",
"headers": {
"Authorization": "Bearer ${BIOSCIENCES_API_KEY}"
}
}
}
}所需的环境变量
创建部署时在Horizon控制台中设置这些:
| 变量 | 描述 | 必填 |
|---|---|---|
BIOGRID_API_KEY | BioGRID交互API密钥(免费注册) | 对于BioGRID是 |
NCBI_API_KEY | Entrez/PubMed费率限制增加(可选,免费) | 否 |
大多数生命科学API(HGNC、UniProt、ChEMBL、Open Targets、STRING、Ensembl、PubChem、IUPHAR/GtoPdb、WikiPathways、ClinicalTrials.gov)都是完全公开的,不需要API密钥。
本地开发
# Run the gateway in interactive dev mode (MCP Inspector UI)
fastmcp dev src/biosciences_mcp/servers/gateway.py
# Run a specific server
uv run fastmcp run src/biosciences_mcp/servers/hgnc.py
uv run fastmcp dev src/biosciences_mcp/servers/.py测试命令
# By tier
uv run pytest -m unit -v # 399 unit tests — no network
uv run pytest -m integration -v # 294 integration tests — live APIs
uv run pytest -m e2e -v # 4 e2e tests — requires live gateway
uv run pytest -m "not integration" -v # Fast local dev (unit only)
# By API
uv run pytest -m "unit and hgnc" -v
uv run pytest -m "unit and clinicaltrials" -v
uv run pytest -m "integration and chembl" -v
# E2e against the deployed cloud endpoint
FASTMCP_CLOUD_ENDPOINT=https://biosciences-mcp.fastmcp.app/mcp \
uv run pytest -m e2e -v封装结构
src/biosciences_mcp/
├── clients/ # Async HTTP clients (httpx-based)
│ ├── base.py # LifeSciencesClient base class
│ ├── hgnc.py
│ ├── uniprot.py
│ └── ... # 13 clients total
├── models/ # Pydantic v2 models
│ ├── envelopes.py # PaginationEnvelope, ErrorEnvelope
│ ├── cross_references.py
│ └── ... # Domain entity models
└── servers/ # FastMCP server definitions
├── gateway.py # Unified gateway (mounts all 12 servers)
├── hgnc.py
└── ... # 12 servers代理人所有权
由维护 MCP平台工程师 代理人(代理人3)。看 代理商.md 了解完整的团队定义。
依赖项
| 方向 | 存储库 | 关系 |
|---|---|---|
| 上游 | 生物科学计划 | 方案和ADR(ADR-001、ADR-004) |
| 下游 | 生物科学深度试剂 | LangGraph代理使用MCP工具 |
| 下游 | 生物科学时间 | 时间活动调用MCP工具 |
| 下游 | 生物科学研究 | 图形生成器工作流使用MCP工具 |
相关存储库
许可证
麻省理工学院
