Skip to content
Index Ai Academy
Phase 9 · Protocol foundations

Discovery, capabilities and the two eras

server/discover, declared capabilities, and talking to legacy and modern software alike.

About 30 minutes · Versions and API rules checked November 2026 · A free account opens the whole lesson.
Already have an account? Sign in to open this lesson

What it covers8

First principles

How does a host know which optional interaction a server actually supports?

Capability discovery moves assumptions into declared data. Read the advertised capabilities, choose a mutually supported flow, and gate operations that rely on optional support.

  1. Starting point

    Host requests available capabilities

  2. What changes

    Server declares what it supports

  3. Result

    Host offers only operations whose requirements are met

Compare all three steps
  1. Starting point

    Host requests available capabilities

  2. What changes

    Server declares what it supports

  3. Result

    Host offers only operations whose requirements are met

Complete and reverse the trace

Given Host requests available capabilities and Host offers only operations whose requirements are met, write down the missing step that connects them.

Compare with the worked step

Server declares what it supports

Now take Server declares what it supports and the result above. Write an input and an implementation that could produce this trace.

Check one starting point

Host requests available capabilities. Check that your implementation produces the result shown above.

Try it on a new case

A tool needs an interactive response from the client, and the client declares no such capability. Should the host start the call?

Show worked reasoning

The host should prevent the incompatible call and explain the missing capability. Otherwise the server can reach a point where it needs a response the client cannot provide.

Run, change, and build

Check this when debugging. Using a client capability the request didn't declare.

Trace the cause · MCP message and permission
  1. Mark which message crosses the client–server boundary and which check determines what the caller may do.
  2. Change the tool input or approved scope. Compare the returned message and stored state to distinguish a denial from an allowed change.
  3. Try the same reasoning on this case. A tool needs an interactive response from the client, and the client declares no such capability. Should the host start the call?

Why it matters

Versions and stateless requests made every MCP request stand on its own. That raises two questions. How does a client find out what a server can do before it starts asking? And how do new clients keep talking to the many servers that still open with a handshake? MCP answers the first with a method called server/discover and a vocabulary of capabilities, and the second with dual-era software that speaks both styles. You'll meet both in the wild, and the server you build in Capstone: a production MCP server has to get them right.

What you'll be able to do

  • Implement server/discover and say what a host does with its result
  • Declare capabilities on both sides, and refuse a request that needs one the client didn't declare
  • Tell a legacy server from a modern one, and fall back to the initialize handshake
  • Handle MissingRequiredClientCapability and name extensions
Quick check
The sign on a shop's door tells you its hours and what it sells. What does an MCP client ask a server first?
  1. Nothing: clients start calling tools straight away
  2. What it offers: its versions, capabilities and instructions
  3. For a copy of its source code to check it over
  4. For its password, so the client can log in as the server
Show the answer

What it offers: its versions, capabilities and instructions

Discovery tells the client what the server can do and which protocol revisions it speaks, so the client knows what to ask for and how. This lesson covers that sign on the door.

The idea: the sign on the door, and two eras

This rests on Versions and stateless requests: every request names its own version and capabilities. Two questions follow. How does a client learn what a server offers before it asks? And how does a new client still reach a server that wants a handshake?

The sign on the door: server/discover

Walk up to a shop and the sign on the door tells you the hours, what it sells and whether it takes cards. You know before you go in.

Every modern server must implement server/discover. It's that sign. It returns:

  • supportedVersions: the revisions it speaks, newest first.
  • capabilities: the optional features it offers (more on these below).
  • serverInfo, inside the result's _meta: its name and version.
  • instructions (optional): plain-language guidance a host can pass to the model about how to use the server. "Use confirm_order only after the customer has seen the total" is the kind of thing that goes here.
  • ttlMs and cacheScope: how long the answer may be cached, in milliseconds, and whether a shared cache may keep it ("public") or only this caller ("private"). Every discover result carries both.
