René's URL Explorer Experiment


Title: On Windows 11 when you initialize an mcp client it hangs indefinitely · Issue #552 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: On Windows 11 when you initialize an mcp client it hangs indefinitely · Issue #552 · modelcontextprotocol/python-sdk

X Title: On Windows 11 when you initialize an mcp client it hangs indefinitely · Issue #552 · modelcontextprotocol/python-sdk

Description: Describe the bug On Windows 11 when you initialize an mcp client it hangs indefinitely. To Reproduce Code to reproduce: # ruff: noqa import asyncio from mcp import ClientSession, StdioServerParameters from mcp.client.sse import sse_clien...

Open Graph Description: Describe the bug On Windows 11 when you initialize an mcp client it hangs indefinitely. To Reproduce Code to reproduce: # ruff: noqa import asyncio from mcp import ClientSession, StdioServerParamet...

X Description: Describe the bug On Windows 11 when you initialize an mcp client it hangs indefinitely. To Reproduce Code to reproduce: # ruff: noqa import asyncio from mcp import ClientSession, StdioServerParamet...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"On Windows 11 when you initialize an mcp client it hangs indefinitely","articleBody":"**Describe the bug**\nOn Windows 11 when you initialize an mcp client it hangs indefinitely.\n\n**To Reproduce**\nCode to reproduce:\n```python\n# ruff: noqa\nimport asyncio\n\nfrom mcp import ClientSession, StdioServerParameters\nfrom mcp.client.sse import sse_client\nfrom mcp.client.stdio import stdio_client\n\n\nasync def run():\n    params = StdioServerParameters(\n        command='bunx', args=['@playwright/mcp@latest']\n    )\n    async with stdio_client(params) as (read, write):\n        print('inside client')\n        async with ClientSession(read, write) as c:\n            print('inside ClientSession')\n            await c.initialize()\n        print('exit ClientSession')\n    print('exit stdio_client')\n\n\nasync def run_sse():\n    async with sse_client('http://localhost:8931/sse') as (read, write):\n        async with ClientSession(read, write) as c:\n            await c.initialize()\n        print('exit ClientSession')\n    print('exit sse_client')\n\n\nif __name__ == '__main__':\n    asyncio.run(run_sse())  # works\n    asyncio.run(run())  # does not work\n\n```\n\n**Expected behavior**\nin both cases it should print both exit statements\n\n**Desktop (please complete the following information):**\n - OS: Windows 11\n - Python Version: Tested on both 3.13.1 and 3.12.7\n\n\n**Additional context**\ncounterintuitively commenting out the code meant to support windows fixes this issue:\n```python\nimport os\nimport sys\nfrom contextlib import asynccontextmanager\nfrom pathlib import Path\nfrom typing import Literal, TextIO\n\nimport anyio\nimport anyio.lowlevel\nfrom anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream\nfrom anyio.streams.text import TextReceiveStream\nfrom pydantic import BaseModel, Field\n\nimport mcp.types as types\n\n# from .win32 import (\n#     create_windows_process,\n#     get_windows_executable_command,\n#     terminate_windows_process,\n# )\n\n# Environment variables to inherit by default\nDEFAULT_INHERITED_ENV_VARS = (\n    [\n        \"APPDATA\",\n        \"HOMEDRIVE\",\n        \"HOMEPATH\",\n        \"LOCALAPPDATA\",\n        \"PATH\",\n        \"PROCESSOR_ARCHITECTURE\",\n        \"SYSTEMDRIVE\",\n        \"SYSTEMROOT\",\n        \"TEMP\",\n        \"USERNAME\",\n        \"USERPROFILE\",\n    ]\n    if sys.platform == \"win32\"\n    else [\"HOME\", \"LOGNAME\", \"PATH\", \"SHELL\", \"TERM\", \"USER\"]\n)\nprint( sys.platform)\n\ndef get_default_environment() -\u003e dict[str, str]:\n    \"\"\"\n    Returns a default environment object including only environment variables deemed\n    safe to inherit.\n    \"\"\"\n    env: dict[str, str] = {}\n\n    for key in DEFAULT_INHERITED_ENV_VARS:\n        value = os.environ.get(key)\n        if value is None:\n            continue\n\n        if value.startswith(\"()\"):\n            # Skip functions, which are a security risk\n            continue\n\n        env[key] = value\n\n    return env\n\n\nclass StdioServerParameters(BaseModel):\n    command: str\n    \"\"\"The executable to run to start the server.\"\"\"\n\n    args: list[str] = Field(default_factory=list)\n    \"\"\"Command line arguments to pass to the executable.\"\"\"\n\n    env: dict[str, str] | None = None\n    \"\"\"\n    The environment to use when spawning the process.\n\n    If not specified, the result of get_default_environment() will be used.\n    \"\"\"\n\n    cwd: str | Path | None = None\n    \"\"\"The working directory to use when spawning the process.\"\"\"\n\n    encoding: str = \"utf-8\"\n    \"\"\"\n    The text encoding used when sending/receiving messages to the server\n\n    defaults to utf-8\n    \"\"\"\n\n    encoding_error_handler: Literal[\"strict\", \"ignore\", \"replace\"] = \"strict\"\n    \"\"\"\n    The text encoding error handler.\n\n    See https://docs.python.org/3/library/codecs.html#codec-base-classes for\n    explanations of possible values\n    \"\"\"\n\n\n@asynccontextmanager\nasync def stdio_client(server: StdioServerParameters, errlog: TextIO = sys.stderr):\n    \"\"\"\n    Client transport for stdio: this will connect to a server by spawning a\n    process and communicating with it over stdin/stdout.\n    \"\"\"\n    read_stream: MemoryObjectReceiveStream[types.JSONRPCMessage | Exception]\n    read_stream_writer: MemoryObjectSendStream[types.JSONRPCMessage | Exception]\n\n    write_stream: MemoryObjectSendStream[types.JSONRPCMessage]\n    write_stream_reader: MemoryObjectReceiveStream[types.JSONRPCMessage]\n\n    read_stream_writer, read_stream = anyio.create_memory_object_stream(0)\n    write_stream, write_stream_reader = anyio.create_memory_object_stream(0)\n\n    command = _get_executable_command(server.command)\n\n    # Open process with stderr piped for capture\n    process = await _create_platform_compatible_process(\n        command=command,\n        args=server.args,\n        env=(\n            {**get_default_environment(), **server.env}\n            if server.env is not None\n            else get_default_environment()\n        ),\n        errlog=errlog,\n        cwd=server.cwd,\n    )\n\n    async def stdout_reader():\n        assert process.stdout, \"Opened process is missing stdout\"\n\n        try:\n            async with read_stream_writer:\n                buffer = \"\"\n                async for chunk in TextReceiveStream(\n                    process.stdout,\n                    encoding=server.encoding,\n                    errors=server.encoding_error_handler,\n                ):\n                    lines = (buffer + chunk).split(\"\\n\")\n                    buffer = lines.pop()\n\n                    for line in lines:\n                        try:\n                            message = types.JSONRPCMessage.model_validate_json(line)\n                        except Exception as exc:\n                            await read_stream_writer.send(exc)\n                            continue\n\n                        await read_stream_writer.send(message)\n        except anyio.ClosedResourceError:\n            await anyio.lowlevel.checkpoint()\n\n    async def stdin_writer():\n        assert process.stdin, \"Opened process is missing stdin\"\n\n        try:\n            async with write_stream_reader:\n                async for message in write_stream_reader:\n                    json = message.model_dump_json(by_alias=True, exclude_none=True)\n                    await process.stdin.send(\n                        (json + \"\\n\").encode(\n                            encoding=server.encoding,\n                            errors=server.encoding_error_handler,\n                        )\n                    )\n        except anyio.ClosedResourceError:\n            await anyio.lowlevel.checkpoint()\n\n    async with (\n        anyio.create_task_group() as tg,\n        process,\n    ):\n        tg.start_soon(stdout_reader)\n        tg.start_soon(stdin_writer)\n        try:\n            yield read_stream, write_stream\n        finally:\n            # Clean up process to prevent any dangling orphaned processes\n            # if sys.platform == \"win32\":\n            #     await terminate_windows_process(process)\n            # else:\n            process.terminate()\n\n\ndef _get_executable_command(command: str) -\u003e str:\n    \"\"\"\n    Get the correct executable command normalized for the current platform.\n\n    Args:\n        command: Base command (e.g., 'uvx', 'npx')\n\n    Returns:\n        str: Platform-appropriate command\n    \"\"\"\n      # if sys.platform == \"win32\":\n      #     return get_windows_executable_command(command)\n      # else:\n    return command\n\n\nasync def _create_platform_compatible_process(\n    command: str,\n    args: list[str],\n    env: dict[str, str] | None = None,\n    errlog: TextIO = sys.stderr,\n    cwd: Path | str | None = None,\n):\n    \"\"\"\n    Creates a subprocess in a platform-compatible way.\n    Returns a process handle.\n    \"\"\"\n    # if sys.platform == \"win32\":\n    #     print('attempting create windows process')\n    #     process = await create_windows_process(command, args, env, errlog, cwd)\n    #     print('created windows process')\n    # else:\n    process = await anyio.open_process(\n        [command, *args], env=env, stderr=errlog, cwd=cwd\n    )\n\n    return process\n\n```","author":{"url":"https://github.com/BenMawnMahlauNBTC","@type":"Person","name":"BenMawnMahlauNBTC"},"datePublished":"2025-04-21T16:03:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":15},"url":"https://github.com/552/python-sdk/issues/552"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:c9722cfe-c68b-05ee-487d-0fd43d8ce5d6
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE71E:2D7422:3CFE20:52667B:6A5A62B0
html-safe-noncec71f6741e0066ff8efa5eed4f80f0ddb18042443a1a066e1ec8eb9ed9cdb5c96
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzFFOjJENzQyMjozQ0ZFMjA6NTI2NjdCOjZBNUE2MkIwIiwidmlzaXRvcl9pZCI6IjM5ODU2NjM1NjU4MTA1MjQ4NDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac53a46f7be96739c259a12ff12784a03b182152cd8fcac267fa41f582334fcf24
hovercard-subject-tagissue:3008755343
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/552/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d93d4d80ea0728ddd6930c72ebd6c46d34b52d99e55b1e4b731e2f70b1ab7018/modelcontextprotocol/python-sdk/issues/552
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d93d4d80ea0728ddd6930c72ebd6c46d34b52d99e55b1e4b731e2f70b1ab7018/modelcontextprotocol/python-sdk/issues/552
og:image:altDescribe the bug On Windows 11 when you initialize an mcp client it hangs indefinitely. To Reproduce Code to reproduce: # ruff: noqa import asyncio from mcp import ClientSession, StdioServerParamet...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameBenMawnMahlauNBTC
hostnamegithub.com
expected-hostnamegithub.com
None05b9ddf6a47d2dbe13944873a99f5fb4b83ba4871f9cb8a8e256793a63ca9687
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
releasef8d29d1bd03dda2dd14b3f80b8bc27e1111f43bd
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/552#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F552
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%2F552
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/552
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/552
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/552
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/issues/552
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 256 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
On Windows 11 when you initialize an mcp client it hangs indefinitelyhttps://github.com/modelcontextprotocol/python-sdk/issues/552#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/BenMawnMahlauNBTC
BenMawnMahlauNBTChttps://github.com/BenMawnMahlauNBTC
on Apr 21, 2025https://github.com/modelcontextprotocol/python-sdk/issues/552#issue-3008755343
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.