Skip to content

[Deprecated-1b] Implement deprecated Sampling proxy support #6172

Description

@lucarlig

Part of #5677

Split from #5690.

Spec: https://modelcontextprotocol.io/specification/2026-07-28/client/sampling
SEP: https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging
Depends on: #5682 for the generic Multi Round-Trip Requests (MRTR) transport and retry flow.

Context

The Rust dataplane does not currently advertise or proxy Sampling. Sampling is deprecated in MCP 2026-07-28; this work is a deliberate compatibility exception for existing counterparts during the deprecation window. It must not add legacy protocol or session behavior, and the gateway must not become an LLM provider.

Gateway work

  • Carry the per-request ClientCapabilities.sampling declaration and its tools/context sub-capabilities through the modern request path.
  • Proxy sampling/createMessage as an MRTR inputRequest, and route the corresponding inputResponses entry back to the originating upstream request.
  • Preserve opaque MRTR request state and deterministic retry behavior from [Major-4] Multi Round-Trip Requests (MRTR) and required resultType #5682.
  • Enforce capability gates for tool use and context inclusion.
  • Normalize deprecated includeContext: "thisServer" and "allServers" to omission or "none" when proxying.
  • Emit a safe deprecation warning when Sampling is negotiated or used; do not log prompts, sampled content, model preferences, or tool payloads.
  • Document migration to direct LLM-provider integration.
  • Do not implement legacy server-initiated request/session behavior.

Acceptance criteria

  • Modern client ↔ gateway ↔ modern upstream Sampling MRTR round-trips work end to end.
  • Sampling tool fields are rejected unless sampling.tools is declared.
  • Deprecated includeContext values are normalized and covered by tests.
  • Deprecation warning, migration guidance, and removal note are documented.
  • Focused tests cover capability gating, successful retry, declined/error responses, tools, and malformed sampling payloads.

Metadata

Metadata

Assignees

Labels

CF-DATAPLANETasks related to the creation of new Data Plane for ContextForge.mcp-2026-07-28Issues related to compliance with MCP 2026-07-28rustRust programming

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions