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.
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
π Multi-Transport Support: HTTP+SSE, Streamable HTTP, and STDIO
π§ Tools: Expose NestJS methods as MCP tools with automatic discovery and Zod validation
π οΈ Elicitation: Interactive tool calls with user input elicitation
π Progress Notifications: Real-time progress updates for long-running operations
π HTTP Request Access: Full access to request context within MCP handlers
π 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
Are you interested to build ChatGPT widgets (with the OpenAI SDK)?
Find out how to do that with @rekog/MCP-Nest in this repository MCP-Nest-Samples/pizzaz-openai-apps-sdk
Related MCP server: SSE MCP Server
Installation
Optional dependencies
If you use the built-in authorization server with the TypeORM store, install the following optional peer dependencies:
Quick Start
Documentation
Tools Guide - Define and expose NestJS methods as MCP tools
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
Playground
The playground directory contains working examples for all features.
Refer to playground/README.md for details.