@nest-mcp/gateway
v0.2.6
Published
NestJS MCP Gateway - Proxy, route, and aggregate multiple MCP servers
Downloads
1,185
Readme
@nest-mcp/gateway
NestJS module for aggregating multiple upstream MCP servers behind a single unified endpoint, with routing, caching, policies, and transforms.
Installation
npm install @nest-mcp/gateway @modelcontextprotocol/sdk zod@^4
npm install @nestjs/common @nestjs/core reflect-metadata rxjsQuick start
// app.module.ts
import { Module } from '@nestjs/common';
import { McpGatewayModule } from '@nest-mcp/gateway';
import { McpTransportType } from '@nest-mcp/gateway';
@Module({
imports: [
McpGatewayModule.forRoot({
name: 'my-gateway',
version: '1.0.0',
upstreams: [
{
name: 'weather',
transport: {
type: McpTransportType.STREAMABLE_HTTP,
url: 'http://weather-service/mcp',
},
},
{
name: 'search',
transport: {
type: McpTransportType.STREAMABLE_HTTP,
url: 'http://search-service/mcp',
},
},
],
}),
],
})
export class AppModule {}Tools from upstream servers are exposed with a prefix (weather_forecast, search_query). Downstream clients see one unified MCP server.
Features
- Automatic prefixing — tools, resources, and prompts are namespaced by upstream name
- Policy engine — allow/deny/require-approval rules per tool or upstream
- Response caching — TTL-based cache for tool results
- Request/response transforms — custom hooks to rewrite calls
- Health monitoring — periodic ping per upstream
- Task proxying — long-running tasks forwarded with upstream prefix
- Sampling & elicitation — forwarded transparently to the correct upstream
Documentation
Full documentation: github.com/btwld/nest-mcp/docs/gateway
License
BSD-3-Clause
