A robust, multi-tool AI assistant for real estate operations built using LangGraph, the Model Context Protocol (MCP) via langchain-mcp-adapters, and OpenRouter.
The agent orchestrates multiple tools across decoupled local MCP servers, external APIs, and local Python tools:
-
Property Data MCP Server (
property_data_mcp_server.py):- Manages local SQLite property listings (
property_data.db). - Tools:
search_properties(min_price, max_price, beds, baths): Flexible property queries with optional filters.get_property_details(address): Case-insensitive and partial address matching.
- Manages local SQLite property listings (
-
CRM MCP Server (
crm_mcp_server.py):- Manages clients and timestamped interaction notes (
crm_db.db). - Enforces unique email constraints and foreign keys with cascade deletion.
- Tools:
create_client_lead(name, email): Adds a client with duplicate detection.add_note_to_client(email, note): Attaches notes to existing clients.get_client_notes(email): Fetches timestamped notes for a client.
- Manages clients and timestamped interaction notes (
-
Web Search:
- Uses Tavily if
TAVILY_API_KEYis provided in.env. - Automatically and gracefully falls back to DuckDuckGo (
DuckDuckGoSearchRun) if no API key is configured.
- Uses Tavily if
-
Custom Tools:
estimate_property_price_tool(bedrooms, bathrooms): Computes baseline price approximations.end_conversation_tool(farewell_message): Allows the agent to conclude the session when the user indicates they are finished.
-
LangGraph State & Memory:
- Built on LangGraph
StateGraphwith a cyclical ReAct tool loop. - Preserves multi-turn conversational memory via
MemorySavercheckpointer.
- Built on LangGraph
Create and activate a virtual environment, then install dependencies:
python -m venv env
# On Windows PowerShell:
.\env\Scripts\Activate.ps1
# On macOS/Linux:
source env/bin/activate
pip install -r requirements.txtCopy .env.example to .env:
cp .env.example .envEdit .env and set your credentials:
# OpenRouter API Key (https://openrouter.ai/settings/keys)
OPENROUTER_API_KEY=your_openrouter_api_key_here
# OpenRouter Model (Default: google/gemma-4-26b-a4b-it)
OPENROUTER_MODEL=google/gemma-4-26b-a4b-it
# Optional Tavily API Key (Falls back to DuckDuckGo if omitted)
TAVILY_API_KEY=your_tavily_api_key_hereRun the agent without arguments to launch the multi-turn conversational REPL:
python real_estate_agent.py- Context is preserved across conversational turns.
- To exit, type
DONE,bye,exit,quit, or simply tell the agent you are finished!
Pass your query directly as arguments:
python real_estate_agent.py "Find me homes under 600000 with at least 3 bedrooms"- Property Search:
"Find me homes between 300000 and 600000 with 3+ bedrooms." - Property Details:
"Give me details for 123 Oak St" - CRM Client Management:
"Create a new client named Alice Jay with email alice.j@example.com" - Client Notes:
"Add a note to alice.j@example.com saying she prefers houses with 3+ bedrooms""Show me the notes we have for alice.j@example.com in our CRM" - Property Valuation:
"Estimate the price of a 4 bedroom 3 bathroom property" - Web Search:
"Search the web for current real estate mortgage rates and trends" - Complex Multi-Step Inquiries:
"Check if we have any notes on alice.j@example.com, then find available houses based on her preference, and estimate the price for a 4 bed 3 bath house."