多智能体Airbnb预订系统

这是一个基于LangChain和LangGraph的多智能体系统,用于搜索和预订Airbnb房源,通过MCP协议集成外部服务,并具备持久记忆功能。

  • by Balsalobre
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 Balsalobre/lc-mcp-multiagent

使用说明

🏨 LangChain MCP Multi-Agent System

A multi-agent system for searching and booking Airbnb properties, built with LangGraph and the Model Context Protocol (MCP)

Architecture • Installation • Usage • Configuration


✨ Features

  • 🤖 Multi-agent design: an orchestrator coordinating specialized sub-agents
  • 🔌 MCP Protocol: integration with external MCP servers via @langchain/mcp-adapters
  • 🧠 Persistent memory: checkpointer keeps conversation context across turns
  • 🎨 LangGraph Studio: visual UI for debugging and testing agent flows
  • ⚡ Bun runtime: fast execution with native TypeScript support

🏗️ Architecture

┌─────────────────────────────────────────────────────────────┐
│                    🎯 Orchestrator Agent                     │
│              (Travel booking coordinator)                   │
│                                                              │
│   • Coordinates the workflow                                 │
│   • Checks calendar availability                             │
│   • Delegates searches to the sub-agent                      │
│   • Persistent memory with MemorySaver                       │
└──────────────────────────┬──────────────────────────────────┘
                           │
                           ▼
┌─────────────────────────────────────────────────────────────┐
│                  🏠 Airbnb Search Agent                      │
│                (Search specialist)                          │
│                                                              │
│   • Searches properties by location                          │
│   • Filters by dates and number of guests                    │
│   • Returns full property details                            │
└──────────────────────────┬──────────────────────────────────┘
                           │
                           ▼
┌─────────────────────────────────────────────────────────────┐
│                     🔧 MCP Server                            │
│              (@openbnb/mcp-server-airbnb)                   │
│                                                              │
│   Available tools:                                           │
│   • airbnb_search - Search properties                        │
│   • airbnb_listing_details - Listing details                 │
└─────────────────────────────────────────────────────────────┘

📁 Project Structure

lc-mcp-multiagent/
├── 📄 langgraph.json        # LangGraph configuration
├── 📄 package.json          # Dependencies and scripts
├── 📄 .env                  # Environment variables
└── 📁 src/
    ├── 📄 orchestrator.ts   # Main orchestrator agent
    └── 📁 utils/
        ├── 📄 agent.ts      # Airbnb search sub-agent
        └── 📄 mcp.ts        # MCP client and configuration

🛠️ Tech Stack

Technology Description
Agent framework and tools
Agent workflow orchestration
Integration with MCP servers
LLM API provider
Schema validation
Ultra-fast JavaScript runtime

📦 Installation

Prerequisites

Steps

# 1. Clone the repository
git clone https://github.com/Balsalobre/lc-mcp-multiagent.git
cd lc-mcp-multiagent

# 2. Install dependencies
bun install

# 3. Set up environment variables
cp .env.example .env
# Edit .env and add your OPENROUTER_API_KEY

⚙️ Configuration

Environment Variables

Create a .env file in the project root:

# OpenRouter API key (required)
OPENROUTER_API_KEY=sk-or-v1-xxxxxxxxxxxxxxxx

LangGraph Configuration

The langgraph.json file defines the available graphs:

{
  "dependencies": ["."],
  "graphs": {
    "mucp": "./src/orchestrator.ts:default"
  },
  "env": "./.env"
}

🚀 Usage

Start with LangGraph Studio (recommended)

bun run start:cli

This starts:

  • 🌐 API Server: http://localhost:2024
  • 🎨 Studio UI: https://smith.langchain.com/studio?baseUrl=http://localhost:2024

💡 Tip: LangGraph Studio lets you visualize the agent flow, debug in real time, and test conversations.

Available Scripts

Script Command Description
start:cli bun run start:cli Starts the dev server with the LangGraph CLI

🤖 LLM Models

The project uses OpenRouter as its LLM provider:

Parameter Value
Model arcee-ai/trinity-large-preview:free
Temperature 0.2 (deterministic behavior)
Provider OpenRouter

📝 Note: you can change the model in src/orchestrator.ts and src/utils/agent.ts


📋 Search Parameters

The Airbnb search agent accepts the following parameters:

Parameter Type Required Description
location string ✅ City or location to search in
checkin string ✅ Check-in date (DD-MM-YYYY)
checkout string ✅ Check-out date (DD-MM-YYYY)
adults number ❌ Number of adults (default: 1)

Example

// The orchestrator will automatically call the sub-agent with:
{
  location: "Barcelona, Spain",
  checkin: "15-03-2026",
  checkout: "20-03-2026",
  adults: 2
}

🧪 Development

Agent Structure

// Orchestrator - coordinates the flow
const orchestratorAgent = createAgent({
  model,
  systemPrompt: ORCHESTRATOR_PROMPT,
  tools: [callSubAgent],
  checkpointer: new MemorySaver(), // Persistent memory
})

// Sub-agent - specialized search
const subAgent = createAgent({
  model,
  systemPrompt: AIRBNB_AGENT_PROMPT,
  tools: airbnbTools, // Tools from MCP
})

🚧 Roadmap

  • [x] Implement the main orchestrator
  • [x] Integrate the Airbnb MCP server
  • [x] Configure the LangGraph CLI
  • [x] Add persistent memory (checkpointer)
  • [ ] Add a calendar availability agent
  • [ ] Implement the full booking flow
  • [ ] Add more search filters (price, amenities)
  • [ ] Integration tests

📚 Resources


📄 License

Distributed under the MIT License. See LICENSE for more information.


Made with ❤️ using LangChain + LangGraph + MCP