> ## 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 sample code generation

> Control how the Unstructured Transform MCP server generates curl or Python code that shows how to use Transform to partition, enrich, chunk, and embed the data based on your files.

## Generate sample code

After you [connect your AI tool to the Transform MCP server](/transform/get-started/overview) and [have Transform parse your source files](/transform/output) to produce the kind of output you want, you can ask the Unstructured Transform MCP server to generate sample curl or Python code based on the parsing process that Transform just ran. You can then use this code to run Transform in your production environment at scale. To get this code, ask your AI tool the following, depending on whether you want curl or Python code:

<Tabs>
  <Tab title="curl">
    To generate the curl code as downloadable shell script (`.sh`) files, ask your AI tool the following:

    ```text theme={null}
    Provide a complete set of curl code that shows how to perform the parsing 
    process that the Unstructured Transform MCP server just ran on these 
    source files. Provide exactly four downloadable shell script (.sh) files: 
    one to create a single job containing all source files, one to poll its 
    status, one to download all results, and one combined script that performs 
    all three steps. Do not create additional scripts. For reference, use the 
    Unstructured API quickstarts at 
    https://docs.unstructured.io/api-reference/quickstart/*. If you need 
    additional Unstructured API reference documentation, see 
    https://docs.unstructured.io/api-reference/workflow/*, but refer to it 
    only if absolutely necessary.
    ```
  </Tab>

  <Tab title="Python">
    To generate the Python code as downloadable Python script (`.py`) files, ask your AI tool the following:

    ```text theme={null}
    Provide a complete set of Python code that shows how to perform the parsing 
    process that the Unstructured Transform MCP server just ran on these 
    source files. Provide exactly four downloadable Python script (.py) files: 
    one to create a single job containing all source files, one to poll its 
    status, one to download all results, and one combined script that performs 
    all three steps. Do not create additional scripts. For reference, use the 
    Unstructured API quickstarts at 
    https://docs.unstructured.io/api-reference/quickstart/*. If you need 
    additional Unstructured API reference documentation, see 
    https://docs.unstructured.io/api-reference/workflow/*, but refer to it 
    only if absolutely necessary.
    ```
  </Tab>
</Tabs>

See the next section for how to run this code locally.

## Run sample code

<Tip>
  If your local development environment is already set up, skip ahead to
  [get your Unstructured API key and URL](#get-your-unstructured-api-key-and-url).
</Tip>

Before you can run the generated example curl or Python code, you must set up your local development environment. This includes installing curl or Python locally, installing the Unstructured Python SDK locally if you're using Python, and defining and setting two unique local environment variables, which the example code refers to and relies upon.

### Install curl

curl installation instructions vary by operating system and download manager utility. See the
[curl Download](https://curl.se/download.html) page or the documentation for your operating system or
download manager utility.

### Install Python and the SDK

Python installation instructions vary by operating system and download manager utility. See the
[Download Python](https://www.python.org/downloads/) page or the documentation for your operating system or
download manager utility.

Unstructured recommends that you install the Python SDK into a Python virtual environment, such as
[uv](https://docs.astral.sh/uv/). This enables you to isolate and manage various Python package dependencies
for your Python projects.
[Learn more about Python virtual environments](https://realpython.com/python-virtual-environments-a-primer/).

To download and install the Unstructured Python SDK by using `uv`, run a command such as the following from within
a `uv` virtual environment:

```bash theme={null}
uv add unstructured-client
```

For Python package managers other than `uv`, see your package manager provider's documentation.

### Define environment variables

Your local development environment must have access to the following two environment variables:

* `UNSTRUCTURED_API_KEY`, which represents the programmatic access identifier for your user account in the Transform service.
  Each call to the Transform service requires this identifier so that the correct user account is billed (or any remaining free page counts are reduced) accordingly.
* `UNSTRUCTURED_API_URL`, which represents the programmatic API endpoint for the Unstructured Transform service. This service contains
  the file parsing logic and orchestrates all file processing jobs.

To define these environment variables (for example, by setting an `export` or `setx` command or equivalent), see your environment's documentation.

To set these environment variables to the appropriate values, see the following sections.

#### Get your Unstructured API key and URL

1. Sign in to Unstructured Transform, if you have not already done so, at [https://transform.unstructured.io](https://transform.unstructured.io).
2. On the sidebar, click **API Keys**.
3. In the **API Key** field, click the pages icon (**Copy**) to copy your Unstructured API key.
4. Set your `UNSTRUCTURED_API_KEY` environment variable to this value.
5. In the **API URL** field, click the pages icon (**Copy**) to copy your Unstructured API URL. This value should be `https://platform-api.transform.unstructured.io/api/v1`.
6. Set your `UNSTRUCTURED_API_URL` environment variable to this value.

## View Transform API documentation

Unstructured Transform uses the Unstructured API. To view the related
API reference documentation, see the following:

* [Step 1: Create a file parsing job in Transform](/api-reference/api/job/create-job)
* [Step 2: Get the job's details](/api-reference/api/job/get-job)
* [Step 3: Download the completed job's output](/api-reference/api/job/download-job-output)
* [View the OpenAPI specification](https://platform-api.transform.unstructured.io/docs)

## Next steps

* [Get started using Transform in your favorite AI tool](/transform/get-started/overview): Find detailed setup instructions for your AI tool of choice. Connect to the Unstructured Transform MCP server, drag and drop files, and have Transform start producing partitioned and enriched data based on your files in minutes.
* [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.
