Skip to main content
Glama

fetch_entry_flatfile

Retrieve UniProt flatfile data in txt or fasta format for specific protein entry versions to access detailed protein information and sequences.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessionYes
versionYes
formatNotxt

Implementation Reference

  • MCP tool handler for 'fetch_entry_flatfile'. Decorated with @mcp.tool() to register and execute the tool logic, wrapping the raw client fetcher.
    @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
  • Core helper function implementing the HTTP request to UniProt REST API for fetching flatfile, with retry logic. Imported and aliased as fetch_entry_flatfile_raw in server.py.
    @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)
  • Import of the raw fetch_entry_flatfile helper function from uniprot_client, aliased for use in the MCP tool handler.
    from uniprot_mcp.adapters.uniprot_client import ( fetch_entry_flatfile as fetch_entry_flatfile_raw, )

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