Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_alphafold_info_by_protein_symbol

Retrieve protein structure data from the AlphaFold database by providing the protein symbol and species ID. Access PDB and CIF file links along with detailed protein information.

Instructions

Query the AlphaFold database for the protein structure information using the protein name.

This function constructs a query URL to fetch data from the AlphaFold database based on the provided protein name. The response contains links to the PDB and CIF files for the protein structure, as well as general information about the protein.

Args: protein_symbol (Annotated[str, Field, optional): The name of the protein to search for (e.g., "SYNPO"). species (str): The organism ID (e.g., "9606" for human). Default is "9606".

Returns: dict: Protein structure information or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
protein_symbolYesThe name of the gene to search for (e.g., 'SYNPO')
speciesNoThe organism ID (e.g., '9606' for human)9606

Implementation Reference

  • Main tool handler that queries AlphaFold DB by protein symbol. Converts symbol to UniProt ID via helper tool, then fetches prediction data. Includes input schema via 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 to directly query AlphaFold API by UniProt ID, validates ID format and handles HTTP errors.
    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}"}
  • Supporting tool/helper called by the main handler to resolve protein symbol 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
  • Defines the core_mcp FastMCP instance named 'BC' which registers all tools via decorators like @core_mcp.tool(). The 'BC' prefix likely namespaces tools as 'bc_*'.
    from fastmcp import FastMCP core_mcp = FastMCP( # type: ignore "BC", instructions="Provides access to biomedical knowledge bases.", )

Other Tools

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

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