NestJS MCP Server Module
Provides a module for NestJS to create an MCP (Model Context Protocol) server with Server-Sent Events (SSE) transport, allowing services to be exposed as tools that clients can discover and execute.
Enables sending continuous progress updates from tools to clients, allowing for tracking of long-running operations with percentage completion indicators.
Integrates Zod schema validation for tool requests, enabling type-safe parameter validation for tools exposed through the MCP server.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@NestJS MCP Server Moduleshow me available tools in my NestJS app"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
NestJS MCP Server Module
A NestJS module to effortlessly expose tools, resources, and prompts for AI, from your NestJS applications using the Model Context Protocol (MCP).
With @rekog/mcp-nest you define tools, resources, and prompts in a way that's familiar in NestJS and leverage the full power of dependency injection to utilize your existing codebase in building complex enterprise ready MCP servers.
Features
🧩 NestJS Microservice Strategy: MCP runs as a
CustomTransportStrategy, so tools/resources/prompts are real@MessagePatternhandlers — guards, pipes, interceptors, and exception filters apply to them natively🚀 Multi-Transport Support: Streamable HTTP and STDIO — selected via the
transportsarray🕰️ Dual-Era Protocol Support: One endpoint serves both the 2025-era protocol (
initialize+ sessions) and the stateless2026-07-28revision, concurrently — with no change to your tool code🔧 Tools: Expose NestJS methods as MCP tools with automatic discovery and Zod validation
🛠️ Elicitation: Interactive tool calls with user input elicitation
🌐 HTTP Request Access: Full access to request context within MCP handlers
🔐 Per-Tool Authorization: Implement fine-grained authorization for tools
📁 Resources: Serve content and data through MCP resource system
📚 Resource Templates: Dynamic resources with parameterized URIs
💬 Prompts: Define reusable prompt templates for AI interactions
🔐 Guard-based Authentication: Guard-based security with OAuth support
🏠 Built-in Authorization Server — Using the built-in Authorization Server for easy setups. (Beta)
🌐 External Authorization Server — Securing your MCP server with an external authorization server (Keycloak, Auth0, etc).
💉 Dependency Injection: Leverage NestJS DI system throughout MCP components
🔍 Server mutation and instrumentation — Mutate the underlying mcp server for custom logic or instrumentation purposes.
Are you interested to build ChatGPT widgets (with the OpenAI SDK) or MCP apps?
Find out how to do that with @rekog/MCP-Nest in this repository MCP-Nest-Samples
You can easily learn about this package using thechat tab in Context7. Better yet, connect the Context7 MCP server to allow your AI agents to access the documentation and implement MCP-Nest for you.
Related MCP server: mcp-nestjs
Installation
npm install @rekog/mcp-nest \
@modelcontextprotocol/server \
@modelcontextprotocol/core \
@modelcontextprotocol/node \
zod@^4Optional dependencies
The built-in authorization server now lives in a separate package. If you use it, install it alongside @rekog/mcp-nest:
npm install @rekog/mcp-nest-authIf you additionally use the TypeORM store for the authorization server, install the following optional peer dependencies as well:
npm install @nestjs/typeorm typeormQuick Start
MCP-Nest runs as a NestJS microservice transport strategy. Tools, resources,
and prompts live on @McpController() classes (so NestJS guards, pipes,
interceptors, and exception filters apply to them), and the strategy serves them
over one or more transports (Streamable HTTP, STDIO).
// greeting.controller.ts
import { McpController, Tool, McpContext } from '@rekog/mcp-nest';
import { Ctx, Payload } from '@nestjs/microservices';
import { z } from 'zod';
@McpController()
export class GreetingController {
@Tool({
name: 'greeting-tool',
description: 'Returns a greeting with progress updates',
parameters: z.object({ name: z.string().default('World') }),
})
async sayHello(
@Payload() { name }: { name: string },
@Ctx() ctx: McpContext,
) {
await ctx.reportProgress({ progress: 50, total: 100 });
return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
}
}// app.module.ts
import { Module } from '@nestjs/common';
import {
McpStrategy,
MCP_STRATEGY,
StreamableHttpTransport,
} from '@rekog/mcp-nest';
import { GreetingController } from './greeting.controller';
// The strategy is the whole configuration — there is no McpModule.
export const mcp = new McpStrategy({
name: 'my-mcp-server',
version: '1.0.0',
transports: [
new StreamableHttpTransport(),
],
});
@Module({
controllers: [GreetingController],
// Optional: only needed if a provider injects the strategy (e.g. for
// runtime/dynamic tool registration).
providers: [{ provide: MCP_STRATEGY, useValue: mcp }],
})
export class AppModule {}// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule, mcp } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
mcp.setHttpAdapter(app.getHttpAdapter()); // needed for HTTP transports
app.connectMicroservice({ strategy: mcp });
await app.startAllMicroservices(); // mounts the MCP transports
await app.listen(3000); // also serves your normal HTTP routes
}
void bootstrap();Order matters: call
startAllMicroservices()beforelisten()so the MCP HTTP routes are mounted before the server starts accepting connections.
That /mcp endpoint is dual-era: it answers both the 2025-era protocol
(initialize handshake + sessions) and the stateless 2026-07-28 revision,
concurrently, from the same @Tool methods. ctx.reportProgress(...) above
reaches a 2026-07-28 client as-is — every modern request can stream progress
back even though it is sessionless. A 2025-era client needs a session-aware
transport for it (new StreamableHttpTransport({ statefulMode: true }) or
StdioTransport); on the legacy stateless default it is a no-op. See
Protocol Revisions.
For an STDIO-only server, skip the HTTP adapter and use
NestFactory.createMicroservice(AppModule, { strategy: mcp }) with
transports: [new StdioTransport()] and disable logging (stdout is reserved for
the protocol).
Documentation
Migration to the Strategy API - Moving from
McpModule.forRoot(options)toMcpStrategy+@McpControllerProtocol Revisions & Dual-Era Serving - Serving the 2025-era protocol and
2026-07-28from one endpointTools Guide - Define and expose NestJS methods as MCP tools
Discovery and Registration of Tools - Automatic discovery and manual registration of tools
Dynamic Capabilities Guide - Register tools, resources, and prompts programmatically at runtime
Resources Guide - Serve static and dynamic content
Resource Templates Guide - Create parameterized resources
Prompts Guide - Build reusable prompt templates
Built-in Authorization Server - Secure your MCP server with built-in OAuth
External Authorization Server - Securing your MCP server with an external authorization server (Keycloak, Auth0, etc)
Server examples - MCP servers examples (Streamable HTTP, HTTP, and STDIO) and with Fastify support
Examples
The examples directory contains working examples for all features.
Refer to examples/README.md for details.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceA Model Context Protocol server built with NestJS that provides OAuth 2.1 authentication with GitHub and exposes MCP tools through Server-Sent Events transport. Enables secure, real-time communication with JWT-based protection and dependency injection.Last updated
- Alicense-qualityCmaintenanceA NestJS module for building Model Context Protocol (MCP) servers using decorators to expose services as tools, resources, and prompts. It features auto-discovery, a built-in playground UI, and support for multiple transports including SSE and Stdio.Last updated37MIT
- Alicense-qualityDmaintenanceA lightweight Node.js-based MCP server that exposes custom tools via HTTP and Server-Sent Events (SSE) for clients like Postman. It allows users to register tools with type-safe validation to establish bidirectional communication with MCP clients.Last updated1,9831MIT
- Alicense-qualityCmaintenanceBuild MCP servers inside NestJS applications using ordinary controllers with decorators for tools, resources, and prompts, supporting authentication and authorization.Last updated25MIT
Related MCP Connectors
Markdown-first MCP server for Notion API with 8 composite tools and 39 actions.
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP (Model Context Protocol) server for Appwrite
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/rekog-labs/MCP-Nest'
If you have feedback or need assistance with the MCP directory API, please join our Discord server