Sponsored by Deepsite.site

PrivAgents: Agents and MCP servers for Confidential AI Workflows

Created By
UvrajSB8 months ago
PrivAgents is a privacy-first framework where intelligent agents interact with a secure MCP (Model Computation & Processing) server to perform encrypted data analysis using homomorphic encryption.
Content

PrivAgents: Agents and MCP servers for Confidential AI Workflows

PrivAgents is a privacy-first framework that showcases how autonomous agents, both on-device and in the cloud, can perform secure data processing through trustless MCP servers while ensuring complete confidentiality. It leverages Privacy-Enhancing Technologies (PETs) herein Homomorphic Encryption (HE) to compute on encrypted data without ever accessing raw information.

Through a conversational agent interface, user data is encrypted on the device, sent to a secure processing unit (MCP), and the results are returned in encrypted form to be decrypted locally. This creates a secure and intelligent system for sensitive environments such as healthcare, personalization, and finance.

PET enabled MCP server


🔐 Why PrivAgents

On-device models offer privacy but are often limited in power. Cloud models offer power but raise trust concerns. PrivAgents solves this by combining the strengths of both:

  • On-device or cloud-based agents to suit your compute and trust needs
  • Homomorphic encryption ensures data remains private during processing
  • Modular MCP server performs encrypted similarity calculations on the backend
  • End-to-end encrypted pipeline for secure data interaction

⚙️ Supported Agents

  • Ollama Agent for on-device reasoning using local models
  • OpenAI Agent for cloud-based intelligence via API

Choose your agent type based on privacy constraints and available resources.


🧠 Architecture Overview

      +------------------------+
      |     User Device        |
      |  (Agent + Encryption)  |
      +------------------------+
         |   Encrypted Input
         v
+------------------------+   ← Secure Channel →
|     MCP Server         |  (Encrypted Similarity Calculation)
+------------------------+
         |   Encrypted Result
         v
      +------------------------+
      |  User Device (Decrypt) |
      +------------------------+

📁 Project Structure

PrivAgents/
├── agent/           # Ollama and OpenAI agent implementations with PET tools
├── mcp/             # Encrypted processing logic for similarity-based analysis
├── utils/           # Context setup, encryption helpers
├── data/            # Sample inputs and encrypted output files
└── .env             # Configuration for ports and logging

🚀 Getting Started

1. Clone and Set Up

git clone https://github.com/UvrajSB/PrivRec.git
cd PrivRec
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

2. Start the MCP Server

From the root directory:

PYTHONPATH=. python mcp/server.py

3. Run an Agent

  • Ollama Agent (Local Execution)
PYTHONPATH=. python agent/ollama_mcp_agent.py
  • OpenAI Agent (Cloud Execution)
PYTHONPATH=. python agent/openai_mcp_agent.py

Each agent encrypts the user input, sends it for encrypted similarity calculation, and decrypts the response privately on-device.


🎬 Movie Preference Matching: Encrypted End-to-End Personalization

The movie preference matching use case is a working demonstration of how privacy-preserving recommendation systems can function without accessing user data in plaintext. It showcases the end-to-end use of homomorphic encryption to encrypt user preferences, run secure similarity calculations, and deliver personalized results—all while ensuring zero exposure of raw data.


🔁 Workflow Overview

  1. User inputs a movie interest vector
    The user is asked to rate or prioritize different genres (e.g. Action, Romance, Sci-Fi). For example:

    [8, 2, 9] → represents user's preference intensity across three genres.
    
  2. Encryption on the agent side
    The agent (either Ollama or OpenAI based) uses TenSEAL to homomorphically encrypt the interest vector using the BFV scheme. The result is an encrypted tensor, unreadable even to the server.

  3. Encrypted similarity calculation on the MCP server

    • The MCP server has a collection of predefined movie profiles, each represented as a plaintext vector:
      MOVIES = {
        "Inception":     [9, 1, 8],
        "The Notebook":  [1, 9, 2],
        "Interstellar":  [8, 2, 9],
        "The Godfather": [7, 5, 4]
      }
      
    • It performs encrypted similarity calculations between the encrypted user vector and each plaintext movie profile.
    • This similarity is computed using a dot product under encryption, without decrypting the user vector.
  4. Encrypted results are returned
    The server writes the encrypted similarity scores for all movies to a file, for example:

    data/interest_results
    
  5. Decryption on the user device
    The agent loads the encrypted results and decrypts them locally using the original context and keys. The decrypted scores represent how closely each movie matches the user's preferences.

  6. Optional: Rank and display results
    The agent can sort the scores and show the top movie recommendations based on similarity, all while ensuring the user's input and preferences were never visible to the server.

Terminal

📦 Benefits

  • Zero Trust Required: Server never sees user data
  • Agent Agnostic: Works with both on-device and cloud-based LLM agents
  • Extendable: Can support more complex user profiles or additional domains (like music, shopping, healthcare)
  • Educational: Demonstrates how homomorphic encryption works in a practical context

👥 Contributing

Interested in building secure and intelligent systems with PETs? Whether it is extending agent logic, experimenting with new encrypted workflows, or refining the MCP layer, your contributions are welcome. Fork the repo and get started.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Serper MCP ServerA Serper MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Amap Maps高德地图官方 MCP Server
ChatWiseThe second fastest AI chatbot™
Tavily Mcp
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
CursorThe AI Code Editor
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Playwright McpPlaywright MCP server
WindsurfThe new purpose-built IDE to harness magic
DeepChatYour AI Partner on Desktop
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"