To get the most out of this book
To follow along with the examples and exercises in this book, you’ll need the following:
- Python 3.8 or later installed on your system
- A code editor or IDE (VS Code is recommended)
- Basic familiarity with command-line interfaces
- An understanding of HTTP, JSON, and basic networking concepts
- Access to modern AI tools such as Claude or ChatGPT for testing examples
All the code examples are designed to run on Windows, macOS, and Linux. The book includes specific installation instructions and setup guidance for each major platform.
Download the example code files
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Learn-Model-Context-Protocol-with-Python. If there’s an update to the code, it will be updated in the GitHub repository. We also provide comprehensive examples, solutions to exercises, and additional resources to help you master MCP development.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://packt.link/gbp/9781806103232.
Conventions used
There are a number of text conventions used throughout this book.
Code In Text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and protocol names. For example: “The syntax is uvicorn <filename>:<name of app instance>. In this case, the filename is main.py and the app instance is app.”
A block of code is set as follows:
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route
async def homepage(request):
return JSONResponse({'hello': 'world'})
app = Starlette(debug=True, routes=[
Route('/', homepage),
])
Any command-line input or output is written as follows:
npx @modelcontextprotocol/inspector --cli http:localhost:8000/sse --method tools/list
Bold: Indicates a new term, an important word, or words that you see on the screen. For instance, words in menus or dialog boxes appear in the text like this. For example: “Note how Transport Type is set to SSE and URL is set to http://localhost:8000/sse.”
Warnings or important notes appear like this.
Tips and tricks appear like this.