I also got same problem in linux. Instead of running with mcp dev server.py, run with
mcp dev server.py
npx @modelcontextprotocol/inspector uv run server.py
I assumed that you have install uv. This command works perfectly for me.
uv