sam_fetch_attachment_text
Extracts text from SAM.gov opportunity attachments such as RFPs and SOWs using their download URLs. Returns plain text with extraction metadata, handling PDF and HTML formats.
Instructions
Extract the TEXT of a SAM notice attachment (the actual RFP / SOW / Q&A / wage tables) by its download URL — so an AI can read the real solicitation, not just its metadata. Give it a sam_get_opportunity attachments[].url (resourceLinks). Keyless. Handles PDF (via pdfjs) + text/HTML; returns { format, text, pages, filename, sizeBytes, truncated, extracted }. HONEST: a DOCX / binary that can't be read keyless returns text:null + a note (never fabricated); a corrupt/encrypted PDF returns text:null + an extractionError note (never a crash); a DOWN fetch throws a retryable upstream_unavailable (never empty text); a 404 throws not_found. Only sam.gov / api.sam.gov URLs are fetched (SSRF hygiene). maxChars caps the text (default 200000) and truncation is disclosed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | SAM attachment download URL from sam_get_opportunity → attachments[].url / resourceLinks (https://sam.gov/api/prod/opps/v3/opportunities/resources/files/{id}/download). Must be a sam.gov / api.sam.gov host. | |
| maxChars | No | Cap on returned text characters (default 200000, max 500000). Truncation is disclosed in _meta (truncated:true). |