Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_uniprot_protein_info

Retrieve detailed protein information from the UniProt database by providing protein ID, name, gene symbol, or species taxonomy ID. Ensures accurate results with species-specific data.

Instructions

Query the UniProt database for protein information.

Provide either protein_id or protein_name to search for a specific protein. Always provide the species parameter to ensure the correct protein is returned.

Args: protein_id (str, optional): The protein identifier or accession number (e.g., "P04637"). Only provide if protein_name is None. protein_name (str, optional): The name of the protein to search for (e.g., "P53"). gene_symbol (str, optional): The gene name to search for (e.g., "TP53"). species (str, optional): Taxonomy ID (e.g., 10090) as string. include_references (bool, optional): Whether to include references and cross-references in the response. Defaults to False.

Returns: dict: Protein data or error message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gene_symbolNoThe gene symbol to search for (e.g., 'TP53')
include_referencesNoWhether to include references and cross-references in the response
protein_idNoThe protein identifier or accession number (e.g., 'P04637')
protein_nameNoThe name of the protein to search for (e.g., 'P53')
speciesNoTaxonomy ID (e.g., 10090) or species name as string

Implementation Reference

  • The main handler function decorated as an MCP tool that fetches protein information from the UniProt REST API based on protein ID, name, gene symbol, and species.
    @core_mcp.tool() def get_uniprot_protein_info( protein_id: Annotated[ Optional[str], Field(description="Protein accession number (e.g., 'P04637')"), ] = None, protein_name: Annotated[ Optional[str], Field(description="Protein name to search for (e.g., 'P53')"), ] = None, gene_symbol: Annotated[ Optional[str], Field(description="Gene symbol to search for (e.g., 'TP53')"), ] = None, species: Annotated[ Optional[str], Field(description="Taxonomy ID (e.g., '10090') or species name"), ] = None, include_references: Annotated[ bool, Field(description="Include references and cross-references in response"), ] = False, ) -> dict: """Retrieve protein information from UniProt database. Provide at least one of protein_id, protein_name, or gene_symbol. Returns: dict: Protein information with accession, proteinDescription, genes, organism, sequence, functions, keywords, references or error message. """ base_url = "https://rest.uniprot.org/uniprotkb/search" # Ensure at least one search parameter was provided if not protein_id and not protein_name and not gene_symbol: return {"error": "At least one of protein_id or protein_name or gene_symbol must be provided."} query_parts = [] if protein_id: query_parts.append(f"accession:{protein_id}") elif protein_name: query_parts.append(f"protein_name:{protein_name}") elif gene_symbol: query_parts.append(f"gene:{gene_symbol}") if species: species = str(species).strip() # Try to determine if it's a taxonomy ID (numeric) or a name if species.isdigit(): query_parts.append(f"organism_id:{species}") else: query_parts.append(f'taxonomy_name:"{species}"') query = " AND ".join(query_parts) params: dict[str, str | int] = { "query": query, "format": "json", } try: response = requests.get(base_url, params=params) response.raise_for_status() result = response.json() if not result.get("results"): return {"error": "No results found for the given query."} first_result = result["results"][0] # Remove references and cross-references by default to reduce response size if not include_references: first_result.pop("references", None) first_result.pop("uniProtKBCrossReferences", None) return first_result except Exception as e: return {"error": f"Exception occurred: {e!s}"}
  • Defines the FastMCP instance 'core_mcp' with prefix 'BC', used to register all core tools including bc_get_uniprot_protein_info.
    core_mcp = FastMCP( # type: ignore "BC", instructions="Provides access to biomedical knowledge bases.", )
  • Imports the uniprot module, which imports and registers the get_uniprot_protein_info tool via its decorator.
    from .uniprot import *
  • Direct import of the handler function, triggering its decorator-based registration.
    from ._get_uniprot_protein_info import get_uniprot_protein_info

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