MCP-Nest
A NestJS module to effortlessly create Model Context Protocol (MCP) servers for exposing AI tools, resources, and prompts.
claude mcp add --transport stdio rekog-labs-mcp-nest npx -y @rekog/mcp-nest \ --env NODE_OPTIONS="Set Node.js options if needed" \ --env MCP_LOG_LEVEL="info (debug|info|warn|error)"
How to use
MCP-Nest exposes NestJS-based tools, resources, and prompts through the Model Context Protocol (MCP). It lets you define tool methods in your NestJS project, automatically discover them, and expose them via multiple transport types (HTTP, SSE, streamable HTTP, or STDIO). You can leverage NestJS dependency injection, Zod validation for tool parameters, and per-tool authorization to build enterprise-grade AI-assisted workflows. The server supports interactive elicitation, full access to request context within tool handlers, and the ability to serve content and data through a structured resource system. With built-in and external authorization options, you can secure tools and guard access as part of your MCP ecosystem. Start by deploying an MCP-Nest server in your existing NestJS application and then register tools, resources, and prompts as part of your MCP configuration.
How to install
Prerequisites:
- Node.js (14.x or newer) and npm orpn/yarn
- A NestJS project or a place to host the MCP server
Installation steps:
-
Initialize your project (if needed) and install the MCP-Nest package along with the SDK: npm install @rekog/mcp-nest @modelcontextprotocol/sdk zod@^4
-
If you plan to use the built-in authorization server (optional), install additional peer dependencies: npm install @nestjs/typeorm typeorm
-
Create your NestJS module and register MCP components as described in the Quick Start section of the README (define tools, resources, and prompts using the MCP decorators and DI). For example, import McpModule and call McpModule.forRoot with your server name and version.
-
Run your NestJS application as you normally would (for example, npm run start:dev). The MCP endpoints and services will be available once the application is running.
Additional notes
Tips and common considerations:
- Ensure your Node.js version matches the MCP-Nest compatibility requirements.
- When using the built-in authorization server, provide the necessary database and TypeORM store configuration as described in the docs.
- Use the discovery and registration guides to automatically find and register tools, resources, and prompts within your NestJS project.
- For multi-transport setups, you can expose HTTP(S) endpoints, streamable HTTP, or STDIO-based interfaces depending on your deployment scenario.
- Enable environment variables like MCP_LOG_LEVEL to control log verbosity and NODE_OPTIONS to tune Node.js runtime behavior.
- If you integrate external authorization (Keycloak, Auth0, etc.), follow the External Authorization Server docs for proper setup and token handling.
- Keep your tools' parameters validated with Zod schemas to ensure robust MCP interactions.
Related MCP Servers
mcp-agent
Build effective agents using Model Context Protocol and simple workflow patterns
mcp-framework
A framework for writing MCP (Model Context Protocol) servers in Typescript
mcp-graphql
Model Context Protocol server for GraphQL
git
An MCP (Model Context Protocol) server enabling LLMs and AI agents to interact with Git repositories. Provides tools for comprehensive Git operations including clone, commit, branch, diff, log, status, push, pull, merge, rebase, worktree, tag management, and more, via the MCP standard. STDIO & HTTP.
mcp -langfuse
Model Context Protocol (MCP) Server for Langfuse Prompt Management. This server allows you to access and manage your Langfuse prompts through the Model Context Protocol.
codemesh
The Self-Improving MCP Server - Agents write code to orchestrate multiple MCP servers with intelligent TypeScript execution and auto-augmentation