#!/usr/bin/env python3
"""
MCP Server Example

Demonstrates how to run Rora as an MCP (Model Context Protocol) server
for use with AI assistants like Claude Desktop.

Requirements:
    pip install rora

Usage:
    # Start the MCP server directly
    python -m rora.mcp --api-key your_rora_key

    # Or use this script
    python mcp_server.py

Configuration for Claude Desktop (claude_desktop_config.json):
{
  "mcpServers": {
    "rora": {
      "command": "python",
      "args": ["-m", "rora.mcp", "--api-key", "your_rora_key"]
    }
  }
}
"""

import os
import sys


def main():
    api_key = os.environ.get("RORA_API_KEY")

    if not api_key:
        print("Error: RORA_API_KEY environment variable not set")
        print("\nUsage:")
        print("  export RORA_API_KEY=your_api_key")
        print("  python mcp_server.py")
        print("\nOr run directly:")
        print("  python -m rora.mcp --api-key your_api_key")
        sys.exit(1)

    print("Starting Rora MCP Server...")
    print(f"API Key: {api_key[:10]}...")
    print("\nAvailable tools:")
    print("  - rora_register: Register an agent for monitoring")
    print("  - rora_status: Check agent status")
    print("  - rora_run: Run one-off validation")
    print("  - rora_list: List all agents")
    print("  - rora_delete: Delete an agent")
    print("\nStarting server...\n")

    from rora.mcp import main as mcp_main
    mcp_main()


if __name__ == "__main__":
    main()
