Introduction to Model Context Protocol

Understand the Model Context Protocol — client, host, and server roles, the JSON-RPC foundation, tools/resources/prompts, and stdio vs Streamable HTTP transports.

Jun 17, 20266 min readFollow

Topics You Will Master

The roles of MCP client, host, and server and how they communicate
The three building blocks every server exposes: tools, resources, and prompts
Why MCP is built on JSON-RPC 2.0 and why UTF-8 encoding is mandatory
Choosing between stdio and Streamable HTTP transports for local vs production use

The Model Context Protocol (MCP) is an open standard, introduced by Anthropic, for connecting AI models with external tools. The idea is simple: instead of every application inventing its own glue code, MCP defines one protocol so any compliant client can talk to any compliant server.

Real-world AI applications constantly need to reach outside the model — file access and manipulation, database connections and queries, API integrations, and external service communication. MCP standardizes all of that behind three cooperating roles: a client, a host, and a server.

Note

This is a concepts-only lesson. Make sure your tools are installed first — see MCP Dev Setup: Anaconda, uv, and Claude — then continue to Build Your First MCP Server with FastMCP to put these ideas into code.

95% OFF

MCP Mastery: Build AI Apps with Claude, LangChain and Ollama

Build MCP servers and clients with Python, Streamlit, ChromaDB, LangChain, LangGraph agents, and Ollama — from your first tool to cloud deployment.

Enroll Now — 95% OFF →

The big picture: client, host, server

At the highest level, MCP wires three components together:

PLAINTEXT
Client  <->  Host  <->  Server

An MCP host routing a client's requests to one or more servers

Think of it as a marketplace: the client is the user, the server is a service provider, and the host is the middle layer that routes requests between them and keeps everything secure.


MCP Server

Definition: a server provides tools and resources to clients through the MCP protocol.

A weather server is a good example — it exposes the ability to fetch current conditions, forecasts, and historical weather data. Any MCP client can connect and use those capabilities without knowing how they are implemented.

How servers work:

  • Register available tools with the host so clients can discover them.
  • Respond to tool execution requests with results.
  • Manage resource access and data that clients can read.

MCP Server — code example

In practice you rarely write the protocol by hand. FastMCP is the fast, Pythonic way to build MCP servers and clients: you write a normal Python function, decorate it, and FastMCP generates the schema, validation, and documentation automatically.

PYTHON
from fastmcp import FastMCP

mcp = FastMCP("Demo 🚀")

@mcp.tool
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b

if __name__ == "__main__":
    mcp.run()

That is a complete, runnable MCP server exposing one tool named add.

Tip

FastMCP's official documentation is at gofastmcp.com. You build the full version of this server in the next lesson.


MCP Client

The four-step tool call: discover, request, process, then use the result

Definition: a client is an application or AI model that uses the server's capabilities.

Claude Desktop is a familiar example — it acts as an MCP client, connecting to various MCP servers to expand what Claude can do.

When a client calls a server tool, the interaction always follows the same four steps:

  1. The client discovers the available tools from the server.
  2. The client sends a tool execution request.
  3. The server processes the request and returns a result.
  4. The client receives and uses the result.

Note

Analogy: the client is the "user" and the server is the "service provider." The client asks; the server does the work and answers.


MCP Host

Definition: the host is the middle layer between client and server that manages connections and communication.

Host responsibilities:

  • Manages multiple server connections at once.
  • Routes requests between clients and servers.
  • Handles protocol translation and validation.
  • Provides security and error handling.

Claude Desktop's host can connect to many MCP servers simultaneously — weather, database, file system, and more — and present all their tools to the model in a single conversation.


MCP specifications

An MCP server exposing tools, resources, and prompts to its clients

MCP defines standardized rules and protocols so that components communicate predictably.

Important

MCP is built on the JSON-RPC 2.0 protocol for reliable, structured communication between components. JSON-RPC messages MUST be UTF-8 encoded.

Common specification parts:

  • Tools — define available actions and their parameters.
  • Resources — specify data and file access methods.
  • Prompts — standardize reusable AI instructions.

Why standards matter: standard rules mean easy integration. Any MCP-compliant client can work with any MCP-compliant server, regardless of who built them. You build these three building blocks in depth in MCP Tools, Resources, and Prompts.


Transport mechanisms

Choosing stdio for local servers and Streamable HTTP for remote ones

MCP uses JSON-RPC to encode messages (again, UTF-8 is mandatory). The protocol revision used in this course is 2025-06-18. There are two standard transport mechanisms.

1. stdio transport

Communication over standard in and standard out.

  • Local process communication.
  • Direct stdin/stdout messaging.
  • Ideal for local servers.
  • Simple to implement.

2. Streamable HTTP transport

HTTP-based communication with streaming support.

  • Remote server connections.
  • Real-time bidirectional streaming.
  • Web-compatible transport.
  • Scalable for enterprise use.

Choosing the right transport

Use stdio when… Use Streamable HTTP when…
Local file-system access Cloud-based services
Development and testing Multi-user environments
Simple command-line tools Real-time data streaming
Single-user applications Enterprise deployments

In short: stdio is best for local development and simple integrations, while Streamable HTTP is best for production, remote servers, and real-time applications.

Tip

Both transports support the same MCP protocol features. You can switch between transports without changing your server logic — usually just one argument in mcp.run(...).


Official resources

Bookmark these verified, official references as you work through the course:

Note

The TypeScript SDK installs with npm install @modelcontextprotocol/sdk, and a C# SDK ships on NuGet as ModelContextProtocol. This course uses the Python SDK and FastMCP throughout.

With the architecture clear, you are ready to build a working server and client from scratch in Build Your First MCP Server with FastMCP.

Found this useful? Keep building with me.

New tutorials every week on YouTube — or go deeper with a full structured course.

Find this tutorial useful?

Subscribe to our YouTube channels for more practical production walk-throughs.

Discussion & Comments