Skip to content

AAK-MCP-DEPRECATED-002: Use of deprecated sampling capability (sampling/createMessage)

Severity
MEDIUM
Category
MCP Configuration (mcp-config)
Scanner
agent_audit_kit/scanners/mcp_deprecated_features.py
Auto-fixable
No.
SARIF name
McpDeprecatedSampling

What it detects

Server or client code declares or exercises the sampling capability — the sampling/createMessage request, a CreateMessageRequest handler, or the SDK aliases (create_message, .sampling.create). The MCP ratified 2026-07-28 spec deprecates sampling (SEP-2577) under the 12-month deprecation policy (SEP-2596). Server-initiated sampling made the server a privileged caller of the host LLM and had no clean stateless story; it is on the removal path. (Distinct from AAK-MCP-SAMPLING-001, which flags sampling wired up without a consent gate — this rule flags the deprecated capability itself.)

How to fix

Migrate before removal: instead of asking the client to sample via sampling/createMessage, call the LLM provider API directly from the server with its own credentials. Deprecated 2026-07-28; plan to remove ahead of the ~mid-2027 window.

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

agent-audit-kit scan . --rules AAK-MCP-DEPRECATED-002

Limitations

In .py, .ts, .tsx, .js, .jsx, .mjs, .cjs, .rs, .java and .kt sources it looks for sampling/createMessage, CreateMessageRequest (or CreateMessageRequestSchema) and RequestSampling, and, in a file that also contains modelcontextprotocol, FastMCP, McpServer, @mcp., mcp.server, from mcp, import mcp (each as whole words), ServerCapabilities or mcpServers, for create_message(, .sampling.create(, ServerCapabilities( with sampling= before its first ), or a capabilities: { ... } literal that names sampling before its first closing brace. In JSON, any capabilities object or list that lists sampling counts, wherever the key sits, in .mcp.json and any *.mcp.json at any depth, and mcp.json, claude_desktop_config.json, package.json and the per-editor mcp.json files (.cursor, .vscode, .windsurf, .amazonq, .roo, .kiro) directly under the project root. In sources, the TypeScript SDK call server.createMessage({...}), a capabilities literal with a nested object ahead of sampling, and create_message( in a file that names no MCP SDK are not matched; neither is a capabilities object in config/servers.json.

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-DEPRECATED-002.md: the page then shows that text, with the registry reference appended under it.