10. Agent Communication Protocols
MCP Architecture, Clients, Servers, Tools and Resources
MCP architecture splits duties cleanly: the host embeds one or more MCP clients that open transports, handshake, discover capabilities, and enforce policy; MCP servers advertise and execute tools, resources, and prompts against backends. Tools carry JSON schemas and side effects; resources are URI-addressed context; prompts are reusable message templates. Understanding this split is what you need before building or integrating servers with agents.
What you will learn
- Draw host, client, transport, and server boundaries
- List client vs server responsibilities
- Model tools, resources, and prompts with schemas/URIs
- Explain multi-server hosts and capability filtering
- Answer interview questions with short, solid answers
Definition
MCP architecture is the role model and message surface of Model Context Protocol: hosts run clients; clients speak to servers over a transport; servers expose typed capabilities (tools, resources, prompts) backed by real systems. Architecture questions in interviews usually test whether you know who owns policy versus who owns execution.
This lesson zooms into those roles after the MCP overview β still conceptual, with just enough structure to design integrations.
Introduction
This lesson (#3 in Agent Communication Protocols) follows Model Context Protocol (MCP). You know what MCP is; now learn how clients, servers, and primitives fit together.
Next: Building and Integrating MCP with AI Agents β wiring servers into real agent loops.
Big picture
- Host - UX, LLM calls, user consent, org policy
- MCP client - protocol session lifecycle per server
- Transport - stdio for local, HTTP/SSE for remote
- MCP server - capability catalog + executors
- Backends - DBs, APIs, filesystems behind the server
Client vs server
Keep policy on the client/host side; keep domain logic on the server.
- Client: connect, initialize, list, filter, map to LLM tools, invoke, teardown
- Server: advertise, validate args, execute, return structured content
- Client enforces allowlists and HITL prompts
- Server holds scoped credentials for backends
- Neither side should silently escalate privileges
Tools in depth
- Name, description, and JSON Schema for arguments
- Invoked when the model (via host) chooses a tool call
- May perform side effects β mark risk clearly in docs
- Return text, JSON, or other content parts the host can feed back
- Idempotency and timeouts are server design concerns
Resources and prompts
Not everything should be a tool β use the right primitive.
- Resources - URI + metadata; host reads (and may subscribe) for context
- Good for files, tickets, schemas, docs the user/app selects
- Prompts - named templates with arguments producing message lists
- Good for repeatable workflows (βtriage this issueβ)
- Avoid stuffing huge resources blindly into every turn
Multi-server hosts
- One host often attaches many servers (repo, DB, browser, Slack)
- Client merges catalogs then applies per-server and per-tool policy
- Name collisions need namespacing or prefixes in the host UX
- Failure of one server should not kill the whole host session
- Health and reconnect belong in client session management
Transports and sessions
- Local stdio - common for IDE-spawned servers
- HTTP + streaming - remote or shared servers
- Initialize negotiates protocol version and capabilities
- Sessions are stateful for the life of the connection
- Always tear down and rotate short-lived credentials
Failure modes
- Putting allowlists only inside the server (host still exposed)
- Tools without schemas β garbage arguments
- Resources that return unbounded blobs
- One giant server that mixes unrelated trust domains
- Ignoring initialize version skew between client and server
Map to next lessons
- Building MCP with agents = client mapping + tool loop
- A2A later = peer agents, not MCP servers
- Security module = injection and tool execution hardening
Program / implementation notes
Sketch a server with one resource (config://app) and two tools (search_docs, create_ticket). Document which the client will allowlist. Note transport (stdio vs HTTP) for local vs shared use.
- Prefer small single-purpose servers over mega-servers
- Next: Building and Integrating MCP with AI Agents
Advantages and limitations
- Advantage: clear boundaries for reuse and governance
- Advantage: primitives match real product needs (act vs read vs template)
- Advantage: multi-server composition in one host
- Limitation: host must implement robust client session logic
- Limitation: poor server design still leaks secrets or burns tokens
- Limitation: transport choice affects ops and security posture
Key points
- Host embeds MCP clients; servers expose tools/resources/prompts.
- Clients discover and filter; servers validate and execute.
- Tools: schema + call; resources: URI + read; prompts: templates.
- Multi-server hosts merge catalogs under policy.
- Transports carry sessions; initialize negotiates versions.
- Keep trust domains separated across servers.
FAQs
Where should allowlists live?
Primarily in the host/client policy layer. Servers should still validate and least-privilege their backends, but discovery must not equal authorization.
When use a resource instead of a tool?
Use a resource when the host/app needs to read addressable context (file, record, doc). Use a tool when the model should invoke an action with arguments.
Can prompts call tools?
Prompts supply message templates that start a flow. The host/model may then call tools during that conversation; the prompt itself is not the tool executor.
Why split many small servers?
Smaller trust domains, clearer credentials, easier allowlists, and failure isolation when one backend is down.
Interview questions
- Describe MCP architecture in one breath.
Answer A host runs MCP clients that talk over a transport to MCP servers, which expose tools, resources, and prompts backed by real systems under host policy.
- What does the MCP client do?
Answer Opens sessions, initializes, lists capabilities, filters by policy, maps tools to the LLM, invokes calls, and tears down connections.
- What does the MCP server do?
Answer Advertises capabilities, validates arguments, executes against backends with scoped credentials, and returns structured results.
- How are tools modeled?
Answer Named capabilities with descriptions and JSON Schema arguments that the model can invoke; results return as structured content to the host.
- How do resources differ from tools?
Answer Resources are URI-addressed readable context for the host/app; tools are invocable actions that may cause side effects.
- How do multi-server hosts stay safe?
Answer Merge catalogs carefully, namespace collisions, apply per-server/tool allowlists, isolate failures, and require consent for new servers.
Related topics
Practice task
Complete each numbered practice step in a notebook or doc before opening the next lesson.
- Draw host β client β transport β server β backend for one integration.
- Write JSON-schema-like fields for a create_ticket tool (title, body, priority).
- Define one resource URI and mime type for a project README.
- List three host-side filters before offering tools to the model.
- Answer interview questions 1, 2, and 4 in two sentences each.