This Jupyter Notebook demonstrates how to use the BeeAI Re-Act Agent framework integrated with the Model Context Protocol (MCP) Brave Server to perform intelligent internet searches and local lookups via Brave’s Search APIs.
- Connects to the Brave MCP server using a local subprocess.
- Discovers tools (
brave_web_search,brave_local_search) via MCP. - Initializes a Re-Act Agent (based on
OpenAI GPT-4o) that can:- Decide when to use each tool.
- React to responses and iterate intelligently.
- Runs a conversation loop allowing user queries and AI responses.
-
Install dependencies: Make sure you have:
beeai-frameworkmcpdotenv- Access to
npxand the Brave MCP server package
-
Set up
.envfile: -
Adjust paths:
- Update the
.envpath and any system paths according to your local setup.
- Load the environment and dependencies.
- Start the Brave MCP server and discover available tools.
- Initialize the Re-Act Agent with LLM, memory, and tools.
- Run the agent in a conversation loop to handle user queries.
- There's a known bug in the Brave MCP server requiring a
count=5parameter for certain queries. This is temporarily patched via the system prompt. - Outputs are color-coded and printed via a helper
ConsoleReaderclass for easier readability.
brave_web_search: Web searches with filtering/pagination.brave_local_search: Local business lookups with detailed metadata.
"What are the opening hours for La Taqueria on Mission St in San Francisco?"
→ The agent will automatically select the appropriate tool and return real-time business details.