Skip to main content
Glama

Simple MCP

by karar-hayder
main.py1.74 kB
""" Main entry point for the MCP server. """ import logging import sys from config import setup_logging from scheduler import restore_jobs_from_persistence, scheduler from tools import function_registry, mcp # Setup logging setup_logging() def start_scheduler_and_restore_jobs(): """ Start the scheduler and restore jobs from persistence. Returns: int: The number of restored jobs, or 0 on failure. """ try: scheduler.start() logging.info("Scheduler started") except Exception as e: logging.error("Failed to start scheduler: %s", e, exc_info=True) return 0 try: restored_count = restore_jobs_from_persistence(function_registry) logging.info("Restored %d jobs from persistence", restored_count) return restored_count except Exception as e: logging.error("Failed to restore jobs: %s", e, exc_info=True) return 0 def main(): """ Main function to start the FastMCP server and handle shutdown. """ try: logging.info("Starting FastMCP server (stdio transport)") start_scheduler_and_restore_jobs() mcp.run(transport="stdio") except KeyboardInterrupt: logging.info("Received keyboard interrupt, shutting down...") except Exception as e: logging.error("Fatal error in main: %s", e, exc_info=True) finally: # Shutdown the scheduler if scheduler.running: try: scheduler.shutdown() logging.info("Scheduler shutdown complete") except Exception as e: logging.error("Error shutting down scheduler: %s", e, exc_info=True) sys.exit(0) if __name__ == "__main__": main()

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/karar-hayder/Simple-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server