Labsco
IBM logo

MCP Gateway

βœ“ Officialβ˜… 4,000

from IBM

A feature-rich gateway and proxy that federates MCP and REST services, unifying discovery, authentication, rate-limiting, and observability into a single endpoint for AI clients.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

ContextForge

An open source registry and proxy that federates MCP, A2A, and REST/gRPC APIs with centralized governance, discovery, and observability. Optimizes Agent & Tool calling, and supports plugins.

ContextForge Banner

<!-- === CI / Security / Build Badges === -->

Build Python PackageΒ  Dependency ReviewΒ  Tests & CoverageΒ  Lint & Static Analysis

<!-- === Package / Container === -->

Async LicenseΒ  PyPIΒ  Docker ImageΒ 

ContextForge is an open source registry and proxy that federates tools, agents, and APIs into one clean endpoint for your AI clients. It provides centralized governance, discovery, and observability across your AI infrastructure:

  • Tools Gateway β€” MCP, REST, gRPC-to-MCP translation, and TOON compression
  • Agent Gateway β€” A2A protocol, OpenAI-compatible and Anthropic agent routing
  • API Gateway β€” Rate limiting, auth, retries, and reverse proxy for REST services
  • Plugin Extensibility β€” 40+ plugins for additional transports, protocols, and integrations
  • Observability β€” OpenTelemetry tracing with Phoenix, Jaeger, Zipkin, and other OTLP backends

It runs as a fully compliant MCP server, deployable via PyPI or Docker, and scales to multi-cluster environments on Kubernetes with Redis-backed federation and caching.

ContextForge

<!-- vscode-markdown-toc -->

Table of Contents


πŸ“Œ Quick Links

ResourceDescription
5-Minute SetupGet started fast β€” uvx, Docker, Compose, or local dev
Getting HelpSupport options, FAQ, community channels
Issue GuideHow to file bugs, request features, contribute
Full DocumentationComplete guides, tutorials, API reference
DeprecationsDeprecated runtime paths and migration guidance

Overview & Goals

ContextForge is an open source registry and proxy that federates any Model Context Protocol (MCP) server, A2A server, or REST/gRPC API, providing centralized governance, discovery, and observability. It optimizes agent and tool calling, and supports plugins. See the project roadmap for more details.

It currently supports:

  • Federation across multiple MCP and REST services
  • A2A (Agent-to-Agent) integration for external AI agents (OpenAI, Anthropic, custom)
  • gRPC-to-MCP translation via automatic reflection-based service discovery
  • Virtualization of legacy APIs as MCP-compliant tools and servers
  • Transport over HTTP, JSON-RPC, WebSocket, SSE (with configurable keepalive), stdio and streamable-HTTP
  • An Admin UI for real-time management, configuration, and log monitoring (with airgapped deployment support)
  • Built-in auth, retries, and rate-limiting with user-scoped OAuth tokens and unconditional X-Upstream-Authorization header support
  • OpenTelemetry observability with Phoenix, Jaeger, Zipkin, and other OTLP backends
  • Scalable deployments via Docker or PyPI, Redis-backed caching, and multi-cluster federation

ContextForge Architecture

For a list of upcoming features, check out the ContextForge Roadmap


<details> <summary><strong>πŸ”Œ Gateway Layer with Protocol Flexibility</strong></summary>
  • Federates any MCP server or REST API
  • Lets you choose your MCP protocol version (e.g., 2025-11-25)
  • Exposes a single, unified interface for diverse backends
</details> <details> <summary><strong>🧩 Virtualization of REST/gRPC Services</strong></summary>
  • Wraps non-MCP services as virtual MCP servers
  • Registers tools, prompts, and resources with minimal configuration
  • gRPC-to-MCP translation via server reflection protocol
  • Automatic service discovery and method introspection
</details> <details> <summary><strong>πŸ” REST-to-MCP Tool Adapter</strong></summary>
  • Adapts REST APIs into tools with:

    • Automatic JSON Schema extraction
    • Support for headers, tokens, and custom auth
    • Retry, timeout, and rate-limit policies
</details> <details> <summary><strong>🧠 Unified Registries</strong></summary>
  • Prompts: Jinja2 templates, multimodal support, rollback/versioning
  • Resources: URI-based access, MIME detection, caching, SSE updates
  • Tools: Native or adapted, with input validation and concurrency controls
</details> <details> <summary><strong>πŸ“ˆ Admin UI, Observability & Dev Experience</strong></summary>
  • Admin UI built with HTMX 2.0.3 (bundled) + Alpine.js
  • Real-time log viewer with filtering, search, and export capabilities
  • Auth: Basic, JWT, or custom schemes
  • Structured logs, health endpoints, metrics
  • 7,000+ tests, Makefile targets, live reload, pre-commit hooks
</details> <details> <summary><strong>πŸ” OpenTelemetry Observability</strong></summary>
  • Vendor-agnostic tracing with OpenTelemetry (OTLP) protocol support
  • Multiple backend support: Phoenix (LLM-focused), Jaeger, Zipkin, Tempo, DataDog, New Relic
  • Distributed tracing across federated gateways and services
  • Automatic instrumentation of tools, prompts, resources, and gateway operations
  • LLM-specific metrics: Token usage, costs, model performance
  • Zero-overhead when disabled with graceful degradation

See Observability Documentation for setup guides with Phoenix, Jaeger, and other backends.

</details>

Upgrading

For upgrade instructions, migration guides, and rollback procedures, see:


API Reference

Interactive API documentation is available when the server is running:

  • Swagger UI β€” Try API calls directly in your browser
  • ReDoc β€” Browse the complete endpoint reference

Quick Authentication:

Copy & paste β€” that's it
# Generate a JWT token
export TOKEN=$(python3 -m mcpgateway.utils.create_jwt_token \
  --username admin@example.com --exp 10080 --secret my-test-key-but-now-longer-than-32-bytes)

# Test API access
curl -H "Authorization: Bearer $TOKEN" http://localhost:4444/health

For comprehensive curl examples covering all endpoints, see the API Usage Guide.


Testing

Copy & paste β€” that's it
make test            # Run unit tests
make lint            # Run all linters
make doctest         # Run doctests
make coverage        # Generate coverage report

See Doctest Coverage Guide for documentation testing details.


Project Structure

Copy & paste β€” that's it
mcpgateway/          # Core FastAPI application
β”œβ”€β”€ main.py          # Entry point
β”œβ”€β”€ config.py        # Pydantic Settings configuration
β”œβ”€β”€ db.py            # SQLAlchemy ORM models
β”œβ”€β”€ schemas.py       # Pydantic validation schemas
β”œβ”€β”€ services/        # Business logic layer (50+ services)
β”œβ”€β”€ routers/         # HTTP endpoint definitions
β”œβ”€β”€ middleware/      # Cross-cutting concerns
└── transports/      # SSE, WebSocket, stdio, streamable HTTP

tests/               # Test suite (7,000+ tests)
docs/docs/           # Full documentation (MkDocs)
charts/              # Kubernetes/Helm charts
plugins/             # Plugin framework and implementations
mcp-servers/         # Sample/test MCP servers (see note below)

Note: The mcp-servers/ directory contains unsupported sample and test servers, most originating from community contributions, provided for demonstration and integration testing purposes only. They generally lack session management, persistent state, multi-tenancy, authentication, and other production concerns. They do not go through the same review, testing, and security rigor as the core ContextForge codebase and should not be run in production.

Security: Never run untrusted MCP servers directly on your local filesystem. Always use a sandbox, container, or microVM (e.g. gVisor, Firecracker) with restricted capabilities. Exercise caution when registering any remote MCP server, including servers from public catalogs β€” perform your own security evaluation before granting access to your gateway.

For complete structure, see CONTRIBUTING.md or run tree -L 2.


Development

Copy & paste β€” that's it
make dev             # Dev server with auto-reload (:8000)
make test            # Run test suite
make lint            # Run all linters
make coverage        # Generate coverage report

Run make to see all available targets.

For development workflows, see:


Contributing

  1. Fork the repo, create a feature branch.
  2. Run make lint and fix any issues.
  3. Keep make test green.
  4. Open a PR with signed commits (git commit -s).

See CONTRIBUTING.md for full guidelines and Issue Guide #2502 for how to file bugs, request features, and find issues to work on.


Changelog

A complete changelog can be found here: CHANGELOG.md

License

Licensed under the Apache License 2.0 - see LICENSE

Core Authors and Maintainers

Special thanks to our contributors for helping us improve ContextForge:

<a href="https://github.com/ibm/mcp-context-forge/graphs/contributors"> <img src="https://contrib.rocks/image?repo=ibm/mcp-context-forge&max=100&anon=0&columns=10" alt="Contributors to the mcp-context-forge repository" /> </a>

Star History and Project Activity

Star History Chart

<!-- === Usage Stats === -->

PyPi DownloadsΒ  StarsΒ  ForksΒ  ContributorsΒ  Last CommitΒ  Open IssuesΒ