NestJsMcp

NestJS MCP Server is a powerful Model Context Protocol server that provides 40+ specialized tools for NestJS development. It integrates seamlessly with AI assistants like Claude Desktop, Cursor, Claude Code CLI, and any MCP-compatible client.

NestJS MCP Server

A comprehensive Model Context Protocol (MCP) server for NestJS development

TypeScript NestJS MCP License

Supercharge your NestJS development with AI-powered assistance

FeaturesInstallationConfigurationToolsUsageContributing


Overview

NestJS MCP Server is a powerful Model Context Protocol server that provides 40+ specialized tools for NestJS development. It integrates seamlessly with AI assistants like Claude Desktop, Cursor, Claude Code CLI, and any MCP-compatible client.

Why NestJS MCP?

  • Accelerate Development: Generate boilerplate code, controllers, services, and complete CRUD resources in seconds
  • Best Practices Built-in: All generated code follows NestJS best practices and conventions
  • Security First: Built-in security audit tools to identify vulnerabilities in your code
  • Complete Ecosystem: From scaffolding to deployment, covers the entire development lifecycle
  • AI-Powered Learning: Instant explanations of NestJS concepts, decorators, and patterns

Features

Code Generation

Generate production-ready NestJS code with proper decorators, types, and best practices.

Project Scaffolding

Create complete NestJS projects with your preferred database, authentication, and tooling pre-configured.

Testing Tools

Generate unit tests, E2E tests, test factories, and mock repositories automatically.

Security Auditing

Scan your code for common vulnerabilities (SQL injection, XSS, hardcoded secrets, etc.) with severity ratings.

Deployment Automation

Generate Docker, Kubernetes, CI/CD pipelines, Nginx configs, and more.

Documentation & Learning

Access NestJS documentation, concepts, and best practices directly through your AI assistant.


Installation

Prerequisites

  • Node.js 18.x or higher
  • npm 9.x or higher

Quick Start

# Clone the repository
git clone https://github.com/pirumar/NestJsMcp.git
cd nestjs-mcp

# Install dependencies
npm install

# Build the project
npm run build

# Verify installation
npm start

Build Scripts

CommandDescription
npm run buildCompile TypeScript to JavaScript
npm run devWatch mode for development
npm startRun the MCP server

Configuration

Claude Desktop

Add to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "nestjs": {
      "command": "node",
      "args": ["/absolute/path/to/nestjs-mcp/dist/index.js"]
    }
  }
}

Cursor IDE

Add to your Cursor MCP settings (.cursor/mcp.json):

{
  "mcpServers": {
    "nestjs": {
      "command": "node",
      "args": ["/absolute/path/to/nestjs-mcp/dist/index.js"]
    }
  }
}

Claude Code CLI

Add to your Claude Code settings:

{
  "mcpServers": {
    "nestjs": {
      "command": "node",
      "args": ["/absolute/path/to/nestjs-mcp/dist/index.js"]
    }
  }
}

Note: Replace /absolute/path/to/nestjs-mcp with the actual path to your installation.


Available Tools

Code Generation Tools

ToolDescription
nestjs_generate_controllerGenerate controllers with optional CRUD operations
nestjs_generate_serviceGenerate services with repository integration
nestjs_generate_moduleGenerate modules with providers and imports
nestjs_generate_resourceGenerate complete CRUD resources (module, controller, service, entity, DTOs)
nestjs_generate_dtoGenerate DTOs with class-validator decorators
nestjs_generate_entityGenerate TypeORM/Mongoose entities
nestjs_generate_guardGenerate auth, roles, or custom guards
nestjs_generate_interceptorGenerate logging, transform, cache, or timeout interceptors
nestjs_generate_pipeGenerate validation or transform pipes
nestjs_generate_filterGenerate exception filters
nestjs_generate_middlewareGenerate custom middleware

Project Scaffolding Tools

ToolDescription
nestjs_scaffold_projectGenerate a complete NestJS project with customizable options

