From 228665ada1004e34224d1829841e4e22c1e17438 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Tue, 9 Sep 2025 13:49:46 -0600 Subject: [PATCH] Fix MCP server main() function to properly run the FastMCP app - Changed main() to call asyncio.run(app.run()) - This ensures the server stays running and handles MCP protocol - Without this fix, the server would exit immediately --- src/mcrentcast/server.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/mcrentcast/server.py b/src/mcrentcast/server.py index fd55999..670f21e 100644 --- a/src/mcrentcast/server.py +++ b/src/mcrentcast/server.py @@ -768,15 +768,16 @@ else: def main(): """Main entry point for the MCP server.""" - # FastMCP handles the stdio communication automatically - # when the module is imported - pass + # Run the FastMCP server + import asyncio + try: + asyncio.run(app.run()) + except KeyboardInterrupt: + pass + except Exception as e: + logger.error(f"Server error: {e}") + raise if __name__ == "__main__": - # Keep the process running for MCP communication - import asyncio - try: - asyncio.get_event_loop().run_forever() - except KeyboardInterrupt: - pass \ No newline at end of file + main() \ No newline at end of file