A sophisticated AI dining assistant built with Amazon Bedrock AgentCore, featuring BrightData MCP integration for real restaurant search and a React frontend with dynamic model selection.
- Python 3.11+
- Node.js 18+
- AWS CLI configured
- BrightData API token (Get one here)
git clone https://github.com/awsdataarchitect/bedrock-dining-agent.git
cd agentcore
# Setup Python environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
# Setup environment variables
cp .env.example .env
# Edit .env and add your BRIGHTDATA_API_TOKENcd bedrock-dining-agent/frontend
npm install
cd ../..# Start backend (port 8080)
python app.py &
# Start frontend (port 3000)
cd bedrock-dining-agent/frontend && npm start &- Open http://localhost:3000
- Try: "Find Italian restaurants in San Francisco"
- Should return real restaurant results
- Framework: Amazon Bedrock AgentCore with Strands Agent
- Models: 5 selectable models (Nova Premier, Nova Micro, Claude Sonnet 4, Claude Opus 4.1, GPT-OSS 120B)
- MCP Integration: BrightData for real restaurant search
- Port: 8080
- Framework: React with TypeScript + Tailwind CSS
- Features: Model selector, restaurant search, dining plans
- Port: 3000
Create .env file with:
# Required: BrightData MCP API Token
BRIGHTDATA_API_TOKEN=your_brightdata_token_here
# Optional: Frontend URL for CORS (default: http://localhost:3000)
FRONTEND_URL=http://localhost:3000
# Optional: Backend URL for frontend (default: http://localhost:8080)
REACT_APP_API_URL=http://localhost:8080- Nova Premier (Default) - Best performance
- Nova Micro - Cost-effective
- Claude Sonnet 4 - Latest Claude
- Claude Opus 4.1 - Most capable Claude
- GPT-OSS 120B - Open source option
# Backend only
python app.py
# Frontend only
cd bedrock-dining-agent/frontend && npm start
# Both (background)
python app.py & && cd bedrock-dining-agent/frontend && npm start &curl -X POST http://localhost:8080/invocations \
-H "Content-Type: application/json" \
-d '{"prompt": "Find Italian restaurants in San Francisco"}'- search_engine - Google search for restaurants
- scrape_as_markdown - Extract menu data from websites
- create_dining_plan - Generate dining plans with cost estimates
./deploy.sh# Install AgentCore toolkit
pip install bedrock-agentcore strands-agents bedrock-agentcore-starter-toolkit
# Configure and deploy
agentcore configure -e app.py
agentcore launch
# CRITICAL: Set environment variables
aws bedrock-agentcore-control update-agent-runtime \
--agent-runtime-id YOUR_AGENT_ID \
--agent-runtime-artifact 'containerConfiguration={containerUri=YOUR_ECR_URI}' \
--role-arn YOUR_EXECUTION_ROLE_ARN \
--network-configuration 'networkMode=PUBLIC' \
--protocol-configuration 'serverProtocol=HTTP' \
--environment-variables 'BRIGHTDATA_API_TOKEN=your_token_here'
# Test deployed agent
agentcore invoke '{"prompt": "Find restaurants in Toronto"}'To test the deployed AgentCore runtime with your local frontend:
python cloud_proxy.py &This starts a proxy server on port 8081 that connects your local frontend to the deployed AgentCore runtime, enabling seamless local-to-cloud testing.
Environment variables MUST be set at the AgentCore runtime level, NOT in YAML config:
β Wrong (doesn't work):
environment:
BRIGHTDATA_API_TOKEN: "${BRIGHTDATA_API_TOKEN}"β Correct (required):
aws bedrock-agentcore-control update-agent-runtime --environment-variables 'BRIGHTDATA_API_TOKEN=token'The frontend includes a switcher to test both:
- Local: Uses localhost:8080 backend
- Cloud: Uses deployed AgentCore runtime via localhost:8081 proxy
Start cloud proxy for testing:
python cloud_proxy.py &agentcore/
βββ app.py # Main AgentCore application
βββ cloud_proxy.py # Cloud testing proxy
βββ .env # Environment variables
βββ requirements.txt # Python dependencies
βββ .bedrock_agentcore.yaml # AgentCore config will be automatically generated by AgentCore
βββ deploy.sh # Automated deployment
βββ bedrock-dining-agent/
βββ frontend/ # React frontend
βββ src/
βββ package.json
- Environment variables stored in
.env(never committed) - CORS configured for frontend URL only
- No hardcoded API tokens in code
- Production-ready error handling
- β 5 Bedrock models with dynamic switching
- β Smart tool routing based on user intent
- β Local and cloud deployment ready
- β TypeScript frontend with model selector
- β CAPTCHA-protected web scraping via BrightData MCP Server tools
Deploy: ./deploy.sh | Test: http://localhost:3000
--agent-runtime-id YOUR_AGENT_ID
--agent-runtime-artifact 'containerConfiguration={containerUri=YOUR_ECR_URI}'
--role-arn YOUR_EXECUTION_ROLE_ARN
--network-configuration 'networkMode=PUBLIC'
--protocol-configuration 'serverProtocol=HTTP'
--environment-variables 'BRIGHTDATA_API_TOKEN=your_token_here'
#### Verification:
```bash
# Verify environment variables are set
aws bedrock-agentcore-control get-agent-runtime --agent-runtime-id YOUR_AGENT_ID
# Should show: "environmentVariables": {"BRIGHTDATA_API_TOKEN": "your_token"}
Why This Matters: AgentCore has separate deployment and runtime configuration layers. The YAML file handles deployment settings, but runtime environment variables require a separate AWS CLI call to the runtime API.
# Copy environment template
cp .env.example .env
# Edit .env with your actual BrightData API token
# Install Python dependencies
source .venv/bin/activate
pip install -r requirements.txt
# Install frontend dependencies
cd bedrock-dining-agent/frontend
npm install# Kill any existing backend
pkill -f "python app.py"
# Start local backend in background (port 8080)
cd bedrock-dining-agent
source .venv/bin/activate
python app.py & # CRITICAL: Always use & for background# Start cloud proxy in background (port 8081)
cd bedrock-dining-agent
source .venv/bin/activate
python cloud_proxy.py & # CRITICAL: Always use & for background# Kill any existing frontend
pkill -f "npm start"
# Start frontend in background
cd bedrock-dining-agent/frontend
npm start > /dev/null 2>&1 & # CRITICAL: Always use & for background# One-liner to restart everything in background
pkill -f "python app.py" && pkill -f "python cloud_proxy.py" && pkill -f "npm start" && cd agentcore && source .venv/bin/activate && python app.py & && python cloud_proxy.py & && cd bedrock-dining-agent/frontend && npm start > /dev/null 2>&1 &- Frontend: http://localhost:3000
- Backend API: http://localhost:8080/invocations
curl -X POST http://localhost:8080/invocations \
-H "Content-Type: application/json" \
-d '{"prompt": "Find Italian restaurants in San Francisco", "model_id": "us.amazon.nova-premier-v1:0"}'curl -X POST http://localhost:8080/invocations \
-H "Content-Type: application/json" \
-d '{"prompt": "Dining plan for Momo Chowmein", "model_id": "us.anthropic.claude-sonnet-4-20250514-v1:0"}'{
"role": "assistant",
"content": [{
"text": "π **Italian Restaurants in San Francisco**\n\n1. **Restaurant Name** - Description\n - Address: Full address\n - Rating: X.Xβ\n - Phone: (XXX) XXX-XXXX\n\n..."
}]
}- search_engine: CAPTCHA-protected Google search for restaurant discovery
- scrape_as_markdown: Website content extraction for menu data
- create_dining_plan: Smart dining plan creation with auto-menu discovery
- "Find restaurants" β
search_engineβ Returns search results - "Dining plan for [restaurant]" β
create_dining_planβ Auto-finds menu URL β Scrapes menu β Creates plan
The frontend supports seamless switching between local and cloud endpoints:
# Frontend .env file
REACT_APP_API_URL=http://localhost:8080# Frontend .env file
REACT_APP_AGENT_ARN=arn:aws:bedrock-agentcore:us-east-1:YOUR_ACCOUNT_ID:runtime/app-XXXXXXXXXX- Local Backend:
localhost:8080(AgentCore app with MCP integration) - Cloud Proxy:
localhost:8081(FastAPI proxy to deployed AgentCore)
- Endpoint Switcher Component: Toggle between local/cloud in the UI
- Real-time switching: No restart required
- Visual indicators: Shows current endpoint and ARN
- Status display: Local vs Cloud mode clearly indicated
- Development: Use local endpoint (localhost:8080)
- Production: Switch to cloud AgentCore ARN
- Testing: Toggle between both for comparison
- Deployment: Set environment variables for target endpoint
Bedrock AgentCore Cloud Agent: arn:aws:bedrock-agentcore:us-east-1:YOUR_ACCOUNT_ID:runtime/app-XXXXXXXXXX
- β Environment Variables: All credentials stored in .env file
- β No Hardcoded Tokens: BrightData API token from environment
- β CORS Configuration: Configurable frontend URL
- β Input Validation: Proper error handling and validation
- β Production Ready: Clean codebase with no unused dependencies
- Uses actual BrightData search results
- Scrapes real restaurant menus
- No mock or generated data
- 5 Bedrock models available via dropdown
- Dynamic agent creation per request
- Cross-region model support
- Context-aware tool selection
- Proper search β dining plan workflow
- Auto-menu URL discovery
- Environment-based configuration
- Clean, optimized codebase
- Comprehensive error handling
- Ready for AgentCore deployment
- Check if backend is running:
ps aux | grep "python app.py" - Restart:
pkill -f "python app.py" && cd agentcore && source .venv/bin/activate && python app.py &
- Check port 3000:
lsof -i :3000 - Restart:
pkill -f "npm start" && cd bedrock-dining-agent/frontend && npm start > /dev/null 2>&1 &
- Ensure
.envfile exists withBRIGHTDATA_API_TOKEN - Check environment loading:
python -c "import os; from dotenv import load_dotenv; load_dotenv(); print(os.getenv('BRIGHTDATA_API_TOKEN'))"
- Verify model access in Amazon Bedrock console
- Check model IDs match available models in us-east-1
- Ensure cross-region inference is enabled
- Response Time: ~2-3 seconds for restaurant search
- Model Switching: Dynamic per request
- Real Data: 100% actual search results
- Scalability: Ready for AgentCore cloud deployment