diff --git a/src/postgres_mcp/__init__.py b/src/postgres_mcp/__init__.py index c6989fd..a00e349 100644 --- a/src/postgres_mcp/__init__.py +++ b/src/postgres_mcp/__init__.py @@ -1,4 +1,5 @@ import asyncio +import sys from . import server from . import top_queries @@ -6,6 +7,12 @@ def main(): """Main entry point for the package.""" + # As of version 3.3.0 Psycopg on Windows is not compatible with the default + # ProactorEventLoop. + # See: https://www.psycopg.org/psycopg3/docs/advanced/async.html#async + if sys.platform == "win32": + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + asyncio.run(server.main()) diff --git a/src/postgres_mcp/server.py b/src/postgres_mcp/server.py index 9ad7e6f..af5669a 100644 --- a/src/postgres_mcp/server.py +++ b/src/postgres_mcp/server.py @@ -618,7 +618,3 @@ async def shutdown(sig=None): # Exit with appropriate status code sys.exit(128 + sig if sig is not None else 0) - - -if __name__ == "__main__": - asyncio.run(main())