> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trycaesar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CrewAI

> Create CrewAI tools that expose Caesar search and document reading to multi-agent workflows.

Install Caesar beside your CrewAI project:

```bash theme={"system"}
pip install caesar-search crewai pydantic
```

## Search tool

```python theme={"system"}
from typing import Type

from caesar_search import Caesar
from crewai.tools import BaseTool
from pydantic import BaseModel, Field

client = Caesar()  # reads CAESAR_API_KEY


class CaesarSearchInput(BaseModel):
    query: str = Field(..., description="Search query")
    max_results: int = Field(5, description="Maximum results, 1-50")


class CaesarSearchTool(BaseTool):
    name: str = "web_search"
    description: str = "Search the web with Caesar and return ranked results with doc_id values."
    args_schema: Type[BaseModel] = CaesarSearchInput

    def _run(self, query: str, max_results: int = 5) -> str:
        response = client.search(query, max_results=max_results, verbosity="compact")
        return response.model_dump_json()
```

## Read tool

```python theme={"system"}
class CaesarReadInput(BaseModel):
    target: str = Field(..., description="Caesar doc_id or URL")
    query: str | None = Field(None, description="Optional focus question")
    max_chars: int | None = Field(None, description="Optional maximum characters to return")


class CaesarReadTool(BaseTool):
    name: str = "web_fetch"
    description: str = "Read a Caesar doc_id or URL as clean markdown."
    args_schema: Type[BaseModel] = CaesarReadInput

    def _run(self, target: str, query: str | None = None, max_chars: int | None = None) -> str:
        response = client.read(target, query=query, max_chars=max_chars)
        return response.model_dump_json()


tools = [CaesarSearchTool(), CaesarReadTool()]
```

Attach `tools` to the agents that need web retrieval. For a research crew, give search to the planning agent and read to the evidence-gathering agent, or give both tools to a single retrieval specialist.

## Feedback

Crew handoffs can lose the `search_id` unless you preserve it. Store it with the chosen `doc_id` and send feedback after the task is complete:

```python theme={"system"}
client.feedback("result_helpful", search_id=search_id, doc_id=doc_id)
```

## For agents

* Keep the search result JSON available to the crew. It contains `search_id` for feedback and `doc_id` for reading.
* Do not ask every agent to search independently. Let one retrieval agent search, then hand off selected `doc_id` values.
* Use `web_fetch` for evidence before making claims. Snippets are for triage; documents are for citations.
* If your crew runtime supports MCP, the [remote MCP server](/clients/mcp/remote) is the lowest-maintenance integration.
