Full-Stack-Developer-Intern

Full-Stack-Developer-Intern

3.3

This document provides a structured summary of a Model Context Protocol (MCP) server designed for managing travel itineraries.

The MCP server is a backend system designed to manage travel itineraries, specifically for the Phuket and Krabi regions in Thailand. It includes a database architecture using SQLAlchemy to support day-wise hotel accommodations, transfers, and activities. The system also features RESTful API endpoints created with FastAPI for creating and viewing itineraries. Additionally, the MCP server provides recommended itineraries based on the duration of the trip, ranging from 2 to 8 nights. The server is designed to handle proper input validation, error handling, and response formatting, ensuring a seamless experience for users. The database is seeded with realistic data to provide accurate and useful recommendations.

Features

  • Database Architecture: Utilizes SQLAlchemy to design and implement a schema supporting day-wise accommodations, transfers, and activities.
  • RESTful API Endpoints: FastAPI is used to create endpoints for creating and viewing itineraries with proper validation and error handling.
  • MCP Server: Provides recommended itineraries based on the number of nights, enhancing user experience with tailored suggestions.
  • Data Seeding: Realistic data for Phuket and Krabi regions is seeded into the database to ensure accurate itinerary recommendations.
  • Comprehensive Documentation: API documentation includes sample request/response formats for ease of integration and use.

Usage with Different Platforms

FastAPI

python
from fastapi import FastAPI

app = FastAPI()

@app.post('/itineraries/')
async def create_itinerary(itinerary: Itinerary):
    # Logic to create itinerary
    return {'message': 'Itinerary created successfully'}

@app.get('/itineraries/')
async def get_itineraries():
    # Logic to retrieve itineraries
    return {'itineraries': []}

SQLAlchemy

python
from sqlalchemy import create_engine, Column, Integer, String, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, sessionmaker

Base = declarative_base()

class Hotel(Base):
    __tablename__ = 'hotels'
    id = Column(Integer, primary_key=True)
    name = Column(String)
    location = Column(String)

class Itinerary(Base):
    __tablename__ = 'itineraries'
    id = Column(Integer, primary_key=True)
    nights = Column(Integer)
    hotel_id = Column(Integer, ForeignKey('hotels.id'))
    hotel = relationship('Hotel')

engine = create_engine('sqlite:///travel.db')
Base.metadata.create_all(engine)