Skip to main content
Glama
pickleton89

cBioPortal MCP Server

by pickleton89

paginate_results

Handle paginated API responses from cBioPortal to retrieve complete cancer genomics datasets by managing multiple result pages automatically.

Instructions

Delegate to utils.pagination.paginate_results with api_client.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endpointYes
paramsNo
methodNoGET
json_dataNo
max_pagesNo

Implementation Reference

  • The MCP tool handler method for 'paginate_results'. It delegates the pagination logic to the utility function in utils.pagination, passing the server's API client.
    async def paginate_results(
        self,
        endpoint: str,
        params: Optional[Dict[str, Any]] = None,
        method: str = "GET",
        json_data: Any = None,
        max_pages: Optional[int] = None,
    ) -> AsyncGenerator[List[Dict[str, Any]], None]:
        """Delegate to utils.pagination.paginate_results with api_client."""
        async for page in paginate_results(
            self.api_client, endpoint, params, method, json_data, max_pages
        ):
            yield page
  • Core helper function implementing the pagination logic: loops through pages using pageNumber/pageSize, makes API requests via api_client.make_api_request, and yields each page of results until no more pages.
    async def paginate_results(
        api_client,
        endpoint: str,
        params: Optional[Dict[str, Any]] = None,
        method: str = "GET",
        json_data: Any = None,
        max_pages: Optional[int] = None,
    ) -> AsyncGenerator[List[Dict[str, Any]], None]:
        """
        Asynchronous generator that yields pages of results from paginated API endpoints.
    
        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 (None for all available)
    
        Yields:
            Lists of results, one page at a time
        """
        if params is None:
            params = {}
    
        # Ensure we have pagination parameters
        page = params.get("pageNumber", 0)
        page_size = params.get("pageSize", 50)
    
        # Set pagination parameters in the request
        request_params = params.copy()
    
        page_count = 0
        has_more = True
    
        while has_more and (max_pages is None or page_count < max_pages):
            # Update page number for current request
            request_params["pageNumber"] = page
    
            # Make the API request
            results = await api_client.make_api_request(
                endpoint,
                method=method,
                params=request_params.copy(),
                json_data=json_data,
            )
    
            # Check if we got any results
            if not results or len(results) == 0:
                break
    
            yield results
    
            # Check if we have more pages
            has_more = len(results) == page_size
    
            # Increment counters
            page += 1
            page_count += 1
  • Registers 'paginate_results' (line 101) as an MCP tool by adding the instance method to 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")
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but fails completely. It doesn't indicate whether this is a read or write operation, what permissions might be required, whether it makes network calls, what happens on errors, or any rate limiting considerations. The implementation detail about 'utils.pagination.paginate_results' doesn't help the agent understand the tool's behavior.

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

Conciseness3/5

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

The description is extremely concise - just one sentence. However, this conciseness comes at the cost of being severely under-specified. While it's not verbose or repetitive, it fails to provide essential information that would help the agent use the tool effectively.

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

Completeness1/5

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

For a tool with 5 parameters, 0% schema description coverage, no annotations, no output schema, and 15 sibling tools, this description is completely inadequate. It provides no information about what the tool does, when to use it, how parameters work, or what behavior to expect, making it essentially useless for an AI agent.

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

Parameters1/5

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

With 0% schema description coverage and 5 parameters (endpoint, params, method, json_data, max_pages), the description provides absolutely no information about what these parameters mean or how to use them. The description doesn't mention any parameters at all, leaving all 5 completely undocumented.

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

Purpose2/5

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

The description 'Delegate to utils.pagination.paginate_results with api_client' is tautological - it essentially restates the tool name 'paginate_results' and provides implementation details rather than explaining what the tool does. It doesn't specify what resources it paginates or what problem it solves, making the purpose vague and unclear.

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

Usage Guidelines1/5

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

No guidance is provided about when to use this tool versus the 15 sibling tools listed. The description doesn't mention any context, prerequisites, or alternatives, leaving the agent with no information about appropriate usage 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