ADR-0019: Modular Architecture Split (14 Independent Modules)
- Status: Accepted
- Date: 2025-10-27
- Deciders: Core Engineering Team
Context
ContextForge codebase has grown to support diverse use cases:
- Standalone Python module for development
- Serverless deployments (Lambda, Cloud Run, Code Engine)
- Container orchestration (Kubernetes, OpenShift)
- Multi-regional deployments with federation
- Independent utility tools (translate, wrapper, reverse-proxy)
- Plugin ecosystem with external integrations
- MCP servers in multiple languages (Python, Go, Rust)
The monolithic architecture created challenges:
- Large repository difficult to navigate
- Plugins tied to core release cycle
- Utilities that should be standalone had unnecessary dependencies
- Single CI/CD pipeline for everything
- Conflicting versioning needs (core vs. plugins vs. servers)
- Difficult to deploy only what's needed
We needed maximum deployment flexibility while maintaining cohesive functionality.
Decision
We will split ContextForge ecosystem into 14 independently deployable modules that can run standalone or be composed together:
Core Gateway (2 modules)
- mcp-contextforge-gateway-core - FastAPI gateway with 33 services, 11 routers (~150K lines)
- mcp-contextforge-gateway-ui - HTMX + Alpine.js admin interface
Independent Utilities (3 modules) - Zero Gateway Dependencies
- mcp-contextforge-translate - Protocol bridge: stdio ↔ SSE ↔ HTTP ↔ gRPC
- mcp-contextforge-wrapper - MCP client wrapper
- mcp-contextforge-reverse-proxy - NAT/firewall traversal proxy
Plugin Ecosystem (2 modules)
- mcp-contextforge-plugins-python - 40+ Python plugins + framework
- mcp-contextforge-plugins-rust - High-performance PyO3 plugins
MCP Servers (3 modules) - Zero Gateway Dependencies
- mcp-contextforge-mcp-servers-python - 4 Python servers
- mcp-contextforge-mcp-servers-go - 5 Go servers (static binaries, 5-15 MB)
- mcp-contextforge-mcp-servers-rust - Rust servers (static binaries, 3-10 MB)
Agent Runtimes (1 module)
- mcp-contextforge-agent-runtimes - LangChain + future runtimes
Infrastructure (2 modules)
- mcp-contextforge-helm - Kubernetes Helm charts (OCI registry)
- mcp-contextforge-deployment-scripts - Terraform, Ansible, Docker Compose
Documentation (1 module)
- mcp-contextforge-docs - MkDocs Material site
Key Design Principles:
- Zero dependency utilities - translate, wrapper, reverse-proxy can run without gateway
- Zero dependency servers - MCP servers only require MCP SDK
- Independent versioning - Each module has its own semver
- Feature flags - All features configurable via .env (can disable/enable independently)
Consequences
Positive
- 🔧 Maximum deployment flexibility - Deploy only what you need
- 📦 Independent versioning - Core, plugins, utilities version independently
- 🚀 Parallel development - Teams work on different modules without conflicts
- 🎯 Focused repositories - Easier navigation and contribution
- 💡 Clear ownership - CODEOWNERS per repository
- 🌍 Multiple deployment targets - Standalone, serverless, containers, K8s
- 📊 Feature flags - Enable/disable features via environment variables
- 🔌 Zero-dependency utilities - translate/wrapper/reverse-proxy fully standalone
Negative
- 🔄 Cross-repo dependencies - Plugins depend on core gateway version
- 📚 More repositories - 14 repos to maintain vs. 1 monorepo
- 🔀 Coordination overhead - Breaking changes require multi-repo updates
Neutral
- 📦 Multiple package formats - PyPI, containers, Helm, binaries
- 🔀 CI/CD per module - Each module has its own GitHub Actions workflow
Deployment Examples
Standalone Python Module (Development):
python -m mcpgateway # Core gateway only
# SQLite + memory cache, zero external dependencies
Serverless (AWS Lambda):
# Deploy only core gateway + specific plugins
# No need for Helm, deployment scripts, or full server collection
Kubernetes with Optional Components:
# Install base gateway + UI
helm install mcp-gateway contextforge/mcp-gateway
# Optionally add nginx caching proxy
helm install nginx-proxy contextforge/nginx-proxy
# Optionally add specific MCP servers
kubectl apply -f mcp-server-docx.yaml
Edge Deployment (Minimal Footprint):
# Just the translate utility as a static Go binary
./mcptranslate --stdio "command" --port 9000
# No gateway, no Python, just protocol translation
Module Independence Matrix
| Module |
Gateway Dependency |
Can Run Standalone |
Package Formats |
| gateway-core |
- |
✅ Yes |
PyPI, Container |
| gateway-ui |
Requires core |
❌ No |
PyPI |
| translate |
None |
✅ Yes |
PyPI, Container, Binary |
| wrapper |
None |
✅ Yes |
PyPI, Container |
| reverse-proxy |
None |
✅ Yes |
PyPI, Container |
| plugins-python |
Requires core |
❌ No |
PyPI |
| plugins-rust |
Requires core |
❌ No |
PyPI (wheels) |
| mcp-servers-python |
None |
✅ Yes |
PyPI, Container |
| mcp-servers-go |
None |
✅ Yes |
Binary, Container |
| mcp-servers-rust |
None |
✅ Yes |
Binary, Container |
| agent-runtimes |
Optional |
✅ Yes |
PyPI, Container |
| helm |
Deploys others |
✅ Yes |
Helm OCI |
| deployment-scripts |
Deploys others |
✅ Yes |
Git repo |
| docs |
None |
✅ Yes |
GitHub Pages |
Feature Flags
All gateway features are configurable via environment variables:
# Core features
MCPGATEWAY_UI_ENABLED=true
MCPGATEWAY_ADMIN_API_ENABLED=true
MCPGATEWAY_A2A_ENABLED=true
# Performance features
COMPRESSION_ENABLED=true
CACHE_TYPE=redis|memory|database
# Plugin system
PLUGINS_ENABLED=true
PLUGIN_CONFIG_FILE=plugins/config.yaml
# Transport protocols
MCPGATEWAY_SSE_ENABLED=true
MCPGATEWAY_WEBSOCKET_ENABLED=true
This allows deploying the core gateway with only required features enabled, reducing memory footprint and attack surface.
Versioning Strategy
- Core Gateway: Independent semver (e.g., v0.9.0)
- UI: Follows core version
- Plugins: Per-plugin semver (e.g., pii-filter-v1.2.0)
- Standalone Tools: Independent semver (e.g., translate-v1.0.0)
- MCP Servers: Per-server semver (e.g., docx-v1.0.0)
- Helm Chart: Chart version + app version (e.g., Chart: 1.0.0, App: 0.9.0)
Alternatives Considered
| Option |
Why Not |
| Monolithic repository |
Too large, slow CI/CD, conflicting versions, difficult navigation |
| Single binary (Go/Rust rewrite) |
Loss of Python ecosystem, major rewrite cost, slower development |
| Microservices architecture |
Too heavyweight for many use cases, operational complexity |
| Monorepo with Bazel/Nx |
Complex build system, overkill for 14 modules |
Migration Path
- Extract utilities (translate, wrapper, reverse-proxy) to independent repos
- Extract MCP servers (Python, Go, Rust) to independent repos
- Extract plugins to independent repos
- Extract infrastructure (Helm, deployment scripts) to independent repos
- Core gateway remains with UI as optional dependency
- Update documentation with new repository structure
- Maintain backward compatibility during transition
Status
This decision is accepted and planned for implementation. See GitHub issue #1340 for detailed migration plan.
References
- Proposal: GitHub Issue #1340 (Monorepo Split Proposal)
- Current architecture: docs/docs/architecture/index.md
- CLI tools: mcpgateway --help, mcptranslate --help
- Feature flags: .env.example
1---2name: 3047-019-modular-architecture-split-606af2083description: ADR-0019: Modular Architecture Split (14 Independent Modules)4---5# ADR-0019: Modular Architecture Split (14 Independent Modules)67- *Status:* Accepted8- *Date:* 2025-10-279- *Deciders:* Core Engineering Team1011## Context1213ContextForge codebase has grown to support diverse use cases:1415- Standalone Python module for development16- Serverless deployments (Lambda, Cloud Run, Code Engine)17- Container orchestration (Kubernetes, OpenShift)18- Multi-regional deployments with federation19- Independent utility tools (translate, wrapper, reverse-proxy)20- Plugin ecosystem with external integrations21- MCP servers in multiple languages (Python, Go, Rust)2223The monolithic architecture created challenges:2425- Large repository difficult to navigate26- Plugins tied to core release cycle27- Utilities that should be standalone had unnecessary dependencies28- Single CI/CD pipeline for everything29- Conflicting versioning needs (core vs. plugins vs. servers)30- Difficult to deploy only what's needed3132We needed maximum deployment flexibility while maintaining cohesive functionality.3334## Decision3536We will split ContextForge ecosystem into **14 independently deployable modules** that can run standalone or be composed together:3738### Core Gateway (2 modules)391. **mcp-contextforge-gateway-core** - FastAPI gateway with 33 services, 11 routers (~150K lines)402. **mcp-contextforge-gateway-ui** - HTMX + Alpine.js admin interface4142### Independent Utilities (3 modules) - Zero Gateway Dependencies433. **mcp-contextforge-translate** - Protocol bridge: stdio ↔ SSE ↔ HTTP ↔ gRPC444. **mcp-contextforge-wrapper** - MCP client wrapper455. **mcp-contextforge-reverse-proxy** - NAT/firewall traversal proxy4647### Plugin Ecosystem (2 modules)486. **mcp-contextforge-plugins-python** - 40+ Python plugins + framework497. **mcp-contextforge-plugins-rust** - High-performance PyO3 plugins5051### MCP Servers (3 modules) - Zero Gateway Dependencies528. **mcp-contextforge-mcp-servers-python** - 4 Python servers539. **mcp-contextforge-mcp-servers-go** - 5 Go servers (static binaries, 5-15 MB)5410. **mcp-contextforge-mcp-servers-rust** - Rust servers (static binaries, 3-10 MB)5556### Agent Runtimes (1 module)5711. **mcp-contextforge-agent-runtimes** - LangChain + future runtimes5859### Infrastructure (2 modules)6012. **mcp-contextforge-helm** - Kubernetes Helm charts (OCI registry)6113. **mcp-contextforge-deployment-scripts** - Terraform, Ansible, Docker Compose6263### Documentation (1 module)6414. **mcp-contextforge-docs** - MkDocs Material site6566**Key Design Principles:**6768- **Zero dependency utilities** - translate, wrapper, reverse-proxy can run without gateway69- **Zero dependency servers** - MCP servers only require MCP SDK70- **Independent versioning** - Each module has its own semver71- **Feature flags** - All features configurable via .env (can disable/enable independently)7273## Consequences7475### Positive7677- 🔧 **Maximum deployment flexibility** - Deploy only what you need78- 📦 **Independent versioning** - Core, plugins, utilities version independently79- 🚀 **Parallel development** - Teams work on different modules without conflicts80- 🎯 **Focused repositories** - Easier navigation and contribution81- 💡 **Clear ownership** - CODEOWNERS per repository82- 🌍 **Multiple deployment targets** - Standalone, serverless, containers, K8s83- 📊 **Feature flags** - Enable/disable features via environment variables84- 🔌 **Zero-dependency utilities** - translate/wrapper/reverse-proxy fully standalone8586### Negative8788- 🔄 **Cross-repo dependencies** - Plugins depend on core gateway version89- 📚 **More repositories** - 14 repos to maintain vs. 1 monorepo90- 🔀 **Coordination overhead** - Breaking changes require multi-repo updates9192### Neutral9394- 📦 **Multiple package formats** - PyPI, containers, Helm, binaries95- 🔀 **CI/CD per module** - Each module has its own GitHub Actions workflow9697## Deployment Examples9899**Standalone Python Module (Development):**100```bash101python -m mcpgateway # Core gateway only102# SQLite + memory cache, zero external dependencies103```104105**Serverless (AWS Lambda):**106```python107# Deploy only core gateway + specific plugins108# No need for Helm, deployment scripts, or full server collection109```110111**Kubernetes with Optional Components:**112```bash113# Install base gateway + UI114helm install mcp-gateway contextforge/mcp-gateway115116# Optionally add nginx caching proxy117helm install nginx-proxy contextforge/nginx-proxy118119# Optionally add specific MCP servers120kubectl apply -f mcp-server-docx.yaml121```122123**Edge Deployment (Minimal Footprint):**124```bash125# Just the translate utility as a static Go binary126./mcptranslate --stdio "command" --port 9000127# No gateway, no Python, just protocol translation128```129130## Module Independence Matrix131132| Module | Gateway Dependency | Can Run Standalone | Package Formats |133|--------|-------------------|-------------------|-----------------|134| gateway-core | - | ✅ Yes | PyPI, Container |135| gateway-ui | Requires core | ❌ No | PyPI |136| translate | None | ✅ Yes | PyPI, Container, Binary |137| wrapper | None | ✅ Yes | PyPI, Container |138| reverse-proxy | None | ✅ Yes | PyPI, Container |139| plugins-python | Requires core | ❌ No | PyPI |140| plugins-rust | Requires core | ❌ No | PyPI (wheels) |141| mcp-servers-python | None | ✅ Yes | PyPI, Container |142| mcp-servers-go | None | ✅ Yes | Binary, Container |143| mcp-servers-rust | None | ✅ Yes | Binary, Container |144| agent-runtimes | Optional | ✅ Yes | PyPI, Container |145| helm | Deploys others | ✅ Yes | Helm OCI |146| deployment-scripts | Deploys others | ✅ Yes | Git repo |147| docs | None | ✅ Yes | GitHub Pages |148149## Feature Flags150151All gateway features are configurable via environment variables:152153```bash154# Core features155MCPGATEWAY_UI_ENABLED=true156MCPGATEWAY_ADMIN_API_ENABLED=true157MCPGATEWAY_A2A_ENABLED=true158159# Performance features160COMPRESSION_ENABLED=true161CACHE_TYPE=redis|memory|database162163# Plugin system164PLUGINS_ENABLED=true165PLUGIN_CONFIG_FILE=plugins/config.yaml166167# Transport protocols168MCPGATEWAY_SSE_ENABLED=true169MCPGATEWAY_WEBSOCKET_ENABLED=true170```171172This allows deploying the core gateway with only required features enabled, reducing memory footprint and attack surface.173174## Versioning Strategy175176- **Core Gateway:** Independent semver (e.g., v0.9.0)177- **UI:** Follows core version178- **Plugins:** Per-plugin semver (e.g., pii-filter-v1.2.0)179- **Standalone Tools:** Independent semver (e.g., translate-v1.0.0)180- **MCP Servers:** Per-server semver (e.g., docx-v1.0.0)181- **Helm Chart:** Chart version + app version (e.g., Chart: 1.0.0, App: 0.9.0)182183## Alternatives Considered184185| Option | Why Not |186|--------|---------|187| **Monolithic repository** | Too large, slow CI/CD, conflicting versions, difficult navigation |188| **Single binary (Go/Rust rewrite)** | Loss of Python ecosystem, major rewrite cost, slower development |189| **Microservices architecture** | Too heavyweight for many use cases, operational complexity |190| **Monorepo with Bazel/Nx** | Complex build system, overkill for 14 modules |191192## Migration Path1931941. Extract utilities (translate, wrapper, reverse-proxy) to independent repos1952. Extract MCP servers (Python, Go, Rust) to independent repos1963. Extract plugins to independent repos1974. Extract infrastructure (Helm, deployment scripts) to independent repos1985. Core gateway remains with UI as optional dependency1996. Update documentation with new repository structure2007. Maintain backward compatibility during transition201202## Status203204This decision is accepted and planned for implementation. See GitHub issue #1340 for detailed migration plan.205206## References207208- Proposal: GitHub Issue #1340 (Monorepo Split Proposal)209- Current architecture: docs/docs/architecture/index.md210- CLI tools: mcpgateway --help, mcptranslate --help211- Feature flags: .env.example