Skip to main content
Glama

Inbound MCP sampling/createMessage Reverse-Injection Firewall

validate_mcp_sampling_request
Read-onlyIdempotent

Audits inbound MCP sampling/createMessage callbacks to block cross-server context snooping and token quota hijacking before a connected server samples the host LLM.

Instructions

Audits inbound MCP sampling/createMessage callbacks from connected servers to block cross-server context snooping (includeContext='allServers') and token quota hijacking. Use when filtering a connected MCP server's request to sample the host LLM; for scrubbing text returned from a standard synchronous tools/call response, use sanitize_tool_output_stream instead. Stateless read-only edge call (max 32 KB, 60 RPM): accepts 'sampling_request_json' ('max_tokens_ceiling' defaults to '512'), supports '?demo=true' or L402 (20 sats), and returns HTTP 400 if invalid.

Input Schema

NameRequiredDescriptionDefault
max_tokens_ceilingNoMaximum completion token quota allowed for server callbacks; defaults to '2048' when omitted.
sampling_request_jsonYesJSON string or object representing the inbound MCP sampling/createMessage payload.

Output Schema

NameRequiredDescriptionDefault
sampling_safeYesTrue if the sampling request respects context isolation and token caps.
timestamp_utcYesISO-8601 UTC timestamp of the inspection.
recommended_actionYesHost enforcement action ('APPROVE_SAMPLING_REQUEST' or 'REJECT_SAMPLING_REQUEST').
violations_detectedYesSpecific policy violations found in the sampling request.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.3.3

TDQS

A4.4/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already say read-only, idempotent, non-destructive, but the description adds substantial operational context the agent cannot get from them: statelessness, a 32 KB payload cap, 60 RPM rate limit, auth via '?demo=true' or L402 (20 sats), and the HTTP 400 failure mode. That is exactly the kind of beyond-schema behavior disclosure this dimension rewards.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two dense sentences that front-load the purpose, then usage routing, then constraints; very little waste. The parenthetical constraint block (limits, auth, error code) is packed tightly but remains scannable.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With only 2 params, full schema coverage, a rich annotation set and an output schema, the description covers nearly everything an agent needs to call it correctly. The one gap is the wrong stated default for max_tokens_ceiling, which should be reconciled with the schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline would be 3, but the description actively conflicts with the schema: it claims 'max_tokens_ceiling' defaults to '512', while the schema says it 'defaults to 2048' when omitted. That contradiction is worse than silence, since an agent may assume a tighter quota than is actually applied.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Audits inbound MCP sampling/createMessage callbacks') and names the two concrete threats it blocks (includeContext='allServers' snooping and token quota hijacking). It is unmistakable against siblings like sanitize_tool_output_stream or audit_mcp_server_manifest.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit use condition ('when filtering a connected MCP server's request to sample the host LLM') and explicitly routes the adjacent case elsewhere ('for scrubbing text returned from a standard synchronous tools/call response, use sanitize_tool_output_stream instead'). The when/when-not split is fully resolved in the text.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools