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:
parent
fedfc7a6cf
commit
228665ada1
@ -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
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user