zero-trust-mcp

zero-trust-mcp

A lightweight, local-first MCP server that enforces zero-trust data privacy for AI agents by encrypting tool call payloads locally using AES-256-GCM and persisting them to a local SQLite database.

Category
访问服务器

README

Zero-Trust Model Context Protocol (MCP) Integration Server

A lightweight, local-first Model Context Protocol (MCP) server built in Python that enforces zero-trust data privacy for AI agents.

By intercepting tool calls prior to cloud transmission, this server encrypts payloads locally using AES-256-GCM and persists them to a local SQLite database. Sensitive contextual data stays encrypted at rest, gated behind an access token, and every access attempt is actively logged.

🔑 Key Features

  • Model Context Protocol (MCP) Native: Exposes secure tools over standard I/O (stdio) via FastMCP.
  • Zero-Trust Encryption: AES-256-GCM with random 96-bit nonces for authenticated local encryption.
  • Password-Derived Keys: The encryption key is derived from a master password via scrypt, using a salt persisted in the database — ensuring the vault survives server restarts.
  • Access Control: Every tool call (secure_store, secure_retrieve, audit_recent) requires a valid HMAC access token, verified in constant time to resist timing attacks.
  • Audit Logging: Every store/retrieve attempt — successful or not — is written to an append-only audit_log table to ensure complete observability.
  • Live Security Dashboard: Includes a lightweight FastAPI web interface to visually monitor the SQLite audit trail in real-time.
  • AI Client Simulator: An async Python client (ai_client.py) demonstrating programmatic tool-calling over the MCP standard, including rejected-token handling.

📁 Repository Structure

├── crypto_engine.py      # AES-256-GCM + scrypt key derivation
├── access_control.py     # Constant-time access token verification
├── audit_log.py          # Append-only audit trail logic
├── mcp_server.py         # FastMCP protocol server & SQLite DB logic
├── ai_client.py          # Async AI Agent simulator acting as an MCP client
├── dashboard.py          # FastAPI web UI for visualizing security logs
├── test_mcp.py           # Unit tests for crypto, access control, and audit logs
├── .env.example          # Template for required environment variables
├── .gitignore            # Git ignore rules
└── requirements.txt      # Core dependencies

🧠 Threat Model

What this protects against:

  • Data at Rest Theft: Secrets sitting in vault.db are unreadable if the file alone is stolen (they're AES-256-GCM ciphertext, keyed off a password never written to disk).

  • Tampered Ciphertext: GCM is authenticated — tampering causes decryption to fail loudly rather than silently returning garbage.

  • Unauthorized Tool Calls: No access token, no data.

What this does not protect against:

*A compromised local environment that already holds the master password and access token in memory.

*Multi-tenant isolation — right now there is one shared secret vault, not per-agent scoped secrets.

*Network-level threats — this is a local stdio server, not exposed over a network by default.

🛠️ Setup & Usage

  1. Install Dependencies
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
  1. Configure Environment Create a .env file in the root directory and add your passwords (the scripts will auto-load this using python-dotenv):
ZTMCP_MASTER_PASSWORD=your_secure_password
ZTMCP_ACCESS_TOKEN=your_secure_token
  1. Run the AI Client Simulator Watch the automated client connect to the MCP server, authenticate, and securely process data.
python ai_client.py
  1. View the Audit Dashboard Launch the FastAPI server to view real-time access logs.
uvicorn dashboard:app --reload --port 8000
# Open http://127.0.0.1:8000 in your browser
  1. Run the Test Suite
python -m unittest test_mcp.py -v

🚀 Roadmap

  • Per-Agent Identity: Transition from one shared token to agent-specific tokens to log which agent accessed what.

  • Secret Expiry / TTL: Allow secure_store to take an optional expires_at timestamp.

  • Rate Limiting: Throttle brute-force loops against secure_retrieve.

  • Key Rotation: Build a rotate_key tool that re-encrypts all secrets under a new password/salt.

  • OS Keyring Integration: Swap SQLite salt storage for OS keyring integration (e.g. via the keyring package).

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选