> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unstructured.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Unstructured Transform MCP server installation 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](https://www.langchain.com)
and [LangGraph](https://www.langchain.com/langgraph) connect to it *from code*. The
[`langchain-mcp-adapters`](https://github.com/langchain-ai/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](https://www.python.org/downloads/).
* An Unstructured API key, which the Transform MCP server uses as a bearer token. [Get an API key](/transform/overview).
* 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`):

```bash theme={null}
pip install -U langchain-mcp-adapters langchain 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:

```bash theme={null}
export UNSTRUCTURED_API_KEY="<your-unstructured-api-key>"
```

Use `MultiServerMCPClient` to load the Transform tools:

```python theme={null}
import os

from langchain_mcp_adapters.client import MultiServerMCPClient

client = MultiServerMCPClient(
    {
        "unstructured_transform": {
            "transport": "streamable_http",
            "url": "https://mcp.transform.unstructured.io",
            "headers": {
                "Authorization": f"Bearer {os.environ['UNSTRUCTURED_API_KEY']}",
            },
        }
    }
)

# Load the Transform tools as native LangChain tools.
tools = await client.get_tools()
```

<Tip>
  `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.
</Tip>

### 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:

```python theme={null}
import asyncio
import os

from langchain.agents import create_agent
from langchain_mcp_adapters.client import MultiServerMCPClient


async def main() -> None:
    client = MultiServerMCPClient(
        {
            "unstructured_transform": {
                "transport": "streamable_http",
                "url": "https://mcp.transform.unstructured.io",
                "headers": {
                    "Authorization": f"Bearer {os.environ['UNSTRUCTURED_API_KEY']}",
                },
            }
        }
    )

    tools = await client.get_tools()
    agent = create_agent("claude-sonnet-4-6", tools)

    response = await agent.ainvoke(
        {
            "messages": [
                {
                    "role": "user",
                    "content": (
                        "Use the Unstructured Transform tools to parse the file at "
                        "./report.pdf. Provide the results as JSON."
                    ),
                }
            ]
        }
    )
    print(response["messages"][-1].content)


if __name__ == "__main__":
    asyncio.run(main())
```

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](/transform/supported-file-types).
* 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](https://docs.langchain.com/oss/python/langchain/mcp) 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](/transform/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](/transform/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](/support/request).
