virgil-ai/src/mcp/server.py
2025-08-12 16:39:59 +03:00

37 lines
No EOL
883 B
Python

from fastmcp import FastMCP
from src.cache.redis_cache import fetch_plans, get_plan_by_id
mcp = FastMCP(
name="LollyInsurancePlans",
instructions="""
You are a helpful assistant that can fetch insurance plans from the Lolly API.
You can fetch the plan id list by using get_plan_list() tool.
You can fetch the particular plan information by using get_plan_by_id() tool.
"""
)
@mcp.tool()
async def get_plan_by_id(plan_id: int) -> dict:
plan = await get_plan_by_id(plan_id)
return plan
@mcp.tool()
async def get_plan_list() -> list[dict]:
plans = await fetch_plans()
return [
{
"id": p["id"],
"name": p["name"],
"category": p["category"],
} for p in plans
]
if __name__ == "__main__":
mcp.run(
"http",
host="0.0.0.0",
port=8000,
path="/mcp",
)