1
0
forked from rsp2k/mcp-mailu

Fix async/await issues in MCP server entry point

- 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 <noreply@anthropic.com>
This commit is contained in:
Ryan Malloy 2025-07-16 12:39:44 -06:00
parent 31c71c1c5d
commit bcc4cd4327

View File

@ -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.""" """Create the MCP server with Mailu API integration."""
# Get configuration from environment variables # Get configuration from environment variables
@ -707,8 +707,8 @@ async def create_mcp_server() -> FastMCP:
logger.info(f"Fetching OpenAPI spec from: {spec_url}") logger.info(f"Fetching OpenAPI spec from: {spec_url}")
try: try:
async with httpx.AsyncClient() as fetch_client: with httpx.Client() as fetch_client:
response = await fetch_client.get(spec_url) response = fetch_client.get(spec_url)
response.raise_for_status() response.raise_for_status()
spec = response.json() spec = response.json()
@ -789,17 +789,16 @@ async def create_mcp_server() -> FastMCP:
return mcp return mcp
async def main(): def main():
"""Main entry point for the MCP server.""" """Main entry point for the MCP server."""
logger.info("Starting Mailu MCP Server") logger.info("Starting Mailu MCP Server")
try: try:
# Create and run the MCP server # Create and run the MCP server
mcp = await create_mcp_server() mcp = create_mcp_server()
await mcp.run( mcp.run(
transport="stdio", transport="stdio"
capture_keyboard_interrupt=True
) )
except Exception as e: except Exception as e:
@ -808,4 +807,4 @@ async def main():
if __name__ == "__main__": if __name__ == "__main__":
asyncio.run(main()) main()