🧬 ToppGene MCP服务器
  
模型上下文协议(MCP)服务器,允许AI助手直接访问 ToppGene套房 用于功能富集分析。提供一个基因列表,并接收统计排名的通路、疾病、表型和其他注释,以及一个包含完整结果的TSV文件,用于下游分析。
______________________________________________________________________
🚀 快速开始
🎥 演示
- 克隆并进入项目
git clone https://github.com//toppgene-mcp-server.git
cd toppgene-mcp-server- (可选)创建虚拟环境
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate- 安装依赖项
pip install -e .
# or: pip install -r requirements.txt- 运行服务器
python toppgene_mcp.py
# or, after installing in editable mode:
toppgene-mcp服务器通过stdio(默认MCP传输)运行。让它在MCP客户端连接时运行。
______________________________________________________________________
🧩 从流行的MCP客户端连接
克劳德桌面
编辑配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 窗户:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"toppgene": {
"command": "python3",
"args": ["/absolute/path/to/toppgene_mcp.py"]
}
}
}重新启动克劳德桌面;这🔌 MCP指示器应显示 toppgene 如可用。
光标/继续/自定义客户端
任何兼容MCP的客户端都可以使用上面显示的相同命令/args对启动服务器。
______________________________________________________________________
🔍 工具和功能
toppgene_enrichment_analysis:核心工具。接受1-1000个基因(HGNC、Ensembl、Entrez、UniProt、RefSeq),并返回19个注释类别的丰富术语。- 自动基因符号→ 通过ToppGene查找API进行的Entrez ID转换。
- 可配置的p值阈值、多次测试校正、结果限制和响应详细程度(
concise或detailed). - 支持Markdown或JSON响应,因此代理可以叙述发现或后处理原始数据。
每个请求还会在下面写入一个带时间戳的TSV文件 outputs/ 包含完整的富集结果表(类别、术语ID、术语名称、p值、重叠等)。这允许代理运行后续代码执行,如绘图或过滤。
______________________________________________________________________
🧪 可选LangChain代理
LangChain代理示例(toppgene_agent.py)演示了如何使用OpenAI的GPT模型编排MCP工具。要尝试:
pip install -e .[agent]
cp .env.example .env # then add your OPENAI_API_KEY
python test_agent.py代理脚本连接到本地MCP服务器,加载可用工具,并回答有关所提供基因的自然语言问题。
______________________________________________________________________
📁 项目布局
toppgene-mcp-server/
├── README.md
├── LICENSE
├── pyproject.toml
├── requirements.txt
├── toppgene_mcp.py # MCP server entry point
├── toppgene_agent.py # Optional LangChain agent
├── test_agent.py # Smoke test for the agent
├── setup_claude.sh # Helper script for Claude Desktop config
├── outputs/ # Timestamped TSV results (gitignored)
├── docs/
│ ├── INSTALL.md # Legacy installation notes
│ ├── CLAUDE_SETUP.md # Detailed Claude Desktop walkthrough
│ └── TSV_FEATURE.md # TSV output behaviour
└── toppgene_mcp.mov # Demo walkthrough______________________________________________________________________
📚 其他文件
docs/INSTALL.md–快速安装步骤。docs/CLAUDE_SETUP.md–完整的克劳德桌面指南和故障排除提示。docs/TSV_FEATURE.md–深入了解TSV输出工作流程。
______________________________________________________________________
🛡️ 许可证
根据 MIT许可证。欢迎拉取请求和发布报告!
