René's URL Explorer Experiment


Title: MCP Server Hangs Indefinitely After KqueueSelector Log on macOS (Python 3.12, Both STDIO & SSE) · Issue #547 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: MCP Server Hangs Indefinitely After KqueueSelector Log on macOS (Python 3.12, Both STDIO & SSE) · Issue #547 · modelcontextprotocol/python-sdk

X Title: MCP Server Hangs Indefinitely After KqueueSelector Log on macOS (Python 3.12, Both STDIO & SSE) · Issue #547 · modelcontextprotocol/python-sdk

Description: Describe the bug When running an MCP server using mcp-sdk (both FastMCP and the low-level Server with mcp.server.stdio.stdio_server) on macOS with Python 3.12, the server process hangs indefinitely immediately after the DEBUG - Using sel...

Open Graph Description: Describe the bug When running an MCP server using mcp-sdk (both FastMCP and the low-level Server with mcp.server.stdio.stdio_server) on macOS with Python 3.12, the server process hangs indefinitely...

X Description: Describe the bug When running an MCP server using mcp-sdk (both FastMCP and the low-level Server with mcp.server.stdio.stdio_server) on macOS with Python 3.12, the server process hangs indefinitely...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/547

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MCP Server Hangs Indefinitely After KqueueSelector Log on macOS (Python 3.12, Both STDIO \u0026 SSE)","articleBody":"\n\n**Describe the bug**\n\nWhen running an MCP server using `mcp-sdk` (both `FastMCP` and the low-level `Server` with `mcp.server.stdio.stdio_server`) on macOS with Python 3.12, the server process hangs indefinitely immediately after the `DEBUG - Using selector: KqueueSelector` log message appears. This happens during the `server.run()` or `mcp.run()` call.\n\nThe hang occurs regardless of whether the STDIO transport (`transport=\"stdio\"`) or the default web/SSE transport is used. It also occurs even with a minimal server configuration with no custom tools, resources, or plugins registered.\n\n**Environment:**\n\n*   **OS:** macOS 15 Sequoia (Darwin 24.5.0)\n*   **Python:** 3.12.9 (via Homebrew - *Please update if incorrect*)\n*   **mcp-sdk Version:** 1.6.1.dev14+babb477 (Installed via `pip install -e .` from Git main branch using `mcp @ git+https://github.com/modelcontextprotocol/python-sdk.git` in `pyproject.toml` with `hatchling` and `allow-direct-references = true`)\n*   **Key Dependencies:**\n    *   uvicorn: 0.30.3\n    *   starlette: 0.37.2\n    *   anyio: 4.9.0\n\n**To Reproduce**\n\nSteps to reproduce the behavior:\n1.  Ensure Python 3.12.9 and `mcp-sdk` (tested with version `1.6.1.dev14+babb477` installed from Git main branch) are installed in your environment on macOS.\n2.  Save the following minimal STDIO server example (based on the SDK documentation) as `mcp_stdio_test.py`:\n    ```python\n    # From https://github.com/modelcontextprotocol/python-sdk README (Low-Level Server example)\n    import mcp.server.stdio\n    import mcp.types as types\n    from mcp.server.lowlevel import NotificationOptions, Server\n    from mcp.server.models import InitializationOptions\n    import logging # Add logging\n    import asyncio # Add asyncio\n\n    # Configure logging\n    logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')\n    logger = logging.getLogger(__name__)\n\n\n    # Create a server instance\n    logger.debug(\"Creating Server instance...\")\n    server = Server(\"example-server\")\n    logger.debug(\"Server instance created.\")\n\n\n    @server.list_prompts()\n    async def handle_list_prompts() -\u003e list[types.Prompt]:\n        logger.debug(\"Handling list_prompts request...\")\n        return [\n            types.Prompt(\n                name=\"example-prompt\",\n                description=\"An example prompt template\",\n                arguments=[\n                    types.PromptArgument(\n                        name=\"arg1\", description=\"Example argument\", required=True\n                    )\n                ],\n            )\n        ]\n    logger.debug(\"list_prompts handler defined.\")\n\n\n    @server.get_prompt()\n    async def handle_get_prompt(\n        name: str, arguments: dict[str, str] | None\n    ) -\u003e types.GetPromptResult:\n        logger.debug(f\"Handling get_prompt request for: {name}\")\n        if name != \"example-prompt\":\n            raise ValueError(f\"Unknown prompt: {name}\")\n\n        return types.GetPromptResult(\n            description=\"Example prompt\",\n            messages=[\n                types.PromptMessage(\n                    role=\"user\",\n                    content=types.TextContent(type=\"text\", text=\"Example prompt text\"),\n                )\n            ],\n        )\n    logger.debug(\"get_prompt handler defined.\")\n\n\n    async def run():\n        logger.debug(\"run() function started.\")\n        async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):\n            logger.debug(\"stdio_server context entered.\")\n            init_options = InitializationOptions(\n                    server_name=\"example\",\n                    server_version=\"0.1.0\",\n                    capabilities=server.get_capabilities(\n                        notification_options=NotificationOptions(),\n                        experimental_capabilities={},\n                    ),\n                )\n            logger.debug(f\"Initialization options created: {init_options}\")\n            logger.debug(\"Attempting server.run()...\")\n            # Note: Using low-level server.run, not FastMCP's run\n            await server.run(\n                read_stream,\n                write_stream,\n                init_options\n            )\n            logger.debug(\"server.run() finished.\") # This likely won't be reached in normal operation\n\n\n    if __name__ == \"__main__\":\n        logger.info(\"Starting asyncio event loop...\")\n        try:\n            asyncio.run(run())\n        except KeyboardInterrupt:\n            logger.info(\"KeyboardInterrupt received, exiting.\")\n        except Exception as e:\n            logger.critical(f\"Unhandled exception in main loop: {e}\", exc_info=True)\n        finally:\n            logger.info(\"asyncio event loop finished.\")\n    ```\n3.  Run the script from the terminal: `python mcp_stdio_test.py`\n4.  **See error:** Observe the log output. The script hangs indefinitely after the `Attempting server.run()...` log message.\n\n**Expected behavior**\n\nThe server should successfully start, remain running, and be ready to accept MCP connections via STDIO (or SSE if run without `transport=\"stdio\"`). It should not hang during initialization.\n\n**Screenshots**\n\nN/A - The issue is a process hang, the relevant output is text logs shown below.\n\n**Desktop:**\n\n*   **OS:** macOS 15 Sequoia (Darwin 24.5.0)\n*   **Python Version:** 3.12.9 (via Homebrew - *Please update if incorrect*)\n*   **mcp-sdk Version:** 1.6.1.dev14+babb477 (Installed from Git main branch)\n*   **Key Dependencies:**\n    *   uvicorn: 0.30.3\n    *   starlette: 0.37.2\n    *   anyio: 4.9.0\n\n**Smartphone:**\n\nN/A\n\n**Additional context**\n\n*   The issue occurs with both `FastMCP().run(...)` and the low-level `Server().run(...)` implementation.\n*   The hang happens even when all custom tools, resources, plugins, and prompts defined in the application code are commented out.\n*   The issue persists whether using `mcp` installed from PyPI or directly from the Git main branch.\n*   Pinning `uvicorn[standard]` to `0.30.3` (a version used in a previously working commit) did not resolve the issue.\n*   Adding a `time.sleep(10)` before the `run()` call (which seemed to help in older commits) no longer prevents the hang.\n*   Issue #396 seems potentially related as it also involves problems with the STDIO transport, although it describes the client not detecting server termination rather than the server hanging on startup.\n\nThis strongly suggests an underlying issue within `mcp-sdk`'s core run logic or its interaction with `asyncio`/`KqueueSelector` on macOS with recent Python versions or recent `mcp-sdk` versions. The hang point after `KqueueSelector` seems critical.\n\n**Log Output Showing Hang:**\n\n```\n2025-04-21 02:17:29,965 - DEBUG - Creating Server instance...\n2025-04-21 02:17:29,966 - DEBUG - Initializing server 'example-server'\n2025-04-21 02:17:29,966 - DEBUG - Server instance created.\n2025-04-21 02:17:29,966 - DEBUG - Registering handler for PromptListRequest\n2025-04-21 02:17:29,966 - DEBUG - list_prompts handler defined.\n2025-04-21 02:17:29,966 - DEBUG - Registering handler for GetPromptRequest\n2025-04-21 02:17:29,966 - DEBUG - get_prompt handler defined.\n2025-04-21 02:17:29,966 - INFO - Starting asyncio event loop...\n2025-04-21 02:17:29,966 - DEBUG - Using selector: KqueueSelector\n2025-04-21 02:17:29,971 - DEBUG - run() function started.\n2025-04-21 02:17:29,973 - DEBUG - stdio_server context entered.\n2025-04-21 02:17:29,973 - DEBUG - Initialization options created: server_name='example' server_version='0.1.0' capabilities=ServerCapabilities(experimental={}, logging=None, prompts=PromptsCapability(listChanged=False), resources=None, tools=None) instructions=None\n2025-04-21 02:17:29,973 - DEBUG - Attempting server.run()...\n\u003c-- HANGS HERE INDEFINITELY --\u003e\n``` ","author":{"url":"https://github.com/jlcases","@type":"Person","name":"jlcases"},"datePublished":"2025-04-21T00:26:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/547/python-sdk/issues/547"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f49a9c6d-1f40-63cf-8ca0-b23e11c122bf
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idECC6:34BF14:175B95F:2145EEA:6A5A22D5
html-safe-nonce3d0596bc91d32bfd0dcd99b100a11f1b522ea93fa15b754e8fe5c4122af98f89
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQ0M2OjM0QkYxNDoxNzVCOTVGOjIxNDVFRUE6NkE1QTIyRDUiLCJ2aXNpdG9yX2lkIjoiMzExMDE5OTIxNjI2Nzk5MzgxMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacf84819bd55af20e33a050675063b22f629e8a701597ec708261ffe7109e79157
hovercard-subject-tagissue:3007314837
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/547/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5181beee04b0fdb10a1f735473a3c2cbff34c3727982f54f500b10a479f2d705/modelcontextprotocol/python-sdk/issues/547
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5181beee04b0fdb10a1f735473a3c2cbff34c3727982f54f500b10a479f2d705/modelcontextprotocol/python-sdk/issues/547
og:image:altDescribe the bug When running an MCP server using mcp-sdk (both FastMCP and the low-level Server with mcp.server.stdio.stdio_server) on macOS with Python 3.12, the server process hangs indefinitely...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejlcases
hostnamegithub.com
expected-hostnamegithub.com
Nonee31742e80bbd077fd5679c13ed870ce4e0c13803a2fa5beaae557b6769de2c8a
turbo-cache-controlno-preview
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasec9fcdbf98c619d1561ed843fa01d9766a32b5cd9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/547#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F547
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F547
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/547
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/547
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/547
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/issues/547
modelcontextprotocol https://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Notifications https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Fork 3.7k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Star 23.6k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Code https://github.com/modelcontextprotocol/python-sdk
Issues 255 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 303 https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality 6 https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
Code https://github.com/modelcontextprotocol/python-sdk
Issues https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
MCP Server Hangs Indefinitely After KqueueSelector Log on macOS (Python 3.12, Both STDIO & SSE)https://github.com/modelcontextprotocol/python-sdk/issues/547#top
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
needs confirmationNeeds confirmation that the PR is actually required or needed.https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22needs%20confirmation%22
https://github.com/jlcases
jlcaseshttps://github.com/jlcases
on Apr 21, 2025https://github.com/modelcontextprotocol/python-sdk/issues/547#issue-3007314837
MCP Server: Inconsistent Exception Handling in @app.call_tool and Client Undetected Server Termination via Stdio #396https://github.com/modelcontextprotocol/python-sdk/issues/396
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
needs confirmationNeeds confirmation that the PR is actually required or needed.https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22needs%20confirmation%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.