An autonomous agent powered by ReAct (Reason-Act) loop that automates local business reputation management. The agent monitors reviews, responds to customers, and generates weekly performance insights.
- Python 3.8+
- Active MEWCP account with Business & Gmail credentials
- OpenRouter API key
-
Clone or navigate to the project directory:
cd business-agent -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables:
cp .env.example .env # Edit .env with your credentials
See .env.example for all required variables:
Google Business MCP Service:
BUSINESS_MCP_API_KEY: API key for Google Business MCP serviceBUSINESS_CREDENTIAL_ID: Google Business credential ID
Gmail MCP Service:
GMAIL_MCP_API_KEY: API key for Gmail MCP serviceGMAIL_CREDENTIAL_ID: Gmail credential ID
LLM Provider:
OPENROUTER_API_KEY: OpenRouter API key for LLM access
python main.pyThe agent will:
- Get review summary for the location
- Fetch unanswered reviews
- Reply to each review individually
- Pull weekly performance insights
- Send a digest email to the owner
- Output step-by-step reasoning and results
Edit config.py to customize:
- Model Selection: Change
MODELto use different LLM providers:MODEL = "anthropic/claude-sonnet-4-6" # or openai/gpt-4o-mini, etc.
- Max Steps: Adjust
MAX_STEPSto control maximum iterations - API Timeouts: Modify
LLM_TIMEOUTfor HTTP requests
Edit main.py and update the run_agent() call:
await run_agent(
location_name="accounts/YOUR_ACCOUNT_ID/locations/YOUR_LOCATION_ID",
owner_email="owner@yourbusiness.com",
)┌─ Observe ──────────────────────────────────────┐
│ Current state: reviews, insights, progress │
├─ Reason ───────────────────────────────────────┤
│ LLM decides next action (decide function) │
├─ Act ──────────────────────────────────────────┤
│ Execute tool via fastMCP │
├─ Reflect ──────────────────────────────────────┤
│ LLM analyzes result (reflect function) │
├─ Update ──────────────────────────────────────┤
│ State manager tracks progress │
└─ Loop (until done or max steps reached) ───────┘
The agent maintains state including:
location_name: Business locationowner_email: Email recipientreview_stats: Summary of reviewsunanswered_reviews: List of reviews needing repliesreplied_reviews: Tracking of completed repliesinsights: Weekly performance metricsactions_taken: History of executed actions
| Tool | Purpose |
|---|---|
get_review_summary |
Get total reviews, avg rating, reply rate, distribution |
list_reviews |
Fetch recent reviews (can filter by rating) |
reply_to_review |
Post reply to individual review |
get_insights |
Pull weekly metrics (views, clicks, directions) |
send_message |
Send digest email to owner |
The agent prints step-by-step progress:
============================================================
Business Operations Agent | model: google/gemini-2.5-flash
Location : accounts/123456789/locations/987654321
Owner : owner@yourbusiness.com
============================================================
── Step 1 ────────────────────────────────────────────────
Thought : I should start by getting a summary of reviews...
Action : get_review_summary {...}
Result : {'total_reviews': 42, 'avg_rating': 4.5, ...}
Reflect : Good progress. Now I need to list reviews...
[...]
============================================================
Done — 5 steps | 3 replies sent
============================================================
KeyError: 'BUSINESS_MCP_API_KEY'
Solution: Create .env file with all required variables (see .env.example). Make sure both BUSINESS_MCP_API_KEY and GMAIL_MCP_API_KEY are set.
httpx.ConnectError: Unable to connect to gateway.mewcp.com
Solution: Verify MEWCP credentials and API key validity
openrouter.ai 429 Too Many Requests
Solution: Increase LLM_TIMEOUT in config.py or reduce MAX_STEPS
- Add tool to
BUSINESS_TOOLSorGMAIL_TOOLSin tools.py - Add tool specification to
TOOLS_SPECin tools.py - Update
update_state()in state.py if state changes are needed - Tool execution is automatic via executor.py
Edit SYSTEM_PROMPT in prompts.py to change agent behavior, rules, or execution order.
For issues or questions, refer to:
- MEWCP Documentation: https://mewcp.com
- OpenRouter Models: https://openrouter.ai/models
- fastMCP Repository: https://github.com/modelcontextprotocol/python-sdk