File size: 506 Bytes
b4c4bbd
 
 
 
 
6fd208f
b4c4bbd
 
 
 
 
 
 
 
 
 
6fd208f
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# app.py

import random
from fastmcp import FastMCP

# 1. Se define la instancia de FastMCP como antes
mcp = FastMCP(name="Dice Roller")

@mcp.tool
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()