Skip to main content
Glama

Seller Labs Amazon MCP

download_spapi_report

Download a custom SP-API report file by its report_request_id. The bytes are returned gzip-compressed and base64-encoded — you must decompress them yourself before reading.

WORKFLOW:

  1. Run execute_sql on the custom_reports view first to find the right report. Filter by report_type, date range, merchant_id, etc. The view exposes:

    • report_request_id ← pass this to download_spapi_report

    • report_type (e.g. GET_FBA_INVENTORY_AGED_DATA)

    • file_size_bytes (compressed .gz size; NULL for legacy rows)

    • file_format (TSV / CSV / JSON / XML / TXT; NULL = unknown)

    • compression (currently always "gzip")

    • data_start_time / data_end_time / report_generated_ts / created_ts

    • download_path (you generally don't need this — call this tool)

  2. Inspect file_size_bytes BEFORE calling. Decompressed size is typically 3-5× the compressed size for TSV/CSV, ~3× for JSON. If file_size_bytes looks large (above a few MB compressed), CHECK WITH THE USER before downloading — loading a big file into your context will consume a substantial chunk of your token budget. The user might prefer a summary, a narrower date range, or having the file saved to disk via a different flow.

  3. Call download_spapi_report(report_request_id). The response contains bytes_b64 (base64 of the .gz bytes), file_format, compressed_size_bytes, filename_suggestion, and a warning string when the file is over 5 MB compressed. If warning is set, surface it to the user before parsing.

  4. Decompress and parse. CRITICAL: decode the base64 string DIRECTLY to bytes in memory — do NOT write bytes_b64 to a file first and re-read it. Text-mode file writes can mangle base64 payloads in ways that still decode to a plausible byte count: a + getting URL-decoded to space, a newline inserted mid-string by a line-wrapper, or a single character dropped by a serializer will all produce bytes that look the right size but are byte-shifted in the middle. The downstream symptom is a gzip "CRC check failed" or garbled output, falsely blamed on a corrupt source file. Decode straight from the tool response: import base64, gzip data = gzip.decompress(base64.b64decode(result["bytes_b64"]))

    Parse by file_format:

    TSV → csv.reader(text, delimiter='\t')

    CSV → csv.reader(text)

    JSON → json.loads(text) (often line-delimited — try .splitlines())

    XML → xml.etree.ElementTree.fromstring(text)

    TXT → str(text)

    First line of TSV/CSV is usually the header row.

SIZE HANDLING: The tool DOES NOT silently refuse big files. Files above 5 MB compressed are still delivered, but the response includes a warning field telling you the file is large. Read the warning to the user and confirm before processing. The hard upper bound is ~500 MB compressed — above that the tool refuses purely because the response can't be buffered safely server- side. That refusal is a transport limit, not a policy decision. Such files exist only as edge-cases; in practice ask the user to narrow the date range or download the file via the customer portal directly.

ERRORS:

  • "report not found" run id is unknown OR belongs to another org

  • "still in progress" run hasn't reached DOWNLOADED status yet

  • "download disabled" report type contains PII for which the caller's org doesn't have download rights

  • "file expired" S3 lifecycle dropped the file (past retention)

  • "exceeds transport limit" compressed size > 500 MB — point user at the customer portal download path instead

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "reportRequestId": "<reportRequestId>"
    },
    "name": "download_spapi_report"
  }
}

Input Schema

NameRequiredDescriptionDefault
reportRequestIdYesNumeric report_request_id from the `custom_reports` DH view (execute_sql first). Identifies the specific finished run whose .gz file should be returned.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so thoroughly: it discloses the encoding pipeline, the exact response fields, the 5 MB warning threshold, the ~500 MB hard transport limit and its rationale, and a full error taxonomy ('report not found', 'still in progress', 'download disabled' for PII, 'file expired', 'exceeds transport limit'). It also flags a real failure mode (base64 mangling on file round-trips) that would otherwise be misdiagnosed as corrupt data.

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

Conciseness4/5

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

Front-loaded with purpose and encoding, then cleanly sectioned into WORKFLOW / SIZE HANDLING / ERRORS with actionable steps. It is long, and the base64-mangling anecdote plus the inline parsing snippet could be trimmed, but nearly every block carries operational value.

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

Completeness5/5

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

For a single-parameter tool with no annotations and no output schema, the description leaves nothing essential uncovered: it names every return field, the decompression/parsing path per file_format, size thresholds, and the complete set of failure messages. An agent can call and post-process the result without further inference.

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 coverage is 100% and the parameter description already states that reportRequestId comes from the custom_reports view via execute_sql, so the description largely echoes the schema. The workflow adds provenance and sequencing context, but no new format, range, or type detail about the id itself.

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

Purpose5/5

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

The first sentence gives a specific verb and resource ('Download a custom SP-API report file by its report_request_id') and immediately discloses the payload encoding (gzip + base64), so the agent knows exactly what the tool returns. It is clearly distinguished from the sibling execute_sql, which is positioned as the discovery step.

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

Usage Guidelines5/5

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

Provides an explicit prerequisite workflow (query the custom_reports view via execute_sql first, use its report_request_id), a pre-call gate (inspect file_size_bytes and check with the user above a few MB), and a documented alternative (customer portal for oversized files). When-to-use and when-to-confirm are both spelled out.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources