MCP Gateway

A relay/hub adapter package that lets multiple MCP nodes interconnect through a central gateway with transparent routing, session management, schema discovery, policy enforcement, and audit logging.

Overview

mcp_gateway provides the building blocks for a multi-node MCP fabric:

  • Gateway Runtime — orchestrates all gateway responsibilities behind one API.
  • Server / Client Adapters — let an MCP server publish itself to the gateway, and an MCP client consume gateway-routed services transparently.
  • Provider Registry — registers nodes (servers and clients) with capabilities and namespaces.
  • Schema Manager — aggregates and resolves schemas across nodes.
  • Namespace Resolver / Route Manager — multi-tenant routing with collision-free namespaces.
  • Dispatch Mediator — request/response relay with session affinity.
  • Stream Relay — bidirectional streaming pass-through.
  • Session Manager — tracks sessions across the relay boundary.
  • Event Bus — publish/subscribe across the gateway fabric.
  • Policy Enforcer + Audit Logger + Rate Limit Store — pluggable security and observability.
  • Gateway Tools — high-level commands for common gateway operations.

Quick Start

import 'package:mcp_gateway/mcp_gateway.dart';

final gateway = GatewayRuntime();
await gateway.start();

// Publish a server through the gateway
final serverAdapter = GatewayServerAdapter(gateway: gateway);
await serverAdapter.register(myServer, namespace: 'tenantA/billing');

// Connect a client through the gateway
final clientAdapter = GatewayClientAdapter(gateway: gateway);
final response = await clientAdapter.call(
  namespace: 'tenantA/billing',
  method: 'invoice/list',
  params: {...},
);

Support

License

MIT — see LICENSE.

Libraries

mcp_gateway
MCP Gateway — relay adapter package for MCP node interconnection.