Skip to main content
Glama
josefdc

UniProt MCP Server

by josefdc

fetch_entry

Retrieve structured protein data from UniProtKB by accession number to analyze sequences, annotations, and cross-references.

Instructions

Return a structured UniProt entry.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessionYes
fieldsNo
versionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
goNoGene Ontology annotations extracted from the entry.
idNoUniProt entry name/ID.
xrefsNoCross-references to external databases.
featuresNoAnnotated sequence features.
organismNoScientific name of the source organism.
reviewedYesTrue for Swiss-Prot, False for TrEMBL.
sequenceNoProtein sequence metadata when available.
accessionYesPrimary accession identifier.
raw_payloadNoOriginal UniProt payload for debugging or future enrichment.
taxonomy_idNoNCBI taxonomy identifier for the organism.
gene_symbolsNoCanonical gene symbols associated with the entry.
protein_nameNoRecommended protein name where available.

Implementation Reference

  • The handler function for the 'fetch_entry' tool, registered via @mcp.tool(). Fetches UniProt entry JSON, handles missing entries with a stub, and parses to Entry model.
    @mcp.tool()  # type: ignore[misc]
    async def fetch_entry(
        accession: str,
        fields: list[str] | None = None,
        version: str | None = None,
    ) -> Entry:
        """Return a structured UniProt entry."""
    
        if version is not None:
            raise ValueError(
                "Versioned entries are only available as flatfiles. "
                "Use fetch_entry_flatfile(accession, version) for historical versions."
            )
        normalized, payload = await _load_entry(accession, fields=fields)
        if not payload:
            return Entry(
                accession=normalized,
                reviewed=False,
                gene_symbols=[],
                features=[],
                go=[],
                xrefs=[],
            )
        return parse_entry(payload)
  • Pydantic BaseModel defining the output schema Entry returned by the fetch_entry tool.
    class Entry(BaseModel):
        """Normalized UniProtKB entry."""
    
        model_config = ConfigDict(protected_namespaces=())
    
        accession: str = Field(description="Primary accession identifier.")
        id: str | None = Field(default=None, description="UniProt entry name/ID.")
        reviewed: bool = Field(description="True for Swiss-Prot, False for TrEMBL.")
        protein_name: str | None = Field(
            default=None, description="Recommended protein name where available."
        )
        gene_symbols: list[str] = Field(
            default_factory=list, description="Canonical gene symbols associated with the entry."
        )
        organism: str | None = Field(
            default=None, description="Scientific name of the source organism."
        )
        taxonomy_id: int | None = Field(
            default=None, description="NCBI taxonomy identifier for the organism."
        )
        sequence: Sequence | None = Field(
            default=None, description="Protein sequence metadata when available."
        )
        features: list[Feature] = Field(
            default_factory=list, description="Annotated sequence features."
        )
        go: list[GOAnnotation] = Field(
            default_factory=list, description="Gene Ontology annotations extracted from the entry."
        )
        xrefs: list[XRef] = Field(
            default_factory=list, description="Cross-references to external databases."
        )
        raw_payload: dict[str, object] | None = Field(
            default=None,
            description="Original UniProt payload for debugging or future enrichment.",
        )
  • Helper function parse_entry that transforms raw UniProt JSON into the structured Entry model, invoked by the fetch_entry handler.
    def parse_entry(js: dict[str, Any]) -> Entry:
        """Convert a UniProt entry payload into the Entry model."""
    
        accession = js.get("primaryAccession") or js.get("accession")
        if not accession:
            raise ValueError("UniProt entry payload missing primary accession.")
    
        entry_type = js.get("entryType") or ""
        xrefs, go_terms = _extract_xrefs(js)
    
        entry = Entry(
            accession=str(accession),
            id=js.get("uniProtkbId") or js.get("id"),
            reviewed=entry_type.startswith("UniProtKB reviewed"),
            protein_name=_extract_protein_name(js),
            gene_symbols=_extract_gene_symbols(js),
            organism=(js.get("organism") or {}).get("scientificName")
            if isinstance(js.get("organism"), dict)
            else None,
            taxonomy_id=_to_int_or_none((js.get("organism") or {}).get("taxonId"))
            if isinstance(js.get("organism"), dict)
            else None,
            sequence=_extract_sequence(js),
            features=_extract_features(js),
            go=_extract_go(js) or go_terms,
            xrefs=xrefs,
            raw_payload=js,
        )
        return entry
  • Internal helper _load_entry used by fetch_entry to fetch and normalize the raw JSON payload from UniProt API.
    async def _load_entry(
        accession: str,
        *,
        fields: Iterable[str] | None = None,
    ) -> tuple[str, dict[str, Any]]:
        normalized = _validate_accession(accession)
        async with new_client() as client:
            payload = await fetch_entry_json(client, normalized, fields=fields)
        return normalized, cast(dict[str, Any], payload)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but only states it returns structured data without detailing aspects like rate limits, authentication needs, error handling, or what 'structured' entails. It misses critical behavioral traits for a read operation.

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 zero waste, front-loading the core purpose. It's appropriately sized for a simple tool, though its brevity contributes to gaps in other dimensions.

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

Completeness3/5

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

Given 3 parameters with 0% schema coverage and no annotations, the description is incomplete as it lacks parameter semantics and behavioral details. However, the presence of an output schema reduces the need to explain return values, making it minimally adequate but with clear gaps.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate but adds no parameter information. It doesn't explain what 'accession', 'fields', or 'version' mean, their formats, or how they affect the output, leaving all three parameters semantically undocumented.

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 ('Return') and the resource ('a structured UniProt entry'), providing specific verb+resource pairing. However, it doesn't differentiate from sibling tools like 'fetch_entry_flatfile' or 'get_sequence', which likely retrieve similar data in different formats or scopes.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'fetch_entry_flatfile' or 'get_sequence'. The description lacks context about use cases, prerequisites, or exclusions, leaving the agent to infer usage from tool names alone.

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/josefdc/Uniprot-MCP'

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