> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-docs-scavio-google-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Brave Agent - Search for Brave

> Create an agent that uses Anthropic to search for information using the Brave MCP server.

<Warning>
  This example uses the deprecated `@modelcontextprotocol/server-brave-search` package and `claude-sonnet-4-20250514`, which Anthropic retired on June 15, 2026. Apply both migrations below before running. See [Brave's maintained MCP server](https://github.com/brave/brave-search-mcp-server) and [Anthropic model deprecations](https://platform.claude.com/docs/en/about-claude/model-deprecations).
</Warning>

```python brave.py theme={null}
"""MCP Brave Agent - Search for Brave

This example shows how to create an agent that uses Anthropic to search for information using the Brave MCP server.

You can get the Brave API key from https://brave.com/search/api/

Run: `uv pip install anthropic mcp agno` to install the dependencies
"""

import asyncio
from os import getenv

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.mcp import MCPTools
from agno.utils.pprint import apprint_run_response

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


async def run_agent(message: str) -> None:
    async with MCPTools(
        "npx -y @modelcontextprotocol/server-brave-search",
        env={
            "BRAVE_API_KEY": getenv("BRAVE_API_KEY"),
        },
    ) as mcp_tools:
        agent = Agent(
            model=Claude(id="claude-sonnet-4-20250514"),
            tools=[mcp_tools],
            markdown=True,
        )

        response_stream = await agent.arun(message)
        await apprint_run_response(response_stream)


# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    asyncio.run(run_agent("What is the weather in Tokyo?"))
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "agno[mcp]" anthropic
    ```
  </Step>

  <Step title="Prepare Node.js">
    The maintained Brave MCP server requires Node.js 22 or later. Install it, then confirm `node --version` reports v22 or later and `npx` is available:

    ```bash theme={null}
    node --version
    npx --version
    ```
  </Step>

  <Step title="Export your API keys">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
      export BRAVE_API_KEY="your_brave_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:ANTHROPIC_API_KEY="your_anthropic_api_key_here"
      $Env:BRAVE_API_KEY="your_brave_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Update the Brave MCP server">
    Replace `npx -y @modelcontextprotocol/server-brave-search` with `npx -y @brave/brave-search-mcp-server --transport stdio` in the saved file.
  </Step>

  <Step title="Update the Claude model">
    Replace `Claude(id="claude-sonnet-4-20250514")` with `Claude(id="claude-sonnet-4-6")` in the saved file.
  </Step>

  <Step title="Run the example">
    Save the code above as `brave.py`, then run:

    ```bash theme={null}
    python brave.py
    ```
  </Step>
</Steps>

Full source: [cookbook/91\_tools/mcp/brave.py](https://github.com/agno-agi/agno/blob/main/cookbook/91_tools/mcp/brave.py)
