房地产
STDIO全面的房地产数据管理MCP服务器
全面的房地产数据管理MCP服务器
A comprehensive Model Context Protocol (MCP) server for real estate data management. This server provides tools, resources, and prompts for property listings, agent management, market analysis, client relationships, and area intelligence.
The server is built with a modular, componentized architecture for maintainability and scalability:
real-estate-mcp/
├── main.py                    # Main server entry point
├── utils.py                   # Core data management utilities
├── tools/                     # MCP Tools (organized by category)
│   ├── property_tools.py      # Property search, filtering, insights
│   ├── agent_tools.py         # Agent profiles, performance, dashboards
│   ├── market_tools.py        # Market analysis and trends
│   ├── client_tools.py        # Client management and matching
│   ├── area_tools.py          # Area intelligence and amenities
│   └── system_tools.py        # Data management and system tools
├── resources/                 # MCP Resources (organized by domain)
│   ├── property_resources.py  # Property-related resources
│   ├── agent_resources.py     # Agent-related resources
│   ├── market_resources.py    # Market analysis resources
│   ├── client_resources.py    # Client management resources
│   └── location_resources.py  # Area and amenity resources
├── prompts/                   # MCP Prompts (user-controlled templates)
│   ├── __init__.py            # Central prompt registration
│   ├── property_prompts.py    # Property analysis and comparison prompts
│   ├── client_prompts.py      # Client matching and consultation prompts
│   ├── market_prompts.py      # Market analysis and investment prompts
│   └── agent_prompts.py       # Agent performance and development prompts
└── data/                      # Real estate data files
    ├── properties/
    ├── agents/
    ├── clients/
    ├── market/
    ├── transactions/
    ├── areas/
    └── amenities/
