Get the FREE Ultimate OpenClaw Setup Guide →

nestjs

MCP server from adrian-d-hidalgo/nestjs-mcp-server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio adrian-d-hidalgo-nestjs-mcp-server npx -y @nestjs-mcp/server

How to use

This MCP server provides a NestJS modular library for exposing MCP resources, tools, and prompts to LLMs. It wraps the official MCP SDK and keeps types and specifications aligned with the MCP server ecosystem, while offering decorators, modules, and integration patterns to register resources, tools, and prompts in a scalable NestJS application. Use it to define resolvers, tools, and prompts in a NestJS project, then expose them via the MCP server module so clients (LLMs) can call tools and query resources in a standardized way. The Quickstart demonstrates registering McpModule.forRoot in your AppModule and exposing a simple health-check tool, illustrating how tools are declared with decorators and how the MCP server is bootstrapped within NestJS.

How to install

Prerequisites:

  • Node.js (12.x or newer) and npm/yarn/pnpm
  • A NestJS project (or start a new one)

Step-by-step installation:

  1. Create a NestJS app if you don’t have one
    • npm i -g @nestjs/cli
    • nest new my-mcp-app
  2. Install the MCP server library and its peer SDK
    • npm install @nestjs-mcp/server @modelcontextprotocol/sdk zod

      or using yarn/pnpm

      yarn add @nestjs-mcp/server @modelcontextprotocol/sdk zod pnpm add @nestjs-mcp/server @modelcontextprotocol/sdk zod
  3. Integrate the MCP module in your NestJS app
    • Open src/app.module.ts and import McpModule with configuration as shown in the Quickstart
  4. Run the app
    • npm run start
    • or npm run build && node dist/main.js

Notes:

  • The MCP server is a library module for NestJS. You configure it via McpModule.forRoot or McpModule.forRootAsync.
  • The SDK dependency (@modelcontextprotocol/sdk) provides the underlying MCP runtime used by the module.

Additional notes

Tips and considerations:

  • The MCP configuration supports options such as name, version, instructions, transports, and protocolOptions. Adjust logging and transports to suit your environment (e.g., SSE, WebSocket).
  • Ensure compatibility with the underlying MCP SDK types; keep @modelcontextprotocol/sdk in sync with the library version you use.
  • When using McpModule.forRootAsync, provide a factory that resolves configuration at runtime (useful with @nestjs/config or other config modules).
  • For testing, you can create simple Resolver/Tool/Resource decorators as shown in the README to verify endpoint exposure and behavior.
  • If you plan to deploy outside of a NestJS app, consider how the MCP server will be started and whether you need a dockerized/containerized setup leveraging the NestJS build artifacts.

Related MCP Servers

Sponsor this space

Reach thousands of developers