Get started with Unstructured Transform for LangChain and LangGraph
Learn how to connect the Unstructured Transform MCP server to LangChain and LangGraph agents. Your agents can then point to your files and have Transform start producing partitioned, enriched, chunked, and embedded data based on your files in minutes.
Unlike end-user AI tools that add the Transform MCP server through a settings screen, LangChain
and LangGraph connect to it from code. The
langchain-mcp-adapters library loads the Transform MCP
server’s tools as native LangChain tools, which you can then hand to any LangChain or LangGraph 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 API key.
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:
MultiServerMCPClient is stateless by default: each tool call opens a fresh MCP session, runs the tool, and cleans
up. This is the recommended mode for the Transform tools, whose job lifecycle is driven by explicit tool calls rather
than a long-lived session.
The agent decides when to call each Transform tool: it requests an upload URL, uploads each file, starts the transform,
polls for status, and returns the results, one output per input file.
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 your agent’s system prompt.
The bearer-token approach shown above is the simplest and works well for scripts, backends, and shared-service setups.
If you instead need per-user OAuth (for example, to refresh short-lived tokens at runtime), pass an
httpx_client_factory to the server configuration so that each request is issued with a freshly generated
Authorization header. See the
langchain-mcp-adapters documentation for details on injecting
runtime headers.
401 Unauthorized on tool calls. Confirm the UNSTRUCTURED_API_KEY environment variable is set and that the
Authorization header is formatted as Bearer <your-unstructured-api-key>.
ModuleNotFoundError: langchain_mcp_adapters. Re-run pip install -U langchain-mcp-adapters in the same Python
environment that runs your agent.
No tools are loaded. Verify the URL is https://mcp.transform.unstructured.io and the transport is
streamable_http, and check that your network allows outbound HTTPS to mcp.transform.unstructured.io.
RuntimeError about the event loop.client.get_tools() and agent.ainvoke(...) are async. Call them from an
async function (for example, via asyncio.run(main())) rather than at the top level of a script.
Control Transform file partitioning 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.