๐ซ CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
feat: Add Airbnb MCP integration use case for CAMEL Agents as MCP Client (#2393)
Sarthak Bhardwaj056802005870
diff --git a/apps/Airbnb-MCP/README.md b/apps/Airbnb-MCP/README.mdnew file mode 100644index 000000000..773af87ca--- /dev/null+++ b/apps/Airbnb-MCP/README.md@@ -0,0 +1,118 @@+# ๐ก Airbnb Listings Search (Streamlit + CAMEL-AI + MCP)++A Streamlit app that leverages the [CAMEL-AI OWL framework](https://github.com/camel-ai/owl) and **MCP (Model Context Protocol)** to automatically search Airbnb listings via a custom MCP server. The app displays search parameters and returns the top 5 listings in a clean, responsive card-grid UI.++---++## โจ Features++- **Interactive UI**: Sidebar for entering city, check-in/out dates and number of adults.+- **Session state**: Remembers your last chosen dates.+- **Agent-driven search**: Uses a CAMEL-AI `ChatAgent` + MCPToolkit to query Airbnb via `@openbnb/mcp-server-airbnb`.+- **Responsive cards**: Displays each listing in its own styled card.++---++## ๐ Prerequisites++- Python >=3.10,<3.13+- Node.js & npm (for the MCP server plugin)+- A valid OpenAI API key set in your environment:+ ```bash+ export OPENAI_API_KEY="your_api_key_here"+ ```++---++## ๐ ๏ธ Setup++1. **Clone the repo**++ ```bash+ git clone https://github.com/your-org/your-repo.git+ cd your-repo/owl/community_usecase/Airbnb-MCP+ ```++2. **Create a virtual environment**++ ```bash+ python -m venv venv+ source venv/bin/activate # macOS/Linux+ venv\\Scripts\\activate # Windows+ ```++3. **Install Python dependencies**++ ```bash+ pip install -r requirements.txt+ ```++---++## โ๏ธ Configuration++1. **Environment variables**+ Create a `.env` file in the project root with:+ ```ini+ OPENAI_API_KEY=your_openai_key_here+ ```++2. **MCP Server config**+ Ensure `mcp_servers_config.json` (next to `app.py`) contains:+ ```json+ {+ "mcpServers": {+ "airbnb": {+ "command": "npx",+ "args": ["-y", "@openbnb/mcp-server-airbnb", "--ignore-robots-txt"]+ }+ }+ }+ ```++---++## ๐ Running the App++From the `Airbnb-MCP` folder, run:++```bash+streamlit run app.py+```++This will launch the Streamlit UI in your browser. Use the sidebar to choose your city, dates and number of guests, then click **Search Listings**.++---++## ๐ง Customization++- **Prompt**: Edit the search prompt inside `app.py` if you want to tweak wording or number of results.+- **Styling**: Modify the CSS in the header section of `app.py` to change colors, fonts or card layout.+- **Logging**: Change `set_log_level("DEBUG")` to `INFO` in production.++---++## ๐ Project Structure++```+Airbnb-MCP/+โโโ assets/+โ โโโ logo_camel_ai.png+โ โโโ logo_airbnb_mcp.png+โโโ mcp_servers_config.json+โโโ app.py # Main Streamlit application+โโโ requirements.txt # Python deps+โโโ .env # Env file with OPENAI_API_KEY+```++---++## ๐ References++- [CAMEL-AI OWL Framework](https://github.com/camel-ai/owl)+- [Anthropic MCP Docs](https://docs.anthropic.com/en/docs/agents-and-tools/mcp)+- [@openbnb/mcp-server-airbnb (npm)](https://www.npmjs.com/package/@openbnb/mcp-server-airbnb)++---++*Happy listing searches!*diff --git a/apps/Airbnb-MCP/app.py b/apps/Airbnb-MCP/app.pynew file mode 100644index 000000000..1f998f39e--- /dev/null+++ b/apps/Airbnb-MCP/app.py@@ -0,0 +1,136 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+import asyncio+import base64+import datetime+from pathlib import Path++import streamlit as st+from dotenv import load_dotenv++from camel.agents import ChatAgent+from camel.logger import set_log_level+from camel.models import ModelFactory+from camel.toolkits import MCPToolkit+from camel.types import ModelPlatformType, ModelType++# โโโ Page config โโโ+st.set_page_config(page_title="Airbnb Listings Search", layout="wide")+++# โโโ Load & encode logos โโโ+with open("assets/logo_camel_ai.png", "rb") as f:+ camel_bytes = f.read()+with open("assets/logo_airbnb_mcp.png", "rb") as f:+ airbnb_bytes = f.read()++camel_b64 = base64.b64encode(camel_bytes).decode()+airbnb_b64 = base64.b64encode(airbnb_bytes).decode()++# โโโ Header with Logos โโโ+st.markdown(+ f"""+ <div style="text-align: center; margin-bottom: 2rem;">+ <h1>Airbnb Listings Search</h1>+ <img src="data:image/png;base64,{camel_b64}" width="80" alt="Camel-AI logo" style="margin:0 20px;" />+ <img src="data:image/png;base64,{airbnb_b64}" width="80" alt="Airbnb MCP logo" style="margin:0 20px;" />+ <p style="font-size:14px; color:gray; margin-top:0.5rem;">+ Powered by Camel-AI & Airbnb MCP+ </p>+ </div>+ """, # noqa: E501+ unsafe_allow_html=True,+)++# โโโ Load env & logging โโโ+load_dotenv()+set_log_level("DEBUG")++# โโโ Persist defaults โโโ+if "checkin" not in st.session_state:+ st.session_state.checkin = datetime.date.today()+if "checkout" not in st.session_state:+ st.session_state.checkout = datetime.date.today() + datetime.timedelta(+ days=1+ )++# โโโ Sidebar inputs โโโ+st.sidebar.header("Search parameters")+city = st.sidebar.text_input("City", "")+checkin = st.sidebar.date_input("Check-in", value=st.session_state.checkin)+checkout = st.sidebar.date_input("Check-out", value=st.session_state.checkout)+adults = st.sidebar.number_input("Adults", min_value=1, value=2)++# โโโ Main: show parameters & run search โโโ+if st.sidebar.button("Search Listings"):+ # Save for next time+ st.session_state.checkin = checkin+ st.session_state.checkout = checkout++ # Quick summary on the main page+ st.subheader("๐ You are searching for")+ cols = st.columns(4)+ cols[0].metric("City", city)+ cols[1].metric("Check-in", checkin.strftime("%Y-%m-%d"))+ cols[2].metric("Check-out", checkout.strftime("%Y-%m-%d"))+ cols[3].metric("Adults", adults)++ # Build prompt+ prompt = f"""+ Find me the best Airbnb in {city} with a check-in date+ of {checkin:%Y-%m-%d} and a check-out date of+ {checkout:%Y-%m-%d} for {adults} adults.+ Return the top 5 listings with their names, prices, and locations.+ """++ # Run the agent+ with st.spinner("Searchingโฆ"):++ async def run_task():+ config_path = Path(__file__).parent / "mcp_servers_config.json"+ mcp = MCPToolkit(config_path=str(config_path))+ await mcp.connect()+ tools = list(mcp.get_tools())+ agent = ChatAgent(+ system_message="You are an Airbnb search assistant.",+ model=ModelFactory.create(+ model_platform=ModelPlatformType.OPENAI,+ model_type=ModelType.GPT_4O,+ model_config_dict={"temperature": 0.7},+ ),+ tools=tools,+ )+ res = await agent.astep(prompt)+ try:+ await mcp.disconnect()+ except Exception:+ pass+ return res++ result = asyncio.run(run_task())++ # Show results+ st.success("Search complete!")+ st.markdown("### Results")+ st.markdown(result.msgs[0].content)+# โโโ Footer โโโ+st.markdown(+ """+ <hr style="margin-top:3rem">+ <p style="text-align:center; color:gray; font-size:0.8rem;">+ Powered by Camel-AI & Airbnb MCP+ </p>+ """,+ unsafe_allow_html=True,+)diff --git a/apps/Airbnb-MCP/assets/logo_airbnb_mcp.png b/apps/Airbnb-MCP/assets/logo_airbnb_mcp.pngnew file mode 100644index 000000000..8b5b43395Binary files /dev/null and b/apps/Airbnb-MCP/assets/logo_airbnb_mcp.png differdiff --git a/apps/Airbnb-MCP/assets/logo_camel_ai.png b/apps/Airbnb-MCP/assets/logo_camel_ai.pngnew file mode 100644index 000000000..9b1050150Binary files /dev/null and b/apps/Airbnb-MCP/assets/logo_camel_ai.png differdiff --git a/apps/Airbnb-MCP/assets/screenshot.png b/apps/Airbnb-MCP/assets/screenshot.pngnew file mode 100644index 000000000..c5e8ea5dfBinary files /dev/null and b/apps/Airbnb-MCP/assets/screenshot.png differdiff --git a/apps/Airbnb-MCP/mcp_servers_config.json b/apps/Airbnb-MCP/mcp_servers_config.jsonnew file mode 100644index 000000000..7fb2e637f--- /dev/null+++ b/apps/Airbnb-MCP/mcp_servers_config.json@@ -0,0 +1,12 @@+{+ "mcpServers": {+ "airbnb": {+ "command": "npx",+ "args": [+ "-y",+ "@openbnb/mcp-server-airbnb",+ "--ignore-robots-txt"+ ]+ }+ }+}diff --git a/apps/Airbnb-MCP/requirements.txt b/apps/Airbnb-MCP/requirements.txtnew file mode 100644index 000000000..c80191302--- /dev/null+++ b/apps/Airbnb-MCP/requirements.txt@@ -0,0 +1,4 @@+camel-ai[all]+streamlit+python-dotenv+diff --git a/apps/chat_with_github/README.md b/apps/chat_with_github/README.mdnew file mode 100644index 000000000..94280f08a--- /dev/null+++ b/apps/chat_with_github/README.md@@ -0,0 +1,116 @@+````markdown+# ๐ค GitHub Repo Chat Explorer++A Streamlit-based chat interface powered by **CAMEL-AI** and **MCP (Model Context Protocol)** that lets you conversationally explore any GitHub repository. Ask questions like "How many files?", "Show me the README contents", or follow-up queriesโall in context of the chosen repo.++---++## โจ Features++- **Interactive Chat UI**: Chat with your repository using Streamlit's chat components.+- **Dynamic Context**: Set or change the GitHub repo URL in the sidebar to switch contexts on the fly.+- **Session Memory**: Keeps your question-answer history until you change the repo.+- **Agent-Powered**: Under the hood, a `ChatAgent` + MCPToolkit fetches and processes repo data.++---++## ๐ธ Screenshot++++_A conversation where the user asks about the repo structure and README file._++---++## ๐ Prerequisites++- Python >=3.10,<3.13+- Node.js & npm (for MCP server plugin)+- OpenAI API key in `.env`:+ ```bash+ export OPENAI_API_KEY="your_key_here"+ ```++---++## ๐ ๏ธ Installation++1. **Clone the repo**++ ```bash+ git clone https://github.com/your-org/your-repo.git+ cd your-repo/owl/community_usecase/gitingest+ ```++2. **Python environment**++ ```bash+ python -m venv venv+ source venv/bin/activate # macOS/Linux+ venv\\Scripts\\activate # Windows+ pip install -r requirements.txt+ ```++3. **Install MCP plugin**++ ```bash+ npm install -g @openbnb/mcp-server-git+ ```++---++## โ๏ธ Configuration++- **.env**: Create in project root:+ ```ini+ OPENAI_API_KEY=your_key_here+ ```+- **mcp_servers_config.json**: Next to `app.py`:+ ```json+ {+ "mcpServers": {+ "gitingest": {+ "command": "npx",+ "args": ["-y", "@openbnb/mcp-server-git"]+ }+ }+ }+ ```++---++## ๐ Running the App++```bash+streamlit run app.py+```+Set the repo in the sidebar, then start chatting!++---++## ๐ง Customization++- Tweak system prompts in `st.chat_message` calls.+- Adjust temperature or model type in `ModelFactory.create`.+- Style the UI via CSS in the header section.++---++## ๐ Project Structure++```+Gitingest/+โโโ assets/+โ โโโ logo_camel_ai.png+โ โโโ logo_github.png+โ โโโ screenshot_chat.png+โโโ mcp_servers_config.json+โโโ app.py # Main Streamlit chat app+โโโ requirements.txt # Python dependencies+โโโ .env # Env vars+```++---++*Happy repo chatting!*+````diff --git a/apps/chat_with_github/app.py b/apps/chat_with_github/app.pynew file mode 100644index 000000000..34471cc15--- /dev/null+++ b/apps/chat_with_github/app.py@@ -0,0 +1,130 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+import asyncio+import base64+import logging+from pathlib import Path++import streamlit as st+from dotenv import load_dotenv++from camel.agents import ChatAgent+from camel.logger import set_log_level+from camel.models import ModelFactory+from camel.toolkits import MCPToolkit+from camel.types import ModelPlatformType, ModelType++# Silence noisy asyncio cancellation messages+logging.getLogger("asyncio").setLevel(logging.CRITICAL)++# โโโ Page Config โโโ+st.set_page_config(page_title="Chat with your Repo", layout="wide")++# โโโ Load assets & logos โโโ+ROOT = Path(__file__).resolve().parents[2]+ROOT = Path(__file__).resolve().parent+ASSETS = ROOT / "assets"+with open(ASSETS / "logo_camel_ai.png", "rb") as f:+ camel_b64 = base64.b64encode(f.read()).decode()+with open(ASSETS / "logo_github.jpg", "rb") as f:+ gh_b64 = base64.b64encode(f.read()).decode()++# โโโ Header โโโ+st.markdown(+ f"""+ <div style='text-align:center; margin-bottom:2rem;'>+ <h1>Chat with any Github Repo</h1>+ <img src='data:image/png;base64,{camel_b64}' width='80' style='margin:0 20px;'>+ <img src='data:image/png;base64,{gh_b64}' width='80' style='margin:0 20px;'>+ <p style='font-size:14px; color:gray;'>Powered by Camel-AI & Git-Ingest MCP</p>+ </div>+ """, # noqa: E501+ unsafe_allow_html=True,+)++# โโโ Initialize โโโ+load_dotenv()+set_log_level("DEBUG")++# โโโ Session State Setup โโโ+if 'repo_url' not in st.session_state:+ st.session_state['repo_url'] = ''+if 'messages' not in st.session_state:+ st.session_state['messages'] = []++# โโโ Sidebar: Repo Input โโโ+st.sidebar.header("Repository")+repo = st.sidebar.text_input("GitHub Repo URL", st.session_state['repo_url'])+if st.sidebar.button("Set Repo"):+ st.session_state['repo_url'] = repo.strip()+ st.session_state['messages'] = [] # reset conversation++# โโโ Main: Chat UI โโโ+if not st.session_state['repo_url']:+ st.info("Please set a GitHub repository URL in the sidebar to start.")+ st.stop()++# Display existing messages+for msg in st.session_state['messages']:+ if msg['role'] == 'user':+ st.chat_message('user').markdown(msg['content'])+ else:+ st.chat_message('assistant').markdown(msg['content'])++# Chat input+if user_input := st.chat_input("Ask a question about the repoโฆ"):+ # Add user message+ st.session_state['messages'].append(+ {'role': 'user', 'content': user_input}+ )+ st.chat_message('user').markdown(user_input)++ # Define async function to query the agent+ async def query_agent(question: str):+ config_path = Path(__file__).parent / "mcp_servers_config.json"+ toolkit = MCPToolkit(config_path=str(config_path))+ await toolkit.connect()+ tools = list(toolkit.get_tools())+ agent = ChatAgent(+ system_message=f"You are a GitHub repo assistant. Repository: {st.session_state['repo_url']}", # noqa: E501+ model=ModelFactory.create(+ model_platform=ModelPlatformType.OPENAI,+ model_type=ModelType.GPT_4O,+ model_config_dict={"temperature": 0},+ ),+ tools=tools,+ )+ prompt = f"{question}\nRepository: {st.session_state['repo_url']}"+ response = await agent.astep(prompt)+ await toolkit.disconnect()+ return response.msgs[0].content++ # Run the agent+ with st.spinner("Thinkingโฆ"):+ answer = asyncio.run(query_agent(user_input))++ # Display assistant reply+ st.session_state['messages'].append(+ {'role': 'assistant', 'content': answer}+ )+ st.chat_message('assistant').markdown(answer)++# โโโ Footer โโโ+st.markdown(+ """+ <hr>+ <p style='text-align:center; color:gray; font-size:0.8rem;'>Powered by Camel-AI & GitHub MCP</p>+ """, # noqa: E501+ unsafe_allow_html=True,+)diff --git a/apps/chat_with_github/assets/logo_camel_ai.png b/apps/chat_with_github/assets/logo_camel_ai.pngnew file mode 100644index 000000000..9b1050150Binary files /dev/null and b/apps/chat_with_github/assets/logo_camel_ai.png differdiff --git a/apps/chat_with_github/assets/logo_github.jpg b/apps/chat_with_github/assets/logo_github.jpgnew file mode 100644index 000000000..52c497a6cBinary files /dev/null and b/apps/chat_with_github/assets/logo_github.jpg differdiff --git a/apps/chat_with_github/assets/screenshot_chat.png b/apps/chat_with_github/assets/screenshot_chat.pngnew file mode 100644index 000000000..270dbe1a6Binary files /dev/null and b/apps/chat_with_github/assets/screenshot_chat.png differdiff --git a/apps/chat_with_github/demo_git_ingest.py b/apps/chat_with_github/demo_git_ingest.pynew file mode 100644index 000000000..886a59d66--- /dev/null+++ b/apps/chat_with_github/demo_git_ingest.py@@ -0,0 +1,127 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+import asyncio+import base64+import logging+from pathlib import Path++import streamlit as st+from dotenv import load_dotenv++from camel.agents import ChatAgent+from camel.logger import set_log_level+from camel.models import ModelFactory+from camel.toolkits import MCPToolkit+from camel.types import ModelPlatformType, ModelType++# Silence noisy asyncio cancellation messages+logging.getLogger("asyncio").setLevel(logging.CRITICAL)++# โโโ Page Config โโโ+st.set_page_config(page_title="GitHub Repo Explorer", layout="wide")++# โโโ Load assets & logos โโโ+ROOT = Path(__file__).resolve().parents[2]+ASSETS = ROOT / "assets"+with open(ASSETS / "logo_camel_ai.png", "rb") as f:+ camel_b64 = base64.b64encode(f.read()).decode()+with open(ASSETS / "logo_github.JPG", "rb") as f:+ gh_b64 = base64.b64encode(f.read()).decode()++# โโโ Header โโโ+st.markdown(+ f"""+ <div style='text-align:center; margin-bottom:2rem;'>+ <h1>GitHub Repo Explorer</h1>+ <img src='data:image/png;base64,{camel_b64}' width='80' alt='Camel-AI' style='margin:0 20px;'>+ <img src='data:image/png;base64,{gh_b64}' width='80' alt='GitHub' style='margin:0 20px;'>+ <p style='font-size:14px; color:gray;'>Powered by Camel-AI & Git-Ingest MCP</p>+ </div>+ """, # noqa: E501+ unsafe_allow_html=True,+)++# โโโ Initialize โโโ+load_dotenv()+set_log_level("DEBUG")++# โโโ Sidebar Inputs โโโ+st.sidebar.header("Search parameters")+repo_url = st.sidebar.text_input(+ "GitHub Repo URL", "https://github.com/1sarthakbhardwaj/Ollama"+)+query = st.sidebar.text_area(+ "Query", "Show me the directory tree of this repository.", height=100+)++# โโโ Run query โโโ+if st.sidebar.button("Run Query"):+ # echo parameters+ st.subheader("๐ Your search parameters")+ cols = st.columns(2)+ cols[0].write(f"**Repo URL:** {repo_url}")+ cols[1].write(f"**Query:** {query}")++ # call agent+ async def run_task():+ config = Path(__file__).parent / "mcp_servers_config.json"+ toolkit = MCPToolkit(config_path=str(config))+ await toolkit.connect()+ tools = list(toolkit.get_tools())+ agent = ChatAgent(+ system_message="You are a GitHub repo explorer.",+ model=ModelFactory.create(+ model_platform=ModelPlatformType.OPENAI,+ model_type=ModelType.GPT_4O,+ model_config_dict={"temperature": 0},+ ),+ tools=tools,+ )+ prompt = f"{query}\nRepository: {repo_url}"+ resp = await agent.astep(prompt)+ await toolkit.disconnect()+ return resp++ with st.spinner("Running queryโฆ"):+ result = asyncio.run(run_task())++ # display+ st.success("Query complete!")+ st.markdown("### Result")++ raw = result.msgs[0].content or ""+ # strip fences+ lines = [+ line for line in raw.splitlines() if not line.strip().startswith("```")+ ]+ clean = "\n".join(lines).strip()+ st.code(clean)++ # tool calls+ st.markdown("### Tool Calls")+ for rec in result.info.get("tool_calls", []):+ name = getattr(rec, "tool_name", None) or getattr(+ rec, "name", "<unknown>"+ )+ args = getattr(rec, "args", None) or getattr(rec, "arguments", {})+ st.markdown(f"- **{name}**: `{args}`")++# โโโ Footer โโโ+st.markdown(+ """+ <hr>+ <p style='text-align:center; color:gray; font-size:0.8rem;'>Powered by Camel-AI & GitHub MCP</p>+ """, # noqa: E501+ unsafe_allow_html=True,+)diff --git a/apps/chat_with_github/mcp_servers_config.json b/apps/chat_with_github/mcp_servers_config.jsonnew file mode 100644index 000000000..c7dfe5857--- /dev/null+++ b/apps/chat_with_github/mcp_servers_config.json@@ -0,0 +1,13 @@+{+ "mcpServers": {+ "mcp-git-ingest": {+ "command": "uvx",+ "args": [+ "--from",+ "git+https://github.com/adhikasp/mcp-git-ingest",+ "mcp-git-ingest"+ ]+ }+ }+ }+\ No newline at end of filediff --git a/apps/chat_with_github/requirements.txt b/apps/chat_with_github/requirements.txtnew file mode 100644index 000000000..c80191302--- /dev/null+++ b/apps/chat_with_github/requirements.txt@@ -0,0 +1,4 @@+camel-ai[all]+streamlit+python-dotenv+