Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_alphafold_info_by_protein_symbol

Retrieve AlphaFold protein structure predictions by converting protein symbols to UniProt IDs and fetching detailed structural data including PDB/CIF files and confidence scores.

Instructions

Query AlphaFold database using protein name. First converts protein symbol to UniProt ID, then fetches structure predictions.

Returns: dict: AlphaFold prediction data including PDB/CIF file URLs, confidence scores, and metadata or error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
protein_symbolYesGene/protein name (e.g., 'SYNPO')
speciesNoTaxonomy ID (e.g., '9606' for human)9606

Implementation Reference

  • The core handler function for the 'bc_get_alphafold_info_by_protein_symbol' tool. It resolves the protein symbol to a UniProt ID using another tool, then fetches AlphaFold structure predictions. Includes input schema via Pydantic Annotated Fields.
    @core_mcp.tool() def get_alphafold_info_by_protein_symbol( protein_symbol: Annotated[str, Field(description="Gene/protein name (e.g., 'SYNPO')")], species: Annotated[ str, Field(description="Taxonomy ID (e.g., '9606' for human)"), ] = "9606", ) -> dict: """Query AlphaFold database using protein name. First converts protein symbol to UniProt ID, then fetches structure predictions. Returns: dict: AlphaFold prediction data including PDB/CIF file URLs, confidence scores, and metadata or error message. """ # Get the UniProt Id from the protein_symbol try: uniprot_id = get_uniprot_id_by_protein_symbol.fn(protein_symbol, species) if uniprot_id: result = get_alphafold_info_by_uniprot_id(uniprot_id) if isinstance(result, dict) and "error" in result: return {"error": result["error"]} elif isinstance(result, list) and len(result) > 0: # If result is a list, return the first item return result[0] elif isinstance(result, dict): # If result is a dict, return it directly return result else: return {"error": "Unexpected result format from AlphaFold query"} else: return {"error": "No results found for the given protein name"} except requests.exceptions.RequestException as e: return {"error": f"Failed to fetch AlphaFold info: {e!s}"}
  • Helper function called by the handler to query AlphaFold API directly using UniProt ID.
    def get_alphafold_info_by_uniprot_id( uniprot_id: Annotated[str, Field(description="UniProt protein ID (e.g., 'P62258')")], ) -> dict: """Query AlphaFold database for protein structure data. Returns: dict: AlphaFold prediction data including PDB/CIF file URLs, confidence scores, and metadata or error message. """ # Ensure the UniProt ID is in uppercase uniprot_id = uniprot_id.upper() # Validate the UniProt ID format if not re.match(r"^[A-Z0-9]{6}$", uniprot_id): return {"error": "Invalid UniProt ID format"} # Construct the URL for AlphaFold database query url = f"https://alphafold.ebi.ac.uk/api/prediction/{uniprot_id}" try: # Make the request and get the response response = requests.get(url) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: return {"error": f"Failed to fetch AlphaFold info: {e!s}"}
  • Helper tool called by the main handler (via .fn()) to resolve protein symbol and species to UniProt ID using UniProt REST API.
    @core_mcp.tool() def get_uniprot_id_by_protein_symbol( protein_symbol: Annotated[str, Field(description="Gene or protein name to search for (e.g., 'SYNPO')")], species: Annotated[ str, Field(description="Organism taxonomy ID (e.g., '9606' for human)"), ] = "9606", ) -> str | None: """Retrieve UniProt accession ID from protein name and species. Returns the primary accession or None if not found. Returns: str or None: UniProt accession ID string (e.g., 'P04637') or None if not found. """ url = f"https://rest.uniprot.org/uniprotkb/search?query=protein_name:{protein_symbol}+AND+organism_id:{species}&format=json" response = requests.get(url) response.raise_for_status() data = response.json() if data["results"]: return data["results"][0]["primaryAccession"] return None
  • The FastMCP server instance 'core_mcp' with prefix 'BC' to which all tools including 'bc_get_alphafold_info_by_protein_symbol' are registered via decorators.
    core_mcp = FastMCP( # type: ignore "BC", instructions="Provides access to biomedical knowledge bases.", )

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/biocontext-ai/knowledgebase-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server