model context protocol

Model Context Protocol (MCP) Explained for Developers

Table of Contents

Short answer. The model context protocol (MCP) is an open protocol that lets an AI application, called the host, talk to outside servers through one client per server. Servers offer three things: tools the model can call, resources the application can read and prompts the user can pick. Messages are JSON-RPC 2.0 over stdio or Streamable HTTP. In the current specification, dated 2026-07-28, there is no initialize handshake and no session: each request carries its own protocol version and capabilities. MCP is not an agent framework. Build a server when several AI hosts need the same capability; for one application you control, call the API directly.

Written by the AgileFever editorial team. Facts checked on November 18, 2026 against the official pages of the organizations named in this post. AgileFever sells training for some of the topics covered here, and we say so wherever it applies. Protocol facts come from the specification and docs at modelcontextprotocol.io, and injection guidance from OWASP.

Most explainers describe the model context protocol the way it worked in 2025: a handshake, a session, then messages. The revision dated 2026-07-28 removed both. If you read older articles and then open the current official 2026-07-28 specification, the two do not match. This guide follows the current text, notes what changed, walks through a minimal server, and ends with a security checklist for developers who plan to ship one. It assumes you know HTTP and JSON. For the wider course picture, read the agentic AI course syllabus checklist.

What the model context protocol is, and what it is not

Anthropic announced the model context protocol on November 25, 2024, as an open standard with a specification, SDKs, local server support in Claude Desktop and a set of reference servers. The specification says it takes some inspiration from the Language Server Protocol: one agreed message format, so an integration written once works in many applications.

The docs state the scope narrowly. MCP covers context exchange between a client and a server. It does not dictate how an AI application uses the model or manages the context it receives.

Question MCP answers it? Who answers it instead
How does an app list and call a tool on a remote system? Yes: tools/list, tools/call Not needed
Which tool should the model pick, and in what order? No The model and the host application
How are plans, memory and retries managed across steps? No An agent framework or your own loop

The model context protocol sits under an agent, not in place of one. A framework decides what to do next. For how frameworks differ, see AI agent frameworks compared.

Host, client and server: the three roles

How one host connects to many servers
Host (AI application)Holds the model, UI and consentClient 1Client 2Client 3Server A: fileslocal, stdioServer B: databaselocal, stdioServer C: SaaS toolremote, Streamable HTTP + OAuthJSON-RPC 2.0JSON-RPC 2.0JSON-RPC 2.0

Based on the architecture page of the 2026-07-28 specification.

The host is the AI application: a desktop assistant, an IDE or your own agent service. It creates one client for each server, controls which connections are allowed, enforces consent and joins the results into what the model sees. Each client talks to exactly one server and attaches the protocol version and its capabilities to every request.

A server is any program that provides context, local over stdio or remote over HTTP. One design principle matters for security: a server should not be able to read the whole conversation or see into other servers. The host keeps the history.

Tools, resources, prompts and elicitation

The specification groups server features by who decides to use them. Developers often expose everything as a tool and lose that distinction.

Primitive Who decides to use it Methods Typical use
Tools The model (model-controlled) tools/list, tools/call Create a ticket, run a query, call an API
Resources The application (application-controlled) resources/list, resources/read, resources/templates/list File contents, a database schema, a document
Prompts The user (user-controlled) prompts/list, prompts/get Slash commands and menu templates
Elicitation (client feature) The server asks, the user answers elicitation/create inside an input-required result Confirm an action, ask for a missing value

Elicitation has two modes. Form mode collects simple structured values. URL mode sends the user to a page outside the client, which the specification requires for anything like a password, API key, token or payment credential. Roots, sampling and logging are deprecated as of 2026-07-28; do not adopt them in new work.

What changed in the 2026-07-28 specification

Check the date on what you read. A model context protocol article that explains initialize, notifications/initialized or Mcp-Session-Id describes revision 2025-11-25 or earlier. SDKs adopt new revisions on their own schedules, per the official SDK page, so you may meet both in practice.
Topic 2025-11-25 and earlier 2026-07-28
Starting a connection Client sends initialize, then a notifications/initialized No handshake. Every request carries protocolVersion and clientCapabilities in _meta; server/discover is optional
Sessions Optional Mcp-Session-Id header on HTTP Removed. Cross-call state uses handles that your tools return and accept as arguments
Server asks the user something Server sends its own request to the client Server returns resultType: input_required; client retries the original request with the answer
Change notifications HTTP GET stream and resources/subscribe One subscriptions/listen request that stays open
Resuming a broken stream Last-Event-ID replay Removed. The client sends a new request with a new ID

Source: Key Changes page of the MCP specification, revision 2026-07-28, checked November 18, 2026.

The practical effect: any server instance can answer any request, with no sticky routing or shared session store. Older servers still exist, so clients must detect them. On stdio, a client sends server/discover first and falls back to initialize if the answer is not a recognised modern reply. On HTTP, it tries a modern request and inspects a 400 response before falling back.

Request and response flow, message by message

A tool call that needs the user to confirm
ClientServerUser1 server/discover (optional)versions, capabilities2 tools/listtools with inputSchema3 tools/call, id 7resultType: input_required4 ask for confirmationaccept5 tools/call, id 8 + inputResponsesresultType: complete, content

Illustrative sequence from the Tools, Elicitation and Multi Round-Trip Requests pages of the 2026-07-28 specification. Every request also carries version and capabilities in _meta.

Step Method or field Sent by What it carries
1 (optional) server/discover Client Returns supportedVersions, capabilities, server name and version, optional instructions
2 tools/list Client Tool names, descriptions, inputSchema; result has ttlMs and cacheScope
3 tools/call Client name and arguments; success returns content and isError
4 resultType: input_required Server inputRequests such as elicitation/create, plus an opaque requestState
5 tools/call again Client A different JSON-RPC id, inputResponses, and the exact requestState
6 resultType: complete Server Final content or structuredContent

A tool can fail in two ways. A malformed request or unknown tool is a JSON-RPC error. A failed API call or bad argument is a normal result with isError: true, which the client should pass to the model so it can correct itself. Also, the server treats requestState as attacker-controlled input, because it travels through the client. If it influences authorization or business logic, protect its integrity with an HMAC or authenticated encryption and reject anything that fails verification.

Transports: stdio or Streamable HTTP

Point stdio Streamable HTTP
Who starts the server The client launches it as a subprocess It runs as an independent process or service
Framing One JSON-RPC message per line; no embedded newlines Each message is its own HTTP POST to a single endpoint
Logging Write only to stderr; stdout must hold nothing but MCP messages Standard output logging is fine
Authorization Should not use the OAuth framework; read credentials from the environment Should follow the OAuth-based framework
Required headers None; metadata is in the body MCP-Protocol-Version, Mcp-Method, and Mcp-Name for calls and reads
Pick it for A tool that runs on the user’s own machine A shared or hosted server with many users

On HTTP, the body stays the source of truth. If a header and the body disagree, the server must reject the request with status 400 and error code -32020. The older HTTP+SSE transport is deprecated.

Build a minimal model context protocol server

The official tutorial builds a weather server. The steps below follow its pattern

Minimal server in seven steps
1
Pick one read-only job
Start with a lookup, not a tool that writes or deletes.
2
Install the SDK
The Python tutorial requires Python 3.10 or higher and Python MCP SDK 2.0.0 or higher, installed with uv add "mcp[cli]". The TypeScript path uses @modelcontextprotocol/server.
3
Declare one tool
Give it a clear name, a one-sentence description and typed arguments. The SDK builds the inputSchema from type hints and the docstring.
4
Return text, and report failures as results
For a bad argument, return a message the model can act on, not a stack trace.
5
Run it over stdio
Never print to stdout in a stdio server. It corrupts the message stream. Use the logging module, which writes to stderr.
6
Register it in a host
A desktop host reads an mcpServers entry with a command and args, with absolute paths.
7
Test with MCP Inspector, then with a model
Check that tools/list shows the schema you intended before any model sees it.

The Python shape below uses the tutorial’s SDK calls. The body is a placeholder.

from mcp.server import MCPServer

mcp = MCPServer("ticket-lookup")


@mcp.tool()
async def get_ticket_status(ticket_id: str) -> str:
    """Get the status of a support ticket.

    Args:
        ticket_id: The ticket number, for example T-1042
    """
    # Replace with a read-only call to your own system.
    return f"Ticket {ticket_id}: lookup not connected yet."


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

Pattern adapted from the official Build an MCP server tutorial for 2026-07-28. Install and import details can change between SDK releases, so check the tutorial for your SDK version.

TypeScript trap. The tutorial says serveStdio answers both 2026-07-28 clients and older ones that open with initialize. Wiring by hand with server.connect(new StdioServerTransport()) still compiles, but a server started that way serves only 2025-era clients.

Authorization for remote model context protocol servers

Authorization is optional. Servers reached over HTTP should follow the framework, and stdio servers take credentials from their environment. Your MCP server acts as an OAuth 2.1 resource server and the user’s client acts as the OAuth client.

Requirement Applies to Why it matters
Publish Protected Resource Metadata (RFC 9728) Server (must) Lets a client find the authorization server after a 401 with a WWW-Authenticate header
Send the resource parameter (RFC 8707) in authorization and token requests Client (must) Ties the token to one MCP server
Check that each token was issued for your server Server (must) Blocks tokens meant for other services
Answer 401 for a bad token, 403 with insufficient_scope for a missing scope Server Lets the client ask for more access only when needed
Never accept or forward a token that was not issued for your server Server (must not) Token passthrough is forbidden in the specification

For client registration the specification prefers Client ID Metadata Documents; Dynamic Client Registration is deprecated but still available. The security best-practices page adds confused-deputy attacks on servers that proxy to third-party APIs, and SSRF through URLs fetched during discovery.

MCP server or plain API: a decision table

The specification does not say when to build a server. This table is our editorial judgement.

Your situation Better fit Reason
One application you own calls one backend Plain API call or the model provider’s function calling No second party to standardise with
Two or more AI hosts (an IDE, a desktop assistant, an internal agent) need the same capability MCP server Write the integration once; each host brings its own client
The user should see, approve or deny each action MCP server with a host that shows confirmations The specification expects a human who can deny tool calls
A deterministic job with no model in the loop Plain code or a normal API A model-facing layer adds cost and risk
A vendor already runs a server for the system Use it after a security review Building a second one gives you maintenance without new capability

In practice an MCP server wraps an existing API. It does not replace it.

Team leads weighing how much of this engineers must learn can read agentic AI training for engineering managers, and AI tools for software teams covers where assistants help across coding, testing and operations.

Security checklist for developers

The specification says MCP cannot enforce its security principles at the protocol level, so your host and server must. With the model context protocol the biggest practical risk is prompt injection through tool results: a tool that returns web pages, emails or tickets returns text written by someone else, and the model may follow instructions inside it. OWASP says there is no foolproof prevention and recommends limiting impact.

Check What to do Basis
Treat every tool result as untrusted input Label returned text as data, filter it, and never let it widen permissions OWASP LLM01: segregate external content
Least privilege Give each tool the narrowest scope. Start read-only. Split read and write tools so scopes can differ Security best practices: scope minimization; OWASP privilege control
Confirm destructive actions Show the exact inputs and require approval before delete, send, pay or deploy Spec: a human in the loop who can deny invocations
Validate and limit Validate every argument, rate limit calls, sanitize outputs Spec tools page: servers must do all four
Keep secrets out of forms Use URL-mode elicitation for passwords, keys and tokens Spec elicitation page
Protect local HTTP servers Validate the Origin header, bind to 127.0.0.1, require authentication Spec Streamable HTTP security section
Block path tricks Validate resource URIs and sanitize file paths against directory traversal Spec resources page
Bind state to the user Use random, expiring handles tied to the verified user. Possession of a handle is not proof of identity Security best practices: state handle hijacking
Review before you install Read the exact command a local server runs. Sandbox it Security best practices: local server compromise

Where to learn this hands-on

AgileFever sells the GenAI and Agentic AI BootCamp. As listed on November 18, 2026, it runs 74 hours over 8 weeks, and its curriculum includes a module on agent communication protocols covering an introduction to MCP, the A2A and ACP protocols, and when to apply each. The page shows $2,000 for the US and ₹85,000 for India, before 18% GST, and asks for basic Python (functions, JSON and APIs). The page does not name a protocol revision.

Additional discounts are available. Contact us to know more.

You do not need a course to use MCP servers, and the official tutorial is enough for a first server. A course helps if you want MCP alongside agent design, evaluation and deployment. For options, see our guide to agentic AI bootcamps.

Questions people ask

What is the model context protocol?

An open protocol, announced by Anthropic on November 25, 2024, that standardises how an AI application connects to outside tools and data. A host creates one client per server, and servers offer tools, resources and prompts over JSON-RPC 2.0.

Is MCP an agent framework?

No. The official docs limit MCP to context exchange and say it does not dictate how an application uses the model or manages context. Planning, memory and retries belong to the host or to an agent framework. MCP is one way a chosen action reaches a tool.

Does MCP replace REST APIs?

No. An MCP server usually sits in front of an existing API and exposes a small set of operations in a form a model can discover and call. Use the API directly when no AI host needs the capability.

Do I need OAuth for an MCP server?

Authorization is optional in the specification. Servers reached over HTTP should follow its OAuth-based framework, while stdio servers should instead read credentials from the environment. A remote server holding user data should authenticate every request anyway.

Does the current MCP version still use an initialize handshake?

Not in revision 2026-07-28. Every request carries the protocol version and client capabilities in its metadata, and servers must implement server/discover. Older revisions used initialize, so clients detect which kind of server they reached and fall back when needed.

Which languages have official MCP SDKs?

The official SDK page lists TypeScript, Python, C#, Go, Rust and Ruby at Tier 1, Java at Tier 2, and Swift, PHP and Kotlin at Tier 3. SDKs adopt new revisions on their own schedules, so check yours.

AgileFever

Contact Us

    By checking the box, you consent to receive registrations, class reminders, updates, support text messages from AgileFever at the provided number. Message and data rates may apply. Message frequency varies (typically 1–2 msgs/week). To end messaging from us, you may always reply with STOP. You may also reply with HELP for more information. Check Privacy Policy and Terms & Conditions.