cBioPortal MCP Server

by pickleton89
MIT License
  • Linux
  • Apple

cBioPortal MCP Server

A Model Context Protocol (MCP) server that enables AI assistants to interact with cancer genomics data from cBioPortal, a platform for exploring multidimensional cancer genomics datasets.

Features

  • 🔍 Cancer Studies: Browse and search cancer studies available in cBioPortal
  • 🧬 Genomic Data: Access gene mutations, clinical data, and molecular profiles
  • 🔎 Search Capabilities: Find studies, genes, and samples with keyword search
  • 📊 Multiple Data Types: Retrieve mutations, clinical data, and study metadata
  • 🔄 FastMCP Integration: Built on the high-performance FastMCP framework

Table of Contents

Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package installer)
  • Git (optional, for cloning the repository)

Set Up Environment

# 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

Install Dependencies

# Install the MCP SDK and FastMCP framework pip install mcp>=2.0.0 # Install additional dependencies pip install requests

Download the Server

Download the cbioportal_server.py script to your working directory or clone this repository:

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

Make the Script Executable (Linux/macOS only)

chmod +x cbioportal_server.py

Usage

Starting the Server

To start the server with default settings:

python cbioportal_server.py

This launches the server using the public cBioPortal API at https://www.cbioportal.org/api.

Advanced Options

Customize server behavior with command-line arguments:

# 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

Configuration

Using with Claude Desktop

  1. Install Claude Desktop
  2. Open Claude Desktop
  3. Click on the MCP Servers icon in the toolbar
  4. Add a new MCP server with the following configuration:
{ "mcpServers": { "cbioportal": { "command": "python", "args": ["/path/to/cbioportal_server.py"], "env": {} } } }

Replace /path/to/cbioportal_server.py with the actual path to your script.

Using with VS Code

Configure the MCP server in your workspace settings:

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

Available Tools

The cBioPortal MCP server provides the following tools:

Tool NameDescription
get_cancer_studiesList all available cancer studies in cBioPortal
get_cancer_typesGet a list of all cancer types
get_study_detailsGet detailed information about a specific cancer study
get_samples_in_studyGet a list of samples associated with a study
get_genesGet information about specific genes by their Hugo symbol or Entrez ID
search_genesSearch for genes by keyword in their symbol or name
get_mutations_in_geneGet mutations in a specific gene for a given study
get_clinical_dataGet clinical data for patients in a study
get_molecular_profilesGet a list of molecular profiles available for a study
search_studiesSearch for cancer studies by keyword

Examples

Here are examples of questions you can ask AI assistants connected to this server:

"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"

Troubleshooting

Server Fails to Start

  • Ensure you have Python 3.8+ installed: python --version
  • Verify all dependencies are installed: pip list | grep mcp
  • Check for error messages in the console

Connection Issues with Claude Desktop

  • Verify the path to the script is correct in your configuration
  • Make sure the script has execute permissions
  • Check the Claude logs for detailed error messages

API Connection Issues

  • Ensure you have internet connectivity
  • Verify that the cBioPortal API is accessible: curl https://www.cbioportal.org/api/cancer-types
  • Try using a different API endpoint if available

Development

Extending the Server

You can extend the functionality of the server by adding new methods to the CBioPortalMCPServer class and registering them as tools:

# 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)

Future Improvements

Potential improvements for future versions:

  • Asynchronous API handling for better performance
  • Pagination support for large result sets
  • Caching for frequently accessed data
  • Authentication support for private cBioPortal instances
  • Additional endpoints for more comprehensive data access

Updates and Maintenance

To update to the latest version of the MCP SDK:

pip install -U mcp

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

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 -
    9
    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 -
    1
    Python
    • Linux
    • Apple

View all related MCP servers

ID: 06rhrqm6mn