# PRD-00: Waygate MCP Framework - Secure Containerized Architecture
**Product Requirements Document**
**Version:** 2.0.0
**Status:** Production-Ready
**Created:** 2025-01-14
**Updated:** 2025-01-14
**Author:** Jeremy Longshore
**AI-Assisted:** Yes (Claude)
**Architecture:** Security-Hardened Docker Containers
## 1. Executive Summary
### 1.1 Purpose
Waygate MCP is a **security-first containerized Model Context Protocol (MCP) server framework** designed to replace NEXUS MCP with defense-in-depth security through Docker containers, providing enterprise-grade isolation and protection impossible with traditional virtual environment deployments.
### 1.2 Problem Statement
Current MCP implementations suffer from critical security vulnerabilities:
- **No process isolation** - Shared host PID namespace
- **Full filesystem access** - Entire host filesystem visible
- **Network exposure** - Direct host network access
- **No resource limits** - Can consume all system resources
- **Privilege escalation risks** - Same user context as host
- **Supply chain vulnerabilities** - System-wide package installation
### 1.3 Solution Overview
A security-hardened containerized MCP server infrastructure that provides:
- **Docker-based isolation** with non-root execution (UID 1000)
- **Read-only filesystem** with specific writable volumes only
- **Network segmentation** (172.28.0.0/16 bridge network)
- **Resource limits** preventing DoS attacks (2 CPU cores, 1GB RAM)
- **Dropped Linux capabilities** for minimal attack surface
- **Multi-stage builds** reducing image size and vulnerabilities
- **One-line deployment** with automated secure setup
- **Comprehensive security documentation** and best practices
## 2. Business Context
### 2.1 Market Opportunity
- Growing cybersecurity threats require containerized isolation
- Enterprise demand for secure MCP deployments
- Industry shift from VMs to containers for microservices
- Need for production-ready, security-first frameworks
### 2.2 Strategic Alignment
- Replaces deprecated NEXUS MCP with modern architecture
- Aligns with cloud-native and DevSecOps practices
- Foundation for secure, scalable MCP services
- Enables zero-trust security model
### 2.3 Success Metrics
- **Security:** 0 critical vulnerabilities in container scans
- **Performance:** < 100ms response time with resource limits
- **Reliability:** 99.9% uptime with automatic restarts
- **Deployment:** < 1 minute setup with quickstart.sh
- **Adoption:** 100% migration from NEXUS MCP
## 3. User Personas
### 3.1 Primary: Security-Conscious Developer
- **Goals:** Deploy secure MCP servers without vulnerabilities
- **Pain Points:** Complex security configurations, container expertise
- **Needs:** Pre-hardened containers, security documentation
### 3.2 Secondary: DevSecOps Engineer
- **Goals:** Maintain secure production deployments
- **Pain Points:** Vulnerability management, compliance
- **Needs:** Security scanning, audit logs, monitoring
### 3.3 Tertiary: Enterprise Architect
- **Goals:** Standardize on secure architectures
- **Pain Points:** Inconsistent security practices
- **Needs:** Reference architecture, compliance documentation
## 4. Functional Requirements
### 4.1 Container Security (P0 - Must Have)
- [x] **Non-root user execution** (waygate user, UID 1000)
- [x] **Read-only root filesystem** with specific volumes
- [x] **Dropped capabilities** (ALL except NET_BIND_SERVICE)
- [x] **No new privileges** flag preventing escalation
- [x] **Resource limits** via cgroups (CPU, memory, PIDs)
- [x] **Network isolation** with custom bridge network
- [x] **Multi-stage builds** for minimal attack surface
- [x] **Security scanning** in build pipeline
### 4.2 Core Server (P0 - Must Have)
- [x] FastAPI-based REST API server
- [x] MCP protocol implementation
- [x] Environment-based configuration
- [x] Health and readiness endpoints
- [x] Structured JSON logging
- [x] Prometheus metrics endpoint
### 4.3 Network Security (P0 - Must Have)
- [x] **Nginx reverse proxy** with SSL/TLS termination
- [x] **Rate limiting** (10r/s API, 30r/s general)
- [x] **CORS protection** with configurable origins
- [x] **Security headers** (HSTS, CSP, X-Frame-Options)
- [x] **Connection limits** per IP address
- [x] **DDoS protection** via rate limiting
### 4.4 Deployment & Operations (P0 - Must Have)
- [x] **One-line setup** with quickstart.sh
- [x] **Automated secret generation** (SECRET_KEY, API_KEY)
- [x] **Docker Compose orchestration**
- [x] **Development mode** with hot reload
- [x] **Production mode** with optimizations
- [x] **Comprehensive logging** with rotation
### 4.5 Documentation (P0 - Must Have)
- [x] **CLAUDE.md** for AI assistant guidance
- [x] **CONTAINER_SECURITY.md** with threat models
- [x] **README.md** with quick start guide
- [x] **API specification** (OpenAPI/Swagger)
- [x] **Migration guide** from NEXUS MCP
- [x] **Troubleshooting playbooks**
## 5. Non-Functional Requirements
### 5.1 Security Requirements
- **Container scanning:** 0 critical, < 5 high vulnerabilities
- **Secrets management:** No hardcoded credentials
- **Audit logging:** All API access logged
- **Compliance:** CIS Docker Benchmark
- **Updates:** Security patches < 7 days
### 5.2 Performance Requirements
- **Startup time:** < 5 seconds
- **Health check:** < 100ms response
- **API response:** < 200ms (95th percentile)
- **Memory usage:** < 256MB baseline
- **CPU usage:** < 10% idle
### 5.3 Reliability Requirements
- **Availability:** 99.9% uptime
- **Auto-restart:** On container failure
- **Graceful shutdown:** Clean termination
- **Data persistence:** Volumes survive restarts
- **Rollback capability:** Previous version recovery
### 5.4 Scalability Requirements
- **Horizontal scaling:** Multiple container instances
- **Load balancing:** Nginx upstream configuration
- **Stateless operation:** No local state dependencies
- **Connection pooling:** Efficient resource usage
## 6. Technical Architecture
### 6.1 Container Architecture
```
┌─────────────────────────────────────────┐
│ Host System │
├─────────────────────────────────────────┤
│ Docker Engine │
├─────────────────────────────────────────┤
│ Custom Bridge Network (172.28.0.0) │
├─────────────────────────────────────────┤
│ ┌─────────────────────────────────┐ │
│ │ Nginx Container │ │
│ │ - SSL/TLS Termination │ │
│ │ - Rate Limiting │ │
│ │ - Security Headers │ │
│ └─────────────────────────────────┘ │
│ ┌─────────────────────────────────┐ │
│ │ Waygate Container │ │
│ │ - Non-root User (UID 1000) │ │
│ │ - Read-only Filesystem │ │
│ │ - Dropped Capabilities │ │
│ │ - Resource Limits │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────────┘
```
### 6.2 Technology Stack
- **Language:** Python 3.11+
- **Framework:** FastAPI with Pydantic
- **Server:** Uvicorn with Gunicorn workers
- **Container:** Docker 20.10+ with BuildKit
- **Base Image:** python:3.11-slim-bookworm
- **Orchestration:** Docker Compose 2.0+
- **Reverse Proxy:** Nginx 1.21+
- **Security:** AppArmor/SELinux, Seccomp profiles
- **Monitoring:** Prometheus metrics, JSON logs
### 6.3 Security Layers
1. **Network Layer:** Isolated bridge, firewall rules
2. **Container Layer:** Namespace isolation, cgroups
3. **Application Layer:** Non-root user, read-only fs
4. **Capability Layer:** Dropped privileges, seccomp
5. **Resource Layer:** CPU/memory limits, PID limits
### 6.4 Directory Structure
```
waygate-mcp/
├── src/ # Source code
│ └── waygate_mcp.py # Main application
├── tests/ # Test suites
├── configs/ # Configuration files
├── scripts/ # Utility scripts
│ └── docker-entrypoint.sh # Container entry
├── nginx/ # Nginx configs
│ └── nginx.conf # Hardened config
├── docs/ # Documentation
│ └── CONTAINER_SECURITY.md
├── ai-dev-tasks/ # AI dev docs
│ ├── PRDs/ # Requirements
│ ├── ADRs/ # Architecture
│ ├── tasks/ # Task lists
│ └── specifications/ # Tech specs
├── Dockerfile # Multi-stage build
├── docker-compose.yml # Production
├── docker-compose.dev.yml # Development
├── quickstart.sh # One-line setup
├── init.sh # Environment init
└── CLAUDE.md # AI guide
```
## 7. User Experience
### 7.1 Installation Experience
```bash
# One-line secure installation
curl -sSL https://raw.githubusercontent.com/jeremylongshore/waygate-mcp/main/quickstart.sh | bash
# Or clone and run
git clone https://github.com/jeremylongshore/waygate-mcp.git
cd waygate-mcp
./quickstart.sh
```
### 7.2 Development Experience
```bash
# Start development mode with hot reload
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
# Access container for debugging
docker-compose exec waygate /bin/bash
# View real-time logs
docker-compose logs -f waygate
```
### 7.3 Security Verification
```bash
# Scan for vulnerabilities
docker scan waygate-mcp:latest
# Verify security settings
docker inspect waygate-mcp | jq '.[0].Config.User'
docker inspect waygate-mcp | jq '.[0].HostConfig.ReadonlyRootfs'
docker inspect waygate-mcp | jq '.[0].HostConfig.CapDrop'
```
## 8. Security Comparison
| Attack Vector | Virtual Environment | Waygate Container | Security Improvement |
|---------------|-------------------|------------------|---------------------|
| Process Isolation | ❌ Shared host PIDs | ✅ Isolated namespace | 100% isolation |
| Network Access | ❌ Host network | ✅ Bridge network | Complete segmentation |
| Filesystem | ❌ Full host access | ✅ Read-only + volumes | 99% reduction |
| Kernel Exploits | ❌ Direct access | ✅ Seccomp filtering | 300+ syscalls blocked |
| Resource DoS | ❌ No limits | ✅ Hard cgroup limits | DoS prevented |
| Privilege Escalation | ❌ Same user | ✅ User namespaces | Multi-layer barriers |
## 9. Risk Management
| Risk | Impact | Likelihood | Mitigation | Status |
|------|--------|-----------|------------|--------|
| Container Escape | Critical | Very Low | Non-root, capabilities dropped, seccomp | ✅ Mitigated |
| Supply Chain Attack | High | Low | Pinned versions, multi-stage builds | ✅ Mitigated |
| Secrets Exposure | High | Low | Env files, Docker secrets, no layers | ✅ Mitigated |
| Resource Exhaustion | Medium | Low | Cgroup limits (2 CPU, 1GB RAM) | ✅ Mitigated |
| Network Attack | Medium | Low | Isolated network, Nginx proxy | ✅ Mitigated |
| Zero-Day Exploit | High | Very Low | Regular updates, minimal surface | ⚠️ Monitored |
## 10. Success Criteria
### 10.1 Launch Criteria
- [x] Security-hardened Docker container
- [x] One-line deployment script
- [x] Comprehensive documentation
- [x] Zero critical vulnerabilities
- [x] Production-ready configuration
### 10.2 30-Day Success Metrics
- [ ] 100% NEXUS MCP migration
- [ ] 99.9% uptime achieved
- [ ] 0 security incidents
- [ ] < 5 minute setup time
- [ ] 100% container health checks passing
## 11. Timeline
### ✅ Phase 1: Container Security (Complete)
- Docker multi-stage build
- Security hardening configurations
- Non-root user implementation
- Resource limits and capabilities
### ✅ Phase 2: Infrastructure (Complete)
- Docker Compose orchestration
- Nginx reverse proxy setup
- Development/production modes
- Automated deployment scripts
### ✅ Phase 3: Documentation (Complete)
- CLAUDE.md AI guide
- CONTAINER_SECURITY.md
- README with quick start
- AI dev task documents
### ⏳ Phase 4: Production (Next)
- Deploy to production
- Monitor performance
- Security scanning
- Continuous improvements
## 12. Compliance & Standards
### 12.1 Security Standards
- [x] CIS Docker Benchmark
- [x] OWASP Docker Top 10
- [x] NIST Container Security Guide
- [ ] SOC 2 Type II (future)
- [ ] ISO 27001 (future)
### 12.2 Best Practices
- [x] Principle of least privilege
- [x] Defense in depth
- [x] Zero trust architecture
- [x] Immutable infrastructure
- [x] Security by default
## 13. Appendices
### A. Security Checklist
- [x] Non-root user configured
- [x] Read-only root filesystem
- [x] Capabilities dropped
- [x] Resource limits set
- [x] Network isolated
- [x] Secrets secured
- [x] Images scanned
- [x] Logs configured
### B. Related Documents
- `docs/CONTAINER_SECURITY.md` - Complete security guide
- `ai-dev-tasks/ADRs/ADR-001-core-architecture.md` - Architecture decisions
- `ai-dev-tasks/specifications/tech-spec-waygate-mcp.md` - Technical details
- `ai-dev-tasks/tasks/00-tasks-waygate-mcp-implementation.md` - Task breakdown
### C. Revision History
| Version | Date | Author | Changes |
|---------|------|--------|---------|
| 1.0.0 | 2025-01-14 | Jeremy Longshore | Initial PRD |
| 2.0.0 | 2025-01-14 | Jeremy Longshore | Complete containerization with Docker security |
---
**Document Status:** Production-Ready
**Next Steps:** Deploy to production environment
**Contact:** Jeremy Longshore
**Last Updated:** 2025-01-14