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
This commit is contained in:
Ryan Malloy 2025-09-09 13:49:46 -06:00
parent fedfc7a6cf
commit 228665ada1

View File

@ -768,15 +768,16 @@ else:
def main(): def main():
"""Main entry point for the MCP server.""" """Main entry point for the MCP server."""
# FastMCP handles the stdio communication automatically # Run the FastMCP server
# when the module is imported import asyncio
try:
asyncio.run(app.run())
except KeyboardInterrupt:
pass pass
except Exception as e:
logger.error(f"Server error: {e}")
raise
if __name__ == "__main__": if __name__ == "__main__":
# Keep the process running for MCP communication main()
import asyncio
try:
asyncio.get_event_loop().run_forever()
except KeyboardInterrupt:
pass