@nestjs/mcp
OfficialProvides an MCP module for NestJS applications, exposing decorated provider methods as MCP tools, resources, and prompts while running through Nest guards, interceptors, pipes, and exception filters. It supports Streamable HTTP and stdio transports and optional OAuth 2.1 resource-server behavior.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Description
Model Context Protocol module for Nest: tools, resources and prompts are methods of your providers, declared with decorators and a schema (Zod, ArkType, Valibot or JSON Schema), and run through Nest's guards, interceptors, pipes and exception filters. The server is served over Streamable HTTP from your existing Nest application (Express, Fastify or the Node adapter), statelessly so it scales behind any load balancer, to clients of both the 2026-07-28 and the 2025 protocol revisions, and over stdio from a standalone application context. It can act as an OAuth 2.1 resource server with protected resource metadata, WWW-Authenticate challenges, per-tool scopes and a token verifier of your own, and comes with an in-memory test client. Built on the official MCP TypeScript SDK (@modelcontextprotocol/server).
Related MCP server: mcp-nestjs
Installation
$ npm i --save @nestjs/mcp @modelcontextprotocol/server zodZod 4.2 or later; any other Standard Schema library that produces JSON Schema works too.
Quick Start
Import the module, and decorate the methods of a provider:
import { Injectable, Module } from '@nestjs/common';
import { McpModule, Resource, Tool, type McpContext } from '@nestjs/mcp';
import * as z from 'zod';
@Injectable()
export class NotesTools {
constructor(private readonly notes: NotesService) {}
@Tool({
description: 'Save a note',
inputSchema: z.object({ text: z.string().describe('What to remember') }),
})
add({ text }: { text: string }, ctx: McpContext) {
return this.notes.add(text, ctx.authInfo?.clientId);
}
@Resource({ uri: 'notes://all', mimeType: 'application/json' })
all() {
return this.notes.all();
}
}
@Module({
imports: [McpModule.forRoot({ name: 'notes', version: '1.0.0' })],
providers: [NotesService, NotesTools],
})
export class AppModule {}app.listen(3000) now serves the MCP endpoint at http://localhost:3000/mcp, a route like any other (the global prefix and middleware apply to it). Guards, interceptors, pipes and filters run around every call; McpExecutionContext.create(context) reads the call in them, as GqlExecutionContext does for GraphQL.
The sample is a notes server with a guard and an interceptor, served over HTTP and stdio: npm run build && npx tsc -p sample/tsconfig.json, then node sample/dist/main.js (HTTP) or node sample/dist/stdio.js (stdio).
Read Overview & Tutorial to get started and for the module's options, Primitives for tools, resources, prompts, guards and authorization, Transports for the HTTP endpoint and stdio, and Testing for the in-memory client.
Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Stay in touch
Author - Kamil Myśliwiec
Website - https://nestjs.com
Twitter - @nestframework
License
Nest is MIT licensed.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Host any HTTP API as a standard MCP server; auto-distribute to 12+ mainstream agent platforms.
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Discover MCP servers and A2A agents; verify, message, post, follow, react, and receive webhooks.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceA NestJS module that allows services to be exposed as an MCP server with Server-Sent Events transport, facilitating tool discovery and execution by clients.735MIT
- AlicenseNot gradedqualityDmaintenanceA NestJS module for building Model Context Protocol (MCP) servers using decorators to expose services as tools, resources, and prompts. It features auto-discovery, a built-in playground UI, and support for multiple transports including SSE and Stdio.19 npmMIT
- AlicenseNot gradedqualityDmaintenanceBuild MCP servers inside NestJS applications using ordinary controllers with decorators for tools, resources, and prompts, supporting authentication and authorization.65 npmMIT
- AlicenseNot gradedqualityCmaintenanceNestJS package that provides decorator-based tool discovery, TypeBox/AJV validation, and MCP SDK server construction for building MCP servers.66 npmMIT