"""Add a fixed resource and prompt to the local label workshop."""
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("label-context")
RULES = "A label contains 1 to 80 characters after trimming. Internal spaces are preserved."


@mcp.tool()
def normalize_label(text: str) -> dict[str, str]:
    """Trim a label; reject empty labels or more than 80 characters."""
    label = text.strip()
    if not 1 <= len(label) <= 80:
        raise ValueError("Expected 1 to 80 characters after trimming")
    return {"label": label}


@mcp.resource("workshop://rules")
def label_rules() -> str:
    """Read the fixed lab rules."""
    return RULES


@mcp.prompt()
def review_label(text: str) -> str:
    """Prepare a message explaining a label under the lab rules."""
    return f"Explain this label using these rules: {RULES}\nLabel: {text}"


if __name__ == "__main__":
    mcp.run(transport="stdio")
