Skip to content

Add starter/unstructured-transform-ai-sdk - #1541

Open
mikedownesdev wants to merge 2 commits into
vercel:mainfrom
mikedownesdev:add-unstructured-transform-ai-sdk
Open

Add starter/unstructured-transform-ai-sdk#1541
mikedownesdev wants to merge 2 commits into
vercel:mainfrom
mikedownesdev:add-unstructured-transform-ai-sdk

Conversation

@mikedownesdev

Copy link
Copy Markdown

Adds starter/unstructured-transform-ai-sdk — a Next.js chat app that connects the AI SDK to Unstructured's Transform MCP server.

Paste a public document URL and the model parses it (PDF, DOCX, XLSX, images, and 70+ formats) into clean Markdown via MCP tool calls — no parsing code of your own. The model drives the full async job lifecycle: start the transform, pace status polling with a wait helper, fetch results, and download the parsed Markdown.

Included

  • One-click Deploy to Vercel button with the two required env vars pre-declared.
  • .env.example and setup instructions.
  • MIT LICENSE.
  • A keyless preview mode: deployed without keys, the app renders the UI and explains how to run it live, instead of erroring on the first request.

Environment variables

  • ANTHROPIC_API_KEY — the chat model (Claude).
  • UNSTRUCTURED_API_KEY — authenticates the Transform MCP server (get one).

Notes / verified

  • npm install, tsc --noEmit, and next build all pass.
  • The full parse flow was verified end-to-end against the production server (https://mcp.transform.unstructured.io).
  • The downloadText tool is restricted to the Transform host over HTTPS to avoid SSRF from the serverless function.
  • Opened as a draft — happy to adjust placement, naming, or add gallery frontmatter to match your submission conventions.

A Next.js chat app that connects the AI SDK to Unstructured's Transform MCP
server: paste a public document URL and the model parses it (PDF, DOCX, XLSX,
images, and 70+ formats) into clean Markdown via MCP tool calls. Includes a
one-click Deploy button, .env.example, MIT license, and a keyless "preview
mode" so a demo deploy renders the UI instead of erroring without keys.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@mikedownesdev is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Deployment failed with the following error:

The `vercel.ts` schema validation failed with the following message: `rewrites[0]` missing required property `destination`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mintlify-docs-rewrite Error Error Jul 28, 2026 2:22pm

@socket-security

socket-security Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​next@​15.5.205270919970
Addednpm/​@​ai-sdk/​anthropic@​4.0.11701008898100
Addednpm/​@​ai-sdk/​react@​4.0.20981007598100
Addednpm/​@​types/​node@​22.20.11001008195100
Addednpm/​ai@​7.0.198610010099100
Addednpm/​@​ai-sdk/​mcp@​2.0.109110010098100

View full report

@mikedownesdev
mikedownesdev marked this pull request as ready for review July 28, 2026 15:06

// The download_url from get_transform_results is served from the Transform host.
// Restrict downloads to that host so a crafted prompt cannot turn this tool into
// an SSRF vector (e.g. fetching internal/metadata URLs from the serverless function).

@vercel vercel Bot Jul 28, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The downloadText tool requires the pre-signed download_url host to exactly equal the MCP host, but pre-signed result URLs are served from cloud object storage, so every download throws and the app can never read parsed output.

Fix on Vercel

The Transform server renamed its tools (transform_files -> start_transform_job,
check_transform_status -> check_job_status, get_transform_results ->
get_job_results). The system prompt hardcoded the old names.

Rewrote the prompt to describe the workflow by intent and name only the app's
own wait/downloadText tools, so the model uses whatever tools the server
exposes — resilient to future renames. Verified end-to-end against the live
server: the model drives start_transform_job -> check_job_status -> get_job_results
-> downloadText and returns the parsed summary.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mikedownesdev

Copy link
Copy Markdown
Author

Thanks for flagging this. I checked it against the live server and the premise doesn't hold for this MCP server, so the allowlist is working as intended.

The concern assumes the pre-signed download_url is served from cloud object storage (a different host). For Unstructured's Transform server, the results tool returns a download_url on the MCP host itself (https://mcp.transform.unstructured.io/output/…?token=…), so it matches the allowlist and the download succeeds. Verified end-to-end against production:

download_url host: mcp.transform.unstructured.io
GET status: 200 | final host after redirects: mcp.transform.unstructured.io | bytes: 150883

The full agent flow also completes — the model downloads and summarizes the parsed Markdown. The host restriction is deliberate SSRF hardening (so a crafted prompt can't turn downloadText into a fetch of internal/metadata URLs), and since the real download URL is on the allowed host, it doesn't block legitimate downloads. Leaving it as-is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant