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():
|
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
|
||||||
pass
|
try:
|
||||||
|
asyncio.run(app.run())
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
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
|
|
Loading…
x
Reference in New Issue
Block a user