How ibm/mcp-context-forge works
ContextForge is a federated gateway: clients reach a unified MCP-facing service, which applies access controls and routes tool, agent, API, and LLM requests to registered backends. Its documented capabilities also include virtualizing REST/gRPC APIs, transport alternatives, plugins, administration, and telemetry. The graph emphasizes those product stages and the supported LLM and observability internals; many unsampled subsystems are represented at their exact enclosing directory, with links omitted where wiring was not shown.
Main entry points: main.py Gateway application · llm_provider_service.py LLM provider registry · sqlalchemy.py SQL instrumentation · llm_proxy_service.py LLM proxy
Components 25
Gateway and transports
- Gateway application
mcpgateway/main.py - MCP transports
mcpgateway/transports - LLM proxy
mcpgateway/services/llm_proxy_service.py - Provider HTTP client
mcpgateway/services/http_client_service.py
Federation and registries
- Tool registry and routing
mcpgateway/services/tool_service.py - Prompt registry
mcpgateway/services/prompt_service.py - Resource registry
mcpgateway/services/resource_service.py - Federated catalog
mcpgateway/services/catalog_service.py - A2A agent integration
mcpgateway/services/a2a_service.py - REST and gRPC adapters
mcpgateway/services/grpc_service.py - LLM chat
mcpgateway/routers/llmchat_router.py - LLM provider registry
mcpgateway/services/llm_provider_service.py
Governance and administration
- Authentication and RBAC
mcpgateway/middleware/rbac.py - Plugin manager
mcpgateway/plugins/gateway_plugin_manager.py - Admin UI
mcpgateway/admin_ui/app.js - Admin API routes
mcpgateway/routers/llm_admin_router.py - Validation and credentials
mcpgateway/common/validators.py - Runtime configuration
mcpgateway/config.py
Storage and observability
- Gateway database
mcpgateway/db.py - Structured logging
mcpgateway/services/logging_service.py - OpenTelemetry
mcpgateway/services/observability_service.py - SQL instrumentation
mcpgateway/instrumentation/sqlalchemy.py - Redis federation and cache
mcpgateway/cache
Other components
- AI client
- MCP and API backends
Connections 28
- AI client → Gateway application: sends requests
- Gateway application → MCP transports: serves via
- Gateway application → Authentication and RBAC: enforces access
- Gateway application → Tool registry and routing: routes tool calls
- Gateway application → Prompt registry: exposes prompts
- Gateway application → Resource registry: exposes resources
- Gateway application → Federated catalog: federates services
- Gateway application → A2A agent integration: routes agents
- Gateway application → REST and gRPC adapters: virtualizes APIs
- Tool registry and routing → MCP and API backends: invokes backends
- A2A agent integration → MCP and API backends: connects agents
- REST and gRPC adapters → MCP and API backends: adapts services
- Gateway application → Plugin manager: supports plugins
- AI client → LLM chat: starts chat
- LLM chat → LLM provider registry: uses providers
mcpgateway/routers/llmchat_router.py - LLM provider registry → LLM proxy: routes completions
mcpgateway/services/llm_proxy_service.py - LLM proxy → Provider HTTP client: sends HTTP requests
mcpgateway/services/llm_proxy_service.py - Provider HTTP client → MCP and API backends: calls provider APIs
- Admin UI → Admin API routes: calls admin routes
- Admin API routes → LLM provider registry: manages providers
mcpgateway/routers/llm_admin_router.py - LLM provider registry → Gateway database: persists records
mcpgateway/services/llm_provider_service.py - Gateway application → Runtime configuration: loads settings
- Gateway application → Validation and credentials: validates inputs
- Gateway application → Structured logging: records events
- Gateway application → OpenTelemetry: emits telemetry
- SQL instrumentation → OpenTelemetry: records query spans
mcpgateway/instrumentation/sqlalchemy.py - SQL instrumentation → Gateway database: observes queries
mcpgateway/instrumentation/sqlalchemy.py - Gateway application → Redis federation and cache: uses federation cache