Unit 11 of 12 · about 6 hours · implement

MCP host, client and server roles, capability discovery, and tools, resources and prompts

MCP standardizes communication, not permission to act or durable effect semantics. A small protocol fixture lets you check that boundary without a model or hosted service.

You'll be able to

  • Separate host policy, client communication and server capabilities under MCP 2026-07-28.
  • Build a small stdio server and client with mcp 2.3.0 and verify discovery, per-request metadata and typed results on the wire.
  • Distinguish tools, resources, prompts and the tasks extension without treating any capability as application authority.

Covers

MCP host, client, server and capability negotiationMCP tools, resources, prompts, tasks and trust boundaries
1

Read

In this order, only the parts listed

0 of 7 done

  1. MCP 2026-07-28: ownership and versioningModel Context Protocol Specification 2026-07-28

    Core Components and Capability Negotiation; then Versioning and Compatibility, Protocol Version Negotiation at https://modelcontextprotocol.io/specification/2026-07-28/basic/versioning

    Read the modern per-request protocol. Skip implementing legacy initialization compatibility.

  2. MCP 2026-07-28: discoveryModel Context Protocol Specification 2026-07-28

    Request; Response; When to Call

  3. MCP 2026-07-28: stdio and HTTP bindingsModel Context Protocol Specification 2026-07-28

    Opening framing rules; Request Metadata; Shutdown; then Streamable HTTP, opening summary, Sending Messages and Receiving Messages at https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http

    Implement only stdio. Read HTTP to identify one POST per message, request-scoped SSE and the absence of protocol sessions, GET streams and Last-Event-ID resumption. Skip HTTP server implementation.

  4. MCP 2026-07-28: tools and errorsModel Context Protocol Specification 2026-07-28

    Listing Tools; Calling Tools; Output Schema; Error Handling; Security Considerations

  5. MCP 2026-07-28: resources and promptsModel Context Protocol Specification 2026-07-28

    Resources, User Interaction Model and Reading Resources; then Prompts, User Interaction Model and Getting a Prompt at https://modelcontextprotocol.io/specification/2026-07-28/server/prompts

    Optional feature survey: read these small slices and implement one resource. Prompt implementation is not required.

  6. MCP: tasks and deprecated featuresModel Context Protocol Specification 2026-07-28

    How Tasks work; Task lifecycle (page read 2026-10-18); MCP 2026-07-28 Deprecated Features registry at https://modelcontextprotocol.io/specification/2026-07-28/deprecated

    Optional feature survey only. Identify tasks as an opt-in extension and roots and sampling as deprecated; do not implement them.

  7. Official Python SDK: a tiny server and clientModel Context Protocol Specification 2026-07-28

    A server in 15 lines; A client in 10 lines; Clients, What you can pass to Client and Calling a tool at https://py.sdk.modelcontextprotocol.io/client/ (pages read 2026-10-18)

    Use mcp 2.3.0. Replace the HTTP example with StdioServerParameters and run the server with transport="stdio". No Inspector, model or credentials are needed.

2

Focus on

  • The host owns integration, consent and policy; each client communicates with one server. In this revision there is no initialize handshake. Requests carry protocol version, client information and capabilities in _meta; server/discover advertises supported versions and features.
  • Stdio uses newline-delimited JSON-RPC; stdout is protocol-only. Keep diagnostics on stderr and close the child process cleanly. Discovery does not grant user, tenant or resource authority.
  • Tools expose operations with input and optional output schemas. Resources expose context and prompts expose server-authored templates. All returned text remains untrusted, including descriptions and templates.
  • Tasks require the io.modelcontextprotocol/tasks extension and cooperative cancellation. A task handle does not establish recipient deduplication or approval expiry; the workflow still owns those contracts.
Common mistakes · 3
  • Teaching the older initialize and notifications/initialized handshake as the current protocol. That belongs to 2025-11-25 and earlier revisions.
  • Checking only whether the client raised an exception. Tool failures can be results with isError: true; JSON-RPC errors are a separate wire mechanism. Inspect the actual response.
  • Using deprecated roots as a filesystem isolation boundary, or assuming capability discovery authenticates a server. Neither enforces resource access.
3

Try it yourself

Closed-book, before checking anything

Using mcp 2.3.0 on your CPU, rebuild the SDK's add tool and one static policy resource. Launch it as a stdio subprocess and call add with integer arguments 2 and 3: structured_content must be {"result": 5}, and is_error must be False. Read the policy resource. Record the wire through a transparent stdio relay and verify server/discover, protocol version 2026-07-28 and per-request _meta, with no initialize message. Then pass a tool's returned text through the host as data, not permission to invoke another action.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Must a modern client call server/discover before every operation?Answer

    No. Servers must implement discovery, but clients may omit it and handle unsupported-version errors. Every request still carries the required metadata.

  2. 2.The server advertises a destructive tool. Who decides whether Alice may use it?Answer

    The application's execution policy and the effect-owning server enforce Alice's authority. Advertisement is feature discovery, not a grant.

  3. 3.Can a 2026-07-28 HTTP client resume a dropped SSE stream using Last-Event-ID?Answer

    No. That protocol resumption mechanism and protocol sessions are absent in this revision. Application recovery needs explicit operation or task identities.

  4. 4.Does acknowledging tasks/cancel prove the effect stopped?Answer

    No. Task cancellation is cooperative. Reconcile the business operation and retain uncertainty if its effect may have committed.

You're done when

