What is NestJS MCP Server Module?
It is a NestJS module that simplifies building an MCP (Model Context Protocol) server with Server-Sent Events (SSE) transport. It automatically discovers and registers tools and resources defined with decorators, and integrates Zod-based request validation, progress notifications, and NestJS guard authentication.
How to use NestJS MCP Server Module?
Install the package and its peer dependencies (npm install @rekog/mcp-nest @modelcontextprotocol/sdk zod), then import McpModule.forRoot in your root module with a server name and version. Decorate service methods with @Tool and @Resource to register tools and resources. Optionally apply NestJS guards for endpoint authentication.
Key features of NestJS MCP Server Module
- SSE transport for streaming tool execution and resource access
- Automatic tool and resource discovery via decorators
- Zod-based request validation for tool parameters
- Progress notifications during long-running operations
- Guard-based authentication on
/sse and /messages endpoints
Use cases of NestJS MCP Server Module
- Building a secure MCP server within an existing NestJS application
- Streaming tool calls with real‑time progress updates to AI clients
- Exposing dynamic resources via URI templates with guard‑protected access
- Using MCP tool and resource discovery without manual route registration
评论