# PDF AI Extractor MCP (`devaditya/pdf-ai-extractor-mcp`) Actor

Extracts text, tables, summaries, and structured data from any PDF using OpenAI, Google Gemini, or Claude. Supports bulk AI processing, clean JSON exports, and an AI-ready MCP mode for agent workflows.

- **URL**: https://apify.com/devaditya/pdf-ai-extractor-mcp.md
- **Developed by:** [lalithhh](https://apify.com/devaditya) (community)
- **Categories:** MCP servers, AI, Automation
- **Features:** Limited permissions
- **Stats:** 12 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 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

## 📄 PDF-AI Extractor MCP

**Extract any PDF → Clean Text → AI Analysis using OpenAI, Google Gemini, or Anthropic — with optional MCP Agent Server Mode.**

PDF-AI Extractor MCP is a dual-mode Apify Actor that downloads a PDF, extracts readable text, analyzes it with your chosen AI model, and returns structured output.\
It also runs as an **MCP WebSocket server** so ChatGPT, Claude, LangChain, and other AI agents can use it as a tool.

***

### 🚀 Why This Actor?

Businesses and AI workflows often struggle with PDFs:

- PDFs are messy, inconsistent, or scanned
- Extracting structured data is hard
- AI needs clean text to understand documents
- Agents need a tool interface (MCP)

This Actor solves all of it in one place.

***

### ✨ Key Features

#### 🔍 Smart PDF Extraction

- Downloads PDFs reliably
- Uses `pdf-parse` for robust extraction
- Cleans and normalizes raw PDF text

#### 🤖 Multi-AI Engine Support

Use any major model you want:

- **OpenAI** → GPT-4.1, GPT-4o, o3-mini
- **Google Gemini** → 1.5 Flash / Pro
- **Anthropic Claude** → Haiku / Sonnet / Opus

#### 🧠 AI-Enhanced Document Understanding

Your prompt + extracted PDF text →\
Summaries, structured fields, business insights, compliance checks, custom extraction, etc.

***

### 🔁 Two Operation Modes

#### **1️⃣ NORMAL MODE**

Runs once, returns structured JSON.

Perfect for:

- Document automation
- Backend workflows
- Report preparation
- Daily processing

#### **2️⃣ MCP MODE (Agent Mode)**

Turns into a **WebSocket MCP server**:

- Agents call: `extractPdf()`, `analyze()`, etc.
- ChatGPT, Claude, LangChain tools all supported
- Real-time interaction

***

### 📥 Input Schema

#### Required fields (normal mode only):

| Field | Description |
|-------|-------------|
| `mode` | `"normal"` or `"mcp"` |
| `pdfUrl` | Public PDF URL |
| `aiProvider` | `"openai"`, `"google"`, `"anthropic"` |
| `prompt` | AI instruction |

***

### 🧪 Example Input — Normal Mode

```json
{
  "mode": "normal",
  "pdfUrl": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
  "aiProvider": "openai",
  "prompt": "Extract key business information from this PDF."
}
```

***

### 📡 Example Input — MCP Mode

```json
{
  "mode": "mcp"
}
```

***

### 📤 Output Format (Normal Mode)

```json
{
  "mode": "normal",
  "aiProvider": "openai",
  "pdfUrl": "https://example.com/file.pdf",
  "charactersExtracted": 10542,
  "aiResult": "Structured AI-generated content here..."
}
```

In **MCP mode**, results stream to the connected AI.

***

### 🔧 Environment Variables

Create a `.env` file:

```
OPENAI_API_KEY=your_openai_key
GEMINI_API_KEY=your_gemini_key
ANTHROPIC_API_KEY=your_anthropic_key
MCP_PORT=8080
```

A ready `example.env` is included for users.

***

### 🛠 Architecture Overview

```
PDF URL → Downloader → pdf-parse → Cleaned Text → AI Adapter → Final JSON or MCP Stream
```

***

### 🧪 Running Tests

#### Normal mode:

```
apify run --purge --input-file=tests/input.normal.json
```

#### MCP mode:

```
apify run --purge --input-file=tests/input.mcp.json
```

Connect at:

```
ws://localhost:8080
```

***

### 📦 Project Structure

```
pdf-ai-extractor-mcp/
│
├── main.js
├── package.json
├── .env
├── .gitignore
│
├── src/
│   ├── orchestrator/orchestrator.js
│   ├── connectors/
│   │   ├── openai/adapter.js
│   │   ├── google/adapter.js
│   │   └── anthropic/adapter.js
│   ├── mcp/
│   │   ├── server.js
│   │   └── handlers.js
│   └── utils/
│       ├── pdfTools.js
│       ├── aiTools.js
│       └── fileManager.js
│
├── tests/
│   ├── input.normal.json
│   └── input.mcp.json
│
└── .actor/
    ├── actor.json
    ├── INPUT_SCHEMA.json
    ├── OUTPUT_SCHEMA.json
    └── dataset_schema.json
```

***

### 🏁 Why This Actor Will Do Great on Apify Store

- Multi-AI support is trending
- MCP tools are in demand
- PDF + AI extraction is extremely useful
- Works for enterprise, finance, research, startups
- No competitors offering dual (Normal + MCP) mode
- Very high utility → very likely to make revenue

***

### ❤️ Support & Feedback

Feel free to reach out with feature ideas or improvements.

Happy automating!\
**— PDF-AI Extractor MCP**

# Actor input Schema

## `mode` (type: `string`):

Choose 'normal' for one-time PDF extraction or 'mcp' to start the MCP server.

## `pdfUrl` (type: `string`):

Publicly accessible PDF URL or Apify key-value-store URL.

## `aiProvider` (type: `string`):

Select which AI model provider to use for PDF analysis.

## `prompt` (type: `string`):

Instruction sent to the AI model.

## Actor input object example

```json
{
  "mode": "normal",
  "pdfUrl": "",
  "aiProvider": "openai",
  "prompt": "Extract key information from this PDF."
}
```

# Actor output Schema

## `mode` (type: `string`):

normal or mcp

## `provider` (type: `string`):

openai | google | anthropic

## `pdfUrl` (type: `string`):

The PDF file that was analyzed.

## `charactersExtracted` (type: `string`):

Number of extracted characters (string format).

## `aiResult` (type: `string`):

Final AI-generated output.

## `savedFiles` (type: `string`):

Comma-separated list of saved KV file keys.

# 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("devaditya/pdf-ai-extractor-mcp").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("devaditya/pdf-ai-extractor-mcp").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 devaditya/pdf-ai-extractor-mcp --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,devaditya/pdf-ai-extractor-mcp"
        }
    }
}
```

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/FrHPyGhsE3WXglylC/builds/NC8NkasZeCt76kMKm/openapi.json
