main.py•1.32 kB
#!/usr/bin/env python3
"""KDB MCP Service - Main entry point."""
import asyncio
import sys
import logging
from pathlib import Path
# Add src to path
sys.path.insert(0, str(Path(__file__).parent / "src"))
from kdb_mcp.mcp_server import KDBMCPServer
def setup_logging():
"""Configure logging for the application."""
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(sys.stdout)
]
)
async def main():
"""Main entry point for the KDB MCP service."""
setup_logging()
logger = logging.getLogger(__name__)
# Check for config file argument
config_path = "config/kdb_config.yaml"
if len(sys.argv) > 1:
config_path = sys.argv[1]
logger.info(f"Starting KDB MCP Server with config: {config_path}")
# Create and run server
server = KDBMCPServer(config_path)
try:
await server.run()
except KeyboardInterrupt:
logger.info("Server shutdown requested")
except Exception as e:
logger.error(f"Server error: {e}", exc_info=True)
finally:
logger.info("Cleaning up resources...")
server.cleanup()
logger.info("Server stopped")
if __name__ == "__main__":
asyncio.run(main())