# MCP Agentic Data Transformer (`flowlockautomation/mcp-agentic-data-transformer`) Actor

- **URL**: https://apify.com/flowlockautomation/mcp-agentic-data-transformer.md
- **Developed by:** [Martin B.](https://apify.com/flowlockautomation) (community)
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## MCP Agentic Data Transformer

An Apify Python actor that transforms raw HTML or text with a multi-LLM routing architecture. It either cleans the source into Markdown or extracts data using a schema you provide.

### Features

- Native routing for OpenAI GPT-4o-mini
- Native routing for Anthropic Claude 3.5 Sonnet
- Native routing for Google Gemini 1.5 Flash
- Native routing to Cerebras hardware using Qwen
- Markdown cleanup and schema-based structured extraction

### Requirements

- Python 3.11 (the Docker image is based on `apify/actor-python:3.11`)
- A provider API key, or `TRIAL_OPENAI_API_KEY` for Playground runs
- Apify CLI for running locally or publishing the actor

### Run locally

Install the Apify CLI, then install the Python dependencies:

```powershell
npm install -g apify-cli
python -m pip install -r requirements.txt
```

Create `storage/key_value_stores/default/INPUT.json` with actor input (see examples below), then run:

```powershell
apify run
```

The result is stored in the actor's default dataset. You can also run the actor on the Apify platform by pushing it with `apify push` and supplying the input in the Console or API.

### Input

`raw_text_html` is the preferred source property. `raw_html_or_text` is also accepted as a backward-compatible fallback. The following provider API keys are optional masked inputs; provide the key for each provider you want the actor to route requests to:

- `openai_api_key`
- `anthropic_api_key`
- `gemini_api_key`
- `cerebras_api_key`

The optional `model` input selects the OpenAI model when the OpenAI route is used. It defaults to `gpt-4o-mini`; Playground runs always use that model.

#### Clean to Markdown

Omit `extraction_schema` to clean and format the input as Markdown:

```json
{
  "raw_text_html": "<html><body><h1>Example</h1><p>Source text.</p></body></html>",
  "openai_api_key": "YOUR_OPENAI_API_KEY"
}
```

The dataset item has this shape:

```json
{
  "markdown": "# Example\n\nSource text."
}
```

#### Structured extraction

Provide `extraction_schema` to request a JSON object matching the schema. For example:

```json
{
  "raw_text_html": "Acme invoice INV-42 dated 2026-09-25, total $125.00.",
  "anthropic_api_key": "YOUR_ANTHROPIC_API_KEY",
  "extraction_schema": {
    "type": "object",
    "properties": {
      "invoice_number": { "type": "string" },
      "date": { "type": "string" },
      "total": { "type": "number" }
    },
    "required": ["invoice_number", "date", "total"],
    "additionalProperties": false
  }
}
```

The actor validates the returned object against common JSON Schema constraints, including types, required properties, enums, array items, and additional properties. It also accepts a simple key/type template, for example `{ "name": "string", "age": "integer" }`.

### LLM configuration

The actor routes requests natively to the configured provider. Set one or more provider API keys in the input using the optional masked parameters listed above. When multiple providers are configured, the actor selects the appropriate native route for the requested model or provider.

| Environment variable | Default | Description |
| --- | --- | --- |
| `OPENAI_API_KEY` | None | OpenAI API key. |
| `ANTHROPIC_API_KEY` | None | Anthropic API key. |
| `GEMINI_API_KEY` | None | Google Gemini API key. |
| `CEREBRAS_API_KEY` | None | Cerebras API key. |
| `TRIAL_OPENAI_API_KEY` | None | OpenAI key used for Playground runs when no provider key is configured. |
| `LLM_MODEL` | `qwen-3.8-27b` | Cerebras model used when the Cerebras route is selected. |

Provider-specific environment variables can be used when keys are not supplied in the input. If multiple provider keys are configured, routing priority is OpenAI, Anthropic, Gemini, then Cerebras. Anthropic and Gemini use fixed models; Cerebras uses `LLM_MODEL`.

When no provider key is configured, the actor uses `TRIAL_OPENAI_API_KEY` for a Playground run. These runs are limited to 4,000 input characters and always use `gpt-4o-mini`.

The actor expects each provider's native response to contain the requested Markdown or JSON object.

### Publish

Authenticate with Apify, then push the actor from this directory:

```powershell
apify login
apify push
```

### Output

Each successful run stores one result object in the default dataset. The actor output schema links to the dataset items endpoint. Errors such as missing input, invalid model output, or an unreachable LLM endpoint fail the actor run and appear in its logs.

# Actor input Schema

## `raw_html_or_text` (type: `string`):

The raw HTML or text to transform.

## `extraction_schema` (type: `object`):

A JSON object describing the fields to extract from the raw input.

## `openai_api_key` (type: `string`):

Optional API key used to access OpenAI models.

## `anthropic_api_key` (type: `string`):

Optional API key used to access Anthropic models.

## `gemini_api_key` (type: `string`):

Optional API key used to access Gemini models.

## `cerebras_api_key` (type: `string`):

Optional API key used to access Cerebras models.

## Actor input object example

```json
{}
```

# Actor output Schema

## `markdown` (type: `string`):

Cleaned Markdown output when no extraction schema is provided.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("flowlockautomation/mcp-agentic-data-transformer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("flowlockautomation/mcp-agentic-data-transformer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call flowlockautomation/mcp-agentic-data-transformer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,flowlockautomation/mcp-agentic-data-transformer"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/7b4zPGzSnCb5I7VmO/builds/nVpI6TNTwdms3pAzG/openapi.json
