Skip to main content

LlamaIndex Tools Integration: Clawifi

ClawifiToolSpec gives a LlamaIndex agent web search and page reading through Clawifi:

  • search(query, max_results=None, time_range=None): web search (POST /search/free); one Document per result, with the snippet as text and url, title, rank in metadata.
  • fetch(url, query=None): read a page or PDF (POST /fetch) as Markdown; with query, only the passages that answer it.

Both tools have async versions and wrap the official clawifi SDK.

Source: https://github.com/ReARCLabs/clawifi-llamaindex

Install

pip install llama-index-tools-clawifi

Credentials

Pass api_key= or set 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_KEY in 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.

Without a key, every search Document also carries a keyless_note in its metadata that says which limits applied. If the trial search finds nothing, the result is a single Document whose text is the note (result_count: 0 in metadata), so the note is not lost. Fetch results have the same fields with or without a key. Trial errors are raised as ClawifiKeylessError (with status and retry_after), a subclass of clawifi.ClawifiError.

Usage

from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.anthropic import Anthropic
from llama_index.tools.clawifi import ClawifiToolSpec

tools = ClawifiToolSpec(max_results=5).to_tool_list()
agent = FunctionAgent(tools=tools, llm=Anthropic(model="claude-sonnet-5-5"))

response = await agent.run("What changed in the latest MCP specification?")
print(response)

Direct calls:

spec = ClawifiToolSpec()
results = spec.search("Model Context Protocol", time_range="month")
page = spec.fetch(results[0].metadata["url"], query="who maintains it?")
print(page[0].text)

Options: max_results (default 5; without a key the trial returns at most 3; you can also change spec.max_results later), max_chars (default 20000; longer pages are cut and marked truncated in metadata), api_base, and pre-built client / async_client.

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_base of the client you did pass, unless you set api_base yourself. Without a key, pass both client and async_client if you call both modes; if you pass only one, calls in the other mode raise ClawifiClientConfigError.
  • Trial calls: Clawifi's hosted MCP server is stateless, so each keyless call is a single tools/call request. If a server explicitly asks for initialization (JSON-RPC error -32002, or a "not initialized" / "missing session" / Mcp-Session-Id message), 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. Use CLAWIFI_API_KEY in 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.

Development

pip install -e . pytest pytest-asyncio
pytest

The tests mock every HTTP call.

License

MIT

Metadata

Release files for llama-index-tools-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)

Source distribution for llama-index-tools-clawifi 0.1.0
File Size Uploaded Provenance Actions
llama_index_tools_clawifi-0.1.0.tar.gz 20.5 kB Without provenance Details for llama_index_tools_clawifi-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-tools-clawifi 0.1.0
File Interpreter ABI Platform Actions
llama_index_tools_clawifi-0.1.0-py3-none-any.whl Python 3 none any Details for llama_index_tools_clawifi-0.1.0-py3-none-any.whl

Total release size: 34.6 kB

Release files / llama_index_tools_clawifi-0.1.0.tar.gz

Download URL llama_index_tools_clawifi-0.1.0.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3da7fe652e255ddb93527da4bad496a8e161d28a28bf2c5cd2efb8e0101bd794
BLAKE2b-256 checksum
How to use checksums
19412a81fb5c1e6208e567819016b5f65e02f2248e63cabfe8e771ba4ada7071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.7

Release files / llama_index_tools_clawifi-0.1.0-py3-none-any.whl

Download URL llama_index_tools_clawifi-0.1.0-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
553037dc65c50479f722872b5dca759c8cf4b00d3be1c73a003e0406fd4372e5
BLAKE2b-256 checksum
How to use checksums
eda2d15cf3b7068f125e8adf5b3b322fb4ce4fe0d8074c2c606da7efec5f47f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.7

Security for llama-index-tools-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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page