Skip to content
Back to search

MCP-Nest

A NestJS module to effortlessly create Model Context Protocol (MCP) servers for exposing AI tools, resources, and prompts.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/rekog-labs/MCP-Nest with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/rekog-labs/MCP-Nest'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/rekog-labs--mcp-nest/badge.svg)](/listings/rekog-labs--mcp-nest)

HTML

<a href="/listings/rekog-labs--mcp-nest"><img src="/api/listings/rekog-labs--mcp-nest/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

npm install @rekog/mcp-nest \
  @modelcontextprotocol/server \
  @modelcontextprotocol/core \
  @modelcontextprotocol/node \
  zod@^4

Optional 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-auth

If you additionally use the TypeORM store for the authorization server, install the following optional peer dependencies as well:

npm install @nestjs/typeorm typeorm

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 185 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # NestJS MCP Server Module
  2. <div align="center">
  3. <img src="https://raw.githubusercontent.com/rekog-labs/MCP-Nest/main/image.png" height="200">
  4. [![CI][ci-image]][ci-url]
  5. [![Code Coverage][code-coverage-image]][code-coverage-url]
  6. [![NPM Version][npm-version-image]][npm-url]
  7. [![NPM Downloads][npm-downloads-image]][npm-url]
  8. [![NPM License][npm-license-image]][npm-url]
  9. </div>
  10. A NestJS module to effortlessly expose tools, resources, and prompts for AI, from your NestJS applications using the **Model Context Protocol (MCP)**.
  11. 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.
  12. ## Features
  13. - 🧩 **[NestJS Microservice Strategy](docs/migration-to-v2.md)**: MCP runs as a `CustomTransportStrategy`, so tools/resources/prompts are real `@MessagePattern` handlers — **guards, pipes, interceptors, and exception filters apply to them natively**
  14. - 🚀 **[Multi-Transport Support](docs/server-examples.md#multiple-transport-types)**: Streamable HTTP and STDIO — selected via the `transports` array
  15. - 🕰️ **[Dual-Era Protocol Support](docs/protocol-revisions.md)**: One endpoint serves both the 2025-era protocol (`initialize` + sessions) and the stateless `2026-07-28` revision, concurrently — with **no change to your tool code**
  16. - 🔧 **[Tools](docs/tools.md)**: Expose NestJS methods as MCP tools with automatic discovery and Zod validation
  17. - 🛠️ **[Elicitation](docs/tools.md#interactive-tool-with-elicitation)**: Interactive tool calls with user input elicitation
  18. - 🔁 **[Multi Round-Trip Requests](docs/mrtr.md)**: Elicitation, sampling and roots on protocol revision `2026-07-28` — one handler serves both eras
  19. - 🌐 **[HTTP Request Access](docs/tools.md#understanding-tool-method-parameters)**: Full access to request context within MCP handlers
  20. - 🔐 **[Per-Tool Authorization](docs/per-tool-authorization.md)**: Implement fine-grained authorization for tools
  21. - 📁 **[Resources](docs/resources.md)**: Serve content and data through MCP resource system
  22. - 📚 **[Resource Templates](docs/resource-templates.md)**: Dynamic resources with parameterized URIs
  23. - 💬 **[Prompts](docs/prompts.md)**: Define reusable prompt templates for AI interactions
  24. - 🔐 **[Guard-based Authentication](docs/server-examples.md#server-with-authentication)**: Guard-based security with OAuth support
  25. - 🏠 **[Built-in Authorization Server](docs/built-in-authorization-server.md)** — Using the built-in Authorization Server for easy setups. **(Beta)**
  26. - 🌐 **[External Authorization Server](docs/external-authorization-server.md)** — Securing your MCP server with an external authorization server (Keycloak, Auth0, etc).
  27. - 💉 **[Dependency Injection](docs/dependency-injection.md)**: Leverage NestJS DI system throughout MCP components
  28. - 🔍 **[Server mutation and instrumentation](docs/server-mutation.md)** — Mutate the underlying mcp server for custom logic or instrumentation purposes.
  29. **Are you interested to build ChatGPT widgets (with the OpenAI SDK) or MCP apps?**
  30. Find out how to do that with `@rekog/MCP-Nest` in this repository [MCP-Nest-Samples](https://github.com/rinormaloku/MCP-Nest-Samples)
  31. > [!TIP]
  32. > You can easily learn about this package using the `chat` tab in [Context7](https://context7.com/rekog-labs/mcp-nest?tab=chat). Better yet, connect the [Context7 MCP server](https://github.com/upstash/context7#installation) to allow your AI agents to access the documentation and implement MCP-Nest for you.
  33. ## Installation
  34. ```bash
  35. npm install @rekog/mcp-nest \
  36. @modelcontextprotocol/server \
  37. @modelcontextprotocol/core \
  38. @modelcontextprotocol/node \
  39. zod@^4
  40. ```
  41. ### Optional dependencies
  42. The built-in authorization server now lives in a separate package. If you use it, install it alongside `@rekog/mcp-nest`:
  43. ```bash
  44. npm install @rekog/mcp-nest-auth
  45. ```
  46. If you additionally use the TypeORM store for the authorization server, install the following optional peer dependencies as well:
  47. ```bash
  48. npm install @nestjs/typeorm typeorm
  49. ```
  50. ## Quick Start
  51. MCP-Nest runs as a **NestJS microservice transport strategy**. Tools, resources,
  52. and prompts live on `@McpController()` classes (so NestJS guards, pipes,
  53. interceptors, and exception filters apply to them), and the strategy serves them
  54. over one or more transports (Streamable HTTP, STDIO).
  55. ```typescript
  56. // greeting.controller.ts
  57. import { McpController, Tool, McpContext } from '@rekog/mcp-nest';
  58. import { Ctx, Payload } from '@nestjs/microservices';
  59. import { z } from 'zod';
  60. @McpController()
  61. export class GreetingController {
  62. @Tool({
  63. name: 'greeting-tool',
  64. description: 'Returns a greeting with progress updates',
  65. parameters: z.object({ name: z.string().default('World') }),
  66. })
  67. async sayHello(
  68. @Payload() { name }: { name: string },
  69. @Ctx() ctx: McpContext,
  70. ) {
  71. await ctx.reportProgress({ progress: 50, total: 100 });
  72. return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
  73. }
  74. }
  75. ```
  76. ```typescript
  77. // app.module.ts
  78. import { Module } from '@nestjs/common';
  79. import {
  80. McpStrategy,
  81. MCP_STRATEGY,
  82. StreamableHttpTransport,
  83. } from '@rekog/mcp-nest';
  84. import { GreetingController } from './greeting.controller';
  85. // The strategy is the whole configuration — there is no McpModule.
  86. export const mcp = new McpStrategy({
  87. name: 'my-mcp-server',
  88. version: '1.0.0',
  89. transports: [
  90. new StreamableHttpTransport(),
  91. ],
  92. });
  93. @Module({
  94. controllers: [GreetingController],
  95. // Optional: only needed if a provider injects the strategy (e.g. for
  96. // runtime/dynamic tool registration).
  97. providers: [{ provide: MCP_STRATEGY, useValue: mcp }],
  98. })
  99. export class AppModule {}
  100. ```
  101. ```typescript
  102. // main.ts
  103. import { NestFactory } from '@nestjs/core';
  104. import { AppModule, mcp } from './app.module';
  105. async function bootstrap() {
  106. const app = await NestFactory.create(AppModule);
  107. mcp.setHttpAdapter(app.getHttpAdapter()); // needed for HTTP transports
  108. app.connectMicroservice({ strategy: mcp });
  109. await app.startAllMicroservices(); // mounts the MCP transports
  110. await app.listen(3000); // also serves your normal HTTP routes
  111. }
  112. void bootstrap();
  113. ```
  114. > **Order matters:** call `startAllMicroservices()` before `listen()` so the MCP
  115. > HTTP routes are mounted before the server starts accepting connections.
  116. That `/mcp` endpoint is **dual-era**: it answers both the 2025-era protocol
  117. (`initialize` handshake + sessions) and the stateless `2026-07-28` revision,
  118. concurrently, from the same `@Tool` methods. `ctx.reportProgress(...)` above
  119. reaches a `2026-07-28` client as-is — every modern request can stream progress
  120. back even though it is sessionless. A 2025-era client needs a session-aware
  121. transport for it (`new StreamableHttpTransport({ statefulMode: true })` or
  122. `StdioTransport`); on the legacy stateless default it is a no-op. See
  123. [Protocol Revisions](docs/protocol-revisions.md).
  124. For an STDIO-only server, skip the HTTP adapter and use
  125. `NestFactory.createMicroservice(AppModule, { strategy: mcp })` with
  126. `transports: [new StdioTransport()]` and disable logging (stdout is reserved for
  127. the protocol).
  128. ## Documentation
  129. - **[Migration to the Strategy API](docs/migration-to-v2.md)** - Moving from `McpModule.forRoot(options)` to `McpStrategy` + `@McpController`
  130. - **[Protocol Revisions & Dual-Era Serving](docs/protocol-revisions.md)** - Serving the 2025-era protocol and `2026-07-28` from one endpoint
  131. - **[Tools Guide](docs/tools.md)** - Define and expose NestJS methods as MCP tools
  132. - **[Discovery and Registration of Tools](docs/tool-discovery-and-registration.md)** - Automatic discovery and manual registration of tools
  133. - **[Dynamic Capabilities Guide](docs/dynamic-capabilities.md)** - Register tools, resources, and prompts programmatically at runtime
  134. - **[Resources Guide](docs/resources.md)** - Serve static and dynamic content
  135. - **[Resource Templates Guide](docs/resource-templates.md)** - Create parameterized resources
  136. - **[Prompts Guide](docs/prompts.md)** - Build reusable prompt templates
  137. - **[Built-in Authorization Server](docs/built-in-authorization-server.md)** - Secure your MCP server with built-in OAuth
  138. - **[External Authorization Server](docs/external-authorization-server.md)** - Securing your MCP server with an external authorization server (Keycloak, Auth0, etc)
  139. - **[Server examples](docs/server-examples.md)** - MCP servers examples (Streamable HTTP, HTTP, and STDIO) and with Fastify support
  140. ## Examples
  141. The `examples` directory contains working examples for all features.
  142. Refer to [`examples/README.md`](examples/README.md) for details.
  143. <!-- Badges -->
  144. [ci-url]: https://github.com/rekog-labs/MCP-Nest/actions/workflows/pipeline.yml
  145. [ci-image]: https://github.com/rekog-labs/MCP-Nest/actions/workflows/pipeline.yml/badge.svg
  146. [npm-url]: https://www.npmjs.com/package/@rekog/mcp-nest
  147. [npm-version-image]: https://img.shields.io/npm/v/@rekog/mcp-nest
  148. [npm-downloads-image]: https://img.shields.io/npm/d18m/@rekog/mcp-nest
  149. [npm-license-image]: https://img.shields.io/npm/l/@rekog/mcp-nest
  150. [code-coverage-url]: https://codecov.io/gh/rekog-labs/mcp-nest
  151. [code-coverage-image]: https://codecov.io/gh/rekog-labs/mcp-nest/branch/main/graph/badge.svg

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.