Skip to main content
Glama

cBioPortal MCP Server

by pickleton89

cBioPortal MCP 服务器

高性能异步模型上下文协议 (MCP) 服务器,使 AI 助手能够与cBioPortal (一个探索多维癌症基因组数据集的平台)的癌症基因组数据进行交互。该服务器采用现代异步 Python 构建,可显著加快数据检索速度。

特征

  • 🔍 癌症研究:浏览和搜索 cBioPortal 中可用的癌症研究
  • 🧬 基因组数据:访问基因突变、临床数据和分子图谱
  • 🔎 搜索功能:通过关键字搜索查找研究、基因和样本
  • 📊 多种数据类型:检索突变、临床数据和研究元数据
  • ⚡ 异步性能:完全异步实现,数据检索速度显著加快(最高可提高 4.5 倍)
  • 📚 批量操作:同时获取多个研究和基因以增强性能
  • 🔄 FastMCP 集成:基于高性能 FastMCP 框架构建

目录

安装

先决条件

  • Python 3.8 或更高版本
  • pip(Python 包安装程序)
  • Git(可选,用于克隆存储库)

设置环境

选项 1:使用 venv 和 pip(标准方法)
# Create a virtual environment python -m venv cbioportal-mcp-env # Activate the environment # On Windows: cbioportal-mcp-env\Scripts\activate # On macOS/Linux: source cbioportal-mcp-env/bin/activate
使用 pip 安装依赖项
# Install the MCP SDK and FastMCP framework pip install mcp>=2.0.0 # Install additional dependencies pip install httpx asyncio
选项 2:使用紫外线(更快的替代方案)

UV是一个现代的、高性能的 Python 包管理器和环境管理器,其速度比 pip 快得多。

# Install UV if you don't have it yet pipx install uv # Or with Homebrew # brew install uv # Create and activate a virtual environment with UV uv venv # Activate the environment # On Windows: .venv\Scripts\activate # On macOS/Linux: source .venv/bin/activate
使用 UV 安装依赖项
# Install the MCP SDK and FastMCP framework uv pip install mcp>=2.0.0 # Install additional dependencies uv pip install httpx asyncio

下载服务器

cbioportal_server.py脚本下载到您的工作目录或克隆此存储库:

git clone https://github.com/pickleton89/cbioportal-mcp.git cd cbioportal-mcp

使脚本可执行(仅限 Linux/macOS)

chmod +x cbioportal_server.py

用法

启动服务器

要使用默认设置启动服务器:

python cbioportal_server.py

这将使用https://www.cbioportal.org/api上的公共 cBioPortal API 启动服务器。

高级选项

使用命令行参数自定义服务器行为:

# Use a different cBioPortal API instance python cbioportal_server.py --base-url https://your-cbioportal-instance.org/api # Specify a different transport mechanism (only stdio supported currently) python cbioportal_server.py --transport stdio

配置

与 Claude Desktop 一起使用

  1. 安装 Claude Desktop
  2. 打开 Claude 桌面
  3. 点击工具栏中的 MCP 服务器图标
  4. 添加一个新的 MCP 服务器,配置如下:
{ "mcpServers": { "cbioportal": { "command": "/Users/jeffkiefer/Documents/projects/cbioportal_MCP/.venv/bin/python3", "args": ["/Users/jeffkiefer/Documents/projects/cbioportal_MCP/cbioportal_server.py"], "env": {} } } }

**注意:**请务必将路径替换为 Python 可执行文件和服务器脚本的实际路径。 command字段应指向虚拟环境中的 Python 可执行文件(例如.venv/bin/python3 ),并且args数组的第一个元素应为cbioportal_server.py脚本的路径。如果遇到ENOTDIR错误,请确保将command字段正确设置为 Python 可执行文件,而不是目录。

与 VS Code 一起使用

在您的工作区设置中配置 MCP 服务器:

{ "mcp.servers": { "cbioportal": { "command": "python", "args": ["/path/to/cbioportal_server.py"] } } }

可用工具

cBioPortal MCP 服务器提供以下工具:

工具名称描述
get_cancer_studies列出 cBioPortal 中所有可用的癌症研究
get_cancer_types获取所有癌症类型的列表
get_study_details获取有关特定癌症研究的详细信息
get_samples_in_study获取与研究相关的样本列表
get_genes通过 Hugo 符号或 Entrez ID 获取特定基因的信息
search_genes通过基因符号或名称中的关键词搜索基因
get_mutations_in_gene获取特定研究中特定基因的突变
get_clinical_data获取研究中患者的临床数据
get_molecular_profiles获取可用于研究的分子谱列表
search_studies按关键词搜索癌症研究
get_multiple_studies同时获取多个研究以获得更好的性能
get_multiple_genes通过自动批处理同时检索多个基因

