Skip to main content

agent-gateway

PyPI version Python License: MIT Tests

One gateway. Every agent protocol. Route requests between A2A, MCP, OpenAI Assistants, and plain REST — with a single YAML config.

pip install agentic-gateway

🎬 Demo

agent-gateway demo — unified protocol routing for A2A, MCP, OpenAI, REST
Starting the gateway, routing requests across 4 protocols, and viewing live metrics


The Problem

The AI agent ecosystem is fragmented:

Your App ──→ Agent A (A2A protocol)
         ──→ Agent B (MCP tools)
         ──→ Agent C (OpenAI Assistants API)
         ──→ Agent D (plain REST)

Each speaks a different language. You write adapters for each. Then a new protocol drops and you rewrite everything.

The Solution

                  ┌────────────────────┐
Your App ────────→│   agent-gateway    │────→ Agent A (A2A)
                  │                    │────→ Agent B (MCP)
                  │   One protocol     │────→ Agent C (OpenAI)
                  │   in, any out      │────→ Agent D (REST)
                  └────────────────────┘

Talk to the gateway in any protocol. It translates to any other.

Quick Start

1. Define your gateway

# gateway.yaml
gateway:
  name: my-gateway
  port: 8080

routes:
  - name: search-agent
    upstream:
      protocol: a2a
      url: http://localhost:9000
    expose_as:
      - mcp      # Expose A2A agent as MCP tool
      - rest     # And as REST endpoint

  - name: code-helper
    upstream:
      protocol: mcp
      command: python -m code_helper_mcp
      transport: stdio
    expose_as:
      - a2a      # Expose MCP server as A2A agent
      - openai   # And as OpenAI Assistants-compatible

  - name: legacy-api
    upstream:
      protocol: rest
      url: https://api.example.com/analyze
      method: POST
      headers:
        Authorization: "Bearer ${API_KEY}"
    expose_as:
      - a2a
      - mcp

2. Start the gateway

agent-gateway serve gateway.yaml

3. Connect from any protocol

# As A2A client:
response = a2a_client.send_task("search-agent", "Find recent papers on RLHF")

# As MCP client (from Claude Desktop):
# Just add to claude_desktop_config.json:
#   {"mcpServers": {"gateway": {"url": "http://localhost:8080/mcp"}}}

# As OpenAI-compatible:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/openai/v1")
response = client.chat.completions.create(
    model="code-helper",
    messages=[{"role": "user", "content": "Fix this bug"}],
)

# As REST:
import httpx
response = httpx.post("http://localhost:8080/rest/search-agent", json={"query": "RLHF papers"})

Protocol Support Matrix

From ↓ / To → A2A MCP OpenAI REST
A2A
MCP
OpenAI
REST

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        agent-gateway                             │
│                                                                  │
│  ┌──────────┐    ┌────────────┐    ┌──────────┐    ┌─────────┐ │
│  │ Ingress  │───→│  Router    │───→│Translator│───→│  Egress │ │
│  │          │    │            │    │          │    │         │ │
│  │ • A2A    │    │ • Match    │    │ • A2A↔X  │    │ • HTTP  │ │
│  │ • MCP    │    │   route    │    │ • MCP↔X  │    │ • stdio │ │
│  │ • OpenAI │    │ • Auth     │    │ • OAI↔X  │    │ • SSE   │ │
│  │ • REST   │    │ • Rate     │    │ • REST↔X │    │         │ │
│  └──────────┘    └────────────┘    └──────────┘    └─────────┘ │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Features

  • Protocol translation — Seamless conversion between A2A, MCP, OpenAI, REST
  • YAML configuration — No code required, just declare routes
  • Environment variables${VAR} expansion in config
  • Auth passthrough — Forward headers, tokens, API keys
  • Health checks — Built-in /health endpoint with upstream status
  • Hot reload — Change config without restart (--watch)
  • Middleware — Rate limiting, logging, request/response transforms
  • Discovery — Auto-generates agent cards, tool lists, OpenAPI specs

CLI

# Start gateway
agent-gateway serve gateway.yaml

# Validate config
agent-gateway validate gateway.yaml

# List routes
agent-gateway routes gateway.yaml

# Health check
agent-gateway health http://localhost:8080

Programmatic Usage

from agent_gateway import Gateway

gateway = Gateway.from_yaml("gateway.yaml")

# Translate a single request
result = await gateway.translate(
    source_protocol="rest",
    target_route="search-agent",
    payload={"query": "test"},
)

Why Not Just Use X?

Solution Limitation
mcp-a2a-bridge Only 2 protocols (MCP ↔ A2A)
LangServe LangChain-only, single protocol
Custom adapters One-off, unmaintainable
API Gateway (Kong, etc.) No protocol awareness, just HTTP routing

agent-gateway understands the semantics of each protocol — agent cards, tool schemas, function calling, streaming — and translates them correctly.

Contributing

git clone https://github.com/naveenkumarbaskaran/agent-gateway.git
cd agent-gateway
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

License

MIT

Release files for agentic-gateway 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentic-gateway 2.0.0
File Size Uploaded
agentic_gateway-2.0.0.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentic-gateway 2.0.0
File Interpreter ABI Platform
agentic_gateway-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / agentic_gateway-2.0.0.tar.gz

Download URL agentic_gateway-2.0.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aa01c68a563632527e0c0a4ecf01bf2d1d1d570b14160242578333d16e81d595
BLAKE2b-256 checksum
How to use checksums
ef1ba7d813c49a78cbb6f45715c5209e03c06e30a83117c2c0e770be2154e60a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / agentic_gateway-2.0.0-py3-none-any.whl

Download URL agentic_gateway-2.0.0-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9278c5f2ca307eba06da9901468fbb42b512da97577578341ab752ff188cc009
BLAKE2b-256 checksum
How to use checksums
3773ca5d5ec23a11a13429c3ae993fb1ac68fe05ccde33c6ac8f276bda5b733b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page