Skip to main content
This page explains the Model Context Protocol (MCP) architecture and how clients and servers interact. It starts from a blank state (no MCP servers) so you can reason about what a client needs to discover and call, and what a server must provide.

Overview

An MCP server exposes three high-level things that clients rely on:
  • Tools — callable functions or APIs the server offers.
  • Resources — documents or data to help model reasoning (policies, guides, FAQs).
  • Prompts — pre-defined instructions or behavior templates for LLMs.
Clients discover available tools, fetch supporting resources, follow prompts, and invoke tools via a JSON-RPC-based protocol that can be carried over multiple transports (HTTP, STDIO, TCP, etc.).

Key entities exposed by an MCP server

Tools: what a client needs to know

When building a client you must first discover what tools a server offers — what can it do? Each tool includes:
  • A name and human-friendly title,
  • A description,
  • Input and output schemas (so the client and LLM know how to call and parse results).
Example: a flight search API and a sample response.

Resources: structured supporting data

Resources are referenced by URI and contain metadata so models and clients know how to fetch and interpret them. A resource object typically includes: uri, name, title, description, and mimeType. URIs can be HTTPS, file URIs, or Git locations. Example JSON-RPC result listing resources:
A dark-themed diagram showing a pink "MCP Client" box linked by a dashed green line to a teal "MCP Server" box that connects to a green "Joyair" module with an airplane logo. Nearby are tool icons and labels for Refund Rules, City Guides, and FAQs.

Prompts: instructing the LLM

Prompts encode behavior or constraints the LLM should follow when using tools or reasoning with resources. They can include argument schemas so the model knows what inputs to provide. Example user utterance and a prompt instruction:
Example JSON-RPC response listing prompts:

How server and client communicate: JSON-RPC

MCP uses JSON-RPC 2.0 as the RPC layer. JSON-RPC defines the envelope for requests and responses. Important fields:
  • Request: jsonrpc (must be "2.0"), method, params, id
  • Response: jsonrpc, result (or error), id
Example JSON-RPC request and response:
Example minimal Python client and server handler (illustrative):
JSON-RPC is transport-agnostic — the same messages can travel over different transports.

Transports MCP commonly supports

An infographic titled "Model Context Protocol — JSON-RPC (2.0)" showing a vertical stack of transport options. The colored blocks list Transport, HTTP, STDIO, TCP, UDP, Unix Sockets, and Message Q.

Local vs Remote MCP servers

  • Local hosting: run a server locally and connect over STDIO or HTTP. STDIO is common for IDE extensions because the editor spawns the server process and uses fast two-process communication.
  • Remote hosting: connect to a vendor or central server over HTTPS. Remote hosting introduces security, authentication, and privacy concerns.
If you connect to a remote MCP server, ensure you understand the security and privacy implications. Transmitting sensitive user data to a third-party server requires clear policies and controls.
Best practice: prefer local servers or vetted private endpoints when handling sensitive data. If using remote MCP servers, enforce authentication, encrypt transport, and limit the scope of what is shared.

Why use MCP instead of calling upstream APIs directly?

Using an MCP server centralizes integration logic:
  • The server aggregates and standardizes third-party APIs into tools with consistent schemas.
  • Resources and prompts live with the server, so the model can reference authoritative documents.
  • Clients simply discover tools and call them via the MCP client, rather than re-implementing many API integrations.
Example: direct API call vs. calling through an MCP client Direct API call:
Via MCP client:

Connecting an IDE or client to an MCP server: configuration examples

Clients typically configure MCP endpoints in a JSON file (e.g., mcp.json) that lists servers and how to connect to them. Example: spawn a local server via STDIO (useful for IDEs):
Example: connect to an HTTP MCP server that is already running locally:
Example: connect to a remote HTTPS MCP server:
Commands to start a local MCP server (examples):

Typical client session flow (pseudocode)

A common flow when building an app or agent that uses MCP:

Recap

This lesson covered:
  • The three core MCP entities: tools, resources, and prompts.
  • How MCP uses JSON-RPC 2.0 as the RPC layer and supports multiple transports (HTTP, STDIO, TCP, etc.).
  • How clients discover tools, fetch resources, and invoke tools through an MCP client.
  • Configuration patterns for local STDIO-based servers and remote HTTP(S) servers.
  • A typical session flow for integrating an MCP client into an application.
Further reading:
  • JSON-RPC 2.0 specification: https://www.jsonrpc.org/specification
  • If you plan to deploy MCP servers in production, document authentication, authorization, logging, and data retention policies for compliance and privacy.

Watch Video