ADR-0019: Modular Architecture Split (14 Independent Modules)ΒΆ
- Status: Accepted
- Date: 2025-10-27
- Deciders: Core Engineering Team
ContextΒΆ
The 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 the 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):
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
MCPGATEWAY_ENABLE_FEDERATION=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.8.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.8.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