# Web search and page reading for LangChain

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

Canonical page: https://clawifi.dev/for/langchain

## What Clawifi gives LangChain

A LangChain agent is as good as the tools you hand it. Clawifi gives it web search, page reading and passage selection as MCP tools, 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 LangChain with MCP support

LangChain’s MCP support lives in the `langchain.mcp` namespace, which its docs mark as beta ([LangChain MCP docs](https://docs.langchain.com/oss/python/langchain/mcp)).

**Terminal**

```sh
pip install "langchain[mcp]"
```

### 3. Load the tools and build the agent

Pass the key as the client’s `auth`; it is sent as `Authorization: Bearer <key>` ([LangChain MCP authentication](https://docs.langchain.com/oss/python/langchain/mcp/auth)). Replace the model name with the one you use.

**agent.py**

```python
import asyncio
import os

from fastmcp.client import Client
from langchain.agents import create_agent
from langchain.mcp import MCPAdapter


async def main():
    client = Client("https://api.clawifi.dev/mcp", auth=os.environ["CLAWIFI_API_KEY"])
    async with MCPAdapter(client) as adapter:
        tools = await adapter.list_tools()
        agent = create_agent("your-model", tools)
        result = await agent.ainvoke({"messages": [{"role": "user", "content": "Search the web for the MCP spec and summarise it."}]})
        print(result["messages"][-1].content)


asyncio.run(main())
```

### 4. Run it

Set `CLAWIFI_API_KEY` and run the script. Your model provider’s key is needed too.

Sources for this setup: [Remote MCP](https://clawifi.dev/docs/remote-mcp) · [LangChain MCP docs](https://docs.langchain.com/oss/python/langchain/mcp) · [LangChain MCP authentication](https://docs.langchain.com/oss/python/langchain/mcp/auth). Clawifi works with LangChain; 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://docs.langchain.com/oss/python/langchain/mcp 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 LangChain?

Install `langchain[mcp]`, open `MCPAdapter(Client("https://api.clawifi.dev/mcp", auth=<your key>))`, call `list_tools()`, and pass the tools to `create_agent`.

### What about langchain-mcp-adapters?

Its repository says MCP support has moved into LangChain under `langchain.mcp`. Existing code with `MultiServerMCPClient` can keep working: use the `http` transport, the URL above and an `Authorization: Bearer` header.

### 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 and failures on Clawifi’s side cost 0; a page whose site answers with an error (such as a 404) is charged as usual. The Free plan includes 1,000 credits a month. See [Pricing](https://clawifi.dev/pricing).

## Other agents and frameworks

- [Clawifi for Claude Code](https://clawifi.dev/for/claude-code): One command gives Claude Code a set of web tools: search many engines as one, read pages and PDFs, and get back the passages that answer the question, each with its source.
- [Clawifi for Cursor](https://clawifi.dev/for/cursor): Add Clawifi to Cursor and its agent can search the web, read docs pages and PDFs, and bring back the passages that answer the question, each with its source, while it edits your code.
- [Clawifi for Codex](https://clawifi.dev/for/codex): Add Clawifi to Codex and it can search the web, read pages and PDFs, and return the passages that answer the question, each with its source.
- [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)
