Add Airbnb Tool to AI Agent

Quick Start

1

Set API Key

Set your OpenAI API key as an environment variable in your terminal:

export OPENAI_API_KEY=your_openai_api_key_here
2

Create a file

Create a new file airbnb_search.py with the following code:

from praisonaiagents import Agent, MCP

search_agent = Agent(
    instructions="""You help book apartments on Airbnb.""",
    llm="gpt-4o-mini",
    tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
)

search_agent.start("I want to book an apartment in Paris for 2 nights. 03/28 - 03/30 for 2 adults")
3

Install Dependencies

Make sure you have Node.js installed, as the MCP server requires it:

pip install praisonaiagents
4

Run the Agent

Execute your script:

python airbnb_search.py

Requirements

  • Python 3.10 or higher
  • Node.js installed on your system
  • OpenAI API key (for the agent’s LLM)

Gradio UI

from praisonaiagents import Agent, MCP
import gradio as gr

def search_airbnb(query):
    agent = Agent(
        instructions="You help book apartments on Airbnb.",
        llm="gpt-4o-mini",
        tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
    )
    result = agent.start(query)
    return f"## Airbnb Search Results\n\n{result}"

demo = gr.Interface(
    fn=search_airbnb,
    inputs=gr.Textbox(placeholder="I want to book an apartment in Paris for 2 nights..."),
    outputs=gr.Markdown(),
    title="Airbnb Booking Assistant",
    description="Enter your booking requirements below:"
)

if __name__ == "__main__":
    demo.launch()

Features

Accommodation Search

Search for accommodations on Airbnb with natural language queries.

MCP Integration

Seamless integration with Model Context Protocol.

Booking Details

Specify dates, guests, and location preferences in natural language.

NPM Package

Leverages the official Airbnb MCP server package.

Was this page helpful?