Requirements
Before you begin, you must have the following:- For Python: Python 3.10 or later on your local development machine. To check, in your terminal, run
python --versionorpython3 --version. Install Python. - For .NET: the .NET 8.0 SDK or later on your local development machine. To check, in your terminal, run
dotnet --version. Install .NET. - An Unstructured API key, which the Transform MCP server uses as a bearer token. Get an API key.
- An OpenAI API key, or an Azure OpenAI resource, for the agent’s underlying chat model.
Install the packages
In your terminal, install the Microsoft Agent Framework packages and, for .NET, the Model Context Protocol SDK:These SDKs are in active development, and their APIs change between releases. The versions shown here are the
versions this guide was verified against. If you install different versions, check the
Microsoft Agent Framework release notes for API changes.
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:Authorization header on every request, including the initial initialize handshake. Set the
header on the HTTP client or transport itself, as follows:
Add local file helpers for uploads and downloads
Transform’s job lifecycle mixes MCP tool calls with two plain HTTP requests that are not MCP calls: an HTTPPUT of
the raw file bytes to a pre-signed upload_url, and an HTTP GET of the finished output from a pre-signed
download_url. An agent cannot perform raw HTTP requests through MCP tools alone. To close that gap, the full examples
in the next section register three small local functions as additional agent tools:
describe_local_file: Returns a file’s filename, content type, and exact size in bytes, whichrequest_file_upload_urlrequires.upload_local_file: Sends the file bytes to the pre-signedupload_urlwith an HTTPPUT.download_text: Retrieves the finished Markdown from the pre-signeddownload_urlwith an HTTPGET.
Authorization header on
these two requests, or the storage service rejects them.
Use the tools in an agent
The following example builds an agent that can drive the full Transform job lifecycle. The agent requests an upload URL, uploads the file through the local helper, starts the transform, polls for status, and downloads the Markdown output: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.
Run the agent
The examples default to OpenAI as the chat model provider. Set your OpenAI key and model, place any PDF that is 50 MB or smaller at./sample.pdf, and run the program:
Use Azure OpenAI as the chat model provider
To use Azure OpenAI instead of OpenAI, keep the Transform MCP connection code the same and change only the chat model configuration:Troubleshooting
401 Unauthorizedor aninvalid_tokenerror on connect. Confirm theUNSTRUCTURED_API_KEYenvironment variable is set and that theAuthorizationheader is formatted asBearer <your-unstructured-api-key>. In Python, also confirm the header is set on thehttpx.AsyncClientpassed throughhttp_client, not only throughheader_provider.Session terminatedor404when connecting. Verify the server URL is exactlyhttps://mcp.transform.unstructured.io, with no path appended.- The upload or download request is rejected. The
upload_urlanddownload_urlvalues are pre-signed. Send those two requests without theAuthorizationheader. - The agent reports the job is still running. Transforms take from about 10 seconds to several minutes by page
count. The agent keeps polling
check_transform_statusuntil the status isCOMPLETED. - A compile or import error on the SDK APIs. These SDKs are in active development. Install the exact package versions pinned in this guide, or update the code to the installed versions’ APIs.
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.

