How eqtylab/mcp-guardian works
Project Type and Purpose
• MCP Guardian is a multi-component Rust/TypeScript application for intercepting and controlling LLM “tool call” messages to external MCP servers.
• It consists of:
• A core library (mcp-guardian-core) that implements guard logic, profiles, caching, and a proxy engine.
• A CLI (mcp-guardian-cli) to manage profiles, servers, and collections.
• A background proxy service (mcp-guardian-proxy) that intercepts LLM traffic.
• A desktop GUI (mcp-guardian, built with Tauri + React/TypeScript) for real-time logging and manual approvals.
File Structure
• Top-level crates/directories:
• mcp-guardian-core: core logic and data structures
• mcp-guardian-cli: command-line interface
• mcp-guardian-proxy: daemon that delegates to the core proxy engine
• mcp-guardian: Tauri desktop app (Rust backend + React front-end)
• Shared configuration is read/written via the core library (config.rs, dirs.rs).
• Bindings under each crate connect the core structures to TypeScript or to CLI modules.
• The docs folder contains user guides but is not part of runtime architecture.
Extract Insights from README
• The system sits “in-line” between your LLM and MCP server endpoints.
• Features include:
• Message Logging
• Manual Approvals
• (Future) Automated Scanning
• The GUI communicates with the running proxy to display logs and send approval/deny commands.
Main Components & Interactions
a. Components:
1. LLM Client (e.g., ChatGPT, local LLM)—generates tool-call HTTP/TCP requests.
2. Proxy Service (mcp-guardian-proxy CLI or built-in in Tauri backend)—listens on localhost, forwards requests.
3. Core Library (mcp-guardian-core crate)—implements guard profiles, message interceptor pipeline, caching, and proxy engine.
4. Configuration Store (local filesystem via dirs.rs)—persists guard profiles, server collections.
5. CLI Application (mcp-guardian-cli)—CRUD on profiles, servers, and collections via core library APIs.
6. Desktop GUI (mcp-guardian):
• Front-end (React/TypeScript) — renders pages, dialogs, logs, pending messages.
• Tauri Backend (Rust) — invokes core library functions, starts/stops proxy, exposes a local HTTP/WS API to the front-end.
7. External MCP Server(s)—actual Minecraft-like or other tool-host servers.
b. Relationships & Data Flows:
• LLM Client → Proxy Service (request)
• Proxy Service → Core Library (intercept & apply guard logic)
• Core Library → Configuration Store (load profiles, record logs/cache)
• Core Library → External MCP Server (forward allowed messages)
• Proxy Service ←→ GUI (HTTP/WS API):
– GUI pulls logs, pending message lists
– GUI issues Approve/Deny commands
• CLI → Core Library → Configuration Store (manage profiles, servers, collections)
c. Architectural Patterns & Principles:
• Layered separation: Core library independent of presentation (CLI/GUI) and transport (proxy).
• Single source of truth for guard logic in the core crate.
• Reuse of core across three front-ends (CLI, proxy daemon, Tauri backend).
• Event-driven intercept pipeline for messages (chain of interceptors, filters, manual approval hooks).
• Configuration-as-code: JSON profiles under src/guard_profile/profiles.
d. Key Technologies:
• Rust (all back-end logic, CLI, proxy, Tauri backend)
• TypeScript + React (desktop UI)
• Tauri (bridging Rust & web UI into desktop app)
• nix + flakes, Justfile (build & dev environments)
• JSON files for default profiles and server definitions
Essential Details
• The interceptor pipeline in the core: filters, chain guards, manual approval hook, message logging.
• The core’s config directory layout (guard_profiles, mcp_servers, server_collections).
• How Tauri Backend spawns or integrates with the proxy engine versus the standalone mcp-guardian-proxy.
• Data flow of a tool-call request from client → proxy → core → server, and back with logs sent to GUI.