This starter shows a single-agent ReAct loop using LangGraph that calls tools from an MCP server. It’s designed to be runnable with free-tier access via OpenRouter (or OpenAI if you already have credits).
- Takes a user request like: “Find 2-bedroom rentals in Venice under $4,000 and compare HOA fees.”
- Uses MCP tools to: (1) search a toy
listings.json(local) and (2) do a lightweight web search. - Plans → acts (tool calls) → reasons → returns a concise answer with sources and a plan summary.
- Includes guardrails hooks (approval) and memory notes (simple in-graph state).
- Create a virtual environment and install:
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt- Set your API (choose one):
OpenRouter (recommended free-tier path)
export OPENAI_API_KEY="YOUR_OPENROUTER_KEY"
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export MODEL_ID="meta-llama/llama-3.1-8b-instruct:free"OpenAI (if you already have credits)
export OPENAI_API_KEY="YOUR_OPENAI_KEY"
# No base URL needed for OpenAI; set:
export MODEL_ID="gpt-4o-mini"(You can also copy .env.example to .env and edit values.)
- Start the MCP server (stdio transport):
python mcp_server_re_lax.pyLeave it running in a terminal.
- In another terminal, run the agent:
python agent_langgraph.py "Find 2-bed rentals in Venice under $4,000, compare HOA fees and walkability."- The web search tool uses
duckduckgo-search(free; internet required). - You can extend
mcp_server_re_lax.pyto call real RE APIs (Zillow, Redfin, etc.) later. - This is a teaching starter: compact, readable, and aligned with the lesson slides.