add mcp server
This commit is contained in:
parent
29697f6274
commit
46ec8c7fe3
8 changed files with 1665 additions and 17 deletions
0
src/mcp/__init__.py
Normal file
0
src/mcp/__init__.py
Normal file
37
src/mcp/server.py
Normal file
37
src/mcp/server.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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",
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue