"""FastMCP server for AI assistant integration.

⚠️ AUTO-GENERATED BY PRISM - DO NOT EDIT

This server exposes your application's data via the Model Context Protocol (MCP),
allowing AI assistants to interact with your data.

Usage:
    # Run with SSE transport (HTTP server on port 8765)
    python -m {{ project_name_snake }}.mcp.server --sse

    # Run with stdio transport (for MCP clients like Claude Desktop)
    python -m {{ project_name_snake }}.mcp.server

    # Custom port for SSE
    python -m {{ project_name_snake }}.mcp.server --sse --port=9000
"""

from __future__ import annotations

from fastmcp import FastMCP

{{ register_imports }}

# Create the MCP server
mcp = FastMCP(
    name="{{ title }}",
    instructions="{{ instructions }}",
)


def register_all_tools() -> None:
    """Register all model tools with the MCP server."""
{{ register_block }}


# Register tools on module load
register_all_tools()


def run_server(transport: str = "stdio", port: int = 8765) -> None:
    """Run the MCP server.

    Args:
        transport: Transport type - "stdio" (default) or "sse" for HTTP.
        port: Port for SSE transport (default 8765).
    """
    if transport == "sse":
        mcp.run(transport="sse", port=port)
    else:
        mcp.run()


if __name__ == "__main__":
    import sys

    # Parse simple CLI args for transport
    transport = "stdio"
    port = 8765

    for arg in sys.argv[1:]:
        if arg == "--sse":
            transport = "sse"
        elif arg.startswith("--port="):
            port = int(arg.split("=")[1])

    run_server(transport=transport, port=port)


__all__ = ["mcp", "register_all_tools", "run_server"]
