Secure MCP-gRPC
Provides a secure gRPC transport layer for the Model Context Protocol (MCP) with mutual TLS, token-based authentication, and fine-grained authorization. Includes comprehensive telemetry and a real-time visualization dashboard for monitoring AI model interactions and security events.
README
Secure MCP-gRPC
A secure gRPC transport layer for Model Context Protocol (MCP) with advanced security features, comprehensive telemetry, and real-time visualization.
Developed by Matthew Stanton & Claude AI
š Overview
The Model Context Protocol (MCP) enables AI models to communicate with external tools and data sources. This project adds a secure gRPC transport layer for MCP, providing:
- Enhanced Security: Zero-trust architecture with mutual TLS, token-based authentication, and fine-grained authorization
- Comprehensive Telemetry: Detailed insights into model interactions, performance metrics, and security events
- Visual Traffic Analysis: Real-time visualization of traffic patterns and model communication graphs
- Enterprise-Grade Features: Rate limiting, audit logging, anomaly detection, and more
š Table of Contents
- Features
- Architecture
- Prerequisites
- Quick Start
- Docker Deployment
- Manual Installation
- Configuration
- Security
- Monitoring
- Development
- Contributing
- License
⨠Features
š Security Features
- Mutual TLS Authentication: Secure client-server identification with certificate validation
- Token-based Authentication: Support for JWT and OAuth 2.0
- Fine-grained Authorization: Role-based access control for specific model capabilities
- Rate Limiting: Protection against DoS attacks with per-client limits
- Anomaly Detection: Identification of unusual patterns and potential threats
- Audit Logging: Comprehensive event tracking for compliance requirements
- Secure Defaults: All security features enabled by default with sensible configurations
š Telemetry Capabilities
- Performance Monitoring: Response times, throughput, and resource utilization tracking
- Security Event Logging: Authentication attempts, authorization failures, and suspicious activities
- Usage Analytics: Understanding how models are being used and by whom
- Health Monitoring: Real-time status of all system components
- Anonymous Reporting: Privacy-preserving aggregated insights
š Interaction Tracing
- Request/Response Capture: Full payload logging with configurable sanitization
- Connection Metadata: Detailed information about clients and sessions
- Path Traversal: Tracking of multi-model interaction chains
- Data Lineage: Understanding how data flows between models
- Timing Analysis: Performance bottleneck identification
š Visualization Dashboard
- Traffic Flow Diagrams: Sankey diagrams showing request patterns
- Model Interaction Networks: Graph visualization of model communication
- Security Event Heatmaps: Temporal analysis of security incidents
- Latency Distribution Charts: Performance profiles across different methods
- Real-Time Monitoring: Live updates on system status and metrics
šļø Architecture
The Secure MCP-gRPC system consists of several core components:
āāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā
ā AI Model with ā ā Secure MCP-gRPC ā ā AI Model with ā
ā MCP Client āāāāāāŗā Server āāāāāāŗā MCP Client ā
ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāā¬āāāāāāāāāā āāāāāāāāāāāāāāāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāā
ā Interaction ā
ā Tracer ā
āāāāāāāāāāā¬āāāāāāāā
ā
ā¼
āāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā
ā Prometheus āāāāāāŗā Telemetry āāāāāāŗā Dashboard ā
ā ā ā Dashboard ā ā ā
āāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāā
Key Components:
- Secure MCP-gRPC Server: Core server that handles authentication, authorization, and request processing
- Interaction Tracer: Captures detailed information about model interactions
- Telemetry Dashboard: Web-based visualization of traffic patterns and metrics
- MCP Clients: AI models that communicate with the server
- Prometheus/Grafana: Additional monitoring and alerting tools
š Prerequisites
- Docker and Docker Compose
- Python 3.9+ (for development)
- OpenSSL (for certificate generation)
- Git
- Pre-commit (optional, for development)
š Quick Start
-
Clone the repository:
git clone https://github.com/yourusername/secure-mcp-grpc.git cd secure-mcp-grpc -
Run the setup script:
./setup.sh -
Start the services:
docker-compose -f docker/docker-compose.yml up -d -
Access the services:
- gRPC Server: localhost:50051
- Dashboard: http://localhost:8050
- Grafana: http://localhost:3000
- Prometheus: http://localhost:9090
š³ Docker Deployment
Production Deployment
-
Build and start all services:
docker-compose -f docker/docker-compose.yml up -d -
View logs:
docker-compose -f docker/docker-compose.yml logs -f -
Stop services:
docker-compose -f docker/docker-compose.yml down
Service Details
- MCP Server: Secure gRPC server with mTLS authentication
- Dashboard: Real-time visualization of traffic and metrics
- Prometheus: Metrics collection and storage
- Grafana: Advanced metrics visualization and alerting
Resource Management
Each service has resource limits and reservations:
- MCP Server: 1 CPU, 1GB RAM
- Dashboard: 0.5 CPU, 512MB RAM
- Prometheus: 0.5 CPU, 1GB RAM
- Grafana: 0.5 CPU, 512MB RAM
āļø Configuration
Environment Variables
Key environment variables for the MCP server:
MCP_SERVER_HOST=0.0.0.0
MCP_SERVER_PORT=50051
MCP_AUTH_TYPE=mtls
MCP_CERT_PATH=/app/certs/server.crt
MCP_KEY_PATH=/app/certs/server.key
MCP_CA_PATH=/app/certs/ca.crt
Configuration Files
- Server config:
config/server.yaml - Prometheus config:
config/prometheus/prometheus.yml - Grafana config:
config/grafana/provisioning/
š Security
Certificate Management
-
Generate certificates:
./scripts/generate_certs.sh -
Update certificates:
./scripts/update_certs.sh
Security Best Practices
- Use strong passwords for Grafana
- Keep certificates secure and regularly rotated
- Monitor security events in Grafana
- Use rate limiting for all clients
- Enable audit logging
š Monitoring
Metrics
Key metrics available in Prometheus:
- Request rate
- Response time
- Error rates
- Resource utilization
- Security events
Dashboards
Pre-configured Grafana dashboards:
- Traffic Overview
- Performance Metrics
- Security Events
- Resource Usage
š©āš» Development
Local Development
-
Install development dependencies:
pip install -e ".[dev]" -
Run tests:
pytest tests/ -
Run benchmarks:
pytest tests/benchmarks/
Code Style
- Use Ruff for linting and formatting (replaces Black, isort, and flake8)
- Use mypy for type checking
- Follow PEP 8 guidelines
- Install pre-commit hooks:
pre-commit install
Run linting and formatting:
# Format code
ruff format .
# Lint and auto-fix
ruff check --fix .
# Type check
mypy secure_mcp_grpc
š¤ Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
See CONTRIBUTING.md for detailed guidelines.
š License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
š Acknowledgments
- Matthew Stanton: Lead architect and security expert
- Claude AI: Co-creator and documentation contributor
- Anthropic for their work on Model Context Protocol (MCP)
- The gRPC team for their excellent communication framework
For more detailed information, please refer to the documentation.
Security issues should be reported according to our security policy.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.