# Base44 web scraping: connect Irmu via MCP or API

Add live web scraping to a Base44 app. Connect the Irmu MCP server so the AI builder can read pages, or call the Irmu API from a backend function with a secret.

Two ways to use Irmu in Base44: add the MCP server so the builder's AI can read live pages while it builds, and call the API from a backend function so your published app scrapes in production.

## Option A: MCP server

1. **Open MCP Connections** — Click your workspace name at the bottom left, then Account preferences → Builder, and scroll to MCP Connections. Custom MCP needs a Base44 Builder plan or higher.

2. **Add custom MCP** — Click Add custom MCP, name it Irmu and paste the server URL. Choose OAuth as the authentication.

```text
https://app.irmu.com/mcp
```

3. **Or use an API key** — Instead of OAuth, click Add header, enter Authorization as the header name and Bearer followed by your Irmu API key as the value:

```json
{
  "mcpServers": {
    "irmu": {
      "url": "https://app.irmu.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_IRMU_API_KEY"
      }
    }
  }
}
```

4. **Test & add** — Click Test & add. With OAuth, sign in to Irmu when asked. The connection works in the AI chat for every app on your account.

5. **Try it** — Ask the builder: "Use the Irmu MCP to fetch https://example.com/pricing and build a page comparing its plans."

## Option B: call the API from your app

1. **Add the secret** — In your app's settings, add a secret named IRMU_API_KEY with a key from the Irmu dashboard. Never put it in frontend code.

2. **Create a backend function** — Ask Base44 to create a backend function called scrape. It should look like this:

```typescript
// Base44 backend function (Deno). Secret: IRMU_API_KEY.
Deno.serve(async (req) => {
  const { url } = await req.json();
  const key = Deno.env.get("IRMU_API_KEY");
  const params = new URLSearchParams({ url, format: "markdown" });
  let res = await fetch(`https://app.irmu.com/api/crawl?${params}`, {
    headers: { Authorization: `Bearer ${key}` },
  });
  // Slow pages return 202 with a job id: poll until ready (polling is free).
  while (res.status === 202) {
    const { job_id } = await res.json();
    await new Promise((r) => setTimeout(r, 3000));
    res = await fetch(`https://app.irmu.com/api/crawl/${job_id}`, {
      headers: { Authorization: `Bearer ${key}` },
    });
  }
  return new Response(await res.text(), {
    status: res.status,
    headers: { "Content-Type": "application/json" },
  });
});
```

3. **Call it from your app** — Ask the builder to call the scrape function from your page and save the result to an entity, e.g. "Call the scrape function with this URL and store title and price in a Products entity."

4. **Give the AI the rules** — Paste the Irmu agent rules from /developers#agents into the app's instructions so it handles 202 jobs and errors correctly.

## Prompts to try

- "Extract the 10 best-selling products from this store with Irmu's crawl tool and save them to a Products entity." (tools: crawl)
- "Build a dashboard that checks every week whether Google shows an AI Overview for my keywords and which sites it cites." (tools: google_ai_overview)
- "Make a hotel finder for Madrid next weekend using Irmu's Booking.com search, showing price and rating." (tools: booking_search, booking_hotel)
- "Take a screenshot of my competitors' homepages every Monday and show them in a gallery." (tools: screenshot)

## FAQ

**What does it cost?** The same credits as the REST API: 1 credit for a plain page, more with JavaScript rendering or premium IPs, 30 flat for Google AI Overview, ChatGPT and Booking.com. Using MCP adds nothing. See /pricing.

**I get a 401 error.** The API key is missing or wrong. Check the secret is named IRMU_API_KEY, has no extra spaces, and is read on the server, not in browser code.

**I get a 202 instead of data.** The page took longer than the request window. The response carries a job id; call GET /crawl/{job} until it stops returning 202. Collecting is free.

**Should I use MCP or the API?** MCP lets the AI agent fetch pages while it builds or answers you. The API is for the app you publish, so your users' actions trigger scrapes. Most projects use both.

**Do I need a paid Base44 plan?** Custom MCP connections need a Base44 Builder plan or higher. Backend functions and secrets also depend on your plan; Irmu works the same on any of them.

Full MCP setup: https://irmu.com/docs/mcp · Recipe blocks: https://irmu.com/docs/recipes