@mastra/mcp package loads the Transform
MCP server’s tools as native Mastra tools, which you can then hand to any Mastra agent. 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 Transform API key.
Requirements
You will need:- Node.js 22.13.0 or later on your local development machine. To check, in your terminal, run
node -vornode --version. Install Node.js. - An Unstructured API key, which the Transform MCP server uses as a bearer token. Get an API key.
- A chat model provider and its API key for the agent’s underlying model. For example, an Anthropic or OpenAI key. This topic uses an Anthropic key.
Install the packages
In your terminal, install@mastra/mcp along with Mastra core and a model provider (here, @ai-sdk/anthropic):
package.json has "type": "module" set.
Connect to the Transform MCP server
The Transform MCP server speaks the streamable HTTP transport and authenticates with your Unstructured Transform API key sent as a bearer token. Store your keys in environment variables rather than hard-coding them. Set your Transform API key, and the API key for your model provider (here, Anthropic):MCPClient to load the Transform tools. Set the server url to the root endpoint
https://mcp.transform.unstructured.io/, and pass your API key as an Authorization header through requestInit:
unstructuredTransform_transform_files, unstructuredTransform_check_transform_status,
unstructuredTransform_get_transform_results, and unstructuredTransform_request_file_upload_url.
Use the tools in a Mastra agent
After you load the tools, pass them to an agent. The following example builds a Mastra agent that drives the full Transform job lifecycle for a file reachable at a URL:maxSteps high enough (for example, 50)
that the agent reaches the results step before hitting the step limit.
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.
transform_files tool accepts each input as a URL. The simplest path, shown above, is to pass an https:// URL that
Transform can fetch directly (for example, a public URL or a pre-signed storage URL).
To parse a local file, upload it first. The request_file_upload_url tool returns a signed upload_url, the HTTP
method and headers to use, and a file_ref. Send the file’s bytes to upload_url with that method and those
headers, then pass the returned file_ref (a u10d://file/... value) to transform_files in place of a URL. Perform
this upload step in your own code, because a Mastra agent has no ability to read local files or make raw HTTP requests on
its own.
Provide credentials per request
The bearer-token approach shown above loads the tools once with a single API key, which works well for scripts, backends, and shared-service setups. If you instead need to vary the credential per request (for example, a different end user’s key on each call), build a freshMCPClient for that request and pass its toolsets to the agent’s
generate call rather than binding the tools at agent construction:
Troubleshooting
401 Unauthorizedon tool calls. Confirm theUNSTRUCTURED_API_KEYenvironment variable is set to your Transform API key and that theAuthorizationheader is formatted asBearer <your-unstructured-transform-api-key>. Get or manage your Transform API key.- Authentication errors from the model provider. Confirm the model provider’s API key is set. The Anthropic example
reads
ANTHROPIC_API_KEYfrom the environment. 404 Not Foundwhen connecting. Verify the URL is the root endpointhttps://mcp.transform.unstructured.io/, including the trailing slash, and not a path such as/mcp.Cannot find package '@mastra/mcp'. Re-runnpm install @mastra/mcp @mastra/core @ai-sdk/anthropicin the same project that runs your agent, and confirmpackage.jsonhas"type": "module".- No tools are loaded. Check that your network allows outbound HTTPS to
mcp.transform.unstructured.io. - The agent stops before returning results. It likely hit the
maxStepslimit while polling the job status. RaisemaxStepson thegeneratecall.
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?
- For technical support, request support.

