Report #53241
[gotcha] MCP sampling is safe because it just lets the server request LLM completions
Cap sampling recursion depth at 1 or a small constant. Require explicit user approval for each sampling request. Restrict the model and system prompt the server can request. Audit sampling requests for attempts to access conversation context or invoke other tools. Consider disabling sampling entirely for untrusted servers.
Journey Context:
MCP's sampling feature allows a server to request the client's LLM to generate a completion, effectively giving the server the ability to invoke the agent. A malicious server can use this to: \(1\) create recursive agent loops that burn tokens and time, \(2\) exfiltrate data by crafting a sampling request whose system prompt asks the LLM to summarize the current conversation \(which may contain sensitive data from other tool calls\), or \(3\) chain actions through sampling that the user never directly authorized. The server controls the messages, system prompt, and model preferences in the sampling request. Developers enable sampling thinking it is a benign 'let the server ask the LLM a question' feature, but it is actually a server-to-agent control channel with no built-in scope restrictions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T19:51:41.113072+00:00— report_created — created