MCPSpy
MCP Monitoring with eBPF
claude mcp add --transport stdio alex-ilgayev-mcpspy docker run --rm -i ghcr.io/alex-ilgayev/mcpspy:latest
How to use
MCPSpy is a real-time monitoring tool for Model Context Protocol (MCP) communications, built on eBPF to observe MCP traffic at kernel level. It focuses on the JSON-RPC 2.0 messages exchanged between MCP clients and servers over supported transports (Stdio and HTTP/HTTPS, including Server-Sent Events). When you run MCPSpy, you’ll get real-time visibility into MCP message flows, with options to disable the TUI, output JSONL logs, and run security analyses for prompt-injection and potential data leakage. Use the default TUI mode for interactive exploration, or pipe JSONL output for automated parsing and integration with your observability stack. If you enable security features, MCPSpy can leverage a HuggingFace model via an API to detect prompt-injection patterns in both tool calls and tool responses.
How to install
Prerequisites:
- Linux kernel version 5.15 or later
- Root privileges (required for eBPF)
Option A: Install and run from Docker (recommended to avoid host setup)
- Pull and run the latest MCPSpy image: docker pull ghcr.io/alex-ilgayev/mcpspy:latest docker run --rm -it --privileged ghcr.io/alex-ilgayev/mcpspy:latest
Option B: Build from source (requires Go and build dependencies)
- Install prerequisites:
- Go 1.24+ (see Go install steps below)
- clang/llvm, libbpf, build-essential, and Docker tools as needed
- Install Go (example for Linux): wget https://go.dev/dl/go1.24.1.linux-amd64.tar.gz sudo rm -rf /usr/local/go sudo tar -C /usr/local -xzf go1.24.1.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin
- Build MCPSpy:
git clone https://github.com/alex-ilgayev/mcpspy.git
cd mcpspy
make all
Run the built binary (if applicable):
sudo ./mcpspy
Option C: Docker-based Quick Start (manual build steps can be skipped if you use the image above)
- Build Docker image locally (from repo clone): make image
- Or pull prebuilt image as shown in Option A.
Additional notes
Tips:
- Ensure your host allows privileged containers or has appropriate CAP_NET_ADMIN capabilities for eBPF tracing.
- If you encounter kernel headers or build issues, confirm kernel headers match your running kernel and that libbpf-dev is installed.
- The security features rely on HuggingFace tokens. Provide a valid --hf-token when enabling --security, and consider setting a model with --security-model. The default threshold is 0.5; adjust with --security-threshold as needed.
- The Kubernetes deployment guide demonstrates monitoring MCP traffic from clusters; you may also run MCPSpy in standalone mode or via Docker for local testing.
- When using JSONL output (-o), you can tail the file or stream it into log aggregators for centralized analysis.
Related MCP Servers
edumcp
EDUMCP is a protocol that integrates the Model Context Protocol (MCP) with applications in the education field, dedicated to achieving seamless interconnection and interoperability among different AI models, educational applications, smart hardware, and teaching AGENTs.
lihil
2X faster ASGI web framework for python, offering high-level development, low-level performance.
AIDA
AI-Driven Security Assessment - Connect AI to 400+ pentesting tools via MCP
laravel-toon
TOON encoding for Laravel. Encode data for AI/LLMs with ~50% fewer tokens than JSON.
mcp-package-version
An MCP server that provides LLMs with the latest stable package versions when coding
mcp-web-ui
MCP Web UI is a web-based user interface that serves as a Host within the Model Context Protocol (MCP) architecture. It provides a powerful and user-friendly interface for interacting with Large Language Models (LLMs) while managing context aggregation and coordination between clients and servers.