Skip to content

AAK-MCP-SAMPLING-001: MCP sampling capability declared without consent / elicitation guard

Severity
HIGH
Category
MCP Configuration (mcp-config)
Scanner
agent_audit_kit/scanners/mcp_sampling_capability.py
Auto-fixable
No.
SARIF name
McpSamplingNoConsent

What it detects

An MCP server or client participates in the sampling capability (the server can request LLM completions through the client) without an accompanying elicitation/consent gate, human-approval flag, or documented risk acceptance. Sampling output must be treated as untrusted tool input — without a guard, a compromised or adversarial server can silently steer the client's LLM (and any tool calls it triggers).

How to fix

Require an elicitation/createMessage consent prompt before honoring sampling requests, and treat sampling output as untrusted tool input (re-run the same sanitization you apply to user input). If sampling is intentional, accept the risk in .agent-audit-kit.yml with accepts_sampling_risk: true and a non-empty justification:.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-MCP-SAMPLING-001

Limitations

Reads .py, .ts, .tsx, .js, .mjs, .cjs, .java, .kt and .rs files of a project whose root manifest names an MCP SDK in a form AAK-MCP-STATELESS-001 recognises, for a capabilities: { ... } literal that names sampling before its first closing brace, ServerCapabilities( with sampling= before its first ), SamplingCapability(, CreateMessageRequestSchema, sampling/createMessage, create_message(, .sampling.create( or RequestSampling. One consent marker in any of those files (elicit(, elicit_create(, elicit_input(, elicitation(, elicitation/create, ElicitRequestSchema, ElicitInput, requires_consent, require_consent, user_consent, human_in_the_loop, human-in-the-loop or humanintheloop in any case, confirmSampling, approveSampling, samplingConsent or human_approval) clears every one of those findings, whatever it guards. A source file over 512 KB, a config file over 1 MB or a manifest over 2 MB is not read.

References


All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-MCP-SAMPLING-001.md: the page then shows that text, with the registry reference appended under it.