Setup: Python SDK
This lesson gets you from nothing to a project structure ready to build your first MCP server. About 15 minutes.
What You Need
Python 3.10 or newer. Check with python --version. If yours is older, install a newer one from python.org.
A code editor. VS Code, Cursor, PyCharm, whatever you already use.
A terminal. Whatever your operating system uses.
Note: unlike Building AI Agents, you do NOT need an Anthropic API key to build an MCP server. The server is a passive service that a client (Claude Desktop, Claude Code) will spawn and talk to. The client handles the model calls. You only need an API key on the client side.
Step 1: Create the Project
Open a terminal:
mkdir hardcoded-mcp-server
cd hardcoded-mcp-server
python -m venv .venv
Activate the environment. On macOS or Linux:
source .venv/bin/activate
On Windows PowerShell:
.venv\Scripts\Activate.ps1
Step 2: Install the SDK
pip install "mcp[cli]"
The [cli] extra installs the MCP CLI tool, which includes the Inspector we will use in Lesson 5 for testing. Without [cli], you get the library only.
Step 3: Verify
mcp --help
You should see a help message listing commands like dev, run and install. If you see "command not found", either the venv is not activated or the install failed. Re-check both.
Step 4: A Minimal Server
Create server.py:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("hardcoded-example")
@mcp.tool()
def greet(name: str) -> str:
"""Return a friendly greeting."""
return f"Hello, {name}. Welcome to MCP."
if __name__ == "__main__":
mcp.run()
That is a complete, working MCP server. One tool, one function. When a client connects, it can call greet("world") and get back "Hello, world. Welcome to MCP."
Step 5: Test Run
mcp dev server.py
This opens the MCP Inspector, a browser-based tool for exploring your server. You should see your greet tool listed. Click through and invoke it with a name. You should get the greeting back.
If the Inspector does not open automatically, the CLI will print a URL like http://localhost:5173. Open that in your browser.
TypeScript SDK (Sidebar)
The Python SDK is what this course uses. There is an equally official TypeScript SDK:
npm install @modelcontextprotocol/sdk
Everything you will learn about server anatomy, primitives, testing and deployment applies to both. The choice is mostly personal preference. Python is used here because the AI ecosystem outside coding tools is Python-heavy, and because the MCP Inspector integration is slightly smoother.
If your day job is TypeScript, follow the same lessons and use the TypeScript SDK. The concepts are one-to-one.
Common Setup Problems
mcp: command not found. Virtual environment is not activated, or you installed mcp without the [cli] extra.
Inspector will not open. Browser blocking localhost, or the port is in use. Try a different browser or restart the CLI.
Import errors when running the server. You installed to a different Python than the one your terminal is using. Check with which python (or Get-Command python on Windows).
Key Takeaway
Setup is minimal: create a project, install mcp[cli], write a few lines of Python. In 15 minutes you have a working server with one tool and an Inspector to test it. The rest of this module is about growing this minimal server into something useful.