# Agent Memory Feeder - Web to Clean Markdown Chunks (`apricot_blackberry/agent-memory-feeder`) Actor

Feed your AI agent knowledge. Fetches any web page, strips nav and boilerplate with Mozilla Readability, converts to clean markdown, and splits it into overlapping, deduplicated, token-sized chunks ready for embeddings and RAG. One call turns a URL list into agent memory.

- **URL**: https://apify.com/apricot\_blackberry/agent-memory-feeder.md
- **Developed by:** [Creator Fusion](https://apify.com/apricot_blackberry) (community)
- **Categories:** AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Agent Memory Feeder

Turn web pages and docs into **clean, chunked markdown memory** your AI agent can store in a vector DB and retrieve. Point it at a list of URLs; get back deduplicated, sentence-aware markdown chunks with token estimates and a source hash for each — ready to embed.

Built for agents: direct-first fetching (proxy only as a paid fallback), boilerplate/nav/ad stripping via Mozilla Readability, HTML→markdown conversion, overlapping chunking on sentence boundaries, and near-duplicate removal (Jaccard shingling).

### Input

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `urls` | string\[] | yes | — | Page/doc URLs to convert into memory. |
| `maxCharsPerChunk` | integer | no | `1200` | Target max chunk size in characters (~4 chars/token). |
| `chunkOverlap` | integer | no | `150` | Characters of context carried between adjacent chunks. |
| `proxyConfiguration` | object | no | Apify Proxy | Proxy used **only** when a direct fetch is blocked (403/429/503). Billed to you. |

### Output

One dataset row per memory chunk:

```json
{
  "url": "https://example.com/page",
  "title": "Page Title",
  "chunkIndex": 0,
  "totalChunks": 7,
  "text": "# Heading\n\nClean markdown chunk...",
  "charCount": 1187,
  "tokenEstimate": 297,
  "sourceHash": "9f2c...e1"
}
```

`sourceHash` is the SHA-256 of the full extracted source text — use it to detect when a page changed and re-embed only what moved.

### Behavior

- **Direct-first, proxy-fallback.** Fetches go out on the datacenter IP first; the caller proxy is used only when a page returns 403/429/503. All proxy is billed to you.
- **Partial success.** If some URLs fail, you still get chunks for the ones that worked; failures are logged.
- **Fail-loud.** If *every* URL yields no content, the run exits non-zero with a status message (nothing is billed for empty URLs).

### Run it from an agent

#### MCP (Apify Actors MCP server)

Expose this Actor as a tool via the Apify MCP server, then call:

```json
{
  "tool": "apricot_blackberry/agent-memory-feeder",
  "input": {
    "urls": ["https://en.wikipedia.org/wiki/Retrieval-augmented_generation"],
    "maxCharsPerChunk": 1200,
    "chunkOverlap": 150
  }
}
```

#### curl (run and fetch items)

```bash
curl -X POST "https://api.apify.com/v2/acts/apricot_blackberry~agent-memory-feeder/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"urls":["https://en.wikipedia.org/wiki/Retrieval-augmented_generation"]}'
```

#### JavaScript (apify-client)

```js
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_TOKEN' });

const run = await client.actor('apricot_blackberry/agent-memory-feeder').call({
    urls: ['https://en.wikipedia.org/wiki/Retrieval-augmented_generation'],
    maxCharsPerChunk: 1200,
    chunkOverlap: 150,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
for (const chunk of items) {
    // await vectorStore.add({ id: `${chunk.sourceHash}:${chunk.chunkIndex}`, text: chunk.text });
    console.log(chunk.chunkIndex, chunk.tokenEstimate, chunk.title);
}
```

#### Python (apify-client)

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_TOKEN")
run = client.actor("apricot_blackberry/agent-memory-feeder").call(run_input={
    "urls": ["https://en.wikipedia.org/wiki/Retrieval-augmented_generation"],
    "maxCharsPerChunk": 1200,
    "chunkOverlap": 150,
})
for chunk in client.dataset(run["defaultDatasetId"]).iterate_items():
    # vector_store.add(id=f'{chunk["sourceHash"]}:{chunk["chunkIndex"]}', text=chunk["text"])
    print(chunk["chunkIndex"], chunk["tokenEstimate"], chunk["title"])
```

### Pricing

Pay-per-event. A small actor-start fee plus a per-chunk fee for each memory chunk produced. Empty/failed URLs are never charged. Proxy usage, when the fallback triggers, is billed to your account.

# Actor input Schema

## `urls` (type: `array`):

List of page or document URLs to turn into agent memory. Each is fetched, stripped of navigation/ads/boilerplate, converted to clean markdown, and split into overlapping chunks.

## `maxCharsPerChunk` (type: `integer`):

Target maximum size of each memory chunk in characters. Chunks are split on sentence/paragraph boundaries so they stay under this size. Roughly 4 characters per token, so 1200 is ~300 tokens.

## `chunkOverlap` (type: `integer`):

Number of characters of trailing context carried over from the previous chunk into the next, so retrieval keeps continuity across chunk boundaries.

## `proxyConfiguration` (type: `object`):

Proxy used ONLY as a fallback when a direct fetch is blocked (HTTP 403/429/503). Fetches are billed to you; direct-first keeps cost low. Leave default to enable Apify Proxy fallback.

## Actor input object example

```json
{
  "urls": [
    "https://en.wikipedia.org/wiki/Retrieval-augmented_generation"
  ],
  "maxCharsPerChunk": 1200,
  "chunkOverlap": 150,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# 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 = {
    "urls": [
        "https://en.wikipedia.org/wiki/Retrieval-augmented_generation"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("apricot_blackberry/agent-memory-feeder").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 = { "urls": ["https://en.wikipedia.org/wiki/Retrieval-augmented_generation"] }

# Run the Actor and wait for it to finish
run = client.actor("apricot_blackberry/agent-memory-feeder").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 '{
  "urls": [
    "https://en.wikipedia.org/wiki/Retrieval-augmented_generation"
  ]
}' |
apify call apricot_blackberry/agent-memory-feeder --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,apricot_blackberry/agent-memory-feeder"
        }
    }
}

```

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/0j2UiLoCpOqEveJZp/builds/631mlO1mf3YgDMtw0/openapi.json
