get_protein_info
Retrieve detailed protein function and sequence data from UniProt by entering a valid accession number. Access protein names, organism information, and more for analysis.
Instructions
Get protein function and sequence information from UniProt using an accession No.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accession | Yes | UniProt Accession No. (e.g., P12345) |
Implementation Reference
- src/uniprot_mcp_server/server.py:112-166 (handler)Core handler function that fetches protein data from UniProt API, extracts function, sequence, length, organism, caches the result, and returns structured ProteinInfo.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
- src/uniprot_mcp_server/server.py:173-183 (handler)Tool dispatch logic in call_tool handler specifically for get_protein_info: validates input and calls the core fetch function.if name == "get_protein_info": accession = arguments.get("accession") if not accession: raise ValueError("Accession No. is required") protein_info = await fetch_protein_info(accession) return [ TextContent( type="text", text=json.dumps(protein_info, indent=2) ) ]
- src/uniprot_mcp_server/server.py:78-95 (registration)Registers the get_protein_info tool in the list_tools() function, providing name, description, and input schema.Tool( name="get_protein_info", description=( "Get protein function and sequence information from UniProt " "using an accession No." ), inputSchema={ "type": "object", "properties": { "accession": { "type": "string", "description": "UniProt Accession No. (e.g., P12345)", } }, "required": ["accession"], }, ), Tool(
- TypedDict defining the output schema/structure for protein information returned by the tool.class ProteinInfo(TypedDict): """Type definition for protein information.""" accession: str protein_name: str function: list[str] sequence: str length: int organism: str