#!/usr/bin/env python3
"""
Top-level entry point for Looker Admin MCP server.
This serves as the compatible entry point with the MCP CLI.
"""
import os
import json
import sys
import logging
# --- Debug: Print environment variables ---
# Setup minimal logging just for this
_temp_logger = logging.getLogger('looker-admin-mcp-main-debug')
_temp_logger.setLevel(logging.INFO)
_handler = logging.StreamHandler(sys.stderr)
_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
_handler.setFormatter(_formatter)
_temp_logger.addHandler(_handler)
_temp_logger.info("--- Dumping Environment Variables (at top of src/main.py) ---")
env_dump = dict(os.environ)
# Mask sensitive values
if 'LOOKER_CLIENT_SECRET' in env_dump:
env_dump['LOOKER_CLIENT_SECRET'] = f"<set: {len(env_dump['LOOKER_CLIENT_SECRET'])} chars>"
if 'LOOKERSDK_CLIENT_SECRET' in env_dump:
env_dump['LOOKERSDK_CLIENT_SECRET'] = f"<set: {len(env_dump['LOOKERSDK_CLIENT_SECRET'])} chars>"
# Print to stderr
print(json.dumps(env_dump, indent=2), file=sys.stderr, flush=True)
_temp_logger.info("--- End Environment Variable Dump ---")
# --- End Debug ---
# Import the server AFTER printing env vars
from looker_admin_mcp.server.looker import mcp, main
# Export the server object for MCP CLI compatibility
server = mcp
# The main execution logic is handled by the imported main
if __name__ == "__main__":
main()