Stop guessing what your Model Context Protocol tools execute. Interpose at the libc boundary to detect undeclared network egress, credential access, rogue child processes, and rug-pull attacks before users do.
`mcp-behave` exercises every tool, resource, and prompt under dynamic interposition. Zero findings on honest servers; immediate flags on rogue behavior.
~/.ssh/id_rsa (dereferenced from symlink /tmp/.cache/notes_link).
'format_data' claims offline/local operation, but initiated outbound connection to 198.51.100.24:443.
/var/run/docker.sock.
results.sarif
Built to Defeat Evasive Server Code
Attackers don't follow schema definitions. `mcp-behave` operates at the libc layer to capture the reality of what executes.
No `ptrace` or root privileges required. Injects custom interposition libraries via macOS `DYLD_INSERT_LIBRARIES` and Linux `LD_PRELOAD` with automatic `strace` fallback.
Canonicalizes all paths via `realpath()` and inspects live file descriptors (`fcntl F_GETPATH` on macOS, `/proc/self/fd` on Linux) to prevent symlink traversal cloaking.
4096-byte trace buffers with explicit ! TRUNCATED markers flag and escalate buffer-overflow and path-padding evasions straight to HIGH severity.
Interposes `connect`, `sendto`, `sendmsg`, and `sendmmsg` across IPv4, IPv6, UDP, abstract UNIX sockets (`@containerd-control`), and Docker control sockets.
Detects unauthorized access to `.gnupg`, `.npmrc`, `.pypirc`, `.git-credentials`, AWS, Azure, Google Cloud tokens, and Chrome/Firefox/Safari browser credential databases.
Pin server behavior in `mcp-behave.lock`. Run `mcp-behave check` in CI to fail builds only on undeclared behavioral regressions, with zero false alerts on approved baselines.
How `mcp-behave` Uncovers Lies
The target MCP server is launched with a dynamically interposed C library attached to its address space. Every socket, open call, and process execution is intercepted with microseconds overhead.
`mcp-behave` queries tool schemas and sends varied, realistic synthetic arguments over multiple rounds (--probe-rounds N), preventing static canary avoidance.
Observed kernel actions are audited against tool descriptions, `.mcpbehaverc.json` policies, and the full 62-rule MCP-audit catalog, exporting to SARIF v2.1.0 or failing your CI pipeline.
How `mcp-behave` Compares
Different tools tackle different sides of the MCP security boundary.
| Capability / Angle | mcp-behave | Static Linters | LLM Fuzzers (mcp-auditor) |
|---|---|---|---|
| Observation Level | OS Syscall / Libc layer | Tool description / schema text | JSON-RPC protocol text replies |
| Silent File / Credential Theft | ✓ Caught at open() / realpath() | ✗ Blind | ✗ Blind (unless returned in chat) |
| Undeclared Network Egress | ✓ Caught at connect() / sendmsg() | ✗ Blind | ✗ Blind (out-of-band exfil missed) |
| Token Cost & API Keys | Zero ($0, 100% local) | Zero ($0, 100% local) | Requires OpenAI/OpenRouter keys |
| CI / Regression Lockfile | ✓ mcp-behave.lock & diffing | ✗ Schema-only | ✗ Non-deterministic |
| Execution Speed | < 5 seconds | < 1 second | 1 – 5 minutes per tool |
Integrate `mcp-behave` into GitHub Actions or GitLab CI. Export SARIF v2.1.0 alerts straight into GitHub Security Code Scanning and block pull requests when undeclared scopes creep into releases.
name: Behavioral Security Audit
on: [push, pull_request]
jobs:
mcp-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run mcp-behave
run: |
pip install mcp-behave
mcp-behave audit \
--fail-on HIGH \
--sarif-output results.sarif \
-- python server.py
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
Rigorously Tested on Independent Public Suites
Evaluated against real exploit vectors, prompt injections, and ground-truth execution ledgers.
Multi-server benchmark over filesystem, SQL databases, and HTTP sinks. Features strict authorization context and 15 adversarial evasion techniques.
Measures detection and verified execution prevention via fixture ledgers. Exercises prompt injection, base64 secret flow, unapproved actions, rug pulls, and response bombs.
Evaluates behavioral observation across 60 servers (41 malicious, 19 benign) across 8 OWASP MCP Top 10 categories spanning description poisoning and multi-call state.
Evaluates runtime observation using paired benign baselines vs backdoored twin servers across 7 domains (17 targets). Unlike static scanners, mcp-behave achieves 90.0% Recall, 100.0% Precision (0.0% False Positive Rate), and 85.7% Twin-Pair Separation Accuracy while catching delayed triggers, IMDS SSRF, and container socket escapes inside canary environments.
Distinguishes static schema gaps from runtime facts across 7 official reference MCP servers. Tested with an automated 15-test adversarial campaign proving that Git strictly confines repos when configured, Fetch blocks SSRF and DNS rebinding at connect time, and Filesystem denies traversal and symlink escapes.
The Path to Trustworthy MCP Security
Native macOS `DYLD` and Linux `LD_PRELOAD`, symlink dereferencing, 4KB truncation alerts, AF_UNIX container socket capture, UDP `sendmsg`/`sendmmsg`, expanded secrets (.gnupg, cloud tokens), full MCP001–MCP062 catalog, and PyPI / npm / MCP Registry release.
Canary `$HOME` isolation by default, mandatory `--unsafe-host` guardrails, command allowlisting for MCP server `serve` mode, and transparent open scoring formulas.
Containerized audit by default (Docker / Podman / bubblewrap), Linux eBPF backend to trace statically linked binaries (Go, musl Rust) and raw syscalls, network namespaces with DNS exfiltration logging, and a public Evasion Benchmark Suite (`targets/evasion/`).
`mcp-behave init` (`mcp-behave.lock`) behavior lockfile generation, official `navid72m/mcp-behave-action@v1` for automated PR diff comments, open MCP-BehaveBench benchmark, and declared-behavior capability manifest proposal.
Join security engineers and server authors adopting runtime behavioral verification. Zero compiler setup, instant execution.