Skip to main content
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.

Requirements

You will need:
  • Python 3.10 or later on your local development machine. To check, in your terminal, run python --version or python3 --version. Install Python.
  • 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 example, an Anthropic or OpenAI key) for the agent’s underlying model.

Install the packages

In your terminal, install langchain-mcp-adapters along with LangChain (and, for LangGraph agents, langgraph):

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:
Use MultiServerMCPClient to load the Transform tools:
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.

Use the tools in a LangGraph agent

After you load the tools, pass them to an agent. The following example builds a LangGraph agent that can drive the full Transform job lifecycle:
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.

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 your agent’s system prompt.

Authenticate with OAuth instead of a bearer token

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.

Troubleshooting

  • 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.

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?