import html
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("html-escape")


@mcp.tool()
def html_escape(text: str) -> str:
    """对 HTML 特殊字符进行转义。"""
    return html.escape(text, quote=True)


@mcp.tool()
def html_unescape(text: str) -> str:
    """对 HTML 转义字符进行反转义。"""
    return html.unescape(text)


def main():
    mcp.run()


if __name__ == "__main__":
    main()
