Skip to main content
Glama
pickleton89

cBioPortal MCP Server

by pickleton89

collect_all_results

Retrieve all paginated data from the cBioPortal API by specifying an endpoint, method, and optional parameters. Streamlines access to cancer genomics data for comprehensive analysis.

Instructions

Delegate to utils.pagination.collect_all_results with api_client.

Input Schema

NameRequiredDescriptionDefault
endpointYes
json_dataNo
limitNo
max_pagesNo
methodNoGET
paramsNo

Input Schema (JSON Schema)

{ "additionalProperties": false, "properties": { "endpoint": { "title": "Endpoint", "type": "string" }, "json_data": { "default": null, "title": "Json Data" }, "limit": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Limit" }, "max_pages": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Max Pages" }, "method": { "default": "GET", "title": "Method", "type": "string" }, "params": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "default": null, "title": "Params" } }, "required": [ "endpoint" ], "type": "object" }

Implementation Reference

  • MCP tool handler for 'collect_all_results'. This is the function executed when the tool is called, delegating to the core pagination utility.
    async def collect_all_results( self, endpoint: str, params: Optional[Dict[str, Any]] = None, method: str = "GET", json_data: Any = None, max_pages: Optional[int] = None, limit: Optional[int] = None, ) -> List[Dict[str, Any]]: """Delegate to utils.pagination.collect_all_results with api_client.""" return await collect_all_results( self.api_client, endpoint, params, method, json_data, max_pages, limit )
  • Core implementation of collect_all_results utility. Fetches all pages from paginated API endpoints using paginate_results and concatenates them, respecting max_pages and limit.
    async def collect_all_results( api_client, endpoint: str, params: Optional[Dict[str, Any]] = None, method: str = "GET", json_data: Any = None, max_pages: Optional[int] = None, limit: Optional[int] = None, ) -> List[Dict[str, Any]]: """ Collect all results from a paginated endpoint into a single list. Args: api_client: The APIClient instance to use for requests endpoint: API endpoint path params: Query parameters to include in the request method: HTTP method (GET or POST) json_data: JSON data for POST requests max_pages: Maximum number of pages to retrieve limit: Maximum number of total results to return Returns: List of all collected results (limited by max_pages and/or limit) """ all_results = [] async for page in paginate_results( api_client, endpoint, params, method, json_data, max_pages ): all_results.extend(page) # Stop if we've reached the specified limit if limit and len(all_results) >= limit: all_results = all_results[:limit] break return all_results
  • Tool registration method in CBioPortalMCPServer class. Includes 'collect_all_results' in the tool_methods list and registers it with FastMCP via self.mcp.add_tool.
    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")

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