Skip to content

docs: explain client-side sampling callbacks#2789

Open
He-wei-gui wants to merge 1 commit into
modelcontextprotocol:mainfrom
He-wei-gui:docs/sampling-client-callbacks
Open

docs: explain client-side sampling callbacks#2789
He-wei-gui wants to merge 1 commit into
modelcontextprotocol:mainfrom
He-wei-gui:docs/sampling-client-callbacks

Conversation

@He-wei-gui
Copy link
Copy Markdown

Summary

  • add a Sampling docs page for the server-to-client sampling flow
  • explain that clients opt in with sampling_callback and own the model/provider call
  • document how model_preferences, include_context, and ClientRequestContext reach the callback
  • add the page to the MkDocs navigation

This intentionally keeps the change provider-neutral and docs-only. It complements the existing server-side sampling snippet and avoids adding a full example project or model-provider dependency.

Addresses #1205.

Testing

  • PYTHONIOENCODING=utf-8 uv run mkdocs build --strict

@pranjalbhatia710
Copy link
Copy Markdown

I was about to take a pass at #1205 and checked this PR first. This looks like it covers the missing client-side half of sampling clearly: it answers that the SDK does not call a provider directly, shows where sampling_callback plugs in, and explains that model_preferences / include_context are advisory inputs for the client rather than automatic behavior.

Local validation on current PR head:

uv run --frozen mkdocs build --strict

Result: docs build completed successfully. Only output was the existing MkDocs/Material compatibility warning, not specific to this change.

One small thing I specifically checked: adding sampling.md to mkdocs.yml makes the new page reachable from the docs nav, so this should directly address the discoverability gap from #1205.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants