remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Integrations
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).
@rekog/mcp-nest
handles the complexity of setting up MCP servers. 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 services.
Features
- 🚀 HTTP+SSE and Streamable HTTP Transport
- 🔍 Automatic
tool
,resource
, andprompt
discovery and registration - 💯 Zod-based request validation
- 📊 Progress notifications
- 🔒 Guard-based authentication
- ⏱️ Automatic SSE ping to maintain long connections
Installation
Quick Start
1. Import Module
2. Define Tools and Resource
You are done!
API Endpoints
GET /sse
: SSE connection endpoint (Protected by guards if configured)POST /messages
: Tool execution endpoint (Protected by guards if configured)
Tips
It's possible to use the module with global prefix, but the recommended way is to exclude those endpoints with:
Authentication
You can secure your MCP endpoints using standard NestJS Guards.
1. Create a Guard
Implement the CanActivate
interface. The guard should handle request validation (e.g., checking JWTs, API keys) and optionally attach user information to the request object.
Nothing special, check the NestJS documentation for more details.
2. Apply the Guard
Pass your guard(s) to the McpModule.forRoot
configuration. The guard(s) will be applied to both the /sse
and /messages
endpoints.
That's it! The rest is the same as NestJS Guards.
SSE Ping Service
The module includes an SSE ping service that helps maintain long-lived SSE connections by preventing browser/client timeouts. This is especially useful for clients such as IDE's using your MCP server remotely.
Configuration
You can configure the SSE ping behavior when importing the module:
This server cannot be installed
A NestJS module that allows services to be exposed as an MCP server with Server-Sent Events transport, facilitating tool discovery and execution by clients.