From bcc4cd43270e76ca95113915c00e504798798b25 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Wed, 16 Jul 2025 12:39:44 -0600 Subject: [PATCH] Fix async/await issues in MCP server entry point MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change create_mcp_server() from async to sync function - Replace httpx.AsyncClient with httpx.Client for OpenAPI spec fetching - Make main() function synchronous for proper console script entry point - Remove unsupported capture_keyboard_interrupt parameter from mcp.run() - Fix "coroutine 'main' was never awaited" RuntimeWarning 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/mcp_mailu/server.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/mcp_mailu/server.py b/src/mcp_mailu/server.py index 050deb3..c2192e0 100644 --- a/src/mcp_mailu/server.py +++ b/src/mcp_mailu/server.py @@ -689,7 +689,7 @@ def create_mailu_client(base_url: str, api_token: str) -> httpx.AsyncClient: ) -async def create_mcp_server() -> FastMCP: +def create_mcp_server() -> FastMCP: """Create the MCP server with Mailu API integration.""" # Get configuration from environment variables @@ -707,8 +707,8 @@ async def create_mcp_server() -> FastMCP: logger.info(f"Fetching OpenAPI spec from: {spec_url}") try: - async with httpx.AsyncClient() as fetch_client: - response = await fetch_client.get(spec_url) + with httpx.Client() as fetch_client: + response = fetch_client.get(spec_url) response.raise_for_status() spec = response.json() @@ -789,17 +789,16 @@ async def create_mcp_server() -> FastMCP: return mcp -async def main(): +def main(): """Main entry point for the MCP server.""" logger.info("Starting Mailu MCP Server") try: # Create and run the MCP server - mcp = await create_mcp_server() + mcp = create_mcp_server() - await mcp.run( - transport="stdio", - capture_keyboard_interrupt=True + mcp.run( + transport="stdio" ) except Exception as e: @@ -808,4 +807,4 @@ async def main(): if __name__ == "__main__": - asyncio.run(main()) + main()