# server.py
from mcp.server.fastmcp import FastMCP, Context # 사용 중이신 라이브러리와 호환
from models import *
from adapters.calendar import CalendarAdapter
from adapters.weather import WeatherAdapter
from adapters.places import PlacesAdapter
from adapters.maps import MapsAdapter
from adapters.notify import NotifyAdapter
from adapters.store import StoreAdapter
# ===== Adapters (DI) =====
cal = CalendarAdapter()
wx = WeatherAdapter()
plc = PlacesAdapter()
maps = MapsAdapter()
ntf = NotifyAdapter()
store = StoreAdapter()
mcp = FastMCP("WeekendPlanner") # 서버 이름
# -------- Tools (MCP 노출) --------
@mcp.tool(name="calendar.find_free_blocks")
async def calendar_find_free_blocks(ctx: Context, args: FreeBlocksIn) -> FreeBlocksOut:
blocks = await cal.find_free_blocks(args.range, args.min_minutes)
return FreeBlocksOut(blocks=blocks)
@mcp.tool(name="weather.get_forecast")
async def weather_get_forecast(ctx: Context, args: ForecastIn) -> ForecastOut:
return await wx.get_forecast(args)
@mcp.tool(name="places.search")
async def places_search(ctx: Context, args: PlaceSearchIn) -> PlaceSearchOut:
return await plc.search(args)
@mcp.tool(name="places.details")
async def places_details(ctx: Context, args: PlaceDetailsIn) -> PlaceDetailsOut:
return await plc.details(args)
@mcp.tool(name="maps.route_eta")
async def maps_route_eta(ctx: Context, args: RouteETAIn) -> RouteETAOut:
return await maps.route_eta(args)
@mcp.tool(name="itinerary.save")
async def itinerary_save(ctx: Context, args: ItinerarySaveIn) -> ItinerarySaveOut:
return await store.save(args)
@mcp.tool(name="itinerary.load")
async def itinerary_load(ctx: Context, args: ItineraryLoadIn) -> ItineraryLoadOut:
return await store.load(args)
@mcp.tool(name="notify.send")
async def notify_send(ctx: Context, args: NotifyIn) -> NotifyOut:
return await ntf.send(args)
if __name__ == "__main__":
mcp.run(transport="http", host="0.0.0.0", port=8000)