nestjs
NestJS module for seamless Model Context Protocol (MCP) server integration using decorators.
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:
- Install the MCP module in your NestJS project
npm install @bamada/nestjs-mcp
- Optionally install peer dependencies mentioned in the module's docs (example):
npm install @modelcontextprotocol/sdk zod @nestjs/core @nestjs/common @nestjs/platform-express
- 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 {}
- 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
mcp-graphql
Model Context Protocol server for GraphQL
leetcode
An MCP server enabling automated access to LeetCode's problems, solutions, and public data with optional authentication for user-specific features, supporting leetcode.com & leetcode.cn sites.
rohlik
MCP server that lets you shop groceries across the Rohlik Group platforms (Rohlik.cz, Knuspr.de, Gurkerl.at, Kifli.hu, Sezamo.ro)
hackmd
A Model Context Protocol server for integrating HackMD's note-taking platform with AI assistants.
google-scholar
An MCP server for Google Scholar written in TypeScript with Streamable HTTP
alris
Alris is an AI automation tool that transforms natural language commands into task execution.