ContextForge Architecture
An open-source registry and proxy that federates MCP, A2A, and REST/gRPC APIs with centralized governance, discovery, and observability.
Architecture Diagrams
Visual representations of the ContextForge system from different perspectives.
Component Explorer
Browse all architecture components. Click any card for details.
Service Dependency Graph
Interactive force-directed graph of service relationships. Drag nodes to explore. Scroll to zoom.
Security Architecture
Two-layer security model: Token Scoping (visibility) + RBAC (permissions)
🔑 Authentication
Multiple authentication strategies with secure defaults.
- JWT tokens (HS256, RS256) with audience verification
- Email/password with Argon2id hashing
- OAuth 2.0 authorization code flow with PKCE
- SSO/OIDC (Keycloak, Entra ID, Google, GitHub)
- API tokens with granular scoping
- Session-based persistence with DB authority
🛡 Token Scoping (Layer 1)
Controls what resources a caller can see.
- API tokens: JWT teams claim is sole authority
- Session tokens: DB is authority, JWT only narrows
- Missing teams key = public-only (secure default)
- Admin bypass requires both teams: null + is_admin: true
- Fail-closed on any ambiguity
🔒 RBAC (Layer 2)
Controls what actions a caller can do.
- platform_admin — global wildcard access
- team_admin — team management + read/execute
- developer — tools read/execute, resources read
- viewer — read-only access to team resources
- Permission audit logging on all changes
🔐 Encryption & Secrets
Defense in depth for data at rest and in transit.
- AES encryption for stored tokens and secrets
- mTLS support for plugin-to-gateway communication
- SSL/TLS context caching for performance
- Argon2id password hashing (time=3, mem=64MB)
- Secure cookie flags (httponly, secure, samesite)
✅ Input Validation
Defense at system boundaries with layered validation.
- Pydantic schema validation on all inputs
- JSON-RPC 2.0 structure validation
- Content type and size checking
- Dangerous pattern detection (injection, XSS)
- Jinja2 sandboxed template rendering
🌐 HTTP Security
Comprehensive response hardening and transport security.
- HSTS with long max-age
- Content Security Policy (CSP)
- X-Frame-Options, X-Content-Type-Options
- CORS with domain whitelisting
- Referrer-Policy and XSS-Protection
Data Layer
55 SQLAlchemy ORM models across authentication, MCP entities, observability, and configuration.
Plugin Architecture
Extensible hook-based system with support for in-process Python, remote MCP, gRPC, and STDIO transports.
Plugin Manager & Registry
Central lifecycle management: discovery, loading, validation, configuration, and health monitoring.
Hook System
Event-driven hooks into every MCP operation, HTTP request lifecycle, and policy evaluation.
Plugin Transports
Plugins can run in-process or communicate over network protocols for language-agnostic extensibility.
Execution Modes
Fine-grained control over plugin behavior per-hook with four enforcement levels.
Policy Engine
Declarative policy evaluation with structured payloads, audit trails, and violation reporting.
Protocol Architecture
ContextForge supports 6 transport protocols, the MCP JSON-RPC specification, A2A agent protocol, and OAuth 2.0.
Transport Protocols
MCP JSON-RPC Methods (22 methods)
All methods follow the JSON-RPC 2.0 specification over any supported transport. Dispatched in mcpgateway/main.py.
Higher-Level Protocols
Architecture Decision Records
50 ADRs documenting key architectural choices, technology selections, and design trade-offs.
API Surface
REST endpoints organized by router, plus MCP JSON-RPC protocol methods.
REST API Endpoints by Router
| Router | File | GET | POST | PUT | DELETE | PATCH | Total |
|---|
Core Application Routes (main.py)
| Method | Path | Description |
|---|
MCP Protocol Endpoints
| Transport | Path | Description |
|---|
Technology Stack
Core dependencies powering ContextForge, organized by domain.
Configuration Reference
Key environment variables organized by domain. Click a category to expand. Sources: .env.example | mcpgateway/config.py
Development & CI/CD
Development workflow, 18 GitHub Actions workflows, code quality gates, and the 16-phase release process.
CI/CD Pipeline
GitHub Actions Workflows (18)
Code Quality Gates
Release Process (16 Phases)
Semantic versioning with RC support. Version bumped via bump2version across 4 canonical files.