/cli
/overview

CLI Introduction

Overview

The NitroStack CLI is a powerful command-line tool for creating, developing, and building MCP servers with v3.0's decorator-based architecture.

Features

  • 🚀 Quick Initialization - Create new projects in seconds
  • 🔥 Hot Reload - Development mode with automatic reloading
  • 🎨 Studio Integration - Visual testing environment
  • 🔨 Code Generation - Generate modules, tools, types, and more
  • 📦 Production Builds - Optimize for deployment
  • 🎯 Templates - Pre-built templates (basic, typescript-auth)

Commands

CommandDescription
initCreate a new NitroStack project
devStart development server with Studio
buildBuild project for production
generateGenerate code (types, modules, tools, etc.)

Installation

Global Installation

npm install -g nitrostack

Verify installation:

nitrostack --version

Using npx

No installation required:

npx nitrostack init my-project

Quick Start

# Create a new project
nitrostack init my-server --template typescript-auth

# Navigate to project
cd my-server

# Install dependencies
npm install

# Start development
nitrostack dev

Studio opens at http://localhost:3000 automatically!

Command Reference

nitrostack init

Create a new NitroStack project.

nitrostack init <project-name> [options]

Options:

  • --template <name> - Template to use (typescript, typescript-auth)

Example:

nitrostack init ecommerce --template typescript-auth

nitrostack dev

Start development server with hot reload and Studio.

nitrostack dev [options]

Options:

  • --port <number> - Studio port (default: 3000)

Example:

nitrostack dev --port 8080

nitrostack build

Build project for production.

nitrostack build

Outputs to dist/ directory.

nitrostack generate

Generate code from templates.

nitrostack generate <type> [name] [options]

Types:

  • types - Generate TypeScript types from tools
  • module - Generate a new module
  • tool - Generate a tool definition
  • resource - Generate a resource definition
  • prompt - Generate a prompt definition
  • guard - Generate an authentication guard
  • middleware - Generate middleware
  • interceptor - Generate an interceptor
  • pipe - Generate a pipe
  • filter - Generate an exception filter
  • service - Generate a service

Examples:

# Generate types
nitrostack generate types

# Generate module
nitrostack generate module payments

# Generate tool
nitrostack generate tool create-payment --module payments

# Generate guard
nitrostack generate guard admin

Configuration

CLI behavior can be configured via:

  1. Command-line flags - Highest priority
  2. Environment variables - Medium priority
  3. Config file - Lowest priority

Environment Variables

# .env
NITROSTACK_PORT=3000
NITROSTACK_WIDGET_PORT=3001

Config File

Create nitrostack.config.js:

export default {
  dev: {
    port: 3000,
    widgetPort: 3001,
    openBrowser: true
  },
  build: {
    outDir: 'dist',
    sourcemap: true
  }
};

Development Workflow

  1. Initialize - Create project with init
  2. Develop - Use dev for hot reload + Studio
  3. Generate - Add features with generate
  4. Test - Test in Studio with AI chat
  5. Build - Production build with build
  6. Deploy - Deploy dist/ to server

Best Practices

1. Use Templates

Start with a template for best practices:

nitrostack init my-project --template typescript-auth

2. Generate Code

Use generators instead of manual coding:

nitrostack generate module users
nitrostack generate tool get-user --module users

3. Type Generation

Regenerate types after tool changes:

nitrostack generate types

4. Test in Studio

Always test in Studio before deployment:

nitrostack dev
# Test with AI chat
# Test manual execution

Troubleshooting

Command Not Found

# If installed globally
npm install -g nitrostack

# Or use npx
npx nitrostack --version

Port Already in Use

# Use different port
nitrostack dev --port 8080

Permission Errors

# Fix npm permissions
sudo chown -R $USER /usr/local/lib/node_modules

Next Steps


CLI Version: 3.0.0