grounded-screen
Screen tool results for prompt injection before your agent reads them.
grounded-screen sends untrusted text (a fetched web page, an email, a GitHub issue, a Slack
message, any MCP tool result) to the Injection Screen and gets back a verdict,
injection or clean, with the suspicious spans and character offsets the
server checked against your text. The same package calls Grounded Extract and returns the
object and the grounded map the endpoint returned. It ships a Python client, a Claude Code
PostToolUse hook that stops Claude when a tool result looks like an injection, a
LiteLLM guardrail that blocks, masks or flags MCP tool results, LangChain tools for both
paid routes, a FastMCP middleware that screens tool results on on_call_tool,
and a stdio MCP server with tools grounded_extract and grounded_screen.
Price
0.003 USDC per screened call 0.005 USDC per extract call
Paid per call from your own Base wallet with x402
(3000 atomic units of USDC on eip155:8453 for a screen call, 5000 for an extract
call). No account, no subscription. The client refuses to pay more than 0.003 USDC for one
screen call and more than 0.005 USDC for one extract call, and stops at a daily cap you set
(default 0.50 USDC per UTC day). Screen and extract share that cap and the same wallet key.
GROUNDED_SCREEN_MAX_PER_CALL_USDC can lower either per-call ceiling and cannot
raise either one.
Setup in three steps
- Install.
pip install grounded-screen # client and Claude Code hook pip install git+https://github.com/argus-forge/grounded-screen # the way to install the latest unreleased code pip install "grounded-screen[litellm]" # also the LiteLLM guardrail pip install "grounded-screen[langchain]" # LangChain tools and MCP middleware pip install "grounded-screen[fastmcp]" # FastMCP middleware pip install "grounded-screen[mcp]" # stdio MCP server - Give it a wallet. Export the private key of a Base wallet that holds a little
USDC in the environment of the process that runs the hook or the proxy. Never put it in a
settings or config file.
export GROUNDED_SCREEN_KEY=... # private key of a Base wallet with USDC export GROUNDED_SCREEN_DAILY_CAP_USDC=0.50 # optional, default 0.50 - Wire it in.
Claude Code (
.claude/settings.json){ "hooks": { "PostToolUse": [ { "matcher": "^(WebFetch|WebSearch|mcp__.*)$", "hooks": [ { "type": "command", "command": "grounded-screen-claude-hook", "timeout": 90, "statusMessage": "Screening the tool result for prompt injection" } ] } ] } }LiteLLM proxy (
config.yaml)guardrails: - guardrail_name: grounded-screen litellm_params: guardrail: grounded_screen.litellm_guardrail.GroundedScreenGuardrail mode: post_mcp_call default_on: true on_injection: block # block, mask or flag fail_closed: false max_chunks: 3 mcp_block_behavior: tool_result
What happens on a hit
Claude Code. For WebFetch, WebSearch and MCP tools whose
name contains fetch, browse, email, mail,
issue, github, slack or read_url, the hook screens
the tool result. On an injection verdict it returns "decision": "block" with a reason
that names each suspicious span and tells Claude not to act on the content until you say so, plus
"continue": false so Claude stops and waits for you. Clean results, results that could
not be screened and hook errors pass silently. Fields follow the
Claude Code hooks reference
(PostToolUse decision control, JSON output).
LiteLLM. In mode post_mcp_call the guardrail sees every text of the
MCP tool result before the model does. block rejects the result, mask
replaces the suspicious spans, flag logs them. Results that could not be screened pass
unless fail_closed: true.
Extract
ExtractClient calls POST https://extract.sentinelintel.org/extract
with text and a flat JSON schema. object and grounded are
the object and the grounded map the endpoint returned. extracted is false on a
network error, a timeout, a 5xx, or a cap hit, and the call does not raise. A schema that is
not a JSON object is refused before any payment.
Published limits: a flat object, additionalProperties false, at most 32
properties, required lists every property once, types string, number, integer,
boolean, or null, a description of at most 300 characters, and text longer than 40000
characters is rejected. The example response on the extract site is a shape, not a recorded
call.
from grounded_screen import ExtractClient
schema = {
"type": "object",
"additionalProperties": False,
"required": ["invoice_number", "vendor", "date", "total", "currency", "due_date"],
"properties": {
"invoice_number": {"type": "string"},
"vendor": {"type": "string"},
"date": {"type": "string"},
"total": {"type": "number"},
"currency": {"type": "string"},
"due_date": {"type": "string"},
},
}
result = ExtractClient().extract(
"Invoice INV-20431 from Lakeside Paper Co., dated 2026-11-02, total 1284.50 USD, due 2026-12-02.",
schema,
)
LangChain
Install grounded-screen[langchain]. screen_tool() and
extract_tool() are one tool per paid route. screen_mcp_middleware()
is an AgentMiddleware. Its wrap_tool_call screens MCP tool results
after the tool runs. Tools are built with @tool
(langchain_core/tools/convert.py line 77). The interceptor follows the current
replacement for langchain-mcp-adapters tool interceptors:
migration note,
section "Tool interceptors", and
custom middleware.
AgentMiddleware.wrap_tool_call is langchain/agents/middleware/types.py
line 676 and returns a ToolMessage. Status error is the documented
failed tool result (same file, line 739). MCP provenance is metadata["mcp"] from
langchain/mcp/tools.py _tool_metadata line 183 (return at line 209).
A tool without that key is not screened. Pass the middleware to
create_agent(..., middleware=...) (langchain/agents/factory.py line 895).
from langchain.agents import create_agent
from grounded_screen.langchain_tools import extract_tool, screen_mcp_middleware, screen_tool
agent = create_agent(
model,
tools=[screen_tool(), extract_tool()],
middleware=[screen_mcp_middleware(on_injection="block")], # or "flag"
)
block replaces the tool result with a ToolMessage of status
error that does not include the tool text. flag keeps the text and
adds one warning line. A result that could not be screened is returned unchanged.
FastMCP
Install grounded-screen[fastmcp]. grounded_screen_middleware()
returns a Middleware instance. Register it with add_middleware.
It screens the tool result inside on_call_tool, after the tool has run.
Interface: FastMCP middleware,
section on_call_tool. Middleware.on_call_tool is
fastmcp/server/middleware/middleware.py line 239. ToolError is
fastmcp/exceptions.py line 54. ToolResult is
fastmcp/tools/base.py line 150. Text is read from TextContent.text
the same way response_limiting.py does at line 166.
FastMCP.add_middleware is fastmcp/server/server.py line 820.
from fastmcp import FastMCP
from grounded_screen.fastmcp_middleware import grounded_screen_middleware
mcp = FastMCP("my-server")
mcp.add_middleware(grounded_screen_middleware(on_injection="block")) # or "flag"
block raises ToolError and does not include the tool text.
flag appends one text block and returns the original content. A result that
could not be screened is returned unchanged.
MCP server
Install grounded-screen[mcp]. The console script
grounded-screen-mcp is a stdio MCP server with two tools.
grounded_extract is one paid extract call (0.005 USDC).
grounded_screen is one paid screen call (0.003 USDC). A network error, a
timeout, a 5xx, or a cap hit returns extracted or screened false
and does not raise. Importing the base package does not import the MCP SDK.
The package script grounded-screen is the stdin screener. Start this server
with grounded-screen-mcp. The registry name in server.json is
io.github.argus-forge/grounded-screen.
{
"mcpServers": {
"grounded-screen": {
"command": "uvx",
"args": ["--from", "grounded-screen[mcp]==0.3.0", "grounded-screen-mcp"],
"env": {"GROUNDED_SCREEN_KEY": "..."}
}
}
}
An installed copy uses the same environment and "command": "grounded-screen-mcp".
Interface: MCP Python SDK getting started.
MCPServer is mcp/server/__init__.py line 4 (class at
mcp/server/mcpserver/server.py line 157). @server.tool() is line 669.
run() with no argument uses stdio (line 404).
Measured results
These are the only measurements of the service. Both runs used a loopback instance, so the times do not include the internet round trip or the payment step.
indirect-injection gate
Test set derived from nvidia/Nemotron-RL-Agentic-Indirect-Prompt-Injection-v1
(revision d738d4f3): 1271 strings that contain an injection and 1251 negatives made from
the same strings with the injection removed. Synthetic, enterprise domain, indirect only.
| Metric | Result |
|---|---|
| Recall | 0.9961 (1266/1271) |
| False positive rate | 0.0080 (10/1251) |
| Detections with a span overlapping the injection | 1266/1266 |
| Returned spans whose offsets match the text | 2560/2560 |
| p95 response time, all rows (longest 906 characters) | 1.258 s (median 0.643 s, n = 2522) |
| p95 response time, one 20000 character input | 3.240 s (n = 50) |
public benchmark check
200 attack rows and 200 hard benign rows sampled with a fixed seed from
deepset/prompt-injections, jackhhao/jailbreak-classification and
the post-cutoff instruction-heavy set.
| Slice | Recall | False positive rate |
|---|---|---|
| All | 0.870 (174/200) | 0.060 (12/200) |
| deepset and jackhhao (published before 2026-04-15) | 0.867 (104/120) | 0.025 (4/161) |
| post-cutoff instruction-heavy set | 0.875 (70/80) | 0.205 (8/39) |
| deepset only | 0.759 (22/29) | no benign rows |
Response time on that run: p50 510 ms, p95 2170 ms (n = 400). 8 of the 174 detections had no span the server could locate; the service does not settle such a reply, so the caller pays nothing and gets no verdict. Counting only detections with a located span, recall is 0.830 (166/200).
Grounded Extract
Published at extract.sentinelintel.org, measured on that service with no field descriptions. The example response on that page is a shape, not a recorded call.
| Measurement | Result |
|---|---|
| Price | 0.005 USDC per call |
| MASSIVE short commands | 481 of 500 fields exact |
| VRDU registration forms | 491 of 600 fields matched |
| Long-document misses, adjudicated cold on an earlier prompt before the abstain rule was added | projected 91.4 percent of 600 fields, 95 percent interval 88.2 to 94.5 |
Known limits
- Instruction heavy benign text is often flagged: 8 of 39 post cutoff hard negative benign rows (0.205); polite imperative requests aimed at an assistant were flagged 6 of 7 times.
- ROT13 encoded instructions are mostly missed: 1 of 8 caught.
- Only English text has been measured.
- One GPU serves the screen, so expect about one call a second across all users.
- About 1.3 s is added per screened result (p95 1.258 s on the gate rows, before network and payment time); p95 3.240 s at 20000 characters.
- The pre cutoff public sets may be in the model's training data; the post cutoff set comes from a single template generated source.
- A
cleanverdict means the screen found nothing. It is not proof that text is safe.
Sources
The post-cutoff instruction-heavy set is the Prompt Injection Benchmark (Apache-2.0).