langchain-clawifi
LangChain tools for Clawifi: web search and page reading for agents.
ClawifiSearchsearches the web (POST /search/free) and returns title, URL and snippet for each result.ClawifiFetchreads a page or PDF (POST /fetch) and returns its main content as Markdown. Pass aqueryto get only the passages that answer it.
Both tools wrap the official clawifi Python SDK and support sync and async calls.
Source: https://github.com/ReARCLabs/clawifi-langchain
Install
pip install -U langchain-clawifi
Credentials
Set CLAWIFI_API_KEY, or pass api_key= to a tool. Keys come from clawifi.dev.
export CLAWIFI_API_KEY="..."
Without a key the tools still work, through the keyless trial below.
Keyless trial
The Clawifi REST API needs a key. Without one, the tools call the trial tools of Clawifi's hosted MCP server instead (Remote MCP): search_free and fetch_url at https://api.clawifi.dev/mcp. The trial's limits, from the Clawifi docs:
- 12 calls a minute and 50 a day per address. On a shared host (serverless, CI) many apps can share one outbound address, so set
CLAWIFI_API_KEYin production. - Search returns at most 3 results, and domain and time filters are not applied.
- Fetched pages are cut at 20,000 characters; with
query, up to 3 passages come back. - Usually the day's limit comes back as HTTP 401 ("keyless limit reached") and the minute's limit as HTTP 429 with
Retry-After.
A free account has 1,000 credits a month (sign up). With a key, the tools use the REST API and your plan's limits.
ClawifiSearch returns the same shape with or without a key. Without a key it adds one field, keyless_note, which says which limits applied:
{
"results": [{"rank": 1, "title": "...", "url": "https://...", "snippet": "..."}],
"keyless_note": "Keyless trial through Clawifi's hosted MCP server: at most 3 results, ...",
}
ClawifiFetch returns the same fields with or without a key. The render option is not sent without a key.
Use the tools directly
from langchain_clawifi import ClawifiFetch, ClawifiSearch
search = ClawifiSearch(max_results=5)
out = search.invoke({"query": "what is the Model Context Protocol"})
# {"results": [{"rank": 1, "title": "...", "url": "https://...", "snippet": "..."}, ...]}
# Without a key, out also has "keyless_note".
fetch = ClawifiFetch(max_chars=8000)
page = fetch.invoke({"url": out["results"][0]["url"], "query": "who maintains it?"})
# {"url": "...", "title": "...", "content_status": "ok", "content": "..."}
Use them in an agent
from langchain.agents import create_agent
from langchain_clawifi import ClawifiFetch, ClawifiSearch
agent = create_agent(
model="anthropic:claude-sonnet-5-5",
tools=[ClawifiSearch(), ClawifiFetch()],
)
agent.invoke({"messages": [{"role": "user", "content": "Summarize the latest MCP spec changes."}]})
Options
| Tool | Option | Default | Meaning |
|---|---|---|---|
| both | api_key |
CLAWIFI_API_KEY |
API key; optional |
| both | api_base |
SDK default | Override the API URL |
| both | client / async_client |
built on first call | Pass your own clawifi.Clawifi / AsyncClawifi; see Clients and sessions |
ClawifiSearch |
max_results |
5 |
Results per call when the call does not set one |
ClawifiSearch |
country, language |
none | Passed to the search |
ClawifiFetch |
max_chars |
20000 |
Cut the returned Markdown to this length |
ClawifiFetch |
render |
API default | "never", "auto" or "always" |
Call arguments the model can set: query, max_results, time_range (day/week/month/year), include_domains, exclude_domains for search; url, query for fetch.
API errors, including keyless trial limits, are raised as ToolException. Set handle_tool_error=True on a tool to return the error text to the model instead.
Clients and sessions
- Path: A key, or any client you pass, selects the REST API. The keyless trial is used only when there is neither. A key of only whitespace counts as no key, whether it is passed as an argument or set in
CLAWIFI_API_KEY. - Sync and async: With a key, a mode whose client you did not pass is built with that key. It uses the
api_baseof the client you did pass, unless you setapi_baseyourself. Without a key, pass bothclientandasync_clientif you call both modes; if you pass only one, calls in the other mode raiseClawifiClientConfigError. - Trial calls: Clawifi's hosted MCP server is stateless, so each keyless call is a single
tools/callrequest. If a server explicitly asks for initialization (JSON-RPC error -32002, or a "not initialized" / "missing session" /Mcp-Session-Idmessage), the call initializes once, retries, and then ends any session the server opened. A 404 after that fallback is not retried; the hosted server is stateless, so this does not come up there. The trial limits count tool calls. UseCLAWIFI_API_KEYin production. - Closing:
close()closes the sync HTTP client, and the next call builds a new one.aclose()has nothing to close. A transport you pass in is never closed.
Costs
Each search or fetch call uses Clawifi credits; see Pricing and credits.
Development
pip install -e . pytest pytest-asyncio "langchain-tests>=1.1.9,<2"
pytest
The unit tests mock every HTTP call and never reach the network.
License
MIT
Metadata
Release files for langchain-clawifi 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_clawifi-0.1.0.tar.gz | 25.5 kB | Without provenance | Details for langchain_clawifi-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_clawifi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_clawifi-0.1.0-py3-none-any.whl |
Total release size: 41.1 kB
Release files / langchain_clawifi-0.1.0.tar.gz
| Download URL | langchain_clawifi-0.1.0.tar.gz |
|---|---|
| Size | 25.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56981e036ca37cdc8fbe04d2eddd54d66e9e86efd7e14ca3d03e3ca4a8a61845
|
|
BLAKE2b-256 checksum How to use checksums |
938491af6db862318bd3f1e4f62c1bd9953eba471f0f9522b9f53f2fd1d2e2d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.7
|
Release files / langchain_clawifi-0.1.0-py3-none-any.whl
| Download URL | langchain_clawifi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bae5fa44ebd2f7634ab317b8fbbd1c71413c68345f7c947b0c6135bb3358f4cd
|
|
BLAKE2b-256 checksum How to use checksums |
54725b40c9ec9e22c458542275dc0ed8f02f4ae534da3139cfef70c60b4806c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.7
|
Security for langchain-clawifi 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.