Get the FREE Ultimate OpenClaw Setup Guide →

nestjs

NestJS module for seamless Model Context Protocol (MCP) server integration using decorators.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio bamada-nestjs-mcp npx -y @bamada/nestjs-mcp \
  --env NODE_OPTIONS="optional additional options if needed"

How to use

This MCP server is a NestJS-based implementation of the Model Context Protocol (MCP). It exposes resources, tools, and prompts via decorators such as @McpResource, @McpTool, and @McpPrompt, integrated into a standard NestJS application. The server supports multiple transport layers, including STDIO (for CLI-style usage) and HTTP/SSE (via the built-in McpHttpController at /api/mcp), allowing MCP clients to discover and interact with your resources and tools over the transport of your choice. You can enable logging, validation, and schema-driven parameter definitions using Zod schemas to ensure type-safe interactions with MCP clients.

How to install

Prerequisites:

  • Node.js (≥ 14.x) and npm/yarn installed
  • A NestJS project or a project where you want to integrate MCP support

Installation steps:

  1. Install the MCP module in your NestJS project
npm install @bamada/nestjs-mcp
  1. Optionally install peer dependencies mentioned in the module's docs (example):
npm install @modelcontextprotocol/sdk zod @nestjs/core @nestjs/common @nestjs/platform-express
  1. Integrate MCP into your app (example):
// src/app.module.ts
import { Module } from '@nestjs/common';
import { McpModule, TransportType } from '@bamada/nestjs-mcp';
import { MyMcpProvider } from './my-mcp.provider';

@Module({
  imports: [
    McpModule.forRoot({
      serverInfo: { name: 'my-nestjs-mcp', version: '1.0.0' },
      serverOptions: {},
      transport: TransportType.SSE // or TransportType.STDIO
    }),
  ],
  providers: [MyMcpProvider],
})
export class AppModule {}
  1. Run your NestJS application as usual:
npm run start

Additional notes

Tips:

  • Choose a transport that matches your deployment scenario (STDIO for CLI tools or SSE/HTTP for API clients).
  • Use StderrLogger if you rely on STDIO to avoid clobbering MCP transport output.
  • Define MCP resources, tools, and prompts with Zod schemas for robust validation.
  • Ensure peer dependencies (e.g., @modelcontextprotocol/sdk, zod, @nestjs/*) match the versions compatible with your NestJS project.
  • When debugging, enable verbose logs and verify the MCP provider methods are properly decorated and exported.

Related MCP Servers

Sponsor this space

Reach thousands of developers