Leanpub Header

Skip to main content

LM Studio in Action: Building Safe, Private AI with LLMs, Function Calling and Agents with MCP

This book is 100% completeLast updated on 2026-07-31
+6,305 words in the last 30 days

LM Studio is a great tool for running LLM models locally on your own computer. Tech overviews and Python examples. Deep dive into using Model Context Protocol (MCP)

Minimum price

Free!

$12.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

Share this book

Author

About the Author

Mark Watson

Mark Watson is a consultant specializing in LLMs, deep learning, machine learning, knowledge graphs, and general artificial intelligence software development. He uses Common Lisp, Clojure, Python, Java, Haskell, and Ruby for development.

He is the author of 20+ published books on Artificial Intelligence, Deep Learning, Java, Ruby, Machine Learning, Common LISP, Clojure, JavaScript, Semantic Web, NLP, C++, Linux, and Scheme. He has 55 US Patents.

Mark's consulting customer list includes: Google, Capital One, Olive AI, CompassLabs, Disney, Sitescout.com, Embed.ly, and Webmind Corporation.

Mark wrote ten traditional published books for McGraw Hill, Springer Verlag, J Wiley, and Morgan Kaufman publishers before adopting the LeanPub self-publishing platform.

The Leanpub Podcast

Podcast

Podcast Episode

Contents

Table of Contents

Preface

  1. Setup LM Studio
  2. What’s New Since the First Edition of This Book
  3. About the Author
  4. Requests from the Author
  5. Why Should We Care About Privacy?

Introduction to Using the LM Studio Application

Using the LM Studio Command Line Interface (CLI)

  1. lms ls
  2. lms load
  3. lms unload
  4. lms get
  5. lms chat
  6. lms import
  7. Server Status and Control
  8. lms runtime
  9. lms log stream
  10. Headless Mode: lms daemon
  11. LM Link: lms link
  12. Developing and Publishing

Introduction to LM Studio’s Local Inference API

  1. Using the Python OpenAI Compatibility APIs
  2. Using the Python lmstudio Package
  3. Three Python SDK API Styles
  4. Streaming Responses
  5. Structured Output
  6. Embeddings
  7. The Anthropic Compatibility API
  8. The Responses API
  9. API Authentication
  10. Idle TTL and Auto-Evict
  11. Optional Practice Problems

Tool Use / Function Calling

  1. Native Tool Use via the OpenAI-Compatible API
  2. The Python SDK .act() API
  3. A Worked Example: DuckDuckGo Web Search
  4. Manual Tool Use: Understanding the Basics
  5. Optional Practice Problems

A Technical Introduction to Model Context Protocol and Experiments with LM Studio Using FastMCP

  1. An Introduction to the Model Context Protocol
  2. The Local AI Ecosystem: LM Studio as an MCP Host
  3. Strategic Integration: A Blueprint for Local MCP-Powered Agents
  4. Architectural Design for a Python-Based MCP Server
  5. LM Studio Integration and Execution Guide
  6. Advanced Considerations and Future Trajectories
  7. MCP Wrap Up
  8. Optional Practice Problems

Local Agents With LM Studio Bionic

  1. Two Kinds of Projects: Work and Code
  2. Choosing a Model: Local, Cloud, and Remote
  3. Voice Input
  4. Bionic and Your LM Studio Model Library
  5. When to Use Bionic vs LM Studio Desktop
  6. Wrap Up

Headless Deployment with llmster

  1. Installing llmster on a Linux Server
  2. Running as a systemd Service
  3. JIT Loading for Multi-Model Serving
  4. API Authentication for Network Deployments
  5. Serving Models to Remote Clients with LM Link
  6. Wrap Up

Also by the Author

Also by the Author

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.

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 earned over $15 million writing, 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