Created
October 17, 2025 04:47
-
-
Save initcron/a3fab17b2e4704ce20e13b94e5bb3bb6 to your computer and use it in GitHub Desktop.
Agno Agent to search for AirBnB Listings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # airbnb_mcp.py | |
| from textwrap import dedent | |
| from agno.agent import Agent | |
| from agno.models.google import Gemini | |
| from agno.tools.mcp import MCPTools | |
| from agno.tools.reasoning import ReasoningTools | |
| from agno.os import AgentOS | |
| # Create the Airbnb MCP tools (uses npx under the hood) | |
| # Either of these forms typically works depending on your agno build: | |
| # mcp_tools = MCPTools("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt") | |
| mcp_tools = MCPTools( | |
| command="npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt", | |
| # env={"AIRBNB_COOKIES": "..."} # optional: if you need cookies/headers | |
| ) | |
| agent = Agent( | |
| model=Gemini(id="gemini-2.5-flash"), | |
| tools=[ReasoningTools(add_instructions=True), mcp_tools], | |
| instructions=dedent("""\ | |
| ## Search & Ranking Rules for Airbnb | |
| - Use the Airbnb MCP tools to search and fetch listing details (title, price/night, rating, reviews, beds/bedrooms, location, link). | |
| - Normalize currency to INR when possible and show both INR and local currency if present. | |
| - Return a Top 10 table with: Title, Price/Night, Rating, Reviews, Beds/Bedrooms, Location, Link, Notes. | |
| - Briefly justify the ranking (value, location, reviews, host reliability). | |
| ## Think Tool Usage | |
| - Before each tool call, outline the plan and key filters. | |
| - After tool results, validate fields (e.g., parse "4.92 (138)" into rating=4.92, reviews=138). | |
| - Summarize trade-offs (price vs location vs rating) before final answer. | |
| """), | |
| add_datetime_to_context=True, | |
| markdown=True, | |
| ) | |
| # --- Proper lifecycle wiring for MCPTools (async context manager) --- | |
| async def _mcp_start(): | |
| # Start the MCP subprocess | |
| await mcp_tools.__aenter__() | |
| async def _mcp_stop(): | |
| # Cleanly stop the MCP subprocess | |
| await mcp_tools.__aexit__(None, None, None) | |
| agent_os = AgentOS(agents=[agent]) | |
| app = agent_os.get_app() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment