Understand MCP Architecture and Contracts
Model the host, client, server, lifecycle, capabilities, primitives, and tool contracts that let AI applications connect to external context and actions.
By the end
You will be able to
- Explain MCP host, client, and server responsibilities without collapsing their trust boundaries.
- Trace initialization, protocol-version agreement, capability negotiation, operation, and shutdown.
- Distinguish prompts, resources, and tools by who controls them and what risk they introduce.
- Design a narrow MCP tool contract with typed inputs, outputs, errors, and human-control points.
Start with three roles and one connection per server
An MCP host is the AI application that coordinates policy, consent, model access, and multiple connections. It creates an MCP client for each server. Each client maintains an isolated one-to-one session with its server and routes protocol messages.
An MCP server exposes focused capabilities. Local and remote servers can have very different deployment and credential risks, but neither becomes trusted merely because it speaks MCP. Keep the host responsible for aggregation and user decisions so one server cannot silently observe another server's data.
HOST: user intent, consent, policy, model, aggregation
CLIENT A: session + capability state <-> SERVER A: files
CLIENT B: session + capability state <-> SERVER B: tickets
Rule: data crosses connections only through an explicit host decision.Negotiate before operating
The MCP lifecycle begins with initialization. Client and server agree on a protocol revision and advertise capabilities before normal operation. Each side must use only features that were successfully negotiated.
Treat capability state as runtime evidence. A configured tool name does not prove that a server currently exposes it, supports notifications, or implements the protocol revision your client expects. Fail closed or degrade deliberately when negotiation is incomplete.
Prompts, resources, and tools have different control models
MCP describes prompts as user-controlled templates, resources as application-controlled context, and tools as model-controlled functions. This control hierarchy is a design aid, not an authorization system.
Resources and tool results remain untrusted input. Tool discovery tells a model what may be requested; the host still decides what is exposed, what requires confirmation, and what a trusted executor will authorize.
Make tool contracts narrow and inspectable
A tool definition needs a stable name, a decision-oriented description, and a JSON input schema. Use precise types, required fields, enums, bounds, and descriptions that distinguish similar tools. Where supported, publish an output schema and return structured content that can be validated.
Document side effects, idempotency, error classes, approval policy, and the postcondition separately from the schema. An input schema constrains syntax; it cannot prove identity, ownership, authorization, or a successful real-world effect.
{
"name": "create_training_draft",
"description": "Create one unpublished draft in the named workspace.",
"inputSchema": {
"type": "object",
"properties": {
"workspaceId": {"type": "string", "pattern": "^ws_[a-z0-9]{8}$"},
"title": {"type": "string", "minLength": 3, "maxLength": 120}
},
"required": ["workspaceId", "title"],
"additionalProperties": false
}
}Separate the portable contract from provider adapters
Anthropic and OpenAI expose ways to connect remote MCP servers, while Google ADK documents MCP tools within its own agent framework. Their request shapes, supported transports, approval surfaces, and release maturity can differ.
Keep learning objectives and application policy provider-neutral: required capability, approved server identity, allowed tool set, data policy, approval rule, and expected result. Put provider-specific headers, SDK objects, connector identifiers, and limitations in replaceable adapters verified against current documentation.
Practice activity
Design and negotiate an MCP integration
- Draw the host, one client per server, server capabilities, credentials, data flows, and user-control points for a two-server learning assistant.
- Write an initialization record containing protocol version, advertised capabilities, accepted capabilities, and the behavior when a required capability is absent.
- Define one read tool and one write tool with narrow input schemas, stable result and error shapes, side-effect documentation, and postcondition checks.
- Map the portable contract to one current Anthropic, OpenAI, or Google adapter and list every provider-specific assumption.
What to produce
- An architecture and lifecycle record that preserves connection and trust boundaries.
- Two tool contracts plus a provider-adapter table showing negotiation, approvals, errors, and unsupported behavior.
Reflect before continuing
Which part of the design initially looked like protocol plumbing but actually belonged to application policy?
Evidence
Sources and verification
- MCP architectureModel Context Protocol · verified 2026-07-25
- MCP lifecycleModel Context Protocol · verified 2026-07-25
- MCP toolsModel Context Protocol · verified 2026-07-25
Knowledge check
Make it stick.
Choose the strongest answer for each question. Your attempts become part of your device-local transcript.