Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions samples/python/agents/real_estate_agent/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
.gitignore
tests
.env
.vscode
__pycache__
*.pyc
12 changes: 12 additions & 0 deletions samples/python/agents/real_estate_agent/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# The port the server will run on
PORT=3001

# A secret key to authenticate requests
API_KEY=your-secret-api-key

# The URL of the MCP server
MCP_SERVER_URL=http://localhost:4000/sse


# Your ngrok authtoken
NGROK_AUTHTOKEN=your_ngrok_authtoken_here
117 changes: 117 additions & 0 deletions samples/python/agents/real_estate_agent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyderworkspace

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

.env
.session
31 changes: 31 additions & 0 deletions samples/python/agents/real_estate_agent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.2] - 2025-07-06

### Added
- Deployment scripts for Google Cloud Platform.
- `ngrok` integration for creating a public URL for the agent.
- `gcp_setup.sh` to set up the environment on a GCP VM.
- `gcp_initial_vm_setup.sh` and `gcp_startup_service.sh` for service configuration.

### Changed
- Updated `docker-compose.yml` to use a dedicated network and handle environment variables for deployment.
- The application now listens on `::` to accept connections from any IP address.
- `agent_card.py` now uses an environment variable for the agent's public URL.
- Updated `README.md` with deployment instructions for GCP.

## [0.1.1] - 2025-07-05

### Added
- Integrated `ollama` with the `tinydolphin` model to parse natural language queries into structured JSON.
- A new `parse_query` tool in the `dafty-mcp` to handle query parsing.

### Changed
- The `agent_executor` now calls the `parse_query` tool before searching for properties.
- The `dafty-mcp` client now has a generic `call_tool` method.
- Updated `docker-compose.yml` to include the `ollama` and `ollama-setup` services.
27 changes: 27 additions & 0 deletions samples/python/agents/real_estate_agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use an official Python runtime as a parent image
FROM python:3.13-slim

# Set the working directory in the container
WORKDIR /usr/src/app

# Copy the requirements file to the working directory
COPY requirements.txt ./

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt gunicorn

# Bundle app source
COPY . .

# Create a non-root user and switch to it
RUN useradd --create-home appuser
USER appuser

# Set environment variables
ENV PYTHONUNBUFFERED=1

# Your app binds to port 3001, so expose that
EXPOSE 3001

# Define the command to run your app
CMD ["gunicorn", "-w", "2", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "[::]:3001", "--access-logfile", "-", "--error-logfile", "-", "--log-level", "info"]
15 changes: 15 additions & 0 deletions samples/python/agents/real_estate_agent/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) 2025, Amine REMACHE <[email protected]>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD to THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
81 changes: 81 additions & 0 deletions samples/python/agents/real_estate_agent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Real-Estate Agent (A2A) Sample

![Real Estate Agent Banner](assets/a2a-real-estate-agent-banner.png)

This sample demonstrates a sophisticated real-estate agent based on the Agent-to-Agent (A2A) protocol. The agent is capable of understanding natural language queries, performing filtered searches for rental properties, and returning structured results.

## 🔗 Original Source and Contributions

This sample is a snapshot of an active open-source project. For the latest updates, to report issues, or to contribute, please visit the original repositories:

* **Real-Estate Agent:** `https://github.com/amineremache/robolancerai-real-estate-agent`
* **Dafty MCP Server:** `https://github.com/amineremache/dafty-mcp`

We encourage you to contribute directly to the source projects!

## 🏛️ Architecture

The system is composed of three main services orchestrated with `docker-compose`:

1. **`real-estate-agent`**: The core Python A2A agent that handles user requests and orchestrates tool calls.
2. **`dafty-mcp`**: A Node.js/TypeScript MCP (Model Context Protocol) tool server that provides the tools for interacting with the Daft.ie rental service. It includes a web scraper and an intelligent query parser.
3. **`ollama`**: A local LLM service that runs the `tinydolphin` model to parse natural language queries into structured JSON.

## ✨ Features

- **Natural Language Understanding**: Uses a local LLM to parse user queries like "Find a 2-bed apartment in Dublin under €2000."
- **Filtered Search**: Performs filtered searches based on location, price, and number of bedrooms.
- **Self-Contained Environment**: The entire application runs in a portable and isolated Docker environment.
- **A2A Compliant**: Built on the A2A protocol for standardized agent communication.

## 🚀 Getting Started

### Prerequisites

- Docker and `docker-compose` must be installed.
- You must have a `.env` file in the root of this sample directory. You can create one from the `.env.example` file and add your `API_KEY`.

### Installation and Running

1. **Navigate to the sample directory:**
```bash
cd samples/python/agents/real_estate_agent
```

2. **Build and start the services:**
```bash
docker-compose up --build
```

3. **The services will now be running:**
* The `real-estate-agent` will be available on port `3001`.
* The `dafty-mcp` and `ollama` services will be running in the background.

## 🧪 Testing the Agent

You can send a request to the agent using `curl`. The following example demonstrates how to search for a 2-bedroom apartment in Dublin for under €2000.

```bash
curl -X POST http://localhost:3001/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "message/send",
"params": {
"message": {
"messageId": "1",
"role": "user",
"parts": [
{
"kind": "text",
"text": "Find a 2-bed apartment in Dublin under €2000."
}
]
}
}
}' > results.json
```

The results of the query will be saved to a `results.json` file in your project directory.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions samples/python/agents/real_estate_agent/dafty-mcp/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding .session to this file to prevent it from being copied into the Docker image during the build process. This directory is created at runtime, so there is no need to include it in the image.

.session
.git
.vscode
.idea
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
tests
Loading