bc_get_uniprot_id_by_protein_symbol
Find UniProt accession IDs using protein names and species taxonomy IDs to identify proteins in biological databases.
Instructions
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.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| protein_symbol | Yes | Gene or protein name to search for (e.g., 'SYNPO') | |
| species | No | Organism taxonomy ID (e.g., '9606' for human) | 9606 |
Implementation Reference
- The handler function implementing the tool logic: queries UniProtKB search API with protein name and species to retrieve the primary UniProt accession ID.@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
- Pydantic schema defined via Annotated Field for input parameters: protein_symbol (str) and species (str, default '9606'), output str|None.@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
- src/biocontext_kb/app.py:35-39 (registration)Registers the core_mcp server (with this tool) into the main FastMCP app using slugify('BC')='bc' prefix, making the tool available as 'bc_get_uniprot_id_by_protein_symbol'.for mcp in [core_mcp, *(await get_openapi_mcps())]: await mcp_app.import_server( mcp, slugify(mcp.name), )
- src/biocontext_kb/core/_server.py:3-6 (registration)Creates the core_mcp FastMCP instance named 'BC' where tools are registered via @core_mcp.tool() decorators.core_mcp = FastMCP( # type: ignore "BC", instructions="Provides access to biomedical knowledge bases.", )
- Imports and uses this tool function (via .fn()) as a helper to resolve protein_symbol to uniprot_id before querying AlphaFold.from biocontext_kb.core.uniprot._get_uniprot_id_by_protein_symbol import ( get_uniprot_id_by_protein_symbol, )