Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learn Model Context Protocol with Python
Learn Model Context Protocol with Python

Learn Model Context Protocol with Python: Build agentic systems in Python with the new standard for AI capabilities

Arrow left icon
Profile Icon Christoffer Noring
Arrow right icon
$32.39 $35.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (2 Ratings)
eBook Oct 2025 304 pages 1st Edition
eBook
$32.39 $35.99
Paperback
$44.99
eBook + Subscription
$29.99 Monthly
Arrow left icon
Profile Icon Christoffer Noring
Arrow right icon
$32.39 $35.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (2 Ratings)
eBook Oct 2025 304 pages 1st Edition
eBook
$32.39 $35.99
Paperback
$44.99
eBook + Subscription
$29.99 Monthly
eBook
$32.39 $35.99
Paperback
$44.99
eBook + Subscription
$29.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Learn Model Context Protocol with Python

Introduction to the Model Context Protocol

Generative AI has rapidly become a force in today’s technological landscape, reshaping industries and redefining how we approach problem-solving. From natural language processing to image generation, the integration of generative AI into various domains has opened up new possibilities for innovation and efficiency.

For us developers, integrating generative AI into app development workflows is not without its complexities. We must carefully evaluate factors such as model accuracy, ethical considerations, and computational efficiency.

It’s in the process of building applications that we need to consider how we standardize the way we build our AI applications. Standardization means that everything looks the same, which should mean easier integration and collaboration across different teams and tools.

This is where the Model Context Protocol (MCP) comes in, to standardize how we ensure that AI-powered applications can easily find what they need from tools, content, and prompts; more on that shortly.

The chapter covers the following topics:

  • How we got here, from SOAP to REST to GraphQL to gRPC to MCP
  • The need for a standard
  • Endless possibilities: know how to prompt, and a world of MCP servers is your oyster
  • What is the MCP?

Getting the most out of this book – get to know your free benefits

Unlock exclusive free benefits that come with your purchase, thoughtfully crafted to supercharge your learning journey and help you learn without limits.

Here’s a quick overview of what you get with this book:

Next-gen reader

Figure 1.1: Illustration of the next-gen Packt Reader’s features

Our web-based reader, designed to help you learn effectively, comes with the following features:

Multi-device progress sync: Learn from any device with seamless progress sync.

Highlighting and notetaking: Turn your reading into lasting knowledge.

Bookmarking: Revisit your most important learnings anytime.

Dark mode: Focus with minimal eye strain by switching to dark or sepia mode.

Interactive AI assistant (beta)

Figure 1.2: Illustration of Packt’s AI assistant

Our interactive AI assistant has been trained on the content of this book, to maximize your learning experience. It comes with the following features:

Summarize it: Summarize key sections or an entire chapter.

AI code explainers: In the next-gen Packt Reader, click the Explain button above each code block for AI-powered code explanations.

Note: The AI assistant is part of next-gen Packt Reader and is still in beta.

DRM-free PDF or ePub version

Figure 1.3: Free PDF and ePub

Learn without limits with the following perks included with your purchase:

Learn from anywhere with a DRM-free PDF copy of this book.

Use your favorite e-reader to learn using a DRM-free ePub version of this book.

Unlock this book’s exclusive benefits now

Scan this QR code or go to https://packtpub.com/unlock, then search for this book by name. Ensure it’s the correct edition.

Note: Keep your purchase invoice ready before you start.

How we got here, from SOAP to REST to GraphQL to gRPC to MCP

Before we dive into the details of the MCP, let’s take a step back and look at how we got here.

One of my early memories of using web requests involved using XML to send and receive data. This was back in the days of Simple Object Access Protocol (SOAP), which was a protocol for exchanging structured information in the implementation of web services. It was great, but it was also very complex and felt heavy.

Then came Representational State Transfer (REST), which was a simpler way to build web services. It used HTTP and JSON, which made it easier to work with. REST was, and is, great.

There’s nothing inherently wrong with REST, but you could argue that if you had a backend team and a frontend team, the frontend team would often be waiting for the backend team to finish their work before they could start building the frontend. This is where GraphQL came in, which allowed you to query only the data you needed and made it easier to work with APIs. Of course, that creates other problems, such as over-fetching and under-fetching data and what’s known as the N+1 problem. The N+1 problem is a common performance issue in GraphQL APIs where multiple requests are made to fetch related data, leading to inefficiencies and increased latency.

