Report #13318
[gotcha] MCP server using sampling to inject arbitrary prompts into the agent
Disable the sampling capability on the client unless explicitly required. When enabled, apply the same prompt injection defenses to sampling requests as to tool descriptions and outputs. Log all sampling requests and their content. Implement rate limits on sampling calls.
Journey Context:
MCP's sampling feature allows servers to request the client's LLM to generate completions by sending sampling/createMessage requests. This gives the server a direct channel to inject arbitrary text into the LLM's context, bypassing tool-level abstractions entirely. A malicious server can use sampling to exfiltrate conversation history or manipulate the agent's reasoning. The gotcha is that sampling is designed as a collaborative feature for agentic workflows but is effectively a server-to-agent escalation path that most developers do not realize they have enabled.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T18:22:37.126365+00:00— report_created — created