RL

rekog-labs/mcp-nest

Developer tools
673 stars 0 forks 品質 63 トレンド 63

A NestJS module to effortlessly create Model Context Protocol (MCP) servers for exposing AI tools, resources, and prompts.

概要

![CI][ci-url] ![Code Coverage][code-coverage-url] ![NPM Version][npm-url] ![NPM Downloads][npm-url] ![NPM License][npm-url] A NestJS module to effortlessly expose tools, resources, and prompts for AI, from your NestJS applications using the . With @rekog/mcp-nest you define tools, resources, and prompts in a way that's familiar in NestJS and leverage the full power of dependency injection to utilize your existing codebase in building complex enterprise ready MCP servers. - 🚀 : HTTP+SSE, Streamable HTTP, and STDIO - 🔧 : Expose NestJS methods as MCP tools with automatic discovery and Zod validation - 🛠️ : Interactive tool calls with user input elicitation - 🌐 : Full access to request context within MCP handlers - 🔐 : Implement fine-grained authorization for tools - 📁 : Serve content and data through MCP resource system - 📚 : Dynamic resources with parameterized URIs - 💬 : Define reusable prompt templates for AI interactions - 🔐 : Guard-based security with OAuth support - 🏠...

README

NestJS MCP Server Module

A NestJS module to effortlessly expose tools, resources, and prompts for AI, from your NestJS applications using the Model Context Protocol (MCP).

With @rekog/mcp-nest you define tools, resources, and prompts in a way that’s familiar in NestJS and leverage the full power of dependency injection to utilize your existing codebase in building complex enterprise ready MCP servers.

Features

Are you interested to build ChatGPT widgets (with the OpenAI SDK) or MCP apps? Find out how to do that with @rekog/MCP-Nest in this repository MCP-Nest-Samples

[!TIP] You can easily learn about this package using the chat tab in Context7. Better yet, connect the Context7 MCP server to allow your AI agents to access the documentation and implement MCP-Nest for you.

Installation

npm install @rekog/mcp-nest @modelcontextprotocol/sdk zod@^4

Optional dependencies

If you use the built-in authorization server with the TypeORM store, install the following optional peer dependencies:

npm install @nestjs/typeorm typeorm

Quick Start

// app.module.ts
import { Module } from '@nestjs/common';
import { McpModule } from '@rekog/mcp-nest';
import { GreetingTool } from './greeting.tool';

@Module({
  imports: [
    McpModule.forRoot({
      name: 'my-mcp-server',
      version: '1.0.0',
    }),
  ],
  providers: [GreetingTool],
})
export class AppModule {}
// greeting.tool.ts
import { Injectable } from '@nestjs/common';
import { Tool, Context } from '@rekog/mcp-nest';
import { z } from 'zod';

@Injectable()
export class GreetingTool {
  @Tool({
    name: 'greeting-tool',
    description: 'Returns a greeting with progress updates',
    parameters: z.object({
      name: z.string().default('World'),
    }),
  })
  async sayHello({ name }, context: Context) {
    await context.reportProgress({ progress: 50, total: 100 });
    return `Hello, ${name}!`;
  }
}

Documentation

Playground

The playground directory contains working examples for all features. Refer to playground/README.md for details.

View this README on GitHub

インストール

This server does not publish a one-line install command.

Open the repository installation guide