Skip to main content
Glama
pickleton89

cBioPortal MCP Server

by pickleton89

get_molecular_profiles

Retrieve molecular profiles for a specific cancer study using pagination, sorting, and customizable parameters to analyze genomic data efficiently.

Instructions

Get a list of molecular profiles available for a specific cancer study with pagination support.

Input Schema

NameRequiredDescriptionDefault
directionNoASC
limitNo
page_numberNo
page_sizeNo
sort_byNo
study_idYes

Input Schema (JSON Schema)

{ "additionalProperties": false, "properties": { "direction": { "default": "ASC", "title": "Direction", "type": "string" }, "limit": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Limit" }, "page_number": { "default": 0, "title": "Page Number", "type": "integer" }, "page_size": { "default": 50, "title": "Page Size", "type": "integer" }, "sort_by": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Sort By" }, "study_id": { "title": "Study Id", "type": "string" } }, "required": [ "study_id" ], "type": "object" }

Implementation Reference

  • Core implementation of the get_molecular_profiles tool: validates inputs, fetches all molecular profiles for the study from API, applies sorting and client-side pagination, returns paginated results.
    @handle_api_errors("get molecular profiles") async def get_molecular_profiles( self, study_id: str, page_number: int = 0, page_size: int = 50, sort_by: Optional[str] = None, direction: str = "ASC", limit: Optional[int] = None, ) -> Dict: """ Get a list of molecular profiles available for a specific cancer study with pagination support. """ # Input Validation validate_study_id(study_id) validate_page_params(page_number, page_size, limit) validate_sort_params(sort_by, direction) try: if limit == 0: page_size = FETCH_ALL_PAGE_SIZE profiles = await self.api_client.make_api_request( f"studies/{study_id}/molecular-profiles" ) if sort_by: reverse = direction.upper() == "DESC" profiles.sort(key=lambda p: str(p.get(sort_by, "")), reverse=reverse) total_count = len(profiles) start_idx = page_number * page_size end_idx = start_idx + page_size paginated_profiles = profiles[start_idx:end_idx] if limit and limit > 0 and len(paginated_profiles) > limit: paginated_profiles = paginated_profiles[:limit] has_more = end_idx < total_count return { "molecular_profiles": paginated_profiles, "pagination": { "page": page_number, "page_size": page_size, "total_found": total_count, "has_more": has_more, }, } except Exception as e: return { "error": f"Failed to get molecular profiles for {study_id}: {str(e)}" }
  • Registers all server methods as MCP tools using FastMCP.add_tool(), including 'get_molecular_profiles' in the tool_methods list.
    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") async def paginate_results(
  • Thin wrapper handler in the main CBioPortalMCPServer class that delegates the get_molecular_profiles call to the MolecularProfilesEndpoints instance.
    # --- Molecular Profiles endpoints (delegated to MolecularProfilesEndpoints) --- async def get_molecular_profiles( self, study_id: str, page_number: int = 0, page_size: int = 50, sort_by: Optional[str] = None, direction: str = "ASC", limit: Optional[int] = None, ) -> Dict: """Get a list of molecular profiles available for a specific cancer study with pagination support.""" return await self.molecular_profiles.get_molecular_profiles( study_id, page_number, page_size, sort_by, direction, limit )

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