Skip to main content
Glama
josefdc

UniProt MCP Server

by josefdc

fetch_entry_flatfile

Retrieve UniProt entry flatfiles in txt or fasta format using accession numbers and version identifiers for protein data analysis.

Instructions

Return the UniProt flatfile (txt or fasta) for a specific entry version.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessionYes
versionYes
formatNotxt

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for fetch_entry_flatfile. This is the primary implementation decorated with @mcp.tool(), handling input validation and delegating to the raw client helper.
    @mcp.tool()  # type: ignore[misc]
    async def fetch_entry_flatfile(
        accession: str,
        version: str,
        format: str = "txt",
    ) -> str:
        """Return the UniProt flatfile (txt or fasta) for a specific entry version."""
    
        normalized = _validate_accession(accession)
        normalized_format = format.lower()
        async with new_client() as client:
            text = cast(
                str,
                await fetch_entry_flatfile_raw(
                    client,
                    normalized,
                    version,
                    format=normalized_format,
                ),
            )
        if not text:
            return RESOURCE_NOT_FOUND_MESSAGE.format(accession=normalized)
        return text
  • Supporting utility function (imported as fetch_entry_flatfile_raw) that performs the actual HTTP request to the UniProt API with retry logic and error handling.
    @retry(  # type: ignore[misc]
        reraise=True,
        stop=stop_after_attempt(4),
        wait=_wait_retry_after_or_exponential,
        retry=retry_if_exception(_should_retry),
        before_sleep=_before_sleep,
    )
    async def fetch_entry_flatfile(
        client: httpx.AsyncClient,
        accession: str,
        version: str,
        *,
        format: str = "txt",
    ) -> str:
        """Return a flatfile representation (txt or fasta) for a specific entry version."""
    
        normalized_format = format.lower()
        if normalized_format not in FLATFILE_ACCEPT:
            raise ValueError("format must be 'txt' or 'fasta'")
    
        headers = {"Accept": FLATFILE_ACCEPT[normalized_format]}
        params = {"version": version, "format": normalized_format}
    
        async with _SEMAPHORE:
            response = await client.get(
                f"/uniprotkb/{accession}",
                params=params,
                headers=headers,
            )
        if response.status_code == 404:
            return ""
        if response.status_code >= 400:
            if response.status_code in RETRYABLE_STATUS:
                response.raise_for_status()
            else:
                try:
                    response.raise_for_status()
                except httpx.HTTPStatusError as exc:
                    raise UniProtClientError(str(exc)) from exc
        return cast(str, response.text)
  • The @mcp.tool() decorator registers this function as an MCP tool.
    @mcp.tool()  # type: ignore[misc]
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 of behavioral disclosure. It states the tool returns a flatfile but doesn't describe aspects like rate limits, authentication needs, error handling, or whether it's a read-only operation (implied by 'Return' but not explicit). This leaves significant gaps 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 key action and resource. There is no wasted wording, making it highly concise and well-structured for quick understanding.

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 the tool has an output schema (which should cover return values), no annotations, and low schema coverage, the description is minimally adequate. It states the purpose but lacks details on parameters, behavioral traits, and usage context, making it incomplete for full agent guidance without relying heavily on the output schema.

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 for undocumented parameters. It mentions 'specific entry version' and 'format' but doesn't explain what 'accession' or 'version' represent (e.g., UniProt identifiers), nor does it detail valid formats beyond 'txt or fasta'. This adds minimal value beyond the schema.

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 specific resource ('UniProt flatfile for a specific entry version'), distinguishing it from siblings like 'fetch_entry' or 'get_sequence' by specifying the flatfile format. However, it doesn't explicitly differentiate from all siblings (e.g., 'search_uniprot' might also return flatfiles), so it's not a perfect 5.

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?

The description provides no guidance on when to use this tool versus alternatives like 'fetch_entry' or 'get_sequence', nor does it mention any prerequisites or exclusions. It implies usage for retrieving flatfiles but lacks explicit context for tool selection.

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