Quick Start
This chapter builds a tiny add tool (plus an echo tool) with the official SDK and calls it from Inspector. You do not need Cursor or Claude Code to prove the protocol works.
Minimal server.py
Create server.py in an activated virtual environment:
That is a complete stdio server. The MCPServer name shows up in client identity. @mcp.tool() builds the schema from the function name, docstring, and type hints. mcp.run() with no arguments speaks stdio. Keep the if __name__ == "__main__" guard so mcp dev does not start a second server on import.
Many posts still show
from mcp.server.fastmcp import FastMCP. That is official SDK v1. Use the import above on v2. Decorators andrun()behave the same.
Open it in Inspector
Option A: SDK CLI (preferred)
Option B: hand the launch command to Inspector
Open the printed URL. The Tools tab should list add and echo. Call add with a=1, b=2 and expect 3. Call echo with any string and expect the same text back.
Inspector does what a real host does: spawn server.py and speak tools/list / tools/call over stdio.
Optional: one-shot CLI
Without a browser:
Then call a tool (confirm flags with Inspector --help):
Optional: in-memory client
No subprocess, no port—useful later in pytest:
from mcp import Client and from mcp.server import MCPServer are the two import paths. There is no from mcp import MCPServer.
Optional: Streamable HTTP
Change the entry point to:
Then:
In another terminal, point Inspector at HTTP (flags follow current Inspector help; --server-url plus --transport http is common):
While you learn the protocol, stay on stdio and mcp dev.
Checklist
pip install "mcp[cli]"in a venv- Save the
server.pyabove mcp dev .\server.py(Unix:mcp dev ./server.py)- Call
addandechoin Inspector - (Optional)
Client(mcp)or Streamable HTTP
On failure, read stderr and Inspector’s connection panel, not a chat window. Stdio stdout is the wire—do not print from tools for debugging.