# mcp/cbio.py from pybioportal import PyBioPortal import asyncio async def fetch_cbio_variants(gene_symbol: str) -> list[dict]: """ Fetches mutation/variant data for a specific gene symbol from the default cBioPortal study (e.g. 'brca_mskcc_2020'). """ base_url = "https://www.cbioportal.org" client = PyBioPortal(base_url) # Build the query path for mutations in the gene query_path = f"/mutation?gene={gene_symbol}&studyId=brca_mskcc_2020" loop = asyncio.get_event_loop() df = await loop.run_in_executor( None, lambda: client.get_data_frame(query_path) ) # Convert DataFrame rows to dicts for JSON serialization return df.to_dict(orient="records")