Skip to main content
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 and Anthropic model deprecations.
brave.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

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:
4

Export your API keys

5

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.
6

Update the Claude model

Replace Claude(id="claude-sonnet-4-20250514") with Claude(id="claude-sonnet-4-6") in the saved file.
7

Run the example

Save the code above as brave.py, then run:
Full source: cookbook/91_tools/mcp/brave.py