Initial Checks
Release line
2.x (current stable)
Description
On Windows, get_windows_executable_command() already looks up .ps1 (alongside .cmd / .bat / .exe). The spawn path then passes that path to CreateProcess / anyio.open_process([command, *args]).
Windows cannot execute a .ps1 file directly. The lookup therefore advertises a working command that later fails with WinError 193 (not a valid Win32 application) or FileNotFoundError.
Expected: a command that resolves to something.ps1 is launched through PowerShell (powershell / pwsh -NoProfile -NonInteractive -ExecutionPolicy Bypass -File <script> ...args).
Actual: the SDK finds the .ps1 and then cannot start it.
I hit this on Windows while starting a stdio MCP server whose command is a PowerShell script (or a bare name that shutil.which resolves to .ps1).
I used an LLM to help draft this report after reproducing the failure locally.
Example Code
import asyncio
from pathlib import Path
from mcp.client.stdio import StdioServerParameters, stdio_client
# On Windows, CreateProcess cannot run a .ps1 path returned by
# get_windows_executable_command().
params = StdioServerParameters(command=str(Path(rC:\path\to\server.ps1)))
async def main():
async with stdio_client(params) as streams:
print(streams)
asyncio.run(main())
Direct spawn of the same path also fails:
import subprocess
subprocess.Popen([rC:\path\to\echo-ok.ps1]) # WinError 193
Launching via PowerShell works:
subprocess.Popen(
[powershell, -NoProfile, -NonInteractive, -ExecutionPolicy, Bypass, -File, rC:\path\to\echo-ok.ps1],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
creationflags=getattr(subprocess, CREATE_NO_WINDOW, 0),
)
Python & MCP Python SDK
Python 3.12 on Windows 10/11
MCP Python SDK 2.2.0 (modelcontextprotocol/python-sdk main as of this report)
Initial Checks
Release line
2.x (current stable)
Description
On Windows,
get_windows_executable_command()already looks up.ps1(alongside.cmd/.bat/.exe). The spawn path then passes that path toCreateProcess/anyio.open_process([command, *args]).Windows cannot execute a
.ps1file directly. The lookup therefore advertises a working command that later fails withWinError 193(not a valid Win32 application) orFileNotFoundError.Expected: a command that resolves to
something.ps1is launched through PowerShell (powershell/pwsh -NoProfile -NonInteractive -ExecutionPolicy Bypass -File <script> ...args).Actual: the SDK finds the
.ps1and then cannot start it.I hit this on Windows while starting a stdio MCP server whose command is a PowerShell script (or a bare name that
shutil.whichresolves to.ps1).I used an LLM to help draft this report after reproducing the failure locally.
Example Code
Direct spawn of the same path also fails:
Launching via PowerShell works:
Python & MCP Python SDK
Python 3.12 on Windows 10/11
MCP Python SDK 2.2.0 (
modelcontextprotocol/python-sdkmain as of this report)