Skip to main content
Glama
TakumiY235

UniProt MCP Server

by TakumiY235

get_protein_info

Retrieve protein function and sequence details from UniProt by entering an accession number.

Instructions

Get protein function and sequence information from UniProt using an accession No.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessionYesUniProt Accession No. (e.g., P12345)

Implementation Reference

  • Core handler function that fetches protein information from the UniProt API, extracts relevant fields (name, function, sequence, length, organism), implements caching, and returns a ProteinInfo dict.
    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
  • Dispatch logic within the call_tool handler specifically for 'get_protein_info': validates input, calls fetch_protein_info, and formats response as JSON TextContent.
    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)
            )
        ]
  • Tool registration in list_tools(): defines name, description, and inputSchema for 'get_protein_info'.
        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"],
        },
    ),
  • ProteinInfo TypedDict: schema for the output structure of protein information.
    class ProteinInfo(TypedDict):
        """Type definition for protein information."""
    
        accession: str
        protein_name: str
        function: list[str]
        sequence: str
        length: int
        organism: str
  • Cache class: helper utility used by fetch_protein_info for TTL-based caching of API results.
    class Cache:
        """Simple cache implementation with TTL and max size limit."""
    
        def __init__(self, max_size: int = 100, ttl_hours: int = 24) -> None:
            """Initialize cache with size and TTL limits."""
            self.cache: OrderedDict[str, Tuple[Any, datetime]] = OrderedDict()
            self.max_size = max_size
            self.ttl = timedelta(hours=ttl_hours)
    
        def get(self, key: str) -> Optional[Any]:
            """Get a value from cache if it exists and hasn't expired."""
            if key not in self.cache:
                return None
            item, timestamp = self.cache[key]
            if datetime.now() - timestamp > self.ttl:
                del self.cache[key]
                return None
            return item
    
        def set(self, key: str, value: Any) -> None:
            """Set a value in cache with current timestamp."""
            if len(self.cache) >= self.max_size:
                self.cache.popitem(last=False)
            self.cache[key] = (value, datetime.now())
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions the data source (UniProt) and type of information, but lacks details on behavioral traits like rate limits, error handling, authentication needs, or response format. This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the purpose without unnecessary words. Every part of the sentence contributes to understanding the tool's function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It does not explain what the return values look like (e.g., format of function and sequence information), error cases, or other contextual details needed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the parameter 'accession' well-documented in the schema. The description adds minimal value by mentioning 'UniProt Accession No.' and providing an example, but does not elaborate beyond what the schema already specifies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('protein function and sequence information from UniProt'), specifying the data source and type of information retrieved. It distinguishes from the sibling tool 'get_batch_protein_info' by implying this is for single proteins, though not explicitly contrasting them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you have a UniProt accession number and need protein details, but does not explicitly state when to use this versus the sibling batch tool or other alternatives. No exclusions or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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