realestate://all-properties: Complete property listingsrealestate://all-agents: Agent directoryrealestate://market-overview: Current market trendsrealestate://all-areas: Area informationrealestate://amenities: Complete amenities databaserealestate://properties/area/{area}: Area-specific propertiesrealestate://agent/{agent_id}/dashboard: Agent performance dashboardrealestate://market/area/{area}: Area market analysisrealestate://property/{property_id}/insights: Property insightsrealestate://client/{client_id}/matches: Client property matches# Clone the repository git clone https://github.com/agentic-ops/real-estate-mcp.git cd real-estate-mcp # Create and activate virtual environment python -m venv .venv # On Windows: .venv\Scripts\activate # On macOS/Linux: source .venv/bin/activate # Install dependencies pip install -r requirements.txt # Install in Claude Desktop mcp install main.py
If you prefer manual setup, edit your Claude Desktop config file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{ "mcpServers": { "real-estate": { "command": "C:/absolute/path/to/real-estate-mcp/.venv/Scripts/python.exe", "args": ["C:/absolute/path/to/real-estate-mcp/main.py"], "env": { "PYTHONUNBUFFERED": "1" } } } }
Important:
.venv/Scripts/python.exe on Windows, .venv/bin/python on macOS/Linux)# STDIO mode (default, for Claude Desktop) python main.py # SSE mode (for remote/web access) python main.py sse
To inspect and debug your MCP server during development:
npx @modelcontextprotocol/inspector python main.py
This will launch the MCP Inspector interface, allowing you to:
Once your server is installed in Claude Desktop (see Installation above), you can immediately start using it:
Try these prompts to explore the real estate data:
Windows: Edit %APPDATA%\Claude\claude_desktop_config.json
macOS: Edit ~/Library/Application Support/Claude/claude_desktop_config.json
{ "mcpServers": { "real-estate": { "command": "python", "args": ["C:/absolute/path/to/real-estate-mcp/main.py"], "env": { "PYTHONUNBUFFERED": "1" } } } }
Important Notes:
main.py fileThis server supports two transport modes for different use cases:
Best for: Claude Desktop, MCP Inspector, local development
Advantages:
Usage:
python main.py
Best for: Remote access, web integration, team sharing, cloud deployment
Advantages:
Usage:
python main.py sse
http://127.0.0.1:8000/sse (for establishing SSE connection)http://127.0.0.1:8000/messages/ (for posting MCP messages)// Establish SSE connection const eventSource = new EventSource('http://127.0.0.1:8000/sse'); eventSource.onmessage = function(event) { const mcpMessage = JSON.parse(event.data); // Handle MCP protocol messages }; // Send MCP messages async function sendMCPMessage(message) { const response = await fetch('http://127.0.0.1:8000/messages/', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(message) }); return response.json(); }
utils.py - Data ManagementRealEstateDataManager: Central data access classPropertyFilter: Search and filtering utilitiesmain.py - Server Entry PointEach tool module follows a consistent pattern:
def register_[category]_tools(mcp: FastMCP): """Register all [category] tools with the MCP server""" @mcp.tool() def tool_function(parameters) -> str: """Tool description""" # Implementation return json.dumps(result, indent=2)
Resources are organized by domain for better maintainability:
property_resources.py)agent_resources.py)market_resources.py)client_resources.py)location_resources.py)Each module follows a consistent pattern:
def register_[domain]_resources(mcp: FastMCP): """Register all [domain] resources with the MCP server""" @mcp.resource("realestate://resource-name") def resource_function() -> str: """Resource description""" return json.dumps(data, indent=2)
Prompts guide AI analysis:
@mcp.prompt() def analysis_prompt(param: str = "default") -> str: """Analysis prompt description""" return f""" Detailed analysis instructions for {param}... """
The server operates on comprehensive real estate data:
After installing in Claude Desktop, simply chat with Claude:
User: "What properties are available in Downtown Riverside?"
Claude: Uses the search_properties tool and reads the realestate://properties/area/Downtown Riverside resource to show you all matching properties.
User: "Show me Sarah Chen's performance dashboard"
Claude: Reads the realestate://agent/AG001/dashboard resource to display comprehensive agent metrics.
User: "Find properties under $800k with 3+ bedrooms"
Claude: Uses the filter_properties tool with your criteria and presents matching listings.
# Test with MCP Inspector npx @modelcontextprotocol/inspector python main.py
Then explore tools and resources through the inspector UI.
For proper MCP client integration over HTTP, use the MCP protocol with the correct endpoints:
# Start server in SSE mode python main.py sse
# Establish SSE connection (listen for server messages) curl -N http://127.0.0.1:8000/sse # Send MCP messages (in a separate terminal) # Search properties curl -X POST http://127.0.0.1:8000/messages/ \ -H "Content-Type: application/json" \ -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "search_properties", "arguments": {"query": "Victorian"}}}' # Filter by criteria curl -X POST http://127.0.0.1:8000/messages/ \ -H "Content-Type: application/json" \ -d '{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "filter_properties", "arguments": {"min_price": 500000, "max_price": 1000000}}}' # Get market overview curl -X POST http://127.0.0.1:8000/messages/ \ -H "Content-Type: application/json" \ -d '{"jsonrpc": "2.0", "id": 3, "method": "resources/read", "params": {"uri": "realestate://market-overview"}}' # Match client preferences curl -X POST http://127.0.0.1:8000/messages/ \ -H "Content-Type: application/json" \ -d '{"jsonrpc": "2.0", "id": 4, "method": "tools/call", "params": {"name": "match_client_preferences", "arguments": {"client_id": "CLI001"}}}'
If you want to run the server in SSE mode and connect from Claude Desktop (for remote scenarios):
python main.py ssemcp-remote:{ "mcpServers": { "real-estate-remote": { "command": "npx", "args": ["-y", "mcp-remote", "http://127.0.0.1:8000/sse"] } } }
The project includes a comprehensive test suite covering all components and functionality.
tests/
├── conftest.py              # Pytest configuration and shared fixtures
├── unit/                    # Unit tests for core components
│   ├── test_utils.py        # RealEstateDataManager and PropertyFilter tests
│   └── test_*.py            # Additional unit tests
├── integration/             # Integration tests for MCP components
│   ├── test_property_tools.py    # Property tools integration tests
│   ├── test_all_tools.py         # All other tool categories
│   ├── test_resources.py         # Static and template resources tests
│   └── test_prompts.py            # Prompt template tests
└── __init__.py
tests/unit/)RealEstateDataManagertests/integration/)# Install testing dependencies pip install -r requirements.txt
# Run all tests pytest # Run with coverage report pytest --cov=. --cov-report=html # Run specific test categories pytest tests/unit/ # Unit tests only pytest tests/integration/ # Integration tests only pytest tests/integration/test_property_tools.py # Property tools only
# Run all tests python run_tests.py # Run specific test types python run_tests.py unit # Unit tests only python run_tests.py integration # Integration tests only python run_tests.py property # Property tools only python run_tests.py resources # Resource tests only # Run with verbose output and coverage python run_tests.py all -v -c
conftest.pyhtmlcov/index.htmlThe test suite validates:
For CI/CD pipelines, use:
# Basic test run pytest tests/ --tb=short # With coverage for CI reporting pytest tests/ --cov=. --cov-report=xml --cov-report=term-missing # Specific test categories for staged testing pytest tests/unit/ --tb=short # Fast unit tests first pytest tests/integration/ --tb=short # Integration tests second
When adding new functionality:
tests/unit/ for core logictests/integration/test_*.pyconftest.pyunittest.mock for isolationtest_*.py files, Test* classes, test_* methodstools/@mcp.tool() decoratorregister_*_tools() functionmain.pytests/integration/resources/ (property, agent, market, client, location)@mcp.resource() decorator and URI patternregister_*_resources() functionmain.pytests/integration/test_resources.pyprompts/ (property, client, market, or agent)@mcp.prompt() decoratorregister_*_prompts() functiontests/integration/test_prompts.pyprompts/ directory (e.g., prompts/new_category_prompts.py)register_new_category_prompts(mcp) functionprompts/__init__.pyChoose the right transport mode for your use case:
| Feature | STDIO (Default) | SSE (Remote) | 
|---|---|---|
| Best For | Claude Desktop, local tools | Web apps, remote access, team sharing | 
| Latency | ~1ms (ultra-fast) | 10-100ms (network-dependent) | 
| Multiple Clients | ❌ Single client | ✅ Multiple simultaneous clients | 
| Remote Access | ❌ Local only | ✅ Network access | 
| Setup Complexity | ✅ Simple (no config) | ⚠️ Requires port/URL management | 
| Claude Desktop | ✅ Native support | ⚠️ Requires mcp-remote proxy | 
| Auto-cleanup | ✅ Automatic | ⚠️ Manual management | 
| Security | ✅ Process isolation | ⚠️ Needs authentication | 
Use STDIO when:
Use SSE when:
The server is designed to work best with STDIO transport for the MCP ecosystem, making it:
mcp install main.pyPrimary use case (98% of users):
git clone https://github.com/agentic-ops/real-estate-mcp.git cd real-estate-mcp pip install -r requirements.txt mcp install main.py --name "Real Estate"
Advanced use case (remote deployment):
python main.py sse # Run on server # Configure clients to connect to http://your-server:8000/sse
This project is licensed under the MIT License.
For a comprehensive deep dive into the architecture, design principles, and real-world applications of this MCP server, read the detailed blog post:
🔌 MCP Servers - Model Context Protocol Implementation
The blog post covers:
Built with the Model Context Protocol (MCP) for seamless AI integration