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
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.