Agent Smith (SCAN-MCP): Internet-Scale Automated Security Analysis of MCP Tools

Agent Smith (arXiv:2611.36552) introduces SCAN-MCP, an automated security analysis pipeline for Model Context Protocol (MCP) servers. By combining AST tool-handler slicing, semantic taint filtering, inter-tool dataflow edge inference, and sandboxed proof-of-concept (PoC) confirmation, SCAN-MCP achieves 82.67% precision and 17.33% false discovery rate while uncovering 19/20 multi-tool exploit chains missed by Semgrep and mcp-scanner.
Agent Smith (SCAN-MCP): Internet-Scale Automated Security Analysis of MCP Tools: Agent Smith (arXiv:2611.36552) introduces SCAN-MCP, an automated security analysis pipeline for Model Context Protocol (MCP) servers. By combining AST tool-handler slicing, semantic taint filtering, inter-tool dataflow edge inference, and sandboxed proof-of-concept (PoC) confirmation, SCAN-MCP achieves 82.67% precision and 17.33% false discovery rate while uncovering 19/20 multi-tool exploit chains missed by Semgrep and mcp-scanner. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- Catches Inter-Tool Exploit Chains: Models hidden dataflow edges across separate MCP tools where traditional SAST reports zero findings.
- Slashes False Positives by 63pp: Drops False Discovery Rate from 80.85% (Semgrep) and 49.21% (Pure-LLM) down to 17.33%.
- High-Recall Tool Slicing: Achieves 100.00% precision and recall on tool extraction and slicing, plus 99.60% recall on handler mapping.
- Executable Sandbox Confirmation: Synthesizes and verifies live PoC payloads in isolated containers rather than trusting speculative LLM flags.
import { createAgent } from '@smoke-monkey/harness';const mcpSecurityAuditor = createAgent({agentId: 'scan-mcp-preinstall-gate',provider: 'anthropic',model: 'claude-sonnet-4-5',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'allow',run_command: 'ask',},mcpServers: {semgrep: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', './mcp-audit'] },},});async function auditMcpServerRepo(repoPath: string) {const result = await mcpSecurityAuditor.run(`Extract MCP tool schemas and executable handlers in ${repoPath}, slice single-tool sinks, infer inter-tool dataflow edges, and output a sandbox PoC verification report.`);console.log('MCP Audit Report:', result.summary);}auditMcpServerRepo('./third-party-mcp-server').catch(console.error);
Watch: Related Video Guides
MCP Security Fundamentals Course
Securing The Model Context Protocol Defense Strategies For Ai Tool Ecosystems
What Is Agent Smith (SCAN-MCP)? Closing the Inter-Tool Security Gap
Agent Smith's SCAN-MCP pipeline addresses a blind spot in conventional static analysis: MCP tools do not invoke one another via source-level function calls. Instead, an LLM runtime acts as the implicit control-flow bridge, reading untrusted output from Tool A and passing it as arguments into Tool B.
Because existing scanners inspect functions in isolation, they miss multi-step exploit chains (#TV) where a benign-looking reader tool feeds tainted data into a file writer, SQL runner, or shell executor. SCAN-MCP maps schemas to handlers, slices only tool-reachable code, labels sources/sinks, infers cross-tool edges, and validates vulnerabilities with executable PoCs inside a sandbox.
SCAN-MCP Benchmarks vs Semgrep, A.I.G, mcp-scanner & Pure-LLM
Evaluated across internet-scale MCP server implementations, Full SCAN-MCP outperforms rule-based SAST tools and unguided LLMs on both single-tool vulnerabilities (#SV) and inter-tool chain vulnerabilities (#TV).
| Analyzer / Configuration | Inter-Tool (#TV) | Single-Tool (#SV) | False Discovery Rate (FDR) | Precision (%) |
|---|---|---|---|---|
| Full SCAN-MCP | 19 / 20 | 105 / 130 | 17.33% | 82.67% |
| V3 (w/o Inter-Tool) | 0 / 0 | 105 / 130 | 19.23% | 80.77% |
| Pure-LLM (V4) | 6 / 8 | 58 / 118 | 49.21% | 50.79% |
| A.I.G | 0 / 0 | 70 / 191 | 63.35% | 36.65% |
| V2 (w/o Filters) | 27 / 96 | 141 / 423 | 67.63% | 32.37% |
| V1 (w/o Slicing) | 0 / 0 | 46 / 215 | 78.60% | 21.40% |
| Semgrep | 0 / 0 | 27 / 141 | 80.85% | 19.15% |
| mcp-scanner | 0 / 0 | 0 / 2 | 100.00% | 0.00% |
Stage-level validation shows 100.00% precision / 100.00% recall for tool extraction and slicing, 99.60% recall on handler mapping, 96.00% precision on source-and-sink labeling, and 98.39% precision on inter-tool edge inference (filtering out 78.87% of 9,871 proposed noisy edges before PoC synthesis).
Why Slicing + Filtering Are Mandatory
Removing program slicing drops precision from 82.67% to 21.40% (and loses all inter-tool detection), while removing semantic filters spikes FDR to 67.63%.
Implementing a Pre-Attach MCP Security Verification Pipeline
Before onboarding a third-party MCP server into production, extract its JSON-RPC tool manifest, isolate handler entrypoints, and verify untrusted inputs cannot reach child_process, filesystem writes, or outbound HTTP sinks without sanitization.
# Inspect exported MCP tool schemas via stdio JSON-RPC initialize + tools/list
printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"audit","version":"1.0"}}}\n{"jsonrpc":"2.0","id":2,"method":"tools/list"}\n' \
| npx -y @target-org/mcp-server 2>/dev/null | jq '.result.tools[] | {name, inputSchema}'
# Audit handler sinks for unvalidated shell/fs/network execution
rg -n "execSync|spawn|child_process|writeFile|eval\(|SELECT .*\$\{" ./third-party-mcp-server/srcEnforcing Tool-Boundary Trust in Smoke Monkey Harness
Smoke Monkey Harness treats every third-party MCP tool output as untrusted data rather than privileged instructions, applying explicit human-in-the-loop permission tiers (allow, ask, deny) per tool call. Pairing SCAN-MCP pre-installation audits with Smoke Monkey's runtime permission gating prevents poisoned external MCP responses from pivoting into local shell or filesystem tools.
Frequently Asked Questions
Q:Why do Semgrep and mcp-scanner miss inter-tool MCP vulnerabilities?
Traditional SAST rules trace direct code calls, whereas MCP tools compose at runtime through the LLM's context window. Without inter-tool dataflow edge inference, Semgrep and mcp-scanner detected 0 inter-tool chains in the Agent Smith evaluation.
Q:How does SCAN-MCP reduce false positives to 17.33% FDR?
SCAN-MCP chains four filters: deterministic AST tool slicing (cutting irrelevant repo code), semantic source-sink filtering, edge pruning (rejecting 78.87% of spurious edges), and live sandboxed PoC execution (rejecting 68.09% of unexploitable candidates).
Q:Does SCAN-MCP work when MCP servers use stdio instead of HTTP?
Yes. SCAN-MCP maps tool schemas directly to source-code handler implementations regardless of whether the server exposes JSON-RPC over stdio, WebSocket, or Streamable HTTP.
Q:What is the biggest security risk in public MCP registries?
Unattested tool outputs and missing inter-tool privilege boundaries: even non-malicious servers can be exploited when untrusted data read by one tool is forwarded into a sink tool on the host.
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.