INNER CODE UNIT · Python
root
datawhalechina/wow-fullstack · tutorial/FastAPI/第6章-FastAPI MCP/main.py:317
async def root():
"""主页 - 提供API简介"""
return {
"message": "天气查询API",
"endpoints": [
"/generate-jwt - 生成JWT令牌",
"/city/lookup - 根据城市名查询位置ID",
"/weather/now - 根据位置ID查询当前天气",
"/weather/by-city - 一站式查询城市天气"
],
"docs": "/docs 查看完整API文档"
}
# mcp 实现
mcp = FastApiMCP(
app,
name="My Weather MCP",
description="天气查询API",