René's URL Explorer Experiment


Title: MCP Tool execution hangs indefinitely in stdio mode when calling external Python scripts · Issue #671 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: MCP Tool execution hangs indefinitely in stdio mode when calling external Python scripts · Issue #671 · modelcontextprotocol/python-sdk

X Title: MCP Tool execution hangs indefinitely in stdio mode when calling external Python scripts · Issue #671 · modelcontextprotocol/python-sdk

Description: Describe the bug When using FastMCP in stdio transport mode, any tool that attempts to execute an external Python script will hang indefinitely until timeout, without returning any result or error. The same code works perfectly when usin...

Open Graph Description: Describe the bug When using FastMCP in stdio transport mode, any tool that attempts to execute an external Python script will hang indefinitely until timeout, without returning any result or error....

X Description: Describe the bug When using FastMCP in stdio transport mode, any tool that attempts to execute an external Python script will hang indefinitely until timeout, without returning any result or error....

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MCP Tool execution hangs indefinitely in stdio mode when calling external Python scripts","articleBody":"**Describe the bug**\nWhen using FastMCP in stdio transport mode, any tool that attempts to execute an external Python script will hang indefinitely until timeout, without returning any result or error. The same code works perfectly when using SSE transport mode.\n\n**To Reproduce**\nSteps to reproduce the behavior:\n1. Create a minimal external script (minimal_script.py) that simply prints output and exits\n```\nimport sys\n\ndef main():\n    print(\"Successfully Call!\")\n    return 0\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n```\n2. Create an MCP server with a tool that calls this external script\n```\nimport os\nimport sys\nimport asyncio\nimport subprocess\nfrom typing import Dict, Any\n\nfrom mcp.server.fastmcp import FastMCP\n\n# Initialize MCP\nmcp = FastMCP(\"bug_demo\")\n\n@mcp.tool()\nasync def call_external_script() -\u003e Dict[str, Any]:\n    \"\"\"Call external script and return result\"\"\"\n    # Get script path\n    current_dir = os.path.dirname(os.path.abspath(__file__))\n    script_path = os.path.join(current_dir, \"minimal_script.py\")\n    \n    # Build command\n    cmd = [sys.executable, script_path]\n    \n    try:\n        # Execute external command\n        process = await asyncio.create_subprocess_exec(\n            *cmd,\n            stdout=subprocess.PIPE,\n            stderr=subprocess.PIPE\n        )\n        \n        # Wait for process to complete and get output\n        stdout, stderr = await process.communicate()\n        \n        return {\n            \"success\": process.returncode == 0,\n            \"stdout\": stdout.decode().strip(),\n            \"stderr\": stderr.decode().strip(),\n            \"return_code\": process.returncode\n        }\n    except Exception as e:\n        return {\n            \"success\": False,\n            \"error\": str(e)\n        }\n\nif __name__ == \"__main__\":\n    mcp.run(transport=\"stdio\")\n    # mcp.run(transport=\"sse\")\n```\n3. Run the server in stdio mode\n4. Call the tool (Using MCP Inspector) that executes the external script\n5. Observe that the tool call hangs indefinitely with no response\n\n\n**Expected behavior**\nThe tool should execute the external Python script, capture its output, and return the results promptly, regardless of the transport mode used (stdio or SSE).\n\n**Screenshots**\nWhen using stdio, the tool will hang indefinitely until timeout.\n![Image](https://github.com/user-attachments/assets/4903cabe-d1aa-49fe-8ee8-25b303a97e28)\n\nHowever, correct results can be obtained by using SSE mode.\n![Image](https://github.com/user-attachments/assets/3897ba01-052e-4b4b-85f9-483ad30eef07)\n\n**Desktop (please complete the following information):**\n - OS: Windows 11 24H2 26100.3775\n - Python 3.10.0\n - mcp 1.7.1\n - asyncio 3.4.3\n\n**Additional context**\n· The issue persists regardless of whether using asyncio.create_subprocess_exec() or subprocess.run().\n· I tried printing something in an external py script and found that when calling the tool in STDIO mode, it would be unresponsive, but after timeout, the external py script would be executed and something would be printed out. This is like the running of a py script being blocked until the tool call times out before it can run\n","author":{"url":"https://github.com/ycycycl","@type":"Person","name":"ycycycl"},"datePublished":"2025-05-09T06:17:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/671/python-sdk/issues/671"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e39dc956-297b-5c29-0c2e-46e63c40161f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC0B4:3D4855:8300B0:BDCF03:6A5787C3
html-safe-nonceeb02022bfab8f77d40df2bb490918c44f4257c048d65313d09ddb7cbdf084481
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEI0OjNENDg1NTo4MzAwQjA6QkRDRjAzOjZBNTc4N0MzIiwidmlzaXRvcl9pZCI6IjY2MjM0NjMxMDY5NzgyMTk5NzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacc2fdf56f8cb51d8171744a90025a7739fd0a29299f2b981dab83eb4d26cce876
hovercard-subject-tagissue:3051048670
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/671/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d0f71043463364b75157d9bbd03fcb4dd883d4b6bc0ee0b4f44be1c13a7af703/modelcontextprotocol/python-sdk/issues/671
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d0f71043463364b75157d9bbd03fcb4dd883d4b6bc0ee0b4f44be1c13a7af703/modelcontextprotocol/python-sdk/issues/671
og:image:altDescribe the bug When using FastMCP in stdio transport mode, any tool that attempts to execute an external Python script will hang indefinitely until timeout, without returning any result or error....
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameycycycl
hostnamegithub.com
expected-hostnamegithub.com
Nonec6353e56e94423c9cd5abde7708a859afa36a0c1203c73749055bf6ee6704cd0
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
releasef59ab1c46b638204e2aea09126d089be5dc773b7
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/671#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F671
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%2F671
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/671
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/671
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/671
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/issues/671
modelcontextprotocol https://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Notifications https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Fork 3.6k 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 251 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 289 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 Tool execution hangs indefinitely in stdio mode when calling external Python scriptshttps://github.com/modelcontextprotocol/python-sdk/issues/671#top
P3Nice to haves, rare edge caseshttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P3%22
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
ready for workEnough information for someone to start working onhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22ready%20for%20work%22
https://github.com/ycycycl
ycycyclhttps://github.com/ycycycl
on May 9, 2025https://github.com/modelcontextprotocol/python-sdk/issues/671#issue-3051048670
https://private-user-images.githubusercontent.com/94345876/441999673-4903cabe-d1aa-49fe-8ee8-25b303a97e28.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODQxMjE1ODQsIm5iZiI6MTc4NDEyMTI4NCwicGF0aCI6Ii85NDM0NTg3Ni80NDE5OTk2NzMtNDkwM2NhYmUtZDFhYS00OWZlLThlZTgtMjViMzAzYTk3ZTI4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA3MTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNzE1VDEzMTQ0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNkNzUwOTJjNzA4NjVjZmIzNThhMjcwZWZmNTdiNzc1M2UwZWQ5NGRmYmY3OTI4YzNiMmE1MjUyMGI5MDM3MDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.8MZiD4MzqHZt1D7yB7ncMfGaqyXGKMPPqd38peZwd5c
https://private-user-images.githubusercontent.com/94345876/442000100-3897ba01-052e-4b4b-85f9-483ad30eef07.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODQxMjE1ODQsIm5iZiI6MTc4NDEyMTI4NCwicGF0aCI6Ii85NDM0NTg3Ni80NDIwMDAxMDAtMzg5N2JhMDEtMDUyZS00YjRiLTg1ZjktNDgzYWQzMGVlZjA3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA3MTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNzE1VDEzMTQ0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE3NzUxMGEwYTkzYTIxMmRkN2NhNzg1MmNjM2JjMGIxZjA0YmMxMzkyY2MwYjc5YjNhZGFhMjdhNmZiZWUzODEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.0SyxbidxUR5KJEJ8ZCp20m-AY5RgYcA94AjKh1xp71Y
P3Nice to haves, rare edge caseshttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P3%22
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
ready for workEnough information for someone to start working onhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22ready%20for%20work%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.