Skip to main content
Glama
TakumiY235

UniProt MCP Server

by TakumiY235

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
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks behavioral details. It doesn't disclose whether this is a read-only operation, potential rate limits, authentication needs, or what 'protein information' includes (e.g., format, fields). The description is minimal and adds little beyond the basic action.

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 with no wasted words, clearly front-loading the purpose. It is appropriately sized for a simple tool with one parameter.

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 doesn't explain what 'protein information' entails, potential errors, or behavioral traits, leaving significant gaps for a tool that presumably returns complex data.

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?

Schema description coverage is 100%, with the parameter 'accessions' documented as 'List of UniProt accession No.' in the schema. The description adds no additional meaning beyond this, such as format examples, constraints, or usage tips, so it meets the baseline for high schema coverage.

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 protein information') and the resource ('multiple accession No.'), making the purpose understandable. It distinguishes from the sibling tool 'get_protein_info' by specifying 'multiple' vs. presumably single, though not explicitly naming the alternative.

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 multiple accession numbers are needed, but provides no explicit guidance on when to use this vs. the sibling tool 'get_protein_info' (e.g., for bulk vs. single queries). 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