# Web search and page reading for Pydantic AI

> Give a Pydantic AI agent Clawifi’s MCP tools in a few lines, and it can search the web, read pages and PDFs, and get back the passages that answer each question, with sources.

Canonical page: https://clawifi.dev/for/pydantic-ai

## What Clawifi gives Pydantic AI

Pydantic AI agents call the tools you hand them. Clawifi’s hosted MCP server is one toolset: web search, page reading and passage selection, so you do not write and maintain your own fetchers.

- **Search:** `search_free` searches many engines as one and returns ranked results with their sources.
- **Read:** `fetch_url` and `scrape_url` read pages and PDFs as Markdown; with a `query`, `scrape_url` returns only the passages that answer it.
- **Parse and discover:** `extract_url` pulls structured fields from a page; `map_site` lists a site’s URLs; `start_crawl` and `get_crawl` read several pages.
- **Jobs, history and monitors:** `create_job`, `get_job`, `list_history` and `list_monitors` for longer runs and scheduled checks.
- **Cost first:** `estimate` prices a call before it runs, and the account tools show your credits.

## Set it up

### 1. Get an API key

Create an account at [clawifi.dev/signup](https://clawifi.dev/signup). The Free plan includes 1,000 credits a month. Copy the key the console shows you (it is shown once) and keep it in an environment variable, `CLAWIFI_API_KEY`.

### 2. Install Pydantic AI with MCP support

The MCP client ships as an extra of `pydantic-ai-slim` ([Pydantic AI MCP client docs](https://pydantic.dev/docs/ai/mcp/client/)).

**Terminal**

```sh
pip install "pydantic-ai-slim[mcp]"
```

### 3. Add Clawifi as a toolset

`MCPToolset` connects to the hosted server over Streamable HTTP. Its `auth` argument takes your key and sends it as `Authorization: Bearer <key>`. Replace `your-model` with a model Pydantic AI supports.

**agent.py**

```python
import asyncio
import os

from pydantic_ai import Agent
from pydantic_ai.mcp import MCPToolset

clawifi = MCPToolset("https://api.clawifi.dev/mcp", auth=os.environ["CLAWIFI_API_KEY"])
agent = Agent("your-model", toolsets=[clawifi])


async def main():
    result = await agent.run("Search the web for the MCP specification and summarise it with sources.")
    print(result.output)


asyncio.run(main())
```

### 4. Run it

Set `CLAWIFI_API_KEY` and your model provider’s key, then run the script. Without a key, only `search_free`, `fetch_url`, `scrape_url` and `map_site` run, as a trial: 12 calls a minute and 50 a day per address. The other tools are still listed, but calling one without a key fails with an authorization error, so add your key before you rely on them.

Sources for this setup: [Remote MCP](https://clawifi.dev/docs/remote-mcp) · [Pydantic AI MCP client docs](https://pydantic.dev/docs/ai/mcp/client/). Clawifi works with Pydantic AI; it is not affiliated with its makers.

## Example prompts

> Search the web for the three most cited papers on retrieval-augmented generation, read their abstracts, and return the titles with links.

> Read https://pydantic.dev/docs/ai/mcp/client/ and return only the passages about authentication.

> Map https://docs.python.org/3/library/ and list the first 20 URLs, then read the asyncio page and summarise it.

## Questions

### How do I use Clawifi tools in Pydantic AI?

Install `pydantic-ai-slim[mcp]`, create `MCPToolset("https://api.clawifi.dev/mcp", auth=<your key>)`, and pass it to `Agent(..., toolsets=[...])`. The connection opens when the agent runs.

### My other toolsets use the same tool names. What now?

Call `.prefixed("clawifi")` on the toolset, and the tools become `clawifi_search_free`, `clawifi_fetch_url` and so on.

### Can I use the Python SDK instead of MCP?

Yes. `pip install clawifi` includes a Python client you can wrap in your own tools; see [SDK and CLI](https://clawifi.dev/sdk). MCP saves you writing the wrappers.

### What does it cost?

Each tool call is billed like the API route it runs: most cost 1 credit and a browser render 3. Cache hits, failures on Clawifi’s side and answers with nothing to read (a blocked page, a JavaScript shell, a 404) cost 0. The Free plan includes 1,000 credits a month. See [Pricing](https://clawifi.dev/pricing).

## Other agents and frameworks

- [Clawifi for Mastra](https://clawifi.dev/for/mastra): Connect a Mastra agent to Clawifi’s hosted MCP server with MCPClient, and it can search the web, read pages and PDFs, and get back the passages that answer each question, with sources.
- [Clawifi for Continue](https://clawifi.dev/for/continue): Add Clawifi to Continue as an MCP server, and its agent can search the web, read docs pages and PDFs, and get back the passages that answer each question, with sources.
- [Clawifi for Gumloop](https://clawifi.dev/for/gumloop): Add Clawifi to Gumloop as a custom MCP connector, and your agents can search the web, read pages and PDFs, and get back the passages that answer each question, with sources.
- [All agent guides](https://clawifi.dev/for): Every client and framework.

Next: [Integrations](https://clawifi.dev/integrations) · [Docs](https://clawifi.dev/docs) · [Pricing](https://clawifi.dev/pricing)
