Skip to main content
Glama

get_batch_protein_info

Retrieve protein details for multiple UniProt accession numbers, including names, functions, sequences, and organism data.

Instructions

Get protein information for multiple accession No.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessionsYesList of UniProt accession No.

Implementation Reference

  • Executes the get_batch_protein_info tool by iterating over the list of accessions, fetching protein information for each using the fetch_protein_info helper, handling errors, and returning a JSON-formatted list of results.
    elif name == "get_batch_protein_info": accessions = arguments.get("accessions", []) if not accessions: raise ValueError("At least one accession No. is required") results = [] for accession in accessions: try: protein_info = await fetch_protein_info(accession) results.append(protein_info) except httpx.HTTPError as e: results.append( { "accession": accession, "error": f"Failed to fetch data: {str(e)}", } ) return [ TextContent(type="text", text=json.dumps(results, indent=2)) ]
  • Registers the get_batch_protein_info tool in the MCP server's list_tools handler, including its name, description, and input schema requiring a list of accessions.
    Tool( name="get_batch_protein_info", description="Get protein information for multiple accession No.", inputSchema={ "type": "object", "properties": { "accessions": { "type": "array", "items": {"type": "string"}, "description": "List of UniProt accession No.", } }, "required": ["accessions"], }, ),
  • Core helper function that fetches detailed protein information (name, function, sequence, length, organism) from the UniProt API for a single accession, with caching support. Used by both get_protein_info and get_batch_protein_info.
    async def fetch_protein_info(accession: str) -> ProteinInfo: """Fetch protein information from UniProt API with caching.""" # Check cache first cached_data = self.cache.get(accession) if cached_data: logger.info(f"Cache hit for {accession}") return cached_data logger.info(f"Fetching data for {accession}") async with httpx.AsyncClient() as client: response = await client.get( f"{API_BASE_URL}/{accession}", headers={"Accept": "application/json"}, ) response.raise_for_status() data = response.json() # Extract relevant information protein_info: ProteinInfo = { "accession": accession, "protein_name": data.get("proteinDescription", {}) .get("recommendedName", {}) .get("fullName", {}) .get("value", "Unknown"), "function": [], "sequence": "", "length": 0, "organism": "Unknown", } # Extract function information safely for comment in data.get("comments", []): if comment.get("commentType") == "FUNCTION": texts = comment.get("texts", []) if texts: protein_info["function"].extend( [text.get("value", "") for text in texts] ) # Add sequence information seq_info = data.get("sequence", {}) org_info = data.get("organism", {}) protein_info.update( { "sequence": seq_info.get("value", ""), "length": seq_info.get("length", 0), "organism": org_info.get("scientificName", "Unknown"), } ) # Cache the result self.cache.set(accession, protein_info) return protein_info
  • TypedDict schema defining the structure of protein information returned by the tools.
    class ProteinInfo(TypedDict): """Type definition for protein information.""" accession: str protein_name: str function: list[str] sequence: str length: int organism: str

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/TakumiY235/uniprot-mcp-server'

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