Mcpguard Dynamic logo

Mcpguard Dynamic

Organization
facebook

Kernel-level eBPF sandbox for securing LLM agent tool calls made through the Model Context Protocol (MCP)

Publisherfacebook
Repositorymcpguard-dynamic
LanguageC
Forks
11
Stars
75
Available tools
0
Transport typestdio
LicenseMIT
Links
  • Connect tools to AI workflows

    Mcpguard Dynamic exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    75 stars and 11 forks from the linked repository.

MCPGuard-Dynamic

Kernel-level sandboxing for LLM agent tool calls made through the Model Context Protocol (MCP).

MCPGuard sits as a transparent proxy between an MCP client (the agent / runner) and an MCP server subprocess, applying three layered defenses to every tool invocation. The lowest layer is implemented in eBPF and enforces capability policies at the system-call boundary, so a malicious MCP server cannot bypass policy by hardcoding sensitive behavior inside its own implementation.

This repository contains the proxy, the eBPF programs, the 14-server / 82-case benchmark, and the evaluation harness used in the accompanying paper Kernel-Level Sandboxing for LLM Agent Tool Calls via eBPF.

Architecture

LayerComponentPurpose
L1proxy/policy_engine.pyPer-server capability policy derived from each tool's MCP schema; allowlists for paths, network destinations, processes, env vars.
L2proxy/argument_validator.pyApplication-level inspection of tool-call arguments: path canonicalization, URL validation, prompt-injection detection, env-leak / command-injection detection, sensitive-key scanning, response sanitization.
L3ebpf/*.bpf.c + proxy/ebpf_sandbox.pyOS-level enforcement: three BPF LSM programs (file_guard, net_guard, proc_guard) intercept open() / connect() / execve(), and one tracepoint program (fork_guard) tracks child processes via sched_process_fork so policy carries across forks.

Six switchable defense configurations (proxy/proxy_base.py) cover the ablation space used in the paper: C0 (passthrough), C-AB (AgentBound baseline), C-app (L1 + L2), C-ebpf (L3 only), C-full (L1 + L2 + L3), C-AB+ebpf (AgentBound + L3).

Repository Layout

.
├── proxy/        L1 policy engine, L2 argument validator, L3 eBPF controller, AgentBound baseline
├── ebpf/         BPF C sources for file/net/proc/fork guards + Makefile + vmlinux.h
├── policies/     Per-server JSON capability policies (defaults + overrides)
├── servers/      14 MCP servers: 11 Python (filesystem, notes, weather, shell, sqlite, git, env + malicious/trojan variants) + 3 JavaScript (servers/js/)
├── test_cases/   82 benchmark scenarios across 7 categories (file_read, exfiltration, env_leak, sandbox_escape, priv_escalation, cross_language, benign)
├── notes_data/   170 valid synthetic notes JSON fixtures used by notes_server
├── runner/       evaluate.py, aggregate.py, agentbound_check.py, ebpf_edge_tests.py, latency_benchmark.py, override_workflow.py, smoke_test.py
└── EXECUTION_PLAN.md   Phase-by-phase reproduction instructions

Requirements

  • Linux kernel 6.x with BPF LSM enabled (CONFIG_BPF_LSM=y, lsm=bpf in kernel cmdline)
  • clang 21 or newer with BPF target
  • bpftool for loading BPF programs and maps
  • Python 3.12 (standard library only — no third-party deps)
  • Node.js 16+ (only for the JavaScript MCP servers under servers/js/)

Quick Start

bash
# Build the eBPF programs
cd ebpf && make && cd ..

# Smoke test (one server, a handful of cases)
python3 runner/smoke_test.py

# Full benchmark for one configuration
python3 runner/evaluate.py --config C-full --run-id trial

# Aggregate a reproduced run
python3 runner/aggregate.py --run-id trial

# Reproduce the steady-state latency table after installing eBPF
sudo python3 runner/latency_benchmark.py --run-id codex_20260523_latency --iterations 100 --warmup 20

# Reproduce the audit/override workflow
python3 runner/override_workflow.py --run-id codex_20260523_override

# Run focused eBPF edge tests after installing eBPF
sudo python3 runner/ebpf_edge_tests.py --run-id codex_20260523_ebpf_edges

# Run AgentBound-style baseline conformance checks
python3 runner/agentbound_check.py --run-id codex_20260523_agentbound

C-ebpf, C-full, and C-AB+ebpf now fail closed if the BPF LSM programs and pinned maps are unavailable. Run them only after installing the eBPF layer with root privileges.

Headline Results

Attack Prevention Rate (APR), viable-attack APR (V-APR), and False Positive Rate (FPR) for the single pinned run codex_20260523_full (14-server, 82-case benchmark; this is the fx_r per-category profile — the paper's Table 1 reports N=5 means, so C-app here reads 13/48 vs the 12/48 mean):

ConfigAPRV-APRViable blockedFPR
C021.3%0.0%0/480/21
C-AB37.7%20.8%10/480/21
C-app42.6%27.1%13/480/21
C-ebpf60.7%50.0%24/480/21
C-full68.9%60.4%29/480/21
C-AB+ebpf67.2%58.3%28/480/21

APR includes attacks that fail intrinsically under C0. V-APR uses only attacks that succeed under C0 as the denominator, which is the more conservative measure of defense coverage.

The repeated benign-call latency benchmark is stored in the internal paper workspace as results/latency/codex_20260523_latency.md. It measures BN-01 (filesystem_server.read_file) with 20 warmup calls and 100 measured calls per configuration; C-full adds +0.488 ms median latency relative to C0 and remains at 1.141 ms p95 for this fixed benign call. The public CodeSync tree excludes results/, so external users regenerate this artifact with the command above.

The audit/override workflow is stored internally as results/audit/codex_20260523_override.md. It demonstrates how a benign denial is recorded as a structured audit event and resolved by adding a scoped operator override under policies/overrides-compatible layout.

Focused eBPF edge tests are stored internally as results/ebpf_edges/codex_20260523_ebpf_edges.md. They cover fail-closed map availability, workspace write allow behavior, directory-prefix boundary denial, /tmp staging denial, and localhost exfiltration denial.

The AgentBound-style baseline check is stored internally as results/agentbound/codex_20260523_agentbound.md. It documents that C-AB is a per-server, application-level reproduction and verifies the expected argument-visible coverage and implementation-hidden blind spot.

Threat Model

The MCP server is treated as untrusted. It may be benign-but-misconfigured, intentionally malicious, or a trojanized fork of a legitimate server. The agent / runner and the host OS are trusted. The eBPF layer assumes the kernel is uncompromised; in-kernel privilege escalations (CWE-269 in kernel modules) are out of scope.

Citation

A BibTeX entry will be added here once the paper is published.

Contributing

See CONTRIBUTING.md. All contributors must sign Meta's CLA.

Security

To report a security issue, see SECURITY.md. Please do not file public GitHub issues for security reports.

License

MIT — see LICENSE.

Use Mcpguard Dynamic MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Mcpguard Dynamic is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Mcpguard Dynamic as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Mcpguard Dynamic MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "mcpguard-dynamic": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Mcpguard Dynamic MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Mcpguard Dynamic MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Mcpguard Dynamic to help me with this task?
Mcpguard Dynamic
Sure. I read it.
Here is what I found using Mcpguard Dynamic.

Frequently asked questions

What is the Mcpguard Dynamic MCP server used for?

Mcpguard Dynamic is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Mcpguard Dynamic MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Mcpguard Dynamic with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Mcpguard Dynamic MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Mcpguard Dynamic connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Mcpguard Dynamic MCP to TypingMind?

Mcpguard Dynamic runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Mcpguard Dynamic MCP provide in TypingMind?

Mcpguard Dynamic exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Mcpguard Dynamic MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Mcpguard Dynamic requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