op-injection-scanner
An MCP server for prompt injection boundary enforcement that scans URL content using a tiered LLM model strategy.
README
op-injection-scanner
An MCP server for prompt injection boundary enforcement. AI agents call scan_url(url) instead of fetching URLs directly. The server fetches the URL (with SSRF protection), strips HTML to plain text, and scans the content for prompt injection using a three-tier model escalation strategy (Haiku → Sonnet → Opus). Results are cached by URL and TTL bucket so repeated calls within the cache window incur no additional LLM cost.
Installation
git clone https://github.com/ethereum-optimism/op-injection-scanner
cd op-injection-scanner
bun install
Claude Code MCP config
Add to ~/.claude.json or your project's .claude/settings.json:
{
"mcpServers": {
"op-injection-scanner": {
"command": "bun",
"args": ["run", "/absolute/path/to/op-injection-scanner/src/server.ts"]
}
}
}
The server requires ANTHROPIC_API_KEY in the environment.
Usage
Agents call scan_url with a URL instead of fetching it directly:
scan_url({ url: "https://some-external-docs.example.com/page" })
Clean response — status 200, tool returns:
{
"status": "clean",
"content": "The stripped page text...",
"url": "https://some-external-docs.example.com/page",
"scanned_at": "2026-03-08T12:00:00.000Z",
"model_used": "claude-haiku-4-5",
"escalated": false
}
Blocked response — tool returns isError: true so the calling agent receives a tool error:
{
"status": "blocked",
"reason": "Content contains instructions attempting to override agent behaviour",
"url": "https://malicious.example.com/page",
"scanned_at": "2026-03-08T12:00:00.000Z",
"model_used": "claude-haiku-4-5",
"escalated": false
}
When the tool returns isError: true, the calling agent should not process the URL further.
Environment variables
| Variable | Default | Purpose |
|---|---|---|
ANTHROPIC_API_KEY |
(required) | Anthropic API key — read automatically by the SDK |
CACHE_MAX_ENTRIES |
500 |
Maximum number of cached scan results |
CACHE_TTL_SECONDS |
3600 |
Cache entry lifetime in seconds (1 hour) |
CONFIDENCE_THRESHOLD |
0.8 |
Minimum confidence for a verdict — below this, escalate to next tier |
FETCH_TIMEOUT_MS |
10000 |
HTTP request timeout in milliseconds |
MAX_RESPONSE_BYTES |
2097152 |
Maximum response body size (2 MB) |
MAX_REDIRECTS |
5 |
Maximum number of HTTP redirects to follow |
MAX_URL_LENGTH |
2048 |
Maximum URL length in characters |
Design decisions
Why MCP, not a hook
A Claude Code hook fires automatically on every tool call, but it cannot be selectively invoked or tested in isolation. An MCP server is explicit — agents opt in to scanning, the interface is testable, and it can be extended (new tools, new scan types) without touching hook infrastructure.
v1 scope
This version detects prompt injection only. Malicious intent detection (e.g. phishing, credential harvesting) is a future iteration. The clean verdict means "no injection attempt detected" — not "content is safe in all respects."
Tiered model strategy
- Haiku — fast, cheap, handles the majority of clear-cut cases
- Sonnet — escalated when Haiku returns
uncertainor confidence < 0.8 - Opus — final arbiter, called only when Sonnet also cannot reach a confident verdict; schema enforces a definitive
cleanorblockedverdict (nouncertainallowed); parse failure defaults toblocked
No auth or rate limiting
This is internal dev tooling. Network isolation is the access control. Auth and per-session rate limiting are noted as future work in the source.
DNS rebinding (known v1 limitation)
The SSRF guard resolves DNS once before the request and checks all returned IPs. A sophisticated attacker controlling a low-TTL DNS record could return a public IP on the initial check and re-resolve to a private IP at TCP connection time, bypassing the guard. Full mitigation requires a custom DNS-pinning HTTP client. This is acceptable for internal tooling but must be addressed before any public or shared deployment.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。