Airbnb Mcp

🏠 MCP Airbnb Agent - Search for Airbnb listings!

This example shows how to create an agent that uses MCP and Llama 4 to search for Airbnb listings.

Code

1import asyncio
2from textwrap import dedent
3
4from kern.agent import Agent
5from kern.models.groq import Groq
6from kern.tools.mcp import MCPTools
7from kern.tools.reasoning import ReasoningTools
8
9
10async def run_agent(message: str) -> None:
11 async with MCPTools(
12 "npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt"
13 ) as mcp_tools:
14 agent = Agent(
15 model=Groq(id="meta-llama/llama-4-scout-17b-16e-instruct"),
16 tools=[ReasoningTools(add_instructions=True), mcp_tools],
17 instructions=dedent("""\
18 ## General Instructions
19 - Always start by using the think tool to map out the steps needed to complete the task.
20 - After receiving tool results, use the think tool as a scratchpad to validate the results for correctness
21 - Before responding to the user, use the think tool to jot down final thoughts and ideas.
22 - Present final outputs in well-organized tables whenever possible.
23 - Always provide links to the listings in your response.
24 - Show your top 10 recommendations in a table and make a case for why each is the best choice.
25
26 ## Using the think tool
27 At every step, use the think tool as a scratchpad to:
28 - Restate the object in your own words to ensure full comprehension.
29 - List the specific rules that apply to the current request
30 - Check if all required information is collected and is valid
31 - Verify that the planned action completes the task\
32 """),
33 add_datetime_to_context=True,
34 markdown=True,
35 )
36 await agent.aprint_response(message, stream=True)
37
38
39if __name__ == "__main__":
40 task = dedent("""\
41 I'm traveling to San Francisco from April 20th - May 8th. Can you find me the best deals for a 1 bedroom apartment?
42 I'd like a dedicated workspace and close proximity to public transport.\
43 """)
44 asyncio.run(run_agent(task))

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set your API key

1export GROQ_API_KEY=xxx

Install dependencies

1uv pip install -U groq mcp kern-ai

Run Agent

1python cookbook/01_showcase/01_agents/airbnb_mcp.py
1python cookbook/01_showcase/01_agents/airbnb_mcp.py