Quick check
Which field of a server/discover result tells a client which protocol revisions the server speaks?
  1. serverInfo
  2. capabilities
  3. supportedVersions
  4. instructions
Show the answer

supportedVersions

supportedVersions lists the revisions, newest first. capabilities lists optional features, and serverInfo, in the result's _meta, names the server.

Calling it first is optional. A client can send any request straight away and handle a version error if one comes back. But discover is a cheap way to show "what can this server do?" in one call, and a host can cache the result for as long as ttlMs allows. Like any request, discover itself carries _meta with a version and capabilities. If the server doesn't speak that version, it says so with -32022, the same error as for any other method.

In plain words: discover is one call that returns everything a client needs to decide how to talk to this server.

Quick check
From the lesson on versions: a server that doesn't speak the requested version answers with error −32022 and lists what it supports. The client retries with the first of its own versions that the server shares. What does this print?
ours = ["2026-07-28", "2025-11-25"]
error = {"code": -32022,
         "data": {"supported": ["2025-11-25", "2025-06-18"], "requested": "2026-07-28"}}
retry_with = next((v for v in ours if v in error["data"]["supported"]), None)
print(error["code"] == -32022, retry_with)
  1. True 2025-11-25
  2. True 2026-07-28
  3. False None
  4. True 2025-06-18
Show the answer

True 2025-11-25

The client's first choice isn't in the server's list, and its second is, so it retries with 2025-11-25. A version is one thing the two sides have to agree on. Capabilities, in this lesson, are the other: which optional features each side supports.

Try it now

The practice server is dual-era. Send server/discover and read the versions, capabilities and instructions it returns. An unsupported version gets a 400 listing the supported ones, and the legacy initialize still works. The headers are covered in the Streamable HTTP lesson.

Quick check
A host reads an instructions string from a server's discover result. What should it do with it?
  1. Pass it to the model as guidance on using this server's tools
  2. Show it to the user as an error message from the server
  3. Ignore it, since it's only meant for the server's logs
  4. Use it to pick which protocol version to send next
Show the answer

Pass it to the model as guidance on using this server's tools

instructions is the server's advice to the model, such as when a tool should or shouldn't be called. Versions come from supportedVersions, and the user never needs to see it.

Capabilities: say what you can do

Capabilities are how each side says which optional features it supports. It's like telling a caller that your phone can't receive photos, so they don't send one.

  • Servers list tools, resources and prompts. Each may add details, such as listChanged, which means the server can announce when its list changes.
  • Clients list features such as elicitation, which means the server may ask the user a question mid-call.
  • Both may list extensions: optional add-ons named like io.modelcontextprotocol/tasks.

Because every request carries the client's capabilities, a server knows on each call what it may do. The rule is strict. A server must never rely on a capability the client didn't declare. If a request can't be done without one, the server answers MissingRequiredClientCapability, error code -32021, saying which capabilities it needed:

{"jsonrpc": "2.0", "id": 5, "error": {"code": -32021,
                                      "message": "confirm_order needs elicitation",
  "data": {"requiredCapabilities": {"elicitation": {}}}}}

The client can then decide: add the capability if it has it, or tell the user that this tool needs a feature their app lacks. An empty clientCapabilities of {} is valid. It means "only the basics", and it keeps simple scripts simple.

In plain words: each side declares what it can do, and nobody uses a feature the other side didn't declare.

Quick check
A tool wants to ask the user a question in the middle of a call, which needs the client's elicitation capability. What does this print for three clients' declared capabilities?
def can_ask_user(client_capabilities):
    return "elicitation" in client_capabilities

print(can_ask_user({"elicitation": {}}), can_ask_user({}),
      can_ask_user({"sampling": {}}))
  1. True True False
  2. True False True
  3. False False False
  4. True False False
Show the answer

True False False

Only the first client said it can show a question to its user. For the other two, the server must not send one and hope. It answers with MissingRequiredClientCapability, which names what was needed, and the client can decide what to do about it.

Living with two eras

New software must still talk to old software. Think of a bilingual receptionist who answers each caller in whichever language they open with. The spec defines dual-era clients and servers that speak both styles.

A dual-era server looks at how each request opens. An initialize request gets the legacy handshake. A request carrying modern _meta is served statelessly. The same server does both.

A dual-era client has to find out which kind of server it's facing. On stdio, it sends server/discover first. A proper discover result means the server is modern. So does a modern error such as UnsupportedProtocolVersion, because only a modern server knows that code. Any other error, or no answer at all, means the server is legacy, so the client falls back to initialize. Over HTTP it tries a modern request and reads the body of a 400 the same way.

Quick check
A dual-era client sends server/discover and gets UnsupportedProtocolVersion back. What kind of server is it?
  1. Broken: stop and report it
  2. Unknown: send initialize to find out
  3. Modern: only a modern server knows that error
  4. Legacy: the request failed, so fall back
Show the answer

Modern: only a modern server knows that error

A legacy server has never heard of that error code. Getting it back proves the server speaks the modern style, in a different version.

The answer is a property of the server, not of the moment, so clients cache it instead of probing every time. A client asks again only when its cached discover result's ttlMs runs out, or when a call that used to work starts returning a version error, which means the server was upgraded underneath it.

A modern-only client can't use a legacy server, and a legacy-only client can't use a modern-only server. That's why many SDKs and hosts stay dual-era during the transition, and why the spec now keeps a deprecated feature for at least twelve months before it may be removed (ninety days under an expedited exception).

In plain words: a dual-era client asks "discover?" once. A real answer or a modern error means modern; anything else means legacy.

In your own words
What does a host do with server/discover's result?

Write a sentence or two, then compare it with a good answer in the lesson.

In Python: guards, probes and a live check

This part writes the server's guard and the client's probe, and runs the probe against a server that really is dual-era.

Worked example

A guard before a feature is used

A server checks the request's declared capabilities before it does anything that needs one. The same tool is refused for a plain client and runs for a richer one.

PV = "io.modelcontextprotocol/protocolVersion"
CAPS = "io.modelcontextprotocol/clientCapabilities"

def needs(meta, *names):
    """The capabilities a request lacks, so the server can refuse before it starts."""
    declared = meta.get(CAPS, {})
    return [n for n in names if n not in declared]

plain = {PV: "2026-07-28", CAPS: {}}
rich = {PV: "2026-07-28",
        CAPS: {"elicitation": {}, "extensions": {"io.modelcontextprotocol/tasks": {}}}}

for label, meta in [("plain client", plain), ("rich client", rich)]:
    missing = needs(meta, "elicitation")
    if missing:
        print(label, "-> error -32021, requiredCapabilities:", {m: {} for m in missing})
    else:
        print(label, "-> ask the user, then confirm")
It runs right here in your browser, with nothing to install.

The check happens before the tool does any work, so a refused call changes nothing. The error's data names exactly what was missing (elicitation, for the plain client), so a client can fix its request instead of guessing.

Drill

Check a capability before using it

Capabilities are nested dictionaries, like {"tools": {"listChanged": True}, "resources": {}}. Write supports(caps, path): path is dotted, like "tools.listChanged" or "resources". Return True if every key along the path exists and the final value isn't False or None (an empty dict still means "supported").

def supports(caps, path):
    return path in caps


caps = {"tools": {"listChanged": True}, "resources": {},
        "prompts": {"listChanged": False}}
print(supports(caps, "tools.listChanged"), supports(caps, "elicitation"))
In the lesson, your code is checked as you write it.
Quick check
A server's tool needs to ask the user a question mid-call, but the request's clientCapabilities is {}. What should the server do?
  1. Ask the question anyway, and hope the client turns out to support it
  2. Close the connection, since the client can't do what the tool needs
  3. Silently skip the question and guess the answer the user would give
  4. Return MissingRequiredClientCapability (-32021), naming elicitation as required
Show the answer

Return MissingRequiredClientCapability (-32021), naming elicitation as required

Servers may only use capabilities the client declared on that request. The error tells the client exactly what's missing.

Worked example

A client works out which era a server is from

A dual-era client sends server/discover and decides from the reply. Four replies, four decisions.

MODERN_ERRORS = {-32022, -32021}      # only a modern server knows these codes

def era(reply):
    """Decide from a server's reply to server/discover."""
    if reply is None:
        return "legacy"                    # no answer at all
    if "result" in reply:
        return "modern"
    code = reply["error"]["code"]
    return "modern" if code in MODERN_ERRORS else "legacy"

print(era({"result": {"supportedVersions": ["2026-07-28"]}}))
print(era({"error": {"code": -32022, "message": "Unsupported protocol version"}}))
print(era({"error": {"code": -32601, "message": "Method not found"}}))
print(era(None))
In the lesson you can change this and run it.

A result is modern, and so is a version error, because the server understood the question. Method not found and silence both mean the server never learned discover, so the client should send initialize next. The decision is cached per server.

The probe, live

The practice server speaks both eras. This cell runs era() on three exchanges: a discover that gets a result, a discover with a version the server doesn't know (a modern error, so still modern) and the legacy initialize on the same server.

import requests

URL = "https://api.gradient.test/mcp"
PV = "io.modelcontextprotocol/protocolVersion"
CAPS = "io.modelcontextprotocol/clientCapabilities"
MODERN_ERRORS = {-32022, -32021}


def post(method, version=None, params=None):
    params = dict(params or {})
    headers = {}
    if version:
        params["_meta"] = {PV: version, CAPS: {}}
        headers = {"MCP-Protocol-Version": version, "Mcp-Method": method}
    body = {"jsonrpc": "2.0", "id": 1, "method": method, "params": params}
    return requests.post(URL, json=body, headers=headers).json()


def era(reply):
    if reply is None:
        return "legacy"
    if "result" in reply:
        return "modern"
    return "modern" if reply["error"]["code"] in MODERN_ERRORS else "legacy"


print(era(post("server/discover", "2026-07-28")))
print(era(post("server/discover", "2027-01-15")))
legacy = post("initialize", params={"protocolVersion": "2025-06-18"})
print(legacy["result"]["protocolVersion"], "from the same server")
Drill

Summarize a server for a person

Write summary(result): from a discovery result with capabilities, and the server's name and version in its _meta under INFO, return "NAME VERSION: " followed by the capability names that are present, sorted and joined with ", ", or "no capabilities" if there are none.

INFO = "io.modelcontextprotocol/serverInfo"
RESULT = {
    "_meta": {INFO: {"name": "campaigns", "version": "1.4.0"}},
    "capabilities": {"tools": {"listChanged": True}, "resources": {}, "logging": {}},
}


def summary(result):
    return result["_meta"][INFO]["name"]


print(summary(RESULT))
In the lesson, your code is checked as you write it.
Quick check
The same decision, on two replies. What does this print?
def era(reply):
    if "result" in reply:
        return "modern"
    return "modern" if reply["error"]["code"] in (-32022, -32021) else "legacy"

print(era({"error": {"code": -32601}}), era({"error": {"code": -32021}}))
  1. modern modern
  2. modern legacy
  3. legacy legacy
  4. legacy modern
Show the answer

legacy modern

-32601 (Method not found) isn't a modern code, so the first is legacy. -32021 (MissingRequiredClientCapability) is one, so the second server is modern even though it refused.

In your own words
How do you tell a legacy server from a modern one?

Write a sentence or two, then compare it with a good answer in the lesson.

In the SDK and a real host: instructions in the system prompt

Purpose. See what a real host does with the discover result, and which part of it reaches the model.

Of everything in a discover result, the host sends one field to the model: instructions. Versions and capabilities stay inside the host's client, where they decide what to call. The instructions go into the system prompt, labeled by server, next to the host's own. Server authors set the string when they build the server (the official SDKs take an instructions setting; check the name in the SDK you use).

Because instructions reaches the model, it is also text the model may obey. A server you don't control can put anything there, so a careful host shows it to the user when the server is added, the way it shows tool descriptions (MCP security).

In an engineer's week. A new host version starts probing with server/discover, and a legacy server that logs every unknown method starts logging errors. That is expected: it is the probe. What goes wrong is a client that treats the first error as "server down" instead of "legacy", and a probe repeated on every call because nobody cached the era.

Goes deeper in

In your own words
A host shows the model each server's instructions. Why should it also show them to the user?

Write a sentence or two, then compare it with a good answer in the lesson.

Choose how to practice

Start with a short baseline or choose guided, independent, or AI-assisted practice.

Practice what you just read

  • 3 code examples you can edit and run
  • a practice exercise that checks your code
  • a 5-question quiz
  • 9 review cards for spaced repetition

Try a quiz question

A dual-era client on stdio sends server/discover and gets a "Method not found" error. What should it conclude?

  1. The server is legacy, so fall back to the initialize handshake
  2. The server is broken, because every server has to answer that method
  3. Retry server/discover with another version, starting from the oldest it knows
  4. The server is modern but has no tools, so there's nothing it can discover

Answer it at the end of the lesson to see if you're right, and why.

Before this lesson

Keep learning

Where this lesson leads.

575 lessons in thirteen phases. 176 are free without an account, and a free account opens the rest. See every lesson.

Phase 9 · about 13 hours of study

Model Context Protocol

Build MCP servers, clients and hosts, from the wire format to production 17 lessons 1 free
  1. JSON-RPC 2.0 in depth FreeRequests, notifications, errors and a dispatcher built from scratch.35 min
  2. Versions and stateless requestsRevisions by date, the legacy handshake, per-request _meta and version negotiation.30 min
  3. Discovery, capabilities and the two erasserver/discover, declared capabilities, and talking to legacy and modern software alike.30 min
  4. Transports I: stdioNewline-delimited JSON over a subprocess's standard streams.30 min
  5. Transports II: Streamable HTTPOne endpoint, required headers, JSON or event-stream replies.40 min
  6. Build a server: toolsTool definitions, schemas from type hints, results and two kinds of error.45 min
  7. Resources and promptsReadable data, URI templates and reusable prompt templates.40 min
  8. The same server with the official SDKsYour registry and dispatcher on the SDK's decorator shape, in Python and TypeScript.40 min
  9. Build a clientMetadata on every request, version fallback, paging and caching.40 min
  10. Hosts: connecting servers to a modelMany servers, one agent: namespacing, routing and approvals.40 min
  11. Progress, subscriptions and multi-round-trip requestsLong-running work, change notifications and asking the user mid-call.45 min
  12. Securing remote servers with OAuthProtected resource metadata, PKCE, audiences and scope challenges.45 min
  13. MCP securityTool poisoning, rug pulls, confused deputies and local-server risks.40 min
  14. Lab: attack and defend a hostPoisoned tools, injected results, token replay and the defenses that stop each.40 min
  15. Testing, designing and shipping serversConformance checks, tool design for models, SDKs and deployment.40 min
  16. MCP in production: gateways, limits and auditAn allowlist, per-user rate limits, header checks and an audit log in front of many servers.35 min
  17. Capstone: a production MCP serverA complete, tested server for the practice shop.45 min
Part of a free course 15 lessons

Build and Deploy MCP Integrations

Build a Model Context Protocol client and server, then verify the integration with a compatible host.

Never trained an AI? Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account. Teach it to write