示例

以下是您可以向连接到此服务器的 AI 助手询问的问题示例:

"What cancer studies are available in cBioPortal?" "Search for melanoma studies in cBioPortal" "Get information about the BRCA1 gene" "What mutations in TP53 are present in breast cancer studies?" "Find studies related to lung cancer" "Get clinical data for patients in the TCGA breast cancer study"

表现

该服务器实现了完全异步支持,以显著提高从 cBioPortal API 检索数据时的性能。

基准测试结果

我们的测试表明异步实现可以显著提高性能:

  • 与顺序操作相比,并发研究获取速度提高了 4.57 倍
  • 高效批量处理检索多个基因
  • 顺序操作和并发操作之间的数据质量一致

批量操作优势

服务器提供了利用并发的批量操作的专用工具:

  • get_multiple_studies :使用 asyncio.gather 并行获取多个研究
  • get_multiple_genes :实现智能批处理,实现高效的并发基因检索

这些方法包括详细的性能指标,例如执行时间和批次数,以帮助您了解效率提升。

故障排除

服务器启动失败

  • 确保已安装 Python 3.8+: python --version
  • 验证所有依赖项都已安装: pip list | grep mcp
  • 检查控制台中的错误消息

Claude Desktop 的连接问题

  • 验证配置中的脚本路径是否正确
  • 确保脚本具有执行权限
  • 检查 Claude 日志以获取详细的错误消息

API 连接问题

  • 确保您有互联网连接
  • 验证 cBioPortal API 是否可访问: curl https://www.cbioportal.org/api/cancer-types
  • 如果可用,请尝试使用其他 API 端点

发展

扩展服务器

您可以通过向CBioPortalMCPServer类添加新方法并将其注册为工具来扩展服务器的功能:

# Add a new method def my_new_tool(self, parameter1: str, parameter2: int) -> Dict: # Implementation return {"result": "data"} # Register the new tool self.mcp.tool()(self.my_new_tool)

未来的改进

未来版本的潜在改进:

  • 缓存频繁访问的数据
  • 私有 cBioPortal 实例的身份验证支持
  • 附加端点以实现更全面的数据访问
  • 根据服务器功能微调并发限制
  • 添加请求重试机制以实现更强大的错误处理
  • 为其他端点实现更多并发批量操作方法

更新和维护

要更新到最新版本的 MCP SDK:

pip install -U mcp

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

致谢

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

该服务器使 AI 助手能够与来自 cBioPortal 的癌症基因组数据进行交互,从而允许用户探索癌症研究、访问基因组数据以及检索突变和临床信息。

  1. 特征
    1. 目录
      1. 安装
        1. 先决条件
        2. 设置环境
        3. 下载服务器
        4. 使脚本可执行(仅限 Linux/macOS)
      2. 用法
        1. 启动服务器
        2. 高级选项
      3. 配置
        1. 与 Claude Desktop 一起使用
        2. 与 VS Code 一起使用
      4. 可用工具
        1. 示例
          1. 表现
            1. 基准测试结果
            2. 批量操作优势
          2. 故障排除
            1. 服务器启动失败
            2. Claude Desktop 的连接问题
            3. API 连接问题
          3. 发展
            1. 扩展服务器
            2. 未来的改进
            3. 更新和维护
          4. 执照
            1. 致谢

              Related MCP Servers

              • -
                security
                F
                license
                -
                quality
                Enables AI assistants to interact with Metabase databases and dashboards, allowing users to list and execute queries, access data visualizations, and interact with database resources through natural language.
                Last updated -
                40
                JavaScript
                • Apple
              • -
                security
                F
                license
                -
                quality
                Enables AI assistants to interact with Metabase, providing access to dashboards, questions, databases, and tools for executing queries and viewing data through natural language.
                Last updated -
                JavaScript
                • Apple
              • -
                security
                A
                license
                -
                quality
                An MCP server enabling AI assistants to search and analyze pharmaceutical data through Cortellis. Features comprehensive drug search, ontology exploration, and real-time clinical trial data access.
                Last updated -
                Python
                MIT License
                • Linux
                • Apple
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server providing AI assistants with access to healthcare data tools, including FDA drug information, PubMed research, health topics, clinical trials, and medical terminology lookup.
                Last updated -
                10
                Python
                • Linux
                • Apple

              View all related MCP servers

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/pickleton89/cbioportal-mcp'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server