An interactive MCP (Model Context Protocol) agent built with Python that leverages LangChain, Groq, and Playwright to provide intelligent browser automation and web interactions.
This project implements an MCP agent that can interact with multiple MCP servers including:
- Playwright: Browser automation and web scraping
- Airbnb: Search and retrieve Airbnb listings
- DuckDuckGo Search: Web search capabilities
The agent uses Groq's Qwen model via LangChain for natural language understanding and decision-making, with built-in conversation memory for context-aware interactions.
- 🤖 Intelligent Agent: Powered by Groq's Qwen3-32B model via LangChain
- 🌐 Browser Automation: Full Playwright integration for web interactions
- 💬 Conversation Memory: Maintains context across multiple interactions
- 🔌 MCP Integration: Seamlessly connects to multiple MCP servers
- 📦 Modern Tooling: Built with
uvfor fast dependency management
- Python 3.12 or higher
- uv package manager
- Node.js and npm (for MCP servers that use npx)
- Groq API key
If you don't have uv installed, install it using one of these methods:
# Using curl
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or using pip
pip install uvcd mcp-agent
# Create virtual environment and install dependencies with uv
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
uv pip install -r requirements.txt
# Or use uv sync if you have a pyproject.toml
uv syncCreate a .env file in the project root:
GROQ_API_KEY=your_groq_api_key_hereYou can get a Groq API key from console.groq.com.
The Playwright MCP server may require browser installation:
npx playwright installmcp-agent/
├── main.py # Main agent implementation
├── browser_mcp.json # MCP server configuration
├── pyproject.toml # Python project configuration
├── requirements.txt # Python dependencies
├── uv.lock # uv lock file
├── .env # Environment variables (create this)
└── README.md # This file
# Activate virtual environment
source .venv/bin/activate
# Run the agent
python main.pyOnce the agent is running, you can:
- Chat normally: Type your questions or requests
- Type
clear: Clear the conversation history - Type
exitorquit: End the conversation
You: Search for Airbnb listings in San Francisco for next weekend
You: Take a screenshot of the first search result
You: Navigate to google.com and search for "Python MCP"
You: What was the first thing I asked you?
The browser_mcp.json file configures which MCP servers are available:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
},
"airbnb": {
"command": "npx",
"args": ["-y", "@openbnb/mcp-server-airbnb"]
},
"duckduckgo-search": {
"command": "npx",
"args": ["-y", "duckduckgo-mcp-server"]
}
}
}You can add or remove MCP servers by modifying this configuration file.
In main.py, you can customize:
- Model: Change the Groq model (default:
qwen/qwen3-32b) - Max Steps: Adjust
max_stepsparameter (default: 15) - Memory: Toggle
memory_enabled(default: True)
agent = MCPAgent(
llm=llm,
client=client,
max_steps=15, # Maximum reasoning steps
memory_enabled=True, # Enable conversation memory
)- mcp-use (>=1.4.0): Python library for interacting with MCP servers
- langchain-groq (>=1.0.1): LangChain integration for Groq models
- python-dotenv (>=1.2.1): Environment variable management
- @playwright/mcp: Browser automation server
- @openbnb/mcp-server-airbnb: Airbnb search server
- duckduckgo-mcp-server: DuckDuckGo search server
- Initialization: The agent loads MCP server configurations and initializes the Groq LLM
- User Input: Receives natural language commands from the user
- Reasoning: The LLM decides which MCP tools to use based on the request
- Execution: Calls appropriate MCP server tools (e.g., Playwright for browser actions)
- Response: Returns results to the user with conversation context maintained
- Add the server configuration to
browser_mcp.json - Restart the agent
- The agent will automatically discover and use the new server's tools
You can extend the agent by:
- Adding custom tools to the MCPAgent
- Implementing additional MCP servers
- Customizing the LLM prompt or behavior
- Adding new conversation commands
- MCP Documentation
- mcp-use Python Library
- LangChain Documentation
- Groq API Documentation
- Playwright Documentation
- uv Documentation
[Add your license here]
[Add contribution guidelines here]