Your CPU stdio fixture returns the typed result and resource, its transcript proves modern discovery and metadata, and server-provided text cannot bypass host admission checks.

Only when you can do this without notes.

Leads to

Notes

Resources · 1 for this unit, 13 more in the section
  • Model Context Protocol Specification 2026-07-28Model Context Protocol · required

    Read the 2026-07-28 architecture and versioning pages: there is no initialize handshake, every request carries _meta protocol version, client info and capabilities, and server/discover lists versions and capabilities. Then the stdio and Streamable HTTP bindings, tools/list and tools/call (input and output schemas, isError versus JSON-RPC errors), resources and prompts, the tasks extension, and the roots and sampling deprecations. Build one small stdio server and client, record the wire messages, and keep application authorization outside the protocol.

Also in this section

  • Durable Tool-Using WorkflowRoadmap-Final · primary

    Build the reduced core through typed tools, one approval, one simulated irreversible effect, one compensable effect, capability policy, idempotency, durable intent and outcome, bounded execution and replay. Run kill tests around every persistence and effect boundary before adding an agent loop.

  • AI Agents in Depth - Tools and Asynchronous InteractionBojie Li · required

    Read Chapter 4: 4.2 tool design and schema fidelity, 4.3 MCP, 4.5 versus 4.6 (read-only perception tools against execution tools), the "Idempotency and Cancellation Semantics" passage and the observability part of 4.6, and 4.7 human-in-the-loop timeouts. Add 5.1.5 Failure and Error Recovery and 6.2 asynchronous interaction. Translate the advice into explicit state and effect contracts.

  • Making Retries Safe with Idempotent APIsAmazon Builders' Library · required

    Read "Retrying and the potential for undesirable side effects", "Reducing client complexity with idempotent API design", "Semantic equivalence and support for default retry strategies", "Late arriving requests and the life span of unique client request identifiers" and the parameter-mismatch section. Record the key and the effect atomically, scope keys by caller, and reject a reused key with different parameters.

  • Idempotent RequestsStripe · required

    Read the page as one concrete recipient contract: an Idempotency-Key header, the first result saved and replayed, parameter mismatch rejected, keys pruned after at least 24 hours (API v1), and the different API v2 retry semantics. Encode these cases in your fake effect recipient; do not treat 24 hours as universal.

  • Timeouts, Retries, and Backoff with JitterAmazon Builders' Library · required

    Read "Timeouts", "Retries and backoff" and "Jitter": a timeout leaves the outcome unknown, side-effecting calls are unsafe to retry without idempotency, and retries belong at one layer with a token-bucket budget. Model the unknown outcome as its own workflow state.

  • How to Do Distributed Locking (fencing tokens)Martin Kleppmann · required

    Read "What are you using that lock for?", "Protecting a resource with a lock" and "Making the lock safe with fencing". The effect recipient must remember the highest token and reject older ones (34 accepted, delayed 33 rejected); a random lock value is not a fencing token. Fencing rejects stale authority, while idempotency rejects repeated operations.

  • SagasHector Garcia-Molina and Kenneth Salem · reference

    Read Section 1 (p. 250: compensation does not necessarily restore the earlier state) and Section 9 Designing Sagas, with Sections 4 and 5 on backward and forward recovery. Some actions cannot be compensated; model failed compensation and manual handling explicitly.

  • LangGraph Persistence and InterruptsLangChain · support

    Read persistence (checkpointer versus store; the in-memory saver does not survive a restart), interrupts (interrupt, Command(resume=...), the rules of interrupts, "side effects called before interrupt must be idempotent") and the Functional API determinism and idempotency sections. Resuming restarts the interrupted node from its beginning: reproduce the repeated pre-interrupt action with a SQLite checkpointer across two processes.

  • DBOS Transact Python: Workflows and StepsDBOS · support

    Read the workflow tutorial ("Workflow IDs and Idempotency", "Determinism"), the step tutorial ("Configurable Retries", "Step Timeouts") and the system-database page (SQLite by default). Kill a process mid-workflow and confirm that completed steps do not rerun while the interrupted step does. Choose this or LangGraph as the implementation companion, not both.

  • Temporal: Workflow Replay, Activity Retries and TestingTemporal · reference

    Read Event History and replay, the Python workflow logic requirements, "Make Activities idempotent", the default retry policy (unlimited attempts unless set) and Signals versus Updates. Activities may run more than once, so replay does not make an external effect exactly-once.

  • Writing Effective Tools for AI AgentsAnthropic · support

    Read "Running an evaluation" and "Principles for writing effective tools" through "Prompt-engineering your tool descriptions": a small task-shaped tool surface, unambiguous parameter names, bounded and paginated results, actionable errors. Compare with the OpenAI function-definition best practices and rewrite one tool contract.

  • AI Engineering Handbook - Agent EngineeringHandbook Academy · support

    Study the Part 7 chapters on tool design, MCP and security, human review and long-running agents. Use them to audit user-facing workflow behavior and failure paths after the durable core works.

  • The Hitchhiker's Guide to Agentic AI - Harness and MCPHaggai Roitman · support

    Use v3 sections 18.4 to 18.7 (tool integration, orchestration with the explicit state machine in 18.5.5, state management and checkpoints, error handling), then Chapter 23 for MCP vocabulary and 23.6 for its security model. Its transport lists predate the 2026-07-28 specification and 18.4.5 contradicts Chapter 23, so take protocol facts from the specification.