mcp
Health Warn
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 7 GitHub stars
Code Pass
- Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
An MCP module for NestJS (Node.js) 🤖
A progressive Node.js framework for building efficient and scalable server-side applications.
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).
Installation
$ npm i --save @nestjs/mcp @modelcontextprotocol/server zod
Zod 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.
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found