Installation
This chapter installs the official Python SDK and MCP Inspector, then checks that the commands run. Treat the python-sdk README and py.sdk.modelcontextprotocol.io as the source of truth for package names and imports.
Requirements
Check versions:
Unix:
Create a virtual environment
PowerShell:
If script execution is blocked, allow it once for your user:
Unix / macOS:
Install the official Python SDK
pip install mcp now installs SDK v2 (the 2026-07-28 line). The cli extra adds mcp dev and mcp run:
Or with uv:
Same commands on Unix. SDK only, no CLI: pip install mcp.
Verify the import (v2’s class is MCPServer, not v1’s FastMCP):
Older snippets that from mcp.server.fastmcp import FastMCP raise ModuleNotFoundError on v2. The decorator style (@mcp.tool() and friends) is unchanged; only the class was renamed. Pin mcp>=1.28,<2 only if you must stay on v1. New projects should use v2. The separate community FastMCP project is not the official package this course uses.
Install / launch Inspector
The Inspector package is @modelcontextprotocol/inspector. You usually do not install it globally:
The command prints a URL with a one-time session token; open it in a browser. Three entry points:
With mcp[cli] installed you can also run:
mcp dev starts Inspector and connects to your file over stdio. npx must be on PATH.
Suggested layout
requirements.txt can be a single line: mcp[cli].
Troubleshooting
python is not a command (Windows)?
Use py -3.12 -m venv .venv, then python after activation.
Inspector will not open / Node is too old?
Upgrade Node using the Inspector docs. You can still write TypeScript servers on Node 18 LTS; the debugger may require a newer runtime.
mcp is not a command?
Confirm pip install "mcp[cli]" and an active venv, or run python -m mcp.
Several Python tutorials on one machine?
Give each course its own venv so LangChain and MCP do not fight over packages.