There’s also Google Remote Procedure Call (gRPC), which is a high-performance RPC framework that uses HTTP/2 and Protocol Buffers. gRPC is great for microservices and allows you to define your APIs in a more structured way, but it can be complex to set up and use.

The need for a standard

All of these formats are great in their own right, but they all have their own problems. Also, the problem isn’t often of this nature, but rather a string of questions that we need to ask ourselves when building applications:

  • What does this app/API do? How do we easily expose the capabilities of our applications in a way that is easy to understand and use? Of course, no one has really agreed on a standard for this yet, until now.
  • How do we build apps if prompts are the new way to interact? Add to that that users are becoming accustomed to using prompts to interact with applications, and you start wondering what part is the generative AI part, and what part is the capabilities of the application itself?
  • Should large language model (LLM) and other capabilities be kept separate? Also, do I really need the generative AI part and the capabilities of the application to all be in the same place?
  • If they were kept separate, what could we gain? If we could separate the two, in a client and server part, then maybe we could easily consume servers built by others – Hello agentic era.

These are some good questions to ask yourself. But this doesn’t answer why we need a standard. Let’s look at that further:

  • We, as developers, are too good at programming: Here’s the problem: as developers, we’re almost too good at programming, meaning that we’re used to gluing different things together. We can build applications that use multiple AI models, and we can make applications talk to each other that use different protocols and formats. This is not always easy, but we can do it.
  • We can do it, but at what cost? As mentioned, just because we can glue virtually anything together doesn’t mean we should. Yes, we can wrap anything into a REST API and make it talk to anything else. But how much time and effort does that take?
  • The solution, a standard: Now, you see the need for a standard, hopefully. The great news is that there is a standard that is being developed to solve this problem. It’s called the MCP. This enables you to not only describe your resources and capabilities in a standardized way, but also describe how to interact with them.

That means that you can literally throw the MCP on top of any app and suddenly any client that talks MCP can interact with it. Imagine the following scenario: you have a client, and that client can talk to a number of MCP servers that run both locally and remotely. All of this is made possible because you listed these servers in an mcp.json file.

Suddenly, you have access to tools to access anything you can imagine, from databases to cloud providers to any other service that exposes an MCP server. You’re becoming agentic with little to no effort. Imagine the possibilities!

Let’s talk about some of the possibilities that the MCP opens up for us.

Endless possibilities: know how to prompt, and a world of MCP servers is your oyster

Endless is a big word, so what do we mean? Imagine this: there are skills that you may not have today. In a world with MCP servers, that’s no longer a problem, because with APIs wrapped by the MCP, an agent will allow you to prompt to get what you need done.

Take the creation and management of 3D models, for example. Blender is a common tool for creating 3D models. To use it, you need 3D modeling skills. So, you will spend hours learning how to use the app, and I’m sure it’s a skill worth having.

Due to Blender’s MCP server, knowledge of 3D modeling is no longer needed as much. You can instead state what you want done through a prompt. It’s like the movie The Matrix, where the protagonist, Neo, says, “I know Kung Fu” after having information uploaded directly into his brain. The future is here. If you know how to prompt, you’re Neo.

Here’s the link to the Blender MCP server and the capabilities exposed: https://github.com/ahujasid/blender-mcp.

Any client now, with its own LLM and speaking MCP, will be able to call any MCP server, because Blender isn’t the only example; other major companies are leaning into MCP as well. Here are some examples:

  • GitHub MCP
  • Playwright MCP
  • Google Maps

For a list of MCP servers, check out the following link: https://github.com/modelcontextprotocol/servers.

There are many more servers out there, and more are being added every day, so roll up your sleeves and start building your own MCP servers and use what’s out there as well!

You’re probably thinking what I’m thinking: we all get our own Jarvis, the AI assistant from the movie Iron Man, capable of doing anything. All we need to do is leverage existing MCP servers and build the ones that are missing; just use MCP.

Imagine having a personal assistant that can help you with anything you need, from scheduling appointments to managing your finances. With MCP, this is now possible.

The future is knocking on your door, loud and clear. Are you ready to answer?

What is the MCP?

Here’s what the official MCP website has to say about it:

The Model Context Protocol, MCP is an open protocol designed to standardize how applications provide context to large language models (LLMs). Think of it like a USB-C port for AI applications, providing a standardized way to connect AI models to various data sources and tools.

What does that mean for app developers?

It means the way we build our applications is changing and becoming more standardized. By learning and using MCP, all your apps will be able to communicate with each other and share data in a standardized way. That means you will spend less time worrying about how to connect or glue your app to other apps and more time building the features that matter.

We’ll dive more into the details of these concepts in the next chapter, but for now, we understand at a mile-high level what the MCP is and how it works, and what major components are involved.

Summary and next steps: now what?

We understand the problem, the solution, and the possibilities, which are endless, and we even know some core concepts of the MCP. But we probably need to know a bit more about it before we can start building our own MCP servers. We’ll look at that in the next chapter.

Unlock this book’s exclusive benefits now

Scan this QR code or go to https://packtpub.com/unlock, then search this book by name.

Note: Keep your purchase invoice ready before you start.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • The only resource you'll need to build, test, and deploy MCP servers and clients
  • Take a modern approach toward building, testing, and securing distributed agentic AI apps
  • Get clear, professional guidance on developing for both LLM and non-LLM clients
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

Learn Model Context Protocol with Python introduces developers, architects, and AI practitioners to the transformative capabilities of Model Context Protocol (MCP), an emerging protocol designed to standardize, distribute, and scale AI-driven applications. Through the lens of a practical project, the book tackles the modern challenges of resource management, client-server interaction, and deployment at scale. Drawing from Christoffer's expertise as a published author and tutor at the University of Oxford, you’ll explore the components of MCP and how they streamline server and client development. Next, you’ll progress from building robust backends and integrating LLMs into intelligent clients to interacting with servers via tools such as Claude for desktop and Visual Studio Code agents. The chapters help you understand how to describe the capabilities of hosts, clients, and servers, facilitating better interoperability, easier integration, and clearer communication between different components. The book also covers security best practices and building for the cloud, ensuring that you're ready to deploy your MCP-based apps. Each chapter enables you to develop hands-on skills for building and operating MCP-based agentic apps. The Python primer at the end rounds out the practical toolkit, making this book essential for any team building AI-native applications today.

Who is this book for?

This book is ideal for web developers, software architects, AI practitioners, and tech leads looking to build scalable AI-integrated applications using MCP. Product managers overseeing AI initiatives will also find this book valuable. A basic understanding of web development and AI concepts is needed to make the most of this book.

What you will learn

  • Understand the MCP protocol and its core components
  • Build MCP servers that expose tools and resources to a variety of clients
  • Test and debug servers using the interactive inspector tools
  • Consume servers using Claude Desktop and Visual Studio Code Agents
  • Secure MCP apps, as well as managing and mitigating common threats
  • Build and deploy MCP apps using cloud-based strategies

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 27, 2025
Length: 304 pages
Edition : 1st
Language : English
ISBN-13 : 9781806103225
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Oct 27, 2025
Length: 304 pages
Edition : 1st
Language : English
ISBN-13 : 9781806103225
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Table of Contents

15 Chapters
Introduction to the Model Context Protocol Chevron down icon Chevron up icon
Explaining the Model Context Protocol Chevron down icon Chevron up icon
Building and Testing Servers Chevron down icon Chevron up icon
Building SSE Servers Chevron down icon Chevron up icon
Streamable HTTP Chevron down icon Chevron up icon
Advanced Servers Chevron down icon Chevron up icon
Building Clients Chevron down icon Chevron up icon
Consuming Servers Chevron down icon Chevron up icon
Sampling Chevron down icon Chevron up icon
Elicitation Chevron down icon Chevron up icon
Securing Your Application Chevron down icon Chevron up icon
Bringing MCP Apps to Production Chevron down icon Chevron up icon
Unlock Your Book’s Exclusive Benefits Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(2 Ratings)
5 star 50%
4 star 50%
3 star 0%
2 star 0%
1 star 0%
Alfonso Cruz Feb 18, 2026
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Feefo Verified review Feefo
N/A Jan 29, 2026
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
“Good overall, but somewhat long-winded and unnecessarily elaborate.”
Feefo Verified review Feefo
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.

Modal Close icon
Modal Close icon