Skip to main content
The Vercel AI SDK is an open-source TypeScript toolkit for building AI applications and agents. Unlike end-user AI tools that add the Transform MCP server through a settings screen, the AI SDK connects to it from code: you load the Transform MCP server’s tools through the SDK’s built-in MCP client and hand them to a model call such as generateText or streamText. Because Transform is a hosted remote MCP server, there is nothing to install or run locally: you point the client at the server URL and authenticate with your Unstructured API key.
If you want a running app rather than a script, deploy the ready-made Transform MCP × Vercel AI SDK template. It is a Next.js chat app wired to the Transform MCP server, with a one-click Deploy to Vercel button that prompts for the two API keys below.

Requirements

You will need:
  • Node.js 18 or later on your local development machine. To check, in your terminal, run node --version. Install Node.js.
  • An Unstructured API key, which the Transform MCP server uses as a bearer token. Get an API key.
  • An Anthropic API key, or another model provider that the AI SDK supports, for the agent’s underlying chat model.

Install the packages

In your terminal, install the AI SDK, the Anthropic provider, the AI SDK MCP client, and zod for the local tool schema. tsx runs the TypeScript example directly:
This guide was verified against ai@7, @ai-sdk/anthropic@4, and @ai-sdk/mcp@2. Newer versions typically work, but check the AI SDK release notes if an API has changed.

Connect to the Transform MCP server

The Transform MCP server speaks the streamable HTTP transport and authenticates with your Unstructured API key sent as a bearer token. Store your key in an environment variable rather than hard-coding it:
Create an MCP client with the http transport, then load the server’s tools with mcpClient.tools():
Always close the client with await mcpClient.close() when the request finishes (use a finally block, or streamText’s onFinish callback) so the connection is released.

Add local helper tools for waiting and downloading

Transform’s job lifecycle needs two things the MCP tools do not cover on their own. First, transforms run as async jobs, so the agent must pace its status polling; without a pause it will call check_transform_status many times in a row and exhaust its step budget before the job finishes. Second, get_transform_results returns a pre-signed download_url rather than the parsed text inline, so retrieving the content is a plain HTTP GET. The example below registers two small local tools alongside the MCP tools:
  • wait: Pauses between status checks so a multi-second transform has time to complete.
  • downloadText: Fetches the finished Markdown from the pre-signed download_url with an HTTP GET.
Pre-signed URLs carry their own credentials in the URL itself. The downloadText tool must not send the Authorization header, or the storage service rejects the request. It also restricts downloads to the Transform host, so a crafted prompt cannot turn the tool into a server-side request forgery (SSRF) vector.

Use the tools in an agent

The following example connects to the Transform MCP server, registers the two helper tools, and lets the model drive the full job lifecycle: start the transform, poll for status with paced waits, fetch the results, and download the Markdown output. Save it as transform-agent.ts:
To use a different model provider, swap anthropic('claude-opus-4-8') for any provider the AI SDK supports, and set that provider’s API key.

Parse your source files

Parsing requests have the following limits:
  • Each file must be of a supported file type.
  • Each file must be 50 MB or less in size.
  • Each request must have 10 files or fewer.
  • Only 5 requests can be running at a time.
The Transform MCP server is designed to report these limits back to the agent through its tool responses. Because of this, your agent should notify you whenever it encounters a file that exceeds 50 MB in size, and it should formulate strategies to send requests that are 10 files or fewer and not cause more than 5 requests to be running at a time. You can reinforce this behavior in the system prompt, as the example above does for the polling sequence.

Run the agent

Set your model provider’s key, then run the example. Transforms take from about 10 seconds to several minutes, depending on page count:
The agent works through the tool sequence — transform_files, paced wait and check_transform_status cycles, get_transform_results, and downloadText — then prints a summary of the parsed Markdown.

Troubleshooting

  • 401 Unauthorized or an invalid_token error on connect. Confirm the UNSTRUCTURED_API_KEY environment variable is set and that the Authorization header is formatted as Bearer <your-unstructured-api-key>.
  • 404 or a not-found error when connecting. Verify the server URL is exactly https://mcp.transform.unstructured.io, with no path such as /mcp appended.
  • The agent stops before the job finishes. Each model step counts toward stopWhen: stepCountIs(...), and each poll cycle uses two steps (wait plus check_transform_status). Raise the step count, or increase the seconds the wait tool pauses, for longer transforms.
  • The download request is rejected. The download_url value is pre-signed. Send that request without the Authorization header.
  • A hanging or leaked connection. Call await mcpClient.close() when the request finishes, in a finally block or streamText’s onFinish callback.

Next steps

  • Control Transform file parsing output: Control how the Unstructured Transform MCP server instructs Transform to partition, enrich, chunk, and embed the data based on your files.
  • Control Transform generated sample code: Control how the Unstructured Transform MCP server generates sample curl or Python code that demonstrates how to use Transform to partition, enrich, chunk, and embed the data based on your files.

Questions? Need help?