Skip to main content
Glama
pickleton89

cBioPortal MCP Server

by pickleton89

get_cancer_studies

Retrieve a paginated list of cancer studies from cBioPortal to explore available genomic datasets for cancer research and analysis.

Instructions

Get a list of cancer studies in cBioPortal with pagination support.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
page_numberNo
page_sizeNo
sort_byNo
directionNoASC
limitNo

Implementation Reference

  • MCP tool handler method registered for 'get_cancer_studies', delegates to StudiesEndpoints instance.
    async def get_cancer_studies(
        self,
        page_number: int = 0,
        page_size: int = 50,
        sort_by: Optional[str] = None,
        direction: str = "ASC",
        limit: Optional[int] = None,
    ) -> Dict[str, Any]:
        """Get a list of cancer studies in cBioPortal with pagination support."""
        return await self.studies.get_cancer_studies(
            page_number, page_size, sort_by, direction, limit
        )
  • Core handler logic for fetching paginated list of cancer studies from cBioPortal API.
    @handle_api_errors("get cancer studies")
    @validate_paginated_params
    async def get_cancer_studies(
        self,
        page_number: int = 0,
        page_size: int = 50,
        sort_by: Optional[str] = None,
        direction: str = "ASC",
        limit: Optional[int] = None,
    ) -> Dict[str, Any]:
        """
        Get a list of cancer studies in cBioPortal with pagination support.
    
        Args:
            page_number: Page number to retrieve (0-based)
            page_size: Number of items per page
            sort_by: Field to sort by
            direction: Sort direction (ASC or DESC)
            limit: Maximum number of items to return across all pages (None for no limit)
    
        Returns:
            Dictionary containing list of studies and metadata
        """
        return await self.paginated_request(
            endpoint="studies",
            page_number=page_number,
            page_size=page_size,
            sort_by=sort_by,
            direction=direction,
            limit=limit,
            data_key="studies"
        )
  • Registers the get_cancer_studies method as an MCP tool using FastMCP.add_tool in a loop over tool_methods list (includes get_cancer_studies at line 104).
    def _register_tools(self):
        """Register tool methods as MCP tools."""
        # List of methods to register as tools (explicitly defined)
        tool_methods = [
            # Pagination utilities
            "paginate_results",
            "collect_all_results",
            # Studies endpoints
            "get_cancer_studies",
            "get_cancer_types",
            "search_studies",
            "get_study_details",
            "get_multiple_studies",
            # Genes endpoints
            "search_genes",
            "get_genes",
            "get_multiple_genes",
            "get_mutations_in_gene",
            # Samples endpoints
            "get_samples_in_study",
            "get_sample_list_id",
            # Molecular profiles endpoints
            "get_molecular_profiles",
            "get_clinical_data",
            "get_gene_panels_for_study",
            "get_gene_panel_details",
        ]
    
        for method_name in tool_methods:
            if hasattr(self, method_name):
                method = getattr(self, method_name)
                self.mcp.add_tool(method)
                logger.debug(f"Registered tool: {method_name}")
            else:
                logger.warning(f"Method {method_name} not found for tool registration")
  • Key helper method implementing pagination logic (single page or collect all), called by get_cancer_studies handler.
    async def paginated_request(
        self,
        endpoint: str,
        page_number: int = 0,
        page_size: int = 50,
        sort_by: Optional[str] = None,
        direction: str = "ASC",
        limit: Optional[int] = None,
        data_key: str = "results",
        additional_params: Optional[Dict[str, Any]] = None
    ) -> Dict[str, Any]:
        """
        Make a paginated API request with standardized handling.
        
        Args:
            endpoint: API endpoint to call
            page_number: Page number to retrieve (0-based)
            page_size: Number of items per page
            sort_by: Field to sort by
            direction: Sort direction (ASC or DESC)
            limit: Maximum number of items to return
            data_key: Key name for results in response
            additional_params: Additional parameters to include in the request
            
        Returns:
            Standardized paginated response
        """
        # Build base pagination parameters
        api_params = self.build_pagination_params(
            page_number, page_size, sort_by, direction, limit
        )
        
        # Add any additional parameters
        if additional_params:
            api_params.update(additional_params)
        
        # Special behavior for limit=0 (fetch all results)
        if limit == 0:
            results_from_api = await collect_all_results(
                self.api_client, endpoint, params=api_params
            )
            results_for_response = results_from_api
            has_more = False  # We fetched everything
        else:
            # Fetch just the requested page
            results_from_api = await self.api_client.make_api_request(
                endpoint, params=api_params
            )
            
            # Apply limit if specified
            results_for_response = self.apply_limit(results_from_api, limit)
            
            # Determine if there might be more data available
            has_more = self.determine_has_more(results_from_api, api_params)
        
        return self.build_pagination_response(
            results_for_response, page_number, page_size, has_more, data_key
        )
  • Input validation decorator for pagination parameters (page_number, page_size, etc.), applied to get_cancer_studies.
    def validate_paginated_params(func):
        """
        Decorator to validate common pagination parameters.
        
        Automatically validates page_number, page_size, limit, sort_by, and direction
        parameters if they exist in the function signature.
        """
        @wraps(func)
        async def wrapper(self, *args, **kwargs):
            # Extract parameters from positional args based on function signature
            import inspect
            sig = inspect.signature(func)
            param_names = list(sig.parameters.keys())[1:]  # Skip 'self'
            
            # Build a dictionary of parameter values
            bound_args = sig.bind(self, *args, **kwargs)
            bound_args.apply_defaults()
            
            page_number = bound_args.arguments.get('page_number', 0)
            page_size = bound_args.arguments.get('page_size', 50)
            limit = bound_args.arguments.get('limit', None)
            sort_by = bound_args.arguments.get('sort_by', None)
            direction = bound_args.arguments.get('direction', 'ASC')
            
            # Validate pagination parameters - let exceptions bubble up
            validate_page_params(page_number, page_size, limit)
            validate_sort_params(sort_by, direction)
            
            return await func(self, *args, **kwargs)
        return wrapper
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'pagination support', which hints at handling large datasets, but doesn't describe other critical behaviors like rate limits, authentication requirements, error handling, or what the output looks like (e.g., format, structure). For a tool with 5 parameters and no annotations, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. It directly states what the tool does and adds a key feature ('pagination support'), making it easy to parse quickly. Every part of the sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the tool's behavior beyond basic purpose, lacks parameter details, and offers no guidance on usage or output. For a tool that likely returns structured data (e.g., a list of studies), this leaves too many gaps for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, meaning none of the 5 parameters (page_number, page_size, sort_by, direction, limit) are documented in the schema. The description only vaguely implies pagination parameters but doesn't explain any parameters' purposes, valid values, or interactions (e.g., how 'limit' relates to 'page_size'). This fails to compensate for the lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get a list of cancer studies in cBioPortal with pagination support.' It specifies the verb ('Get'), resource ('cancer studies'), and context ('cBioPortal'), making it easy to understand. However, it doesn't explicitly distinguish this tool from sibling tools like 'search_studies' or 'get_study_details', which would be needed for a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions 'pagination support' but doesn't explain when pagination is necessary or how this differs from tools like 'search_studies' or 'paginate_results'. Without such context, an agent might struggle to choose the right tool for specific scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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