Model Context Protocol from Scratch

The Model Context Protocol end to end — the spec and mental model, transports, tools/resources/prompts, building a server and a client, and shipping MCP securely to production.

8 parts · written by Pratik Dhanave. Start with Part 1 →

← All series · All posts

Part 1 · ·6 min read

What Is the Model Context Protocol?

A model is only as useful as the context and tools it can reach, and MCP is the open standard that lets any AI app plug into any tool through one interface instead of a hundred bespoke integrations.

MCP turns the M×N mess of wiring every AI app to every tool into M+N: wrap each system as a server once, make each app a client once, and any app can use any system.

Part 3 · ·5 min read

MCP Transports: stdio and Streamable HTTP

The same JSON-RPC messages can travel down a subprocess pipe or across the network, and choosing the right transport is mostly a question of where your server lives and who it serves.

The same MCP messages travel over a subprocess pipe or the network — stdio for local tools, streamable HTTP for remote services. How each works and when to choose it.

Part 4 · ·6 min read

MCP Tools: Giving Agents the Power to Act

Tools are the part of the Model Context Protocol that lets a model do things instead of just talk about them, and their design is what separates an agent that helps from one that flails.

Tools are the MCP primitive that lets a model act. How to define them, the tools/list and tools/call methods, results versus errors, and designing tools a model can actually use.

Part 5 · ·5 min read

MCP Resources and Prompts

Tools let a model act, but resources and prompts are how a Model Context Protocol server feeds it the right context and gives users repeatable ways to invoke it.

Beyond tools, MCP servers expose resources (read-only context by URI) and prompts (reusable templates). What each is for, how they appear on the wire, and how to choose.

Part 6 · ·5 min read

Building an MCP Server from Scratch

Everything in the series so far comes together here: a small but complete Model Context Protocol server, in Python, exposing a tool, a resource, and a prompt, runnable and testable in minutes.

Build a complete MCP server in Python with the official SDK — a notes service with a tool, a resource, and a prompt — and test it end to end with the MCP Inspector.

Part 7 · ·5 min read

Building an MCP Client

A server is only half the story; the client is what connects to it, discovers its capabilities, and turns a model's intent into real tool calls.

Build an MCP client that launches a server, discovers its tools, and drives them from a language model — the core of what every MCP host does internally.

Part 8 · ·6 min read

Shipping MCP Securely to Production

An MCP server can run code and see context on the model's behalf, which makes it powerful and dangerous in equal measure — this is how to deploy one without handing attackers the keys.

An MCP server can run code and see context on the model's behalf. Authentication, prompt-injection and tool-poisoning risks, human-in-the-loop, sandboxing, and a production checklist.

This series is part of a larger body of work by Pratik Dhanave, an Agentic AI Architect writing about production AI systems, distributed systems, and cloud-native engineering. Explore all course series, browse every post, or find topics via the tag index.