mcp-behave
Know what your MCP servers actually do — not just what they say they do.
An open-source runtime security auditor for the Model Context Protocol (MCP). Observe file access, network connections and process activity; detect behavioral drift; and investigate retained activity directly from your AI assistant.
Try the demo · Monitor your client · Ask your AI assistant · Docs · Give feedback
Why mcp-behave?
An MCP tool can declare itself read-only, yet the code behind it may write files, launch processes or access the network. Tool descriptions and annotations are useful hints, not an enforcement boundary. A server update can also change runtime behavior without changing its tool descriptions.
mcp-behave helps reveal that gap:
| What a tool declares | What runtime observation may reveal |
|---|---|
| “Read a document” | Expected file reads |
readOnlyHint: true |
An unexpected file write |
| “Works locally” | A connection to an external host |
Illustrative examples, not findings against a particular server.
Quick setup
Configure monitoring and the security assistant in one step:
bash uvx mcp-behave@0.7.0 setup
Supports Claude Desktop, Claude Code, Cursor, Codex, Antigravity, Gemini CLI, VS Code, Cline, Roo Code, Windsurf and Zed.
Preview changes without modifying your configuration:
bash uvx mcp-behave@0.7.0 setup --dry-run
Try it yourself
No AI client, API key or existing MCP server required. Use a controlled synthetic fixture that simulates a server update: the tool metadata and response stay the same, but its runtime behavior changes.
You need uv, a compatible macOS/Linux runtime and a C compiler (Xcode Command Line Tools on macOS; a build toolchain such as build-essential on Debian/Ubuntu).
git clone https://github.com/navid72m/mcp-behave.git
cd mcp-behave
uv run --managed-python --script examples/demo/demo.py
The demo pins v0.6.0 and the tested MCP SDK. The first run downloads dependencies and may install Python 3.12; subsequent runs can reuse the cache. It does not modify your MCP client configuration.
What you'll see:
- A clean behavioral baseline is recorded.
- The unchanged server passes verification.
- The simulated update writes a synthetic file. The real
checkcommand must identify that exact write, return exit code3, and report the same manifest hash.
This is detection, not prevention. If tracing is unavailable or the expected evidence is missing, the demo reports an inconclusive result rather than a pass. Demo details and troubleshooting
Use it with your own MCP server
| Workflow | When to use it |
|---|---|
| Audit | Before connecting: probe declared versus observed behavior. |
| Wrap | During execution: observe live tool calls and runtime activity. |
| Serve | Investigate retained activity from your AI client. |
Install or run a published version:
uvx mcp-behave@0.6.0 --version
# or
python -m pip install mcp-behave==0.6.0
An npm launcher is also available. It delegates to Python and does not currently guarantee a matching Python package version. Prefer a pinned uvx or pip installation when reproducibility matters.
Audit before connecting
Replace the example target with the command that normally launches your MCP server:
uvx mcp-behave@0.6.0 audit -- python -m your_mcp_server
The audit discovers tools, exercises their schemas and reports observed runtime activity, findings and confidence limitations. Use --json or --sarif for machine-readable output.
Safety: An audit executes target code and may invoke mutating tools. Use synthetic data in a disposable environment. For an untrusted target, use an isolated container or VM with appropriate filesystem and network restrictions. Canary HOME redirection is not a sandbox, and
--sandbox autocan fall back to unsandboxed execution.
Monitor your AI client
Guided setup (development preview): configure monitoring and the optional local security assistant together, with a preview and private rollback backup. From a repository checkout, run:
uv run mcp-behave setup --dry-run
uv run mcp-behave setup
The wizard is not yet part of the published v0.6.0 package. See the setup guide for supported clients, prerequisites and rollback. It does not verify native tracing or start target servers.
wrap is the runtime monitoring proxy. Unlike a one-time audit, it observes supported native file, network and process activity while your AI client calls MCP tools.
Option A — Wrap a local stdio server manually
Prefix your existing launch command with mcp-behave wrap:
uvx mcp-behave@0.6.0 wrap --server my-server -- python -m your_mcp_server
Use this as your MCP client's launch command, not as an interactive terminal application. For a controlled filesystem example (requires Node.js/npm):
mkdir -p /tmp/mcpb-demo-files
uvx mcp-behave@0.6.0 wrap --server filesystem-demo \
-- npx -y @modelcontextprotocol/server-filesystem@2.4.1 /tmp/mcpb-demo-files
Example MCP client configuration for the same command:
{
"mcpServers": {
"filesystem-demo": {
"command": "uvx",
"args": [
"mcp-behave@0.6.0", "wrap",
"--server", "filesystem-demo",
"--", "npx", "-y",
"@modelcontextprotocol/server-filesystem@2.4.1",
"/tmp/mcpb-demo-files"
]
}
}
}
Create the fixture directory first. Merge this entry into your existing client configuration. If the client cannot find uvx or npx, use their absolute paths (command -v uvx, command -v npx) and ensure Node.js is on the client's PATH. Restart the client and ask it to create a synthetic hello.txt in the fixture directory. The example enables monitoring, not enforcement or OS isolation.
Option B — Automatically configure an existing server
Already using Claude Desktop? Check the configuration and preview changes. Replace filesystem with the actual configured server name:
uvx mcp-behave@0.6.0 status --client claude
uvx mcp-behave@0.6.0 install filesystem --client claude --dry-run
If the preview is correct, enable monitoring, then restart the client:
uvx mcp-behave@0.6.0 install filesystem --client claude
Undo the integration:
uvx mcp-behave@0.6.0 uninstall filesystem --client claude
Where does the telemetry go?
~/.local/state/mcp-behave/
├── sessions/
│ └── <session-id>.jsonl
└── telemetry.db
The default follows $XDG_STATE_HOME when set. Use --state-dir /absolute/path/to/state to choose a different location. Telemetry may contain private information; keep it local and review coverage before drawing conclusions. For other clients, see integration examples.
Ask your AI assistant
New in v0.6.0: query the retained runtime telemetry through MCP. After wrapping a server, add a separate local stdio entry for the security assistant. Example for clients using an mcpServers configuration (replace the executable path with the output of command -v uvx):
{
"mcpServers": {
"mcp-behave-security": {
"command": "/absolute/path/to/uvx",
"args": ["mcp-behave@0.6.0", "serve"]
}
}
}
Merge the entry into your existing configuration rather than replacing your servers. If your proxy uses an explicit --state-dir, give serve the same directory. Restart your client and generate some monitored activity, then ask:
What MCP server activity was recorded in the last 24 hours? Investigate the latest session and explain any coverage gaps.
The assistant can list recorded servers, summarize retained sessions, query event categories and surface reported telemetry gaps. It does not infer complete coverage, live server status or tool success from incomplete records. Detailed runtime fields are opt-in and may contain sensitive or adversarial content; keep the assistant local and trusted. Active audit execution is denied by default unless the operator explicitly authorizes it.
Try both together: Wrap + Serve walkthrough or run uv run --managed-python --script examples/demo/wrap_serve.py from a clone to exercise the real MCP protocol without an AI client.
How it works
AI client <──> mcp-behave wrap <──> MCP server
│ │
│ native runtime events
▼ │
JSONL + SQLite <──────┘
│
▼
MCP security assistant
| Capability | Use it for |
|---|---|
audit |
Probe a server and review observed behavior |
wrap |
Monitor live local tool calls and runtime events |
init / check |
Detect changes against a reviewed behavioral baseline |
serve |
Investigate retained activity from an MCP client |
--json / --sarif |
Integrate auditing into CI |
--enforce |
Apply a reviewed multi-server lockfile to covered protocol actions |
Validation and limitations
The project-maintained v0.6.0 candidate evaluation reported:
- 557 macOS source tests passed; 549 Linux source tests passed (8 skipped).
- 40/40 selected real-server monitoring scenarios and 40/40 fail-open compatibility scenarios matched expected success/error status across MotherDuck, Excel, Qdrant, DBHub, MCP Memory Service and Desktop Commander.
- JSON and SARIF output parsed for all six targets; retained telemetry storage checks matched across 22 recorded sessions (including two previous-version sessions).
These are selected compatibility and regression tests, not independent certification or exhaustive security verification. Strict fail-closed initialization halted on native telemetry backpressure for all six targets in the tested container setup, in both v0.5.8 and v0.6.0. Automated audit coverage for Memory Service was degraded by an unavailable embedding backend. Randomized temporary paths can trigger behavioral baseline differences.
Native tracing observes selected library calls on compatible macOS and Linux runtimes. Direct syscalls, static binaries, macOS SIP and hardened runtimes can limit coverage. Remote audits do not trace the remote host. A clean audit is not proof of safety. Native activity is observed, not universally blocked or undone; protocol enforcement and OS sandboxing are separate controls. Fail-open compatibility is not proof of inline blocking. Review coverage and policies before enabling enforcement.
Historical validation · Benchmarks · Security policy
Documentation
| Resource | Details |
|---|---|
| Architecture | Runtime engine and data flow |
| CLI reference (v0.5.8) | Advanced setup, sandbox semantics and probe profiles |
| Detection matrix | Detection rules and coverage |
| Integration examples | Real-server fixtures and configurations |
| Technical whitepaper · Research article | Background and experiments |
| Changelog · Roadmap | Project changes and planned work |
Help shape the project
Tried the demo? We'd like to hear from you. Even if it didn't work, your feedback helps improve onboarding.
- What operating system and MCP client are you using?
- Did the demo work? Where did you get stuck?
- Which server or security question would you like to investigate next?
Share your experience in GitHub Discussions · Report a reproducible bug
Do not share private telemetry or credentials. Report vulnerabilities privately as described in SECURITY.md.
Contributions are welcome. For development, install with python -m pip install -e ".[test]" and run pytest -v.
MIT — License.
Metadata
Release files for mcp-behave 0.7.0
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.7.0.tar.gz | 205.2 kB | With provenance | Details for mcp_behave-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcp_behave-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for mcp_behave-0.7.0-py3-none-any.whl |
Total release size: 431.3 kB
Release files / mcp_behave-0.7.0.tar.gz
| Download URL | mcp_behave-0.7.0.tar.gz |
|---|---|
| Size | 205.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca1daa8fcaa34b1409a0853174412845a9b4eae7e0c31276a55f6b91e3d336f0
|
|
BLAKE2b-256 checksum How to use checksums |
8e8d5e1ad99c6ed478a168b0036dc50503d5f4f1b1878ae3b4e50ef10c8a2479
|
| 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 30, 2026.
Transparency logRelease files / mcp_behave-0.7.0-py3-none-any.whl
| Download URL | mcp_behave-0.7.0-py3-none-any.whl |
|---|---|
| Size | 226.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7e99e3bbca1f732cbbafb960effea53854e41958c145685e589e63238589920
|
|
BLAKE2b-256 checksum How to use checksums |
a3f5b1cf710847ce97be1a99a40e2105d46a960628b1d54e96bcc2384e47db3a
|
| 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 30, 2026.
Transparency logSecurity for mcp-behave 0.7.0
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.7.0.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 30, 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.