| # app.py | |
| import random | |
| from fastmcp import FastMCP | |
| # 1. Se define la instancia de FastMCP como antes | |
| mcp = FastMCP(name="Dice Roller") | |
| def roll_dice(n_dice: int) -> list[int]: | |
| """ | |
| Lanza `n_dice` dados de 6 caras y devuelve los resultados. | |
| Roll `n_dice` 6-sided dice and return the results. | |
| """ | |
| return [random.randint(1, 6) for _ in range(n_dice)] | |
| # 2. Se crea explícitamente el objeto de la aplicación ASGI | |
| # Uvicorn buscará esta variable 'app'. | |
| app = mcp.http_app() |