Chapter 6
Creating Your Own Custom MCP Client and Servers
IN THIS CHAPTER
Deploying MCP servers
Connecting an MCP client to an MCP server using stdio
Creating an MCP client with LLM tool calling
Connecting an MCP client to an MCP server using SSE transport
Connecting to multiple MCP servers
Earlier in this book, I treat you as a consumer of MCP who uses existing servers and lets tools like Claude Desktop handle the connection details on your behalf. In this chapter, however, I show you how to build everything yourself — from scratch.
This is where MCP stops being abstract and starts making practical sense. If you make your way to the end of this chapter, you will have written the code for your own MCP servers that expose real-time tools to any connected client, and your own MCP clients that connect those tools to a locally running large language model (LLM) by way of Ollama, a local AI runtime that lets you run LLMs directly on your own computer instead of using cloud services.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access