mcp-behave
Runtime behavioral auditor for MCP servers. Runs an MCP server under
a runtime tracer (macOS dylib, Linux LD_PRELOAD, or strace), exercises
every tool / resource / prompt it advertises, and then compares what it
declared against what it actually did — file reads, network egress, subprocess
execution.
Static scanners read tool descriptions. mcp-behave watches behavior.
See
ARCHITECTURE.mdfor module dependency, data-flow, and sequence diagrams of the audit pipeline.
The idea in one contrast
targets/leaky_server.py and targets/honest_server.py advertise the
identical tool:
format_note— "Formats a markdown note. Purely local text formatting."
A static scanner reads two harmless tools. mcp-behave sees the difference:
| Target | network egress | sensitive file read | findings |
|---|---|---|---|
honest_server |
none | none | 0 |
leaky_server |
93.184.216.34:80 |
~/.ssh/id_rsa (a canary) |
2 HIGH |
The honest server producing zero findings matters as much as the leaky one tripping two — false positives would kill credibility.
Install
pip install mcp-behave
Tracer Requirements
- macOS: Works natively without
straceor root using an injected dylib (DYLD_INSERT_LIBRARIES). Built automatically on first use withcc(Xcode Command Line Tools). - Linux: Works natively without
straceorSYS_PTRACEusing anLD_PRELOADshared library. Built automatically on first use withcc(e.g.gcc). If no compiler is available,straceis used as a fallback if installed onPATH. - Untraced mode: Run on any platform with
--no-tracefor manifest inspection and rug-pull checks without any runtime tracer.
Use
# Audit any stdio MCP server -- pass its launch command:
mcp-behave python -m mcp_server_fetch
mcp-behave npx -y @modelcontextprotocol/server-filesystem /tmp
mcp-behave uvx mcp-server-git
# Run untraced (manifest & rug-pull analysis only, no tracer needed):
mcp-behave --no-trace python -m mcp_server_fetch
# Machine-readable output for CI:
mcp-behave --json --fail-on high python -m mcp_server_fetch
# Connect to an already-running remote server (manifest analysis only,
# no syscall trace possible):
mcp-behave --transport sse http://localhost:8000/sse
Exit codes: 0 clean, 3 findings at or above --fail-on threshold,
2 tracer setup failed, 1 other error.
Useful flags
--no-trace— skip syscall tracing and run manifest analysis only.--tracer {auto,preload,dylib,strace,none}— choose tracer backend explicitly (defaultauto).--json— emit findings as JSON on stdout.--fail-on {never,info,high}— severity that triggers exit code 3 (defaulthigh).--no-dns— skip reverse-DNS lookups (faster, offline-safe).--timeout SECONDS— per-call timeout (default 15).--transport {stdio,sse,streamable-http}— remote transports skip syscall tracing.--out-dir PATH— wheremanifest.jsonandtrace.logare written.
Push results to a dashboard
mcp-behave push uploads a JSON audit result to an
mcp-behave dashboard.
# 1. Sign in at https://<your-dashboard>.vercel.app/settings and mint a token.
export MCP_BEHAVE_DASHBOARD_URL=https://<your-dashboard>.vercel.app
export MCP_BEHAVE_TOKEN=mcpb_...
# 2. Audit something with --json and pipe it to push.
mcp-behave --json python -m mcp_server_fetch \
| mcp-behave push --server-name server-fetch --category network
# Or save to a file first, then push.
mcp-behave --json python -m mcp_server_fetch > audit.json
mcp-behave push audit.json --server-name server-fetch --category network
Flags worth knowing:
--server-name NAME— canonical name on the dashboard. Defaults to the joined server command from the audit JSON; usually you want to set this.--description TEXT— used the first time this server is submitted.--github-url URL,--npm-package PKG,--author NAME— optional server metadata.--category {local,network,database,other}— defaults toother.--dry-run— print the JSON payload that would be POSTed and exit.
The endpoint is rate-limited per token (20 req/min); push exits 1 on HTTP error
and prints the response body to stderr.
What it detects
- Undeclared network egress — IP:port destinations reached during tool calls (reverse-DNS resolved in findings when available).
- Sensitive-path reads —
~/.ssh/*,~/.aws/*,~/.env,~/.netrc, etc. - Rug-pull — the declared manifest hash changes between runs of the same
server (e.g. a tool's description silently changes after the user trusts it).
Hashes persist under
$XDG_DATA_HOME/mcp-behave/manifests/.
Findings are framed as observations ("does X, undeclared"), never accusations.
Docker (works on macOS / Windows hosts)
docker build -t mcp-behave .
# default: runs the bundled leaky target so you can see findings immediately
docker run --rm mcp-behave
# point at a real server
docker run --rm mcp-behave python -m mcp_server_fetch
The container automatically compiles and runs the native LD_PRELOAD tracer
without needing --cap-add=SYS_PTRACE. If you explicitly use --tracer strace,
--cap-add=SYS_PTRACE is required.
The image bundles Node.js (for npx servers), uv (for uvx servers), and
sandbox canary files (sandbox_home/) mounted as $HOME so credential reads
are detectable.
Development
pip install -e ".[test]"
pytest -v
CI tests across Ubuntu and macOS; see .github/workflows/ci.yml.
Known limits
- Runtime tracing requires macOS (DYLD interposition) or Linux (LD_PRELOAD / strace).
Windows and other platforms can run with
--no-tracefor manifest and rug-pull checks. An eBPF backend for system-wide capture is on the roadmap — see ROADMAP.md. - stdio is the only transport with syscall tracing.
sseandstreamable-httpconnect to a remote server we cannot trace; only manifest analysis and rug-pull detection apply there. - Input synthesis is heuristic — JSON Schema
format, key-name hints, and type defaults. Schema-coverage fuzzing (hypothesis-jsonschema) is roadmap. - AF_UNIX egress isn't matched — a server exfiltrating over a unix domain socket would slip past the current network detection.
- Single call per capability — servers that misbehave only on specific inputs or after N calls may not be triggered.
License
MIT. See LICENSE.
Metadata
Release files for mcp-behave 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcp_behave-0.1.4.tar.gz | 33.9 kB | With provenance | Details for mcp_behave-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcp_behave-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for mcp_behave-0.1.4-py3-none-any.whl |
Total release size: 62.5 kB
Release files / mcp_behave-0.1.4.tar.gz
| Download URL | mcp_behave-0.1.4.tar.gz |
|---|---|
| Size | 33.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e5aad9fd71d2006a83fede18ede55d77c80cc4ee3da9b831a5836170c06dd58c
|
|
BLAKE2b-256 checksum How to use checksums |
3df5031188b34b61547209dd79cc28c0a2ca0cfa11bdd191f0633b7933a0b490
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logRelease files / mcp_behave-0.1.4-py3-none-any.whl
| Download URL | mcp_behave-0.1.4-py3-none-any.whl |
|---|---|
| Size | 28.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6deae7beb6a8acf4298c2c3acea8ec7c5a7dfd214150856e2e0e256682eaf0e7
|
|
BLAKE2b-256 checksum How to use checksums |
d1580b1aba1bc6456d7e9e9983a5a1716ceb560d034bd3f340826b754fde1b7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logSecurity for mcp-behave 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mcp_behave-0.1.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.