Practical MCP: A Python Developer's Guide
$19.00
Minimum price
$29.00
Suggested price

Practical MCP: A Python Developer's Guide

From Theory to Production: Building and Deploying AI Tools for LLMs

About the Book

You've seen the incredible power of Large Language Models like Claude, GPT, and Gemini. But you've also hit the wall, watching them fail at simple tasks a junior developer could solve in minutes. These powerful AIs are trapped in a digital room with no tools and no access to the outside world. This book is about kicking down the door.

Practical MCP: A Python Developer's Guide is your hands-on guide to the Model Context Protocol (MCP), a groundbreaking specification for giving AI the tools it needs to interact with the real world. Think of it as the USB-C for AI—a universal standard that lets any model connect to any tool, from a simple Python function to a complex REST API or a private database.

This book takes you on a complete journey, from theory to production. You will learn to:

  • Build Your First Tools: Master the two core Python libraries, `mcp` and `fastmcp`, to create local and remote MCP servers.
  • Integrate with Major Platforms: Connect your custom tools to Anthropic's Claude, Google's Gemini, and OpenAI's ChatGPT.
  • Master Advanced Interactions: Move beyond simple function calls. Create tools that can report progress, send logs, and even pause to ask the user for more information using elicitation.
  • Secure and Deploy Your Servers: Learn to protect your tools with JWT authentication and deploy them to production environments like Google Cloud Run and traditional VMs using Docker and Nginx.
  • Design Sophisticated Architectures: Seamlessly integrate MCP into existing web applications with ASGI, create powerful middleware, and automatically generate a full suite of tools from an OpenAPI specification.
  • Build a Capstone Project: Put it all together by creating a full-stack AI Tarot reading application, orchestrating multiple MCP microservices to perform a complex, multi-step task.
  • Connect to Real-World Services: Tackle the complexities of OAuth 2.0 to build tools that securely access a user's Google Docs and Google Drive, empowering your AI to act on their behalf.

By the end of this book, you won't just be using AI—you'll be extending it. You'll have the practical skills to build robust, secure, and scalable tools that unlock the true potential of Large Language Models.

About the Author

Arjuna Sky Kok
Arjuna Sky Kok

Arjuna Sky Kok is a software engineer, author, and educator specializing in the practical application of artificial intelligence. He is the author of Hands-on Blockchain for Python Developers, 2nd Edition (Packt) and a prolific technical writer for some of the most respected platforms in the developer community, including Kodeco (formerly RayWenderlich), Baeldung, and LogRocket.

His commitment to education extends beyond the page; he is the creator of the "Artificial Intelligence APIs with Python" bootcamp program at Kodeco, where he guides students through real-world AI implementation. His deep expertise in applied AI is further demonstrated by his Udacity Nanodegree certifications in both Self-Driving Car and Robotics Software Engineering.

As an active member of the open-source community, Arjuna has contributed to pivotal projects, including the Hugging Face transformers library, one of the most foundational tools in modern AI. Beyond education and open source, Arjuna has experience in the startup world as a founder, giving him a unique perspective on turning cutting-edge technology into real-world products.

Table of Contents

    • Chapter 1: The Big Picture: Why MCP is a Game-Changer for AI
      • The LLM’s Achilles’ Heel
      • The Duct Tape Solution: Function Calling
      • Enter MCP: A USB-C Port for AI
      • A Tale of Two Libraries: mcp vs. fastmcp
      • Key Takeaways
    • Chapter 2: The “Hello, World” Experience: Your First MCP Servers
      • Setting Up Your Pro Development Environment
      • Creating a Basic Tool (@mcp.tool)
      • Running Locally: The STDIO Transport
      • Running Remotely: The HTTP Transport
      • The MCP Inspector: Your Essential Debugging Partner
      • Key Takeaways
    • Chapter 3: Integrating with LLM Platforms
      • Creating a Universal Tool
      • From localhost to the World with ngrok
      • Integration with Anthropic (Claude)
      • Integration with Google (Gemini)
      • Integration with OpenAI (ChatGPT)
      • Stateful vs. Stateless: A Tale of Two Servers
      • Key Takeaways
    • Chapter 4: Core MCP Components
      • Resources and Prompts: The Foundation of Context
      • The Context Object: Your Tool’s Superpowers
      • Elicitation: Turning a Monologue into a Dialogue
      • Key Takeaways
    • Chapter 5: Authentication and Deployment of MCP Servers
      • Authentication: Guarding Your Tools
      • Deployment: Going Live
      • Key Takeaways
    • Chapter 6: Advanced Server Architecture
      • Integrating with ASGI: Your MCP Server as a Citizen
      • Supercharging Your Server with Middleware
      • From OpenAPI to MCP in One Step
      • Key Takeaways
    • Chapter 7: Community Spotlights
      • The Filesystem MCP Server
      • The SQLite3 MCP Server
      • The Fetching HTML MCP Server
      • Key Takeaways
    • Chapter 8: Capstone Project: The AI Tarot Oracle
      • Project Overview: The AI Oracle
      • Laying the Foundation: Data and Database
      • Building the MCP Servers: The Tools of the Oracle
      • The Brain of the Operation: The LLM Orchestrator
      • The User Interface: A Gradio Front-End
      • Putting It All Together: Running the Oracle
      • Where to Go From Here?
    • Chapter 9: Real-World Integration: The Google Workspace MCP Server
      • Setup and Prerequisites
      • Building the Server (google_workspace_server.py)
      • Building the Client (google_workspace_client.py)
      • The End-to-End Flow in Action
      • Key Takeaways

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub