import subprocess
import sys


def main():
    """Launch MeiGen MCP server via npx (Node.js).

    This is a thin wrapper that delegates to the npm package `meigen`.
    Requires Node.js (>= 18) to be installed.
    """
    try:
        process = subprocess.run(
            ["npx", "-y", "meigen@latest"],
            stdin=sys.stdin,
            stdout=sys.stdout,
            stderr=sys.stderr,
        )
        sys.exit(process.returncode)
    except FileNotFoundError:
        print(
            "Error: Node.js is required but not found.\n"
            "Install from https://nodejs.org (v18 or later)",
            file=sys.stderr,
        )
        sys.exit(1)
    except KeyboardInterrupt:
        sys.exit(0)