Scaffolding Options:

  • Database: PostgreSQL, MySQL, MongoDB, SQLite
  • Authentication: JWT-based auth with Passport
  • Documentation: Swagger/OpenAPI integration
  • Containerization: Docker & Docker Compose
  • Testing: Jest configuration with coverage
  • WebSockets: Socket.io integration

Testing Tools

ToolDescription
nestjs_generate_unit_testGenerate unit tests for services
nestjs_generate_controller_testGenerate controller unit tests
nestjs_generate_e2e_testGenerate end-to-end tests
nestjs_generate_test_factoryGenerate test data factories
nestjs_generate_mock_repositoryGenerate mock repository for testing
nestjs_generate_test_helpersGenerate common test utilities

Security Tools

ToolDescription
nestjs_security_auditComprehensive security audit of your codebase
nestjs_security_checklistGet security best practices checklist
nestjs_generate_secure_mainGenerate security-hardened main.ts

Security Checks Include:

  • SQL Injection vulnerabilities
  • Cross-Site Scripting (XSS)
  • Hardcoded secrets and credentials
  • Insecure cryptographic practices
  • Path traversal vulnerabilities
  • Command injection risks
  • Sensitive data exposure
  • Missing security headers

Deployment Tools

ToolDescription
nestjs_generate_dockerfileGenerate optimized multi-stage Dockerfile
nestjs_generate_docker_composeGenerate Docker Compose configuration
nestjs_generate_github_actionsGenerate GitHub Actions CI/CD pipeline
nestjs_generate_gitlab_ciGenerate GitLab CI/CD pipeline
nestjs_generate_kubernetesGenerate Kubernetes deployment manifests
nestjs_generate_pm2_configGenerate PM2 ecosystem configuration
nestjs_generate_nginx_configGenerate Nginx reverse proxy configuration
nestjs_generate_systemd_serviceGenerate systemd service file
nestjs_generate_env_filesGenerate environment configuration files

Documentation & Learning Tools

ToolDescription
nestjs_explain_conceptDetailed explanation of NestJS concepts
nestjs_explain_decoratorExplain specific decorators with examples
nestjs_explain_cliExplain NestJS CLI commands
nestjs_list_schematicsList all available NestJS schematics
nestjs_list_decoratorsList decorators by category
nestjs_best_practicesGet best practices by category
nestjs_recommended_packagesGet recommended packages by use case
nestjs_search_docsSearch through NestJS documentation
nestjs_request_lifecycleUnderstand the request lifecycle
nestjs_dependency_injectionLearn about dependency injection
nestjs_get_common_errorsGet solutions for common errors

Code Analysis Tools

ToolDescription
nestjs_analyze_codeAnalyze code for issues and anti-patterns
nestjs_suggest_improvementsGet improvement suggestions
nestjs_validate_structureValidate project structure

Available Resources

Access NestJS documentation directly through MCP resources:

Resource URIDescription
nestjs://docs/concepts/{topic}Core concepts (modules, controllers, providers, etc.)
nestjs://docs/techniques/{topic}Techniques (database, auth, validation, caching, etc.)
nestjs://docs/advanced/{topic}Advanced topics (CQRS, events, microservices, etc.)
nestjs://docs/cli/commandsCLI commands reference
nestjs://docs/cli/schematicsSchematics reference
nestjs://docs/decoratorsComplete decorators reference
nestjs://docs/best-practicesBest practices guide
nestjs://docs/packagesRecommended packages
nestjs://docs/errors/{error}Common errors and solutions

Usage Examples

Generate a Complete CRUD Resource

"Generate a complete CRUD resource for 'products' with TypeORM entity"

This creates:

  • products.module.ts
  • products.controller.ts
  • products.service.ts
  • product.entity.ts
  • create-product.dto.ts
  • update-product.dto.ts

Scaffold a New Project

"Scaffold a new NestJS project called 'my-api' with PostgreSQL, JWT auth, Swagger, and Docker"

This generates a complete project structure with:

  • Database configuration
  • Authentication module
  • Swagger setup
  • Docker & Docker Compose files
  • Environment configuration
  • Testing setup

Security Audit

"Run a security audit on my NestJS application"

Returns:

  • List of vulnerabilities with severity ratings
  • CWE references
  • Remediation suggestions
  • Overall security score (A-F grade)

Generate CI/CD Pipeline

"Generate a GitHub Actions workflow for my NestJS project"

Creates a complete CI/CD pipeline with:

  • Linting and type checking
  • Unit and E2E tests
  • Docker build and push
  • Deployment stages

Generate Kubernetes Deployment

"Generate Kubernetes manifests for deploying my NestJS app"

Generates:

  • Deployment with health checks
  • Service (ClusterIP/LoadBalancer)
  • ConfigMap
  • Secret template
  • Horizontal Pod Autoscaler
  • Ingress configuration

Get Error Solutions

"How do I fix the circular dependency error in NestJS?"

Returns:

  • Common causes
  • Step-by-step solutions
  • Code examples

Project Structure

nestjs-mcp/
├── src/
│   ├── index.ts                    # Main MCP server entry point
│   ├── data/
│   │   ├── nestjs-docs.ts          # Core NestJS documentation
│   │   └── advanced-techniques.ts  # Advanced topics & error solutions
│   ├── tools/
│   │   ├── index.ts                # Tools barrel export
│   │   ├── generate.ts             # Code generation tools
│   │   ├── explain.ts              # Documentation tools
│   │   ├── analyze.ts              # Code analysis tools
│   │   ├── scaffold.ts             # Project scaffolding
│   │   ├── testing.ts              # Test generation tools
│   │   ├── security.ts             # Security audit tools
│   │   └── deployment.ts           # Deployment config generators
│   ├── resources/
│   │   ├── index.ts
│   │   └── documentation.ts        # MCP resources
│   └── prompts/
│       ├── index.ts
│       └── templates.ts            # Prompt templates
├── dist/                           # Compiled JavaScript
├── package.json
├── tsconfig.json
└── README.md

Advanced Topics Covered

The MCP server includes comprehensive documentation and code generation for:

TopicDescription
CQRSCommand Query Responsibility Segregation pattern
Event-DrivenEvent emitters and event sourcing
File UploadMulter integration and streaming uploads
StreamingSSE and streaming responses
Health ChecksTerminus health indicators
Task SchedulingCron jobs and intervals
CompressionGzip/Brotli response compression
Rate LimitingThrottling and rate limiting
API VersioningURI, header, and media type versioning
SerializationClass-transformer and interceptors

Common Errors Database

Built-in solutions for common NestJS errors:

  • Circular Dependency - Detection and resolution strategies
  • Cannot Resolve Dependency - Missing provider troubleshooting
  • Invalid Module - Module configuration issues
  • Unknown Element - Template and decorator problems
  • Timeout Errors - Async operation handling
  • Validation Failures - DTO and pipe configuration
  • TypeORM Issues - Database connection and query problems
  • Authentication Errors - JWT and Passport configuration

Contributing

Contributions are welcome! Here's how you can help:

Development Setup

# Fork and clone the repository
git clone https://github.com/pirumar/NestJsMcp.git
cd nestjs-mcp

# Install dependencies
npm install

# Start development mode
npm run dev

Contribution Guidelines

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Areas for Contribution

  • Additional code generators
  • More security checks
  • Extended documentation coverage
  • Bug fixes and improvements
  • Additional deployment targets

Troubleshooting

Common Issues

MCP Server Not Starting

# Ensure the project is built
npm run build

# Check for TypeScript errors
npx tsc --noEmit

Claude Desktop Not Detecting Server

  • Verify the path in claude_desktop_config.json is absolute
  • Restart Claude Desktop after configuration changes
  • Check Claude Desktop logs for connection errors

Permission Errors on Linux/macOS

chmod +x dist/index.js

Roadmap

  • GraphQL code generation
  • Microservices scaffolding
  • gRPC integration templates
  • Database migration generators
  • OpenAPI spec to code generation
  • Custom template support
  • Plugin architecture

License

This project is licensed under the MIT License - see the LICENSE file for details.


Acknowledgments


Built with love for the NestJS community

Report BugRequest Feature

Related Servers