Files
modelcontextprotocol--pytho…/docs/handlers/index.md
T
wehub-resource-sync 49b9bb6724
Deploy Docs / deploy-docs (push) Failing after 1s
Conformance Tests / client-conformance (push) Failing after 3s
Conformance Tests / server-conformance (push) Failing after 1s
GitHub Actions Security Analysis / zizmor (push) Failing after 1s
CI / checks (push) Failing after 59m20s
CI / all-green (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 12:10:27 +08:00

1.3 KiB

Inside your handler

A handler's arguments come from the client. Everything else it can read, and everything it can do while it runs, is here.

What it can read:

  • The Context is the one extra parameter any handler can ask for: the live request, its headers, its session, and the progress and change-notification verbs.
  • Dependencies are parameters the model never sees, filled in by your own functions with Resolve.
  • Lifespan covers state your server builds once at startup, and how a handler reaches it through the Context.

What it can do while it runs:

  • Ask the user for more input with Elicitation, and Multi-round-trip requests, the 2026-07-28 pattern that carries it.
  • Ask the client for an LLM completion or its workspace folders with Sampling and roots, deprecated but still served.
  • Report Progress on something slow.
  • Write logs (to standard error, for whoever operates the server) with Logging.
  • Tell subscribed clients that something changed with Subscriptions.

If you haven't registered a handler yet, start with Tools. Every page here assumes